diff --git a/tasks/format-code-task-000007/environment/Dockerfile b/tasks/format-code-task-000007/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cfbf478ed2391c3134f900b796dede17a5002755 --- /dev/null +++ b/tasks/format-code-task-000007/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:39abf5a6f56accf125a99c5047a0c738af4ff1b920c29267a64b2a0901854f73 diff --git a/tasks/format-code-task-000007/environment/setup/files/blocklist b/tasks/format-code-task-000007/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000007/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-000007/environment/setup/setup.sh b/tasks/format-code-task-000007/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000007/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-000007/tests/test.patch b/tasks/format-code-task-000007/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8b9b7143941ea59354924c27356b11dfdbd957ca --- /dev/null +++ b/tasks/format-code-task-000007/tests/test.patch @@ -0,0 +1,67 @@ +diff --git a/test/LimitOrderProtocol.js b/test/LimitOrderProtocol.js +index 08dc063f..5d9b8f28 100644 +--- a/test/LimitOrderProtocol.js ++++ b/test/LimitOrderProtocol.js +@@ -2086,6 +2086,42 @@ describe('LimitOrderProtocol', function () { + .to.be.revertedWithCustomError(swap, 'InvalidMsgValue'); + }); + ++ it('should be reverted if takerAsset does not contain code', async function () { ++ const { tokens: { dai }, contracts: { swap }, chainId } = await loadFixture(deployContractsAndInit); ++ ++ await dai.mint(addr, '1000000'); ++ ++ const order = buildOrder({ ++ makerAsset: await dai.getAddress(), ++ takerAsset: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', ++ makingAmount: 900, ++ takingAmount: 900, ++ maker: addr1.address, ++ }); ++ ++ const { r, yParityAndS: vs } = ethers.Signature.from(await signOrder(order, chainId, await swap.getAddress(), addr1)); ++ await expect(swap.fillOrder(order, r, vs, 900, fillWithMakingAmount(900))) ++ .to.be.revertedWithCustomError(swap, 'TransferFromTakerToMakerFailed'); ++ }); ++ ++ it('should be reverted if makerAsset does not contain code', async function () { ++ const { tokens: { usdc }, contracts: { swap }, chainId } = await loadFixture(deployContractsAndInit); ++ ++ await usdc.approve(swap, '1000000'); ++ ++ const order = buildOrder({ ++ makerAsset: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee', ++ takerAsset: await usdc.getAddress(), ++ makingAmount: 900, ++ takingAmount: 900, ++ maker: addr1.address, ++ }); ++ ++ const { r, yParityAndS: vs } = ethers.Signature.from(await signOrder(order, chainId, await swap.getAddress(), addr1)); ++ await expect(swap.fillOrder(order, r, vs, 900, fillWithMakingAmount(900))) ++ .to.be.revertedWithCustomError(swap, 'TransferFromMakerToTakerFailed'); ++ }); ++ + it('should revert with takerAsset WETH, unwrap flag is set and taker unable to receive excessive ETH', async function () { + const { tokens: { dai, weth }, contracts: { swap }, chainId } = await loadFixture(deployContractsAndInit); + +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+3R0QqCMBTG8V33FHsCc9b0JYJ6g1AnaKiLuaLHz3ZjBNVNEtH/d7EzzgbnwBcV ++p6Y1+6o/L8Vc4lGmdaijxxruSidxkqpspce+UmmcCKln2+jOafC5k1I4a/2rf+/ef1Q05e+rwe9L ++23V5b6Kh/tyMt/lnU/5JyH+dqjH/+HMrPPfn+ZdGhuCLyiz640XWuTN17uWtF47lpukav3Wmcjtn ++vS1tGx2Gxbf3BgAAAAAAAAAAAAAAACDEFRa4phsAKAAA +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-000007/tests/test.sh b/tasks/format-code-task-000007/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..556da80e0c4045ab1b5795ff01660f342c9e3a49 --- /dev/null +++ b/tasks/format-code-task-000007/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/LimitOrderProtocol.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-000007/tests/test_command.sh b/tasks/format-code-task-000007/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000007/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-000031/environment/Dockerfile b/tasks/format-code-task-000031/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..75f0d7f94340987e1cc87c51f845e0bc64e00181 --- /dev/null +++ b/tasks/format-code-task-000031/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:a4ea0e9a25cca6314783da9a232e7cec11d1d7d106aeedfa684ee15383ad804d diff --git a/tasks/format-code-task-000031/environment/setup/files/blocklist b/tasks/format-code-task-000031/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000031/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-000031/environment/setup/setup.sh b/tasks/format-code-task-000031/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000031/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-000031/tests/test.patch b/tasks/format-code-task-000031/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..38f02a9b3ae6e40fea1c896d7e7ed23d901bff1a --- /dev/null +++ b/tasks/format-code-task-000031/tests/test.patch @@ -0,0 +1,34 @@ +diff --git a/tests/common/osutil/test_default.py b/tests/common/osutil/test_default.py +index cbd01ee0c..7db802715 100644 +--- a/tests/common/osutil/test_default.py ++++ b/tests/common/osutil/test_default.py +@@ -124,7 +124,7 @@ def test_get_first_if_all_loopback(self): + fake_ifaces = {'lo':'127.0.0.1'} + with patch.object(osutil.DefaultOSUtil, 'get_primary_interface', return_value='bogus0'): + with patch.object(osutil.DefaultOSUtil, '_get_all_interfaces', return_value=fake_ifaces): +- self.assertRaises(Exception, osutil.DefaultOSUtil().get_first_if) ++ self.assertEqual(('', ''), osutil.DefaultOSUtil().get_first_if()) + + def test_isloopback(self): + self.assertTrue(osutil.DefaultOSUtil().is_loopback('lo')) +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+3SQU+DMBQHcM79FC+Egx4otIzVmHjwYLKL0YP3BUZ1JNAuUIh+ewtL1JjoLlvM ++4v93oKWP5DX8Hy+HuqnW2oxJcCqpp/J8Xr3v67wXuRRysRBKiCAVIlcqoPxkN/pi6F3REQWdte63 ++7w7VzxT/zN/p3q03tm0LU/F+e7weh/KXUn3kv8yUz3+xlFlA6fGu8LN/nv+mojn4UleM6ded7Rw9 ++3j6tbsJo9XB/l/Dd2zQbZW2uo+k8ZHosGgqji7lAtakdxZch27++NLb05YxfcZkyf+i21mQUt+S3 ++vg1Njz6ZpsyaxPaDq5v94FX6uRga5/tRPLK//i0AAAAAAAAAAAAAAAAAAAAAAGfhHYfs4dIAKAAA +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-000031/tests/test.sh b/tasks/format-code-task-000031/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..841823e32d137a6992ed6909c19c3f64bdd7c86c --- /dev/null +++ b/tasks/format-code-task-000031/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/common/osutil/test_default.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-000031/tests/test_command.sh b/tasks/format-code-task-000031/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000031/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-000036/environment/Dockerfile b/tasks/format-code-task-000036/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f2049e53be707ff4f4e76a77f84afbff31c342da --- /dev/null +++ b/tasks/format-code-task-000036/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:b9ed31bc889585e5ab98623fda9cfce7988a3309a16e09d5e79be6d6e955e110 diff --git a/tasks/format-code-task-000036/environment/setup/files/blocklist b/tasks/format-code-task-000036/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000036/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-000036/environment/setup/setup.sh b/tasks/format-code-task-000036/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000036/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-000036/tests/test.patch b/tasks/format-code-task-000036/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..63945c22267a1586b842e0ff412bce0ff69d8c24 --- /dev/null +++ b/tasks/format-code-task-000036/tests/test.patch @@ -0,0 +1,246 @@ +diff --git a/packages/components/psammead-story-promo/src/layout.test.jsx b/packages/components/psammead-story-promo/src/layout.test.jsx +new file mode 100644 +index 000000000..19d67112d +--- /dev/null ++++ b/packages/components/psammead-story-promo/src/layout.test.jsx +@@ -0,0 +1,218 @@ ++import React from 'react'; ++import { render } from '@testing-library/react'; ++import { latin } from '@bbc/gel-foundations/scripts'; ++import StoryPromo, { Headline, Summary, Link } from './index'; ++ ++const Image = Alt text; ++ ++const Info = ({ promoType }) => ( ++ <> ++ ++ The headline ++ ++ ++ The summary ++ ++ ++ ++); ++ ++const renderLeading = () => { ++ const { container } = render( ++ } ++ promoType="leading" ++ />, ++ ); ++ return container; ++}; ++ ++const getCss = () => ++ Array.from(document.querySelectorAll('style')) ++ .map(s => s.textContent || '') ++ .join('\n'); ++ ++const hashClass = el => { ++ const classes = (el.getAttribute('class') || '').split(/\s+/).filter(Boolean); ++ ++ return classes.filter(c => !c.includes('-sc-'))[0] || classes[classes.length - 1]; ++}; ++ ++const escRe = s => s.replace(/[.()/\\+*?^$|[\]{}]/g, m => `\\${m}`); ++ ++ ++ ++ ++ ++const matchInMedia = (css, cls, minWidth, needle) => { ++ const pattern = new RegExp( ++ `@media\\s*\\(min-width:\\s*${escRe( ++ minWidth, ++ )}\\)(?:\\s*and\\s*\\(max-width:[^)]+\\))?\\s*\\{[^}]*\\.${cls}\\s*\\{[^}]*${escRe( ++ needle, ++ )}`, ++ ); ++ return pattern.test(css); ++}; ++ ++ ++ ++ ++const hasGridColumn1Span = (css, cls, minWidth, n) => { ++ const blockPattern = new RegExp( ++ `@media\\s*\\(min-width:\\s*${escRe( ++ minWidth, ++ )}\\)(?:\\s*and\\s*\\(max-width:[^)]+\\))?\\s*\\{([^}]*\\.${cls}\\s*\\{[^}]*\\})`, ++ 'g', ++ ); ++ const bad = new RegExp( ++ `\\.${cls}\\s*\\{[^}]*grid-column:\\s*1\\s*/\\s*span\\s+${n}\\b`, ++ ); ++ let m; ++ // eslint-disable-next-line no-cond-assign ++ while ((m = blockPattern.exec(css))) { ++ if (bad.test(m[1])) return true; ++ } ++ return false; ++}; ++ ++describe('StoryPromo - Leading layout', () => { ++ it('renders TextGridItem (info) before ImageGridItem (image) in DOM order', () => { ++ const container = renderLeading(); ++ const wrapper = container.firstChild; ++ expect(wrapper.children).toHaveLength(2); ++ const first = wrapper.children[0]; ++ const second = wrapper.children[1]; ++ ++ expect(first.querySelector('h3')).not.toBeNull(); ++ expect(first.querySelector('img')).toBeNull(); ++ expect(second.querySelector('img')).not.toBeNull(); ++ expect(second.querySelector('h3')).toBeNull(); ++ }); ++ ++ it('uses 6/6 grid columns at default (mobile, < 600px) for both items', () => { ++ const container = renderLeading(); ++ const wrapper = container.firstChild; ++ const textCls = hashClass(wrapper.children[0]); ++ const imageCls = hashClass(wrapper.children[1]); ++ const css = getCss(); ++ ++ ++ ++ ++ ++ ++ expect(css).toMatch(new RegExp(`\\.${textCls}\\s*\\{[^}]*span\\s+6\\b`)); ++ expect(css).toMatch(new RegExp(`\\.${imageCls}\\s*\\{[^}]*span\\s+6\\b`)); ++ }); ++ ++ it('uses 3/3 grid columns at min-width 37.5rem (600px) for both items', () => { ++ const container = renderLeading(); ++ const wrapper = container.firstChild; ++ const textCls = hashClass(wrapper.children[0]); ++ const imageCls = hashClass(wrapper.children[1]); ++ const css = getCss(); ++ ++ expect(matchInMedia(css, textCls, '37.5rem', 'span 3')).toBe(true); ++ expect(matchInMedia(css, imageCls, '37.5rem', 'span 3')).toBe(true); ++ ++ ++ ++ ++ ++ expect(hasGridColumn1Span(css, imageCls, '37.5rem', 3)).toBe(false); ++ }); ++ ++ it('uses 2/4 grid columns at min-width 63rem (1008px)', () => { ++ const container = renderLeading(); ++ const wrapper = container.firstChild; ++ const textCls = hashClass(wrapper.children[0]); ++ const imageCls = hashClass(wrapper.children[1]); ++ const css = getCss(); ++ ++ ++ expect(matchInMedia(css, textCls, '63rem', 'span 2')).toBe(true); ++ ++ expect(matchInMedia(css, imageCls, '63rem', 'span 4')).toBe(true); ++ ++ ++ ++ expect(hasGridColumn1Span(css, imageCls, '63rem', 4)).toBe(false); ++ }); ++ ++ it('TextGridItem fallback width is 100% by default (no @supports)', () => { ++ const container = renderLeading(); ++ const wrapper = container.firstChild; ++ const textCls = hashClass(wrapper.children[0]); ++ const css = getCss(); ++ ++ ++ expect(css).toMatch( ++ new RegExp(`\\.${textCls}\\s*\\{[^}]*width:\\s*100%`), ++ ); ++ }); ++ ++ it('TextGridItem fallback width is 50% at min-width 37.5rem', () => { ++ const container = renderLeading(); ++ const wrapper = container.firstChild; ++ const textCls = hashClass(wrapper.children[0]); ++ const css = getCss(); ++ ++ expect(matchInMedia(css, textCls, '37.5rem', 'width:50%')).toBe(true); ++ }); ++ ++ it('TextGridItem fallback width is 33.33% at min-width 63rem', () => { ++ const container = renderLeading(); ++ const wrapper = container.firstChild; ++ const textCls = hashClass(wrapper.children[0]); ++ const css = getCss(); ++ ++ expect(matchInMedia(css, textCls, '63rem', 'width:33.33%')).toBe(true); ++ }); ++ ++ it('ImageGridItem fallback width is 100% by default', () => { ++ const container = renderLeading(); ++ const wrapper = container.firstChild; ++ const imageCls = hashClass(wrapper.children[1]); ++ const css = getCss(); ++ ++ expect(css).toMatch( ++ new RegExp(`\\.${imageCls}\\s*\\{[^}]*width:\\s*100%`), ++ ); ++ }); ++ ++ it('ImageGridItem fallback width is 50% at min-width 37.5rem', () => { ++ const container = renderLeading(); ++ const wrapper = container.firstChild; ++ const imageCls = hashClass(wrapper.children[1]); ++ const css = getCss(); ++ ++ expect(matchInMedia(css, imageCls, '37.5rem', 'width:50%')).toBe(true); ++ }); ++ ++ it('ImageGridItem fallback width is 66.67% at min-width 63rem', () => { ++ const container = renderLeading(); ++ const wrapper = container.firstChild; ++ const imageCls = hashClass(wrapper.children[1]); ++ const css = getCss(); ++ ++ expect(matchInMedia(css, imageCls, '63rem', 'width:66.67%')).toBe(true); ++ }); ++}); ++ ++describe('StoryPromo - Regular promo unaffected', () => { ++ it('regular promo still renders image before info', () => { ++ const { container } = render( ++ } ++ promoType="regular" ++ />, ++ ); ++ const wrapper = container.firstChild; ++ expect(wrapper.children).toHaveLength(2); ++ expect(wrapper.children[0].querySelector('img')).not.toBeNull(); ++ expect(wrapper.children[1].querySelector('h3')).not.toBeNull(); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..9d666d9bf +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest packages/components/psammead-story-promo/src/layout.test.jsx --colors=false"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx jest packages/components/psammead-story-promo/src/layout.test.jsx --colors=false ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000036/tests/test.sh b/tasks/format-code-task-000036/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6be5847dd4ac58802aeb25a4c22d5c9977fd209e --- /dev/null +++ b/tasks/format-code-task-000036/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/components/psammead-story-promo/src/layout.test.jsx +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-000036/tests/test_command.sh b/tasks/format-code-task-000036/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000036/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-000054/environment/Dockerfile b/tasks/format-code-task-000054/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e654056c85067d68e8b839591a9efca418bf128a --- /dev/null +++ b/tasks/format-code-task-000054/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:a5ce2ed54740af4bafad19d1ccf3d0cb768e5dbd40063e012eb4112bd285100a diff --git a/tasks/format-code-task-000054/environment/setup/files/blocklist b/tasks/format-code-task-000054/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000054/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-000054/environment/setup/setup.sh b/tasks/format-code-task-000054/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000054/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-000054/tests/test.patch b/tasks/format-code-task-000054/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8ace84c9371e49d64d9f6abbe47c7161e481283c --- /dev/null +++ b/tasks/format-code-task-000054/tests/test.patch @@ -0,0 +1,204 @@ +diff --git a/src/services/workbench/explorer/__tests__/folderTreeCrud.test.ts b/src/services/workbench/explorer/__tests__/folderTreeCrud.test.ts +new file mode 100644 +index 000000000..0fe32b241 +--- /dev/null ++++ b/src/services/workbench/explorer/__tests__/folderTreeCrud.test.ts +@@ -0,0 +1,170 @@ ++import 'reflect-metadata'; ++import { container } from 'tsyringe'; ++import { FolderTreeService } from '../folderTreeService'; ++import { FileTypes } from 'mo/model/workbench/explorer/folderTree'; ++ ++const folderTreeService = container.resolve(FolderTreeService); ++ ++const buildTree = () => ({ ++ id: 1, ++ name: 'root', ++ fileType: FileTypes.RootFolder, ++ location: 'root', ++ children: [ ++ { ++ id: 2, ++ name: 'src', ++ fileType: FileTypes.Folder, ++ location: 'root/src', ++ children: [ ++ { ++ id: 3, ++ name: 'index.ts', ++ fileType: FileTypes.File, ++ location: 'root/src/index.ts', ++ }, ++ ], ++ }, ++ { ++ id: 4, ++ name: 'a.ts', ++ fileType: FileTypes.File, ++ location: 'root/a.ts', ++ }, ++ ], ++}); ++ ++const childIds = (node: any): number[] => ++ (node?.children || []).map((c: any) => c.id); ++ ++describe('Unified node CRUD on the folder-tree service', () => { ++ beforeEach(() => { ++ folderTreeService.setState({ ++ folderTree: { ++ data: [buildTree()], ++ current: null, ++ }, ++ }); ++ }); ++ ++ describe('get', () => { ++ test('returns the node found anywhere in the hierarchy', () => { ++ expect(folderTreeService.get(1)?.name).toBe('root'); ++ expect(folderTreeService.get(2)?.name).toBe('src'); ++ expect(folderTreeService.get(3)?.name).toBe('index.ts'); ++ expect(folderTreeService.get(4)?.name).toBe('a.ts'); ++ }); ++ ++ test('returns null when no node matches', () => { ++ expect(folderTreeService.get(999)).toBeNull(); ++ }); ++ }); ++ ++ describe('add', () => { ++ test('adds the node as a child of a referenced folder', () => { ++ folderTreeService.add( ++ { id: 10, name: 'utils.ts', fileType: FileTypes.File }, ++ 2 ++ ); ++ ++ expect(folderTreeService.get(10)?.name).toBe('utils.ts'); ++ expect(childIds(folderTreeService.get(2))).toContain(10); ++ }); ++ ++ test('adds the node as a child of a referenced root folder', () => { ++ folderTreeService.add( ++ { id: 11, name: 'lib', fileType: FileTypes.Folder }, ++ 1 ++ ); ++ ++ expect(folderTreeService.get(11)?.name).toBe('lib'); ++ expect(childIds(folderTreeService.get(1))).toContain(11); ++ }); ++ ++ test('places the node alongside a referenced file in the same parent', () => { ++ ++ folderTreeService.add( ++ { id: 12, name: 'extra.ts', fileType: FileTypes.File }, ++ 3 ++ ); ++ ++ expect(folderTreeService.get(12)?.name).toBe('extra.ts'); ++ expect(childIds(folderTreeService.get(2))).toContain(12); ++ ++ expect(childIds(folderTreeService.get(3))).not.toContain(12); ++ }); ++ ++ test('adds a new root entry when no reference id is given', () => { ++ const before = folderTreeService.getState().folderTree?.data ++ ?.length; ++ ++ folderTreeService.add({ ++ id: 20, ++ name: 'root2', ++ fileType: FileTypes.RootFolder, ++ }); ++ ++ const data = folderTreeService.getState().folderTree?.data || []; ++ expect(data.length).toBe((before || 0) + 1); ++ expect(folderTreeService.get(20)?.name).toBe('root2'); ++ expect(data.map((n: any) => n.id)).toContain(20); ++ }); ++ }); ++ ++ describe('update', () => { ++ test('merges the given fields into the existing node in place', () => { ++ folderTreeService.update({ id: 2, name: 'lib', isEditable: true }); ++ ++ const node = folderTreeService.get(2); ++ expect(node?.name).toBe('lib'); ++ expect(node?.isEditable).toBe(true); ++ ++ expect(node?.location).toBe('root/src'); ++ ++ expect(childIds(folderTreeService.get(1))).toContain(2); ++ ++ expect(childIds(node)).toContain(3); ++ }); ++ ++ test('does nothing when no node matches the id', () => { ++ const before = JSON.stringify( ++ folderTreeService.getState().folderTree?.data ++ ); ++ folderTreeService.update({ id: 999, name: 'nope' }); ++ const after = JSON.stringify( ++ folderTreeService.getState().folderTree?.data ++ ); ++ expect(after).toBe(before); ++ }); ++ }); ++ ++ describe('remove', () => { ++ test('removes the node and its subtree', () => { ++ folderTreeService.remove(2); ++ ++ expect(folderTreeService.get(2)).toBeNull(); ++ ++ expect(folderTreeService.get(3)).toBeNull(); ++ ++ expect(childIds(folderTreeService.get(1))).not.toContain(2); ++ }); ++ ++ test('leaves sibling nodes untouched', () => { ++ folderTreeService.remove(2); ++ ++ expect(folderTreeService.get(4)?.name).toBe('a.ts'); ++ expect(childIds(folderTreeService.get(1))).toContain(4); ++ }); ++ ++ test('does nothing when no node matches the id', () => { ++ const before = JSON.stringify( ++ folderTreeService.getState().folderTree?.data ++ ); ++ folderTreeService.remove(999); ++ const after = JSON.stringify( ++ folderTreeService.getState().folderTree?.data ++ ); ++ expect(after).toBe(before); ++ }); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,23 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++npx jest \ ++ src/services/workbench/__tests__/explorerService.test.ts \ ++ src/services/workbench/__tests__/menuBarService.test.ts \ ++ src/services/workbench/__tests__/panelService.test.ts ++ ++ ++npx jest src/services/workbench/explorer/__tests__/folderTreeCrud.test.ts diff --git a/tasks/format-code-task-000054/tests/test.sh b/tasks/format-code-task-000054/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..26518d925b1f3eeac6e1c345d2814e82e9c5939f --- /dev/null +++ b/tasks/format-code-task-000054/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/services/workbench/explorer/__tests__/folderTreeCrud.test.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-000054/tests/test_command.sh b/tasks/format-code-task-000054/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000054/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-000091/environment/Dockerfile b/tasks/format-code-task-000091/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..73e29c49f878f5c90c84cebadf851b07e56f8a92 --- /dev/null +++ b/tasks/format-code-task-000091/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:eb32b79a76215ea2e23af24cebf2c70aa11ebabe818addc77d0db12656a7bb52 diff --git a/tasks/format-code-task-000091/environment/setup/files/blocklist b/tasks/format-code-task-000091/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000091/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-000091/environment/setup/setup.sh b/tasks/format-code-task-000091/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000091/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-000091/tests/test.patch b/tasks/format-code-task-000091/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4ada8c8750231103f6d2530fe8db6fabd4f3f062 --- /dev/null +++ b/tasks/format-code-task-000091/tests/test.patch @@ -0,0 +1,175 @@ +diff --git a/Tests/Functional/Bundle/TestBundle/Controller/SerializerErrorController.php b/Tests/Functional/Bundle/TestBundle/Controller/SerializerErrorController.php +index a2d5708b9..9cca11064 100644 +--- a/Tests/Functional/Bundle/TestBundle/Controller/SerializerErrorController.php ++++ b/Tests/Functional/Bundle/TestBundle/Controller/SerializerErrorController.php +@@ -33,6 +33,11 @@ public function unknownExceptionAction() + throw new \OutOfBoundsException('Unknown exception message.'); + } + ++ public function invalidArgumentExceptionAction() ++ { ++ throw new \InvalidArgumentException('Invalid argument given.'); ++ } ++ + /** + * @View + */ +diff --git a/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml b/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml +index d41c53ecb..f3c307683 100644 +--- a/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml ++++ b/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml +@@ -10,6 +10,10 @@ test_serializer_unknown_exception: + path: /serializer-error/unknown_exception.{_format} + defaults: { _controller: FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller\SerializerErrorController::unknownExceptionAction } + ++test_serializer_invalid_argument_exception: ++ path: /serializer-error/invalid-argument-exception.{_format} ++ defaults: { _controller: FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller\SerializerErrorController::invalidArgumentExceptionAction } ++ + test_serializer_error_invalid_form: + path: /serializer-error/invalid-form.{_format} + defaults: { _controller: FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller\SerializerErrorController::invalidFormAction } +diff --git a/Tests/Functional/SerializerErrorTest.php b/Tests/Functional/SerializerErrorTest.php +index 12c943c96..019223070 100644 +--- a/Tests/Functional/SerializerErrorTest.php ++++ b/Tests/Functional/SerializerErrorTest.php +@@ -155,6 +155,61 @@ public function testSerializeUnknownExceptionJsonWithoutDebugUsingErrorRenderer( + $this->assertEquals('{"code":500,"message":"Internal Server Error"}', $client->getResponse()->getContent()); + } + ++ /** ++ * @dataProvider serializeExceptionCodeMappedToResponseStatusCodeJsonProvider ++ */ ++ public function testSerializeExceptionCodeMappedToResponseStatusCodeJsonUsingErrorRenderer(string $testCase, array $expectedJson) ++ { ++ if (!class_exists(SerializerErrorRenderer::class)) { ++ $this->markTestSkipped(); ++ } ++ ++ $this->iniSet('error_log', file_exists('/dev/null') ? '/dev/null' : 'nul'); ++ ++ $client = $this->createClient(array('test_case' => $testCase, 'debug' => false)); ++ $client->request('GET', '/serializer-error/invalid-argument-exception.json'); ++ ++ $this->assertEquals(json_encode($expectedJson), $client->getResponse()->getContent()); ++ } ++ ++ public function serializeExceptionCodeMappedToResponseStatusCodeJsonProvider(): array ++ { ++ return [ ++ [ ++ 'FlattenExceptionHandlerLegacyFormat', ++ [ ++ 'code' => 400, ++ 'message' => 'Invalid argument given.', ++ ], ++ ], ++ [ ++ 'FlattenExceptionHandlerRfc7807Format', ++ [ ++ 'type' => 'https://tools.ietf.org/html/rfc2616#section-10', ++ 'title' => 'An error occurred', ++ 'status' => 400, ++ 'detail' => 'Invalid argument given.', ++ ], ++ ], ++ [ ++ 'FlattenExceptionNormalizerLegacyFormat', ++ [ ++ 'code' => 400, ++ 'message' => 'Invalid argument given.', ++ ], ++ ], ++ [ ++ 'FlattenExceptionNormalizerRfc7807Format', ++ [ ++ 'type' => 'https://tools.ietf.org/html/rfc2616#section-10', ++ 'title' => 'An error occurred', ++ 'status' => 400, ++ 'detail' => 'Invalid argument given.', ++ ], ++ ], ++ ]; ++ } ++ + /** + * @group legacy + * +diff --git a/Tests/Functional/app/FlattenExceptionHandlerLegacyFormat/config.yml b/Tests/Functional/app/FlattenExceptionHandlerLegacyFormat/config.yml +index c8864537c..1ebc2e8fd 100644 +--- a/Tests/Functional/app/FlattenExceptionHandlerLegacyFormat/config.yml ++++ b/Tests/Functional/app/FlattenExceptionHandlerLegacyFormat/config.yml +@@ -4,6 +4,8 @@ imports: + + fos_rest: + exception: ++ codes: ++ 'InvalidArgumentException': 400 + exception_listener: false + serialize_exceptions: false + flatten_exception_format: 'legacy' +diff --git a/Tests/Functional/app/FlattenExceptionHandlerRfc7807Format/config.yml b/Tests/Functional/app/FlattenExceptionHandlerRfc7807Format/config.yml +index 515c52e78..1bd12447f 100644 +--- a/Tests/Functional/app/FlattenExceptionHandlerRfc7807Format/config.yml ++++ b/Tests/Functional/app/FlattenExceptionHandlerRfc7807Format/config.yml +@@ -4,6 +4,8 @@ imports: + + fos_rest: + exception: ++ codes: ++ 'InvalidArgumentException': 400 + exception_listener: false + serialize_exceptions: false + flatten_exception_format: 'rfc7807' +diff --git a/Tests/Functional/app/FlattenExceptionNormalizerLegacyFormat/config.yml b/Tests/Functional/app/FlattenExceptionNormalizerLegacyFormat/config.yml +index 619abbd9e..cbd34c49a 100644 +--- a/Tests/Functional/app/FlattenExceptionNormalizerLegacyFormat/config.yml ++++ b/Tests/Functional/app/FlattenExceptionNormalizerLegacyFormat/config.yml +@@ -8,6 +8,8 @@ framework: + + fos_rest: + exception: ++ codes: ++ 'InvalidArgumentException': 400 + exception_listener: false + serialize_exceptions: false + flatten_exception_format: 'legacy' +diff --git a/Tests/Functional/app/FlattenExceptionNormalizerRfc7807Format/config.yml b/Tests/Functional/app/FlattenExceptionNormalizerRfc7807Format/config.yml +index 50ff7c58a..cee95d557 100644 +--- a/Tests/Functional/app/FlattenExceptionNormalizerRfc7807Format/config.yml ++++ b/Tests/Functional/app/FlattenExceptionNormalizerRfc7807Format/config.yml +@@ -8,6 +8,8 @@ framework: + + fos_rest: + exception: ++ codes: ++ 'InvalidArgumentException': 400 + exception_listener: false + serialize_exceptions: false + flatten_exception_format: 'rfc7807' +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+3S3W/TMBAA8D7nrzi2aR9CzkdZWiRUpFE6NqmsVbs9TJpUOcm1teTake1sgPjj ++cUK7FRDsZRNC3O/FrX2Oz3cOs0rIYobqNmo9l9jrpmkzej+Pze8kbSft+FXbB7biJEm7nRakz5bR ++lso6bgBaRmv3p7jH1v9R4UP/HVo3y/VqxVUR2uXTnfFI/5M4Pd70P+l2Or7/x5123IL46VL4vf+8 ++/7svokyoKON2GVh0wDAI8gKax5BhEQS7cK58iaSE8dkYCixRFahygTbwb6XUFg2IdQRjSjOhHBqe ++O6GVnygNztGwQlj3fbk0emHQWmi/3U/gKzgu/Ma0PqgvkSvwrw8MiodDr5RwcGjFqpTIymVZ1f8L ++faek5oW9j+iG6VFgVsDMHMJ1WOBH2Gxh7BaN9WnVZ425y5fbe2GuTXPF12HyEuqrcScyIYX7DId7 ++H4ajdyfDKTS38ddHENZWeORrVgATcGCjmz3/kBa+hD3Yv9lseLM9vTV7cJ9itB6Zz4HFkTV5dOWE ++jPpazcWiMrwuZB1cZz2pFLglwvqTdZNgLiQG+KnUxsH0+uPp6OJ69n4wngz6J5fno4vp7GwwHA8m ++vR3fA55JLHrJzg91ufRfsdFppZqecRlN0QguxRc0A2O0qdebBP72WyWEEEIIIYQQQgghhBBCCCGE ++EEIIIb/6BmJ22oUAKAAA +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-000091/tests/test.sh b/tasks/format-code-task-000091/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..34595b1c429eae26ed99a065ca39880d38cf8972 --- /dev/null +++ b/tasks/format-code-task-000091/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' +Tests/Functional/Bundle/TestBundle/Controller/SerializerErrorController.php +Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml +Tests/Functional/SerializerErrorTest.php +Tests/Functional/app/FlattenExceptionHandlerLegacyFormat/config.yml +Tests/Functional/app/FlattenExceptionHandlerRfc7807Format/config.yml +Tests/Functional/app/FlattenExceptionNormalizerLegacyFormat/config.yml +Tests/Functional/app/FlattenExceptionNormalizerRfc7807Format/config.yml +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-000091/tests/test_command.sh b/tasks/format-code-task-000091/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000091/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-000144/environment/Dockerfile b/tasks/format-code-task-000144/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..09c5716b62c30a669cb9dd91d152100ea61905da --- /dev/null +++ b/tasks/format-code-task-000144/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:3c7cf4ebb921cae9b1d6499c1b43ef7ac1986825455bbbc0208f3ce6e9200289 diff --git a/tasks/format-code-task-000144/environment/setup/files/blocklist b/tasks/format-code-task-000144/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000144/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-000144/environment/setup/setup.sh b/tasks/format-code-task-000144/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000144/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-000144/tests/test.patch b/tasks/format-code-task-000144/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c6d2a8cd773ac89ad8b605e91af5292630e32dad --- /dev/null +++ b/tasks/format-code-task-000144/tests/test.patch @@ -0,0 +1,106 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..cfa9c2d98 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_logging.py -k \"test_tensorboard_default_logdir_uses_version_prefix or test_tensorboard_manual_version_creates_version_prefixed_dir or test_tensorboard_auto_version_reads_version_prefixed_dirs or test_tensorboard_auto_version_ignores_bare_digit_dirs or test_tensorboard_save_writes_meta_tags_in_version_dir\" -v"] ++} +diff --git a/tests/test_logging.py b/tests/test_logging.py +index 5467d0aab..1be99f6ff 100644 +--- a/tests/test_logging.py ++++ b/tests/test_logging.py +@@ -340,6 +340,79 @@ def test_tensorboard_log_hyperparams(tmpdir): + logger.log_hyperparams(hparams) + + ++def test_tensorboard_default_logdir_uses_version_prefix(tmpdir): ++ """The experiment directory must be named 'version_' so it matches ++ ModelCheckpoint's default of 'lightning_logs/version_0'.""" ++ logger = TensorBoardLogger(save_dir=str(tmpdir), name="default_prefix_test") ++ _ = logger.experiment ++ ++ name_dir = os.path.join(str(tmpdir), "default_prefix_test") ++ expected = os.path.join(name_dir, "version_0") ++ bare = os.path.join(name_dir, "0") ++ ++ assert os.path.isdir(expected), \ ++ "Expected experiment dir to be 'version_0', got contents: %r" % os.listdir(name_dir) ++ assert not os.path.isdir(bare), \ ++ "Expected bare numeric dir '0' NOT to exist alongside 'version_0'" ++ ++ ++def test_tensorboard_manual_version_creates_version_prefixed_dir(tmpdir): ++ """When the user passes an explicit version, the on-disk directory ++ must be 'version_'.""" ++ logger = TensorBoardLogger(save_dir=str(tmpdir), ++ name="manual_prefix_test", ++ version=5) ++ _ = logger.experiment ++ ++ name_dir = os.path.join(str(tmpdir), "manual_prefix_test") ++ assert os.path.isdir(os.path.join(name_dir, "version_5")) ++ assert not os.path.isdir(os.path.join(name_dir, "5")) ++ ++ ++def test_tensorboard_auto_version_reads_version_prefixed_dirs(tmpdir): ++ """Auto-versioning must scan dirs named 'version_' and pick max+1.""" ++ root_dir = tmpdir.mkdir("auto_version_prefix") ++ root_dir.mkdir("version_0") ++ root_dir.mkdir("version_1") ++ ++ logger = TensorBoardLogger(save_dir=str(tmpdir), name="auto_version_prefix") ++ assert logger.version == 2 ++ ++ ++def test_tensorboard_auto_version_ignores_bare_digit_dirs(tmpdir): ++ """Bare numeric dirs (legacy / unrelated) must NOT be counted by ++ auto-versioning. Only 'version_' dirs participate.""" ++ root_dir = tmpdir.mkdir("auto_version_ignore_bare") ++ ++ root_dir.mkdir("0") ++ root_dir.mkdir("1") ++ root_dir.mkdir("7") ++ ++ logger = TensorBoardLogger(save_dir=str(tmpdir), name="auto_version_ignore_bare") ++ ++ assert logger.version == 0 ++ ++ ++def test_tensorboard_save_writes_meta_tags_in_version_dir(tmpdir): ++ """save() must write meta_tags.csv inside the same 'version_' dir ++ that experiment created (not fall back to save_dir).""" ++ logger = TensorBoardLogger(save_dir=str(tmpdir), ++ name="save_meta_test", ++ version=3) ++ logger.log_hyperparams({"a": 1}) ++ logger.save() ++ ++ expected_csv = os.path.join(str(tmpdir), ++ "save_meta_test", ++ "version_3", ++ logger.NAME_CSV_TAGS) ++ fallback_csv = os.path.join(str(tmpdir), logger.NAME_CSV_TAGS) ++ assert os.path.isfile(expected_csv), \ ++ "meta_tags.csv must be written inside the version_ dir" ++ assert not os.path.isfile(fallback_csv), \ ++ "meta_tags.csv must NOT fall back to save_dir when version dir exists" ++ ++ + def test_custom_logger(tmpdir): + class CustomLogger(LightningLoggerBase): + def __init__(self): +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_logging.py -k "test_tensorboard_default_logdir_uses_version_prefix or test_tensorboard_manual_version_creates_version_prefixed_dir or test_tensorboard_auto_version_reads_version_prefixed_dirs or test_tensorboard_auto_version_ignores_bare_digit_dirs or test_tensorboard_save_writes_meta_tags_in_version_dir" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000144/tests/test.sh b/tasks/format-code-task-000144/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..aaa91de993d7c81e9fafab3f7faf6b1f18b2c252 --- /dev/null +++ b/tasks/format-code-task-000144/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_logging.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-000144/tests/test_command.sh b/tasks/format-code-task-000144/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000144/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-000172/environment/Dockerfile b/tasks/format-code-task-000172/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cdf7e53fbdc2273b95b81737f85bc9a01358f923 --- /dev/null +++ b/tasks/format-code-task-000172/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:6c19f43ea3850ca52a3fe0cb7bc86a29932314b891e422a8883b500424da0967 diff --git a/tasks/format-code-task-000172/environment/setup/files/blocklist b/tasks/format-code-task-000172/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000172/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-000172/environment/setup/setup.sh b/tasks/format-code-task-000172/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000172/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-000172/tests/test.patch b/tasks/format-code-task-000172/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7e4c16271ce61bab6ef0e45067917a0b675b6314 --- /dev/null +++ b/tasks/format-code-task-000172/tests/test.patch @@ -0,0 +1,95 @@ +diff --git a/pkg/auth/auth_test.go b/pkg/auth/auth_test.go +index b96d6500..1838a867 100644 +--- a/pkg/auth/auth_test.go ++++ b/pkg/auth/auth_test.go +@@ -153,6 +153,59 @@ Pollers: + auth_style: certificate_auth + `, + }, ++ ++ { ++ // Issue: credentials_script in Defaults must be called with the ++ // poller's address, not an empty/default one. ++ name: "default credentials_script passes poller addr", ++ pollerName: "ontap1", ++ want: PollerAuth{Username: "foo_ontap", Password: "addr=ontap1.local user=foo_ontap", IsCert: false}, ++ defaultDefined: true, ++ yaml: ` ++Defaults: ++ username: foo_ontap ++ credentials_script: ++ path: testdata/get_pass_args ++Pollers: ++ ontap1: ++ addr: ontap1.local`, ++ }, ++ ++ { ++ // When poller has its own username, the credentials_script ++ // (from Defaults) must be invoked with the poller's username. ++ name: "default credentials_script uses poller username when set", ++ pollerName: "ontap1", ++ want: PollerAuth{Username: "poller_user", Password: "addr=ontap1.local user=poller_user", IsCert: false}, ++ defaultDefined: true, ++ yaml: ` ++Defaults: ++ username: default_user ++ credentials_script: ++ path: testdata/get_pass_args ++Pollers: ++ ontap1: ++ addr: ontap1.local ++ username: poller_user`, ++ }, ++ ++ { ++ // When poller has NO username, the credentials_script ++ // (from Defaults) must be invoked with the default username ++ // (not an empty string). ++ name: "default credentials_script uses default username when poller has none", ++ pollerName: "ontap1", ++ want: PollerAuth{Username: "default_user", Password: "addr=ontap1.local user=default_user", IsCert: false}, ++ defaultDefined: true, ++ yaml: ` ++Defaults: ++ username: default_user ++ credentials_script: ++ path: testdata/get_pass_args ++Pollers: ++ ontap1: ++ addr: ontap1.local`, ++ }, + } + + for _, tt := range tests { +diff --git a/pkg/auth/testdata/get_pass_args b/pkg/auth/testdata/get_pass_args +new file mode 100755 +index 00000000..ff3b7f6d +--- /dev/null ++++ b/pkg/auth/testdata/get_pass_args +@@ -0,0 +1,3 @@ ++#!/bin/bash ++ ++echo "addr=$1 user=$2" +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..35d0d42d +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test -v -run TestCredentials_GetPollerAuth ./pkg/auth/"] ++} +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 -v -run TestCredentials_GetPollerAuth ./pkg/auth/ ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000172/tests/test.sh b/tasks/format-code-task-000172/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..03b59b14d2a66c91955db9daeadf85cc7ca708ba --- /dev/null +++ b/tasks/format-code-task-000172/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/auth/auth_test.go +pkg/auth/testdata/get_pass_args +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-000172/tests/test_command.sh b/tasks/format-code-task-000172/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000172/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-000186/environment/Dockerfile b/tasks/format-code-task-000186/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..48ad75cc5dcea14732b0029f94e0fdba1ecf038b --- /dev/null +++ b/tasks/format-code-task-000186/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:3454a0a03e256ff08de9c3d2368f17bf6b3e1c8c820dc0a23778648c04158056 diff --git a/tasks/format-code-task-000186/environment/setup/files/blocklist b/tasks/format-code-task-000186/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000186/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-000186/environment/setup/setup.sh b/tasks/format-code-task-000186/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000186/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-000186/tests/test.patch b/tasks/format-code-task-000186/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a6754e2ba64c95a926e713b685a15428b4cbb7f8 --- /dev/null +++ b/tasks/format-code-task-000186/tests/test.patch @@ -0,0 +1,268 @@ +diff --git a/cmd/validator/accounts/import_fixture_test.go b/cmd/validator/accounts/import_fixture_test.go +new file mode 100644 +index 0000000000..6fc0b3c23a +--- /dev/null ++++ b/cmd/validator/accounts/import_fixture_test.go +@@ -0,0 +1,239 @@ ++package accounts ++ ++import ( ++ "flag" ++ "io" ++ "os" ++ "path/filepath" ++ "strings" ++ "testing" ++ ++ "github.com/ethereum/go-ethereum/common/hexutil" ++ "github.com/prysmaticlabs/prysm/v4/cmd/validator/flags" ++ "github.com/prysmaticlabs/prysm/v4/config/params" ++ "github.com/prysmaticlabs/prysm/v4/testing/assert" ++ "github.com/prysmaticlabs/prysm/v4/testing/require" ++ validatorAccounts "github.com/prysmaticlabs/prysm/v4/validator/accounts" ++ "github.com/prysmaticlabs/prysm/v4/validator/accounts/iface" ++ validatorWallet "github.com/prysmaticlabs/prysm/v4/validator/accounts/wallet" ++ "github.com/prysmaticlabs/prysm/v4/validator/keymanager" ++ "github.com/prysmaticlabs/prysm/v4/validator/keymanager/local" ++ "github.com/sirupsen/logrus" ++ logTest "github.com/sirupsen/logrus/hooks/test" ++ "github.com/urfave/cli/v2" ++) ++ ++func TestFixtureAccountsImportPromptsWalletDirectoryOnceWhenCreatingWallet(t *testing.T) { ++ local.ResetCaches() ++ keysDir := t.TempDir() ++ firstWalletDir := filepath.Join(t.TempDir(), "wallet-entered-first") ++ secondSentinelDir := filepath.Join(t.TempDir(), "wallet-second-sentinel") ++ defaultWalletDir := filepath.Join(t.TempDir(), "default-wallet") ++ _, _, passwordFilePath := setupWalletAndPasswordsDir(t) ++ keystore, _ := createKeystore(t, keysDir) ++ ++ cliCtx := setupPromptedImportCtx(t, defaultWalletDir, keysDir, passwordFilePath) ++ output, err := runWithStdinAndCapturedStdout( ++ t, ++ strings.Join([]string{firstWalletDir, secondSentinelDir}, "\n")+"\n", ++ func() error { ++ return accountsImport(cliCtx) ++ }, ++ ) ++ require.NoError(t, err) ++ assert.Equal(t, 1, strings.Count(output, "Enter a wallet directory")) ++ ++ firstExists, err := validatorWallet.Exists(firstWalletDir) ++ require.NoError(t, err) ++ assert.Equal(t, true, firstExists) ++ secondExists, err := validatorWallet.Exists(secondSentinelDir) ++ require.NoError(t, err) ++ assert.Equal(t, false, secondExists) ++ ++ importedKeys := fetchWalletPublicKeys(t, cliCtx, firstWalletDir) ++ assert.Equal(t, true, publicKeyHexSet(importedKeys)[keystore.Pubkey]) ++} ++ ++func TestFixtureAccountsImportDiscoversTopLevelAndNestedKeystores(t *testing.T) { ++ keysDir := t.TempDir() ++ topKey := writeImportKeystore(t, keysDir, "validator-root-alpha.json") ++ ++ depthOneDir := filepath.Join(keysDir, "batch-alpha", "validators-a") ++ depthOneKey := writeImportKeystore(t, depthOneDir, "account-beta-01.json") ++ ++ depthTwoDir := filepath.Join(keysDir, "group-gamma", "segment-delta") ++ depthTwoKey := writeImportKeystore(t, depthTwoDir, "deposit-gamma-02.json") ++ ++ importedKeys := importKeystoresFromDir(t, keysDir) ++ importedSet := publicKeyHexSet(importedKeys) ++ assert.Equal(t, true, importedSet[topKey.Pubkey]) ++ assert.Equal(t, true, importedSet[depthOneKey.Pubkey]) ++ assert.Equal(t, true, importedSet[depthTwoKey.Pubkey]) ++ assert.Equal(t, 3, len(importedSet)) ++} ++ ++func TestFixtureAccountsImportStopsAtMaxKeystoreDirectoryDepth(t *testing.T) { ++ hook := logTest.NewGlobal() ++ keysDir := t.TempDir() ++ supportedDir := filepath.Join(keysDir, "outer-supported", "inner-supported") ++ supportedKey := writeImportKeystore(t, supportedDir, "validator-supported-depth.json") ++ ++ tooDeepDir := filepath.Join(keysDir, "outer-too-deep", "inner-too-deep", "beyond-limit") ++ tooDeepKey := writeImportKeystore(t, tooDeepDir, "validator-too-deep-omega.json") ++ ++ infoLogsBeforeImport := countLogEntriesAtLevel(hook, logrus.InfoLevel) ++ importedKeys := importKeystoresFromDir(t, keysDir) ++ importedSet := publicKeyHexSet(importedKeys) ++ assert.Equal(t, true, importedSet[supportedKey.Pubkey]) ++ assert.Equal(t, false, importedSet[tooDeepKey.Pubkey]) ++ assert.Equal(t, true, countLogEntriesAtLevel(hook, logrus.InfoLevel) > infoLogsBeforeImport) ++} ++ ++func TestFixtureAccountsImportLogsStartOfKeystoreImport(t *testing.T) { ++ hook := logTest.NewGlobal() ++ keysDir := t.TempDir() ++ writeImportKeystore(t, keysDir, "validator-start-log.json") ++ ++ infoLogsBeforeImport := countLogEntriesAtLevel(hook, logrus.InfoLevel) ++ _ = importKeystoresFromDir(t, keysDir) ++ assert.Equal(t, true, countLogEntriesAtLevel(hook, logrus.InfoLevel) > infoLogsBeforeImport) ++} ++ ++func TestFixtureAccountsImportDirectoryProcessingFailureReportsImportDirectoryError(t *testing.T) { ++ local.ResetCaches() ++ walletDir, passwordsDir, passwordFilePath := setupWalletAndPasswordsDir(t) ++ missingKeysDir := filepath.Join(t.TempDir(), "missing-keys-dir") ++ cliCtx := setupWalletCtx(t, &testWalletConfig{ ++ walletDir: walletDir, ++ passwordsDir: passwordsDir, ++ keysDir: missingKeysDir, ++ keymanagerKind: keymanager.Local, ++ walletPasswordFile: passwordFilePath, ++ accountPasswordFile: passwordFilePath, ++ }) ++ acc, err := validatorAccounts.NewCLIManager( ++ validatorAccounts.WithWalletDir(walletDir), ++ validatorAccounts.WithKeymanagerType(keymanager.Local), ++ validatorAccounts.WithWalletPassword(password), ++ ) ++ require.NoError(t, err) ++ _, err = acc.WalletCreate(cliCtx.Context) ++ require.NoError(t, err) ++ ++ err = accountsImport(cliCtx) ++ if err == nil { ++ t.Fatal("expected missing keys directory to fail") ++ } ++} ++ ++func importKeystoresFromDir(t *testing.T, keysDir string) [][48]byte { ++ t.Helper() ++ local.ResetCaches() ++ walletDir, passwordsDir, passwordFilePath := setupWalletAndPasswordsDir(t) ++ cliCtx := setupWalletCtx(t, &testWalletConfig{ ++ walletDir: walletDir, ++ passwordsDir: passwordsDir, ++ keysDir: keysDir, ++ keymanagerKind: keymanager.Local, ++ walletPasswordFile: passwordFilePath, ++ accountPasswordFile: passwordFilePath, ++ }) ++ acc, err := validatorAccounts.NewCLIManager( ++ validatorAccounts.WithWalletDir(walletDir), ++ validatorAccounts.WithKeymanagerType(keymanager.Local), ++ validatorAccounts.WithWalletPassword(password), ++ ) ++ require.NoError(t, err) ++ _, err = acc.WalletCreate(cliCtx.Context) ++ require.NoError(t, err) ++ require.NoError(t, accountsImport(cliCtx)) ++ return fetchWalletPublicKeys(t, cliCtx, walletDir) ++} ++ ++func fetchWalletPublicKeys(t *testing.T, cliCtx *cli.Context, walletDir string) [][48]byte { ++ t.Helper() ++ w, err := validatorWallet.OpenWallet(cliCtx.Context, &validatorWallet.Config{ ++ WalletDir: walletDir, ++ WalletPassword: password, ++ }) ++ require.NoError(t, err) ++ km, err := w.InitializeKeymanager(cliCtx.Context, iface.InitKeymanagerConfig{ListenForChanges: false}) ++ require.NoError(t, err) ++ keys, err := km.FetchValidatingPublicKeys(cliCtx.Context) ++ require.NoError(t, err) ++ return keys ++} ++ ++func setupPromptedImportCtx(t testing.TB, defaultWalletDir, keysDir, passwordFilePath string) *cli.Context { ++ t.Helper() ++ app := cli.App{} ++ set := flag.NewFlagSet("fixture-import", 0) ++ set.String(flags.WalletDirFlag.Name, defaultWalletDir, "") ++ set.String(flags.KeysDirFlag.Name, "", "") ++ set.String(flags.WalletPasswordFileFlag.Name, "", "") ++ set.String(flags.AccountPasswordFileFlag.Name, "", "") ++ set.String(flags.KeymanagerKindFlag.Name, keymanager.Local.String(), "") ++ set.String(flags.GrpcHeadersFlag.Name, "", "") ++ ++ assert.NoError(t, set.Set(flags.KeysDirFlag.Name, keysDir)) ++ assert.NoError(t, set.Set(flags.WalletPasswordFileFlag.Name, passwordFilePath)) ++ assert.NoError(t, set.Set(flags.AccountPasswordFileFlag.Name, passwordFilePath)) ++ return cli.NewContext(&app, set, nil) ++} ++ ++func writeImportKeystore(t *testing.T, dir, name string) *keymanager.Keystore { ++ t.Helper() ++ require.NoError(t, os.MkdirAll(dir, params.BeaconIoConfig().ReadWriteExecutePermissions)) ++ keystore, path := createKeystore(t, dir) ++ newPath := filepath.Join(dir, name) ++ require.NoError(t, os.Rename(path, newPath)) ++ return keystore ++} ++ ++func publicKeyHexSet(keys [][48]byte) map[string]bool { ++ out := make(map[string]bool, len(keys)) ++ for _, key := range keys { ++ out[hexutil.Encode(key[:])[2:]] = true ++ } ++ return out ++} ++ ++func countLogEntriesAtLevel(hook *logTest.Hook, level logrus.Level) int { ++ count := 0 ++ for _, entry := range hook.AllEntries() { ++ if entry.Level == level { ++ count++ ++ } ++ } ++ return count ++} ++ ++func runWithStdinAndCapturedStdout(t testing.TB, input string, fn func() error) (string, error) { ++ t.Helper() ++ stdinFile, err := os.CreateTemp(t.TempDir(), "stdin") ++ require.NoError(t, err) ++ _, err = stdinFile.WriteString(input) ++ require.NoError(t, err) ++ _, err = stdinFile.Seek(0, 0) ++ require.NoError(t, err) ++ ++ oldStdin := os.Stdin ++ oldStdout := os.Stdout ++ stdoutReader, stdoutWriter, err := os.Pipe() ++ require.NoError(t, err) ++ outCh := make(chan string, 1) ++ go func() { ++ out, _ := io.ReadAll(stdoutReader) ++ outCh <- string(out) ++ }() ++ ++ os.Stdin = stdinFile ++ os.Stdout = stdoutWriter ++ runErr := fn() ++ require.NoError(t, stdoutWriter.Close()) ++ os.Stdout = oldStdout ++ os.Stdin = oldStdin ++ require.NoError(t, stdinFile.Close()) ++ require.NoError(t, stdoutReader.Close()) ++ return <-outCh, runErr ++} +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 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++case "${1:-}" in ++ base) ++ go test ./cmd/validator/accounts -run '^TestImport_Noninteractive$' -v -count=1 -timeout 120s ++ ;; ++ new) ++ go test ./cmd/validator/accounts -run '^TestFixtureAccountsImport' -v -count=1 -timeout 120s ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000186/tests/test.sh b/tasks/format-code-task-000186/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7bbc6ac83eea8d245e6d92653f6f87c01b400afe --- /dev/null +++ b/tasks/format-code-task-000186/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' +cmd/validator/accounts/import_fixture_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-000186/tests/test_command.sh b/tasks/format-code-task-000186/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000186/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-000203/environment/Dockerfile b/tasks/format-code-task-000203/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..59dba8af9795b1923e0ba0248ca174a31d78fbf4 --- /dev/null +++ b/tasks/format-code-task-000203/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:3e84ec0d461f7934a6c2dc33952fda198255c717778f8d54bb1acd49ec49a897 diff --git a/tasks/format-code-task-000203/environment/setup/files/blocklist b/tasks/format-code-task-000203/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000203/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-000203/environment/setup/setup.sh b/tasks/format-code-task-000203/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000203/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-000203/tests/test.patch b/tasks/format-code-task-000203/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..58434fa697d6a9f9b36ec44f72adc21ce64517c8 --- /dev/null +++ b/tasks/format-code-task-000203/tests/test.patch @@ -0,0 +1,65 @@ +diff --git a/tests/ops/op_math/test_exp.py b/tests/ops/op_math/test_exp.py +index bd54d4c3dd7..e6be0ec2010 100644 +--- a/tests/ops/op_math/test_exp.py ++++ b/tests/ops/op_math/test_exp.py +@@ -139,14 +139,38 @@ def test_prod_base_isingyy(self): + assert qml.math.allclose(op.matrix(), isingxx.matrix()) + + @pytest.mark.autograd +- def test_matrix_autograd_rx(self): ++ @pytest.mark.parametrize("requires_grad", (True, False)) ++ def test_matrix_autograd_rx(self, requires_grad): + """Test the matrix comparing to the rx gate.""" +- phi = np.array(1.234) ++ phi = np.array(1.234, requires_grad=requires_grad) + exp_rx = Exp(qml.PauliX(0), -0.5j * phi) + rx = qml.RX(phi, 0) + + assert qml.math.allclose(exp_rx.matrix(), rx.matrix()) + ++ @pytest.mark.autograd ++ @pytest.mark.parametrize("requires_grad", (True, False)) ++ def test_matrix_autograd_rz(self, requires_grad): ++ """Test the matrix comparing to the rz gate. This is a gate with an ++ autograd coefficient but empty diagonalizing gates.""" ++ phi = np.array(1.234, requires_grad=requires_grad) ++ exp_rz = Exp(qml.PauliZ(0), -0.5j * phi) ++ rz = qml.RZ(phi, 0) ++ ++ assert qml.math.allclose(exp_rz.matrix(), rz.matrix()) ++ ++ @pytest.mark.autograd ++ @pytest.mark.parametrize("requires_grad", (True, False)) ++ def test_tensor_with_pauliz_autograd(self, requires_grad): ++ """Test the matrix for the case when the coefficient is autograd and ++ the diagonalizing gates don't act on every wire for the matrix.""" ++ phi = qml.numpy.array(-0.345, requires_grad=requires_grad) ++ base = qml.PauliZ(0) @ qml.PauliY(1) ++ autograd_op = Exp(base, phi) ++ mat = qml.math.expm(phi * qml.matrix(base)) ++ ++ assert qml.math.allclose(autograd_op.matrix(), mat) ++ + @pytest.mark.autograd + def test_base_no_diagonalizing_gates_autograd_coeff(self): + """Test the matrix when the base matrix doesn't define the diagonalizing gates.""" +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+3STwuCMBjHcc+9iufUTduWs1tvRSwFg3SSM+rdt+xQBNWliOj7gf1he2AbvyWr ++YbMt86rdz6JPUcHC2nEM7sdxrq1RJjM2TUOd1pnKIrEfu9GNoffFTiTaOeef1b3a/1HJNX9f9T5f ++u6Yp2jLp6/ed8Sp/rRbX/JUJ+aeZ1pGo913hsT/Pf13KGPyqKifd0deunUvcSJiGRTl3/cx155Y3 ++ha8vn6Q6dEl3lPgg8V7Mcqon334GAAAAAAAAAAAAAAAA8JdOB4dSjgAoAAA= +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-000203/tests/test.sh b/tasks/format-code-task-000203/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..89de0c6c09e71695e4946bb9f7870939a0c6fa40 --- /dev/null +++ b/tasks/format-code-task-000203/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/ops/op_math/test_exp.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-000203/tests/test_command.sh b/tasks/format-code-task-000203/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000203/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-000204/environment/Dockerfile b/tasks/format-code-task-000204/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a461dd9c2832e54065c851c4e4c6fdc81c1cdaa2 --- /dev/null +++ b/tasks/format-code-task-000204/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:d17c2f81936648d4380660d241455373357dbd10cc816e54c9ead3d3ff5f6006 diff --git a/tasks/format-code-task-000204/environment/setup/files/blocklist b/tasks/format-code-task-000204/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000204/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-000204/environment/setup/setup.sh b/tasks/format-code-task-000204/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000204/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-000204/tests/test.patch b/tasks/format-code-task-000204/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cf64cc55f962fc13e34b6d6dabbee4a78705c6d5 --- /dev/null +++ b/tasks/format-code-task-000204/tests/test.patch @@ -0,0 +1,121 @@ +diff --git a/tests/circuit_graph/test_circuit_graph.py b/tests/circuit_graph/test_circuit_graph.py +index 2b2f086165c..63836e34d31 100644 +--- a/tests/circuit_graph/test_circuit_graph.py ++++ b/tests/circuit_graph/test_circuit_graph.py +@@ -23,6 +23,8 @@ + + import pennylane as qml + from pennylane import numpy as pnp ++from pennylane.tape import QuantumTape ++from pennylane.resource import ResourcesOperation, Resources + from pennylane.circuit_graph import CircuitGraph + from pennylane.wires import Wires + +@@ -92,6 +94,27 @@ def circuit_measure_multiple_with_max_twice(): + ) + + ++class CustomOpDepth2(ResourcesOperation): ++ num_wires = 3 ++ ++ def resources(self): ++ return Resources(num_wires=self.num_wires, depth=2) ++ ++ ++class CustomOpDepth3(ResourcesOperation): ++ num_wires = 2 ++ ++ def resources(self): ++ return Resources(num_wires=self.num_wires, depth=3) ++ ++ ++class CustomOpDepth4(ResourcesOperation): ++ num_wires = 2 ++ ++ def resources(self): ++ return Resources(num_wires=self.num_wires, depth=4) ++ ++ + class TestCircuitGraph: + """Test conversion of queues to DAGs""" + +@@ -318,3 +341,33 @@ def test_print_contents(self): + + expected = """Operations\n==========\nHadamard(wires=[0])\nCNOT(wires=[0, 1])\n\nObservables\n===========\nsample(wires=[0, 1, 2])""" + assert out == expected ++ ++ tape_depth = ( ++ ([qml.PauliZ(0), qml.CNOT([0, 1]), qml.RX(1.23, 2)], 2), ++ ([qml.Hadamard(0), qml.CNOT([0, 1]), CustomOpDepth3(wires=[1, 0])], 5), ++ ( ++ [ ++ qml.RX(1.23, 0), ++ qml.RZ(-0.45, 0), ++ CustomOpDepth3(wires=[3, 4]), ++ qml.Hadamard(0), ++ qml.Hadamard(1), ++ qml.Hadamard(2), ++ qml.Hadamard(3), ++ qml.Hadamard(4), ++ CustomOpDepth2(wires=[1, 2, 3]), ++ qml.RZ(-1, 4), ++ qml.RX(0.5, 4), ++ qml.RX(0.5, 3), ++ CustomOpDepth4(wires=[0, 1]), ++ qml.CNOT(wires=[3, 4]), ++ ], ++ 10, ++ ), ++ ) ++ ++ @pytest.mark.parametrize("ops, true_depth", tape_depth) ++ def test_get_depth(self, ops, true_depth): ++ """Test that depth is computed correctly for operations that define a custom depth > 1""" ++ cg = CircuitGraph(ops, [], wires=[0, 1, 2, 3, 4]) ++ assert cg.get_depth() == true_depth +diff --git a/tests/resource/test_resource.py b/tests/resource/test_resource.py +index 75d2bcf564d..84c9841b6dc 100644 +--- a/tests/resource/test_resource.py ++++ b/tests/resource/test_resource.py +@@ -251,17 +251,12 @@ class _CustomOpWithoutResource(Operation): # pylint: disable=too-few-public-met + Resources(2, 2, {"Hadamard": 1, "CNOT": 1}, {1: 1, 2: 1}, 2, 0), + Resources(3, 3, {"PauliZ": 1, "CNOT": 1, "RX": 1}, {1: 2, 2: 1}, 2, 10), + Resources(2, 6, {"Hadamard": 3, "RX": 2, "CNOT": 1}, {1: 5, 2: 1}, 4, 100), +- Resources(2, 5, {"Hadamard": 1, "CNOT": 1, "Identity": 1, "PauliZ": 2}, {1: 4, 2: 1}, None, 0), ++ Resources(2, 5, {"Hadamard": 1, "CNOT": 1, "Identity": 1, "PauliZ": 2}, {1: 4, 2: 1}, 5, 0), + Resources( +- 3, +- 7, +- {"PauliZ": 3, "CNOT": 1, "RX": 1, "Identity": 1, "CustomOp2": 1}, +- {1: 5, 2: 2}, +- None, +- 10, ++ 3, 7, {"PauliZ": 3, "CNOT": 1, "RX": 1, "Identity": 1, "CustomOp2": 1}, {1: 5, 2: 2}, 6, 10 + ), + Resources(2, 7, {"Hadamard": 3, "RX": 2, "CNOT": 1, "CustomOp2": 1}, {1: 5, 2: 2}, 5, 100), +-) ++) + + + @pytest.mark.parametrize( +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+3S3W6DIBgGYI69Cm6g/OjQyzGIZJJMMYAmvfuh7dpmydaTNkuz9zmQT/kM6Avr ++FvfRt3ZaOXkWkTVK7WP2fdxrqUop66qRsiEiV0IRqp62oxtLTDpQSoL36be+e/Mvil3zTzam1vhx ++1FPP4vC4Ne7lX8rqkr+o65z/W10KQsXjtvCzf56/6ekefGf7IvolGEv59qmcrduZ6NzEtUlu1ckW ++8zENfqroYaS5zC/R7RK5ccEsLrXvQc/D+RjdPmLz8dwZ7GmNU9PX3TZ/WIu//hUAAAAAAAAAAAAA ++AAAAAAAAAC/nE3saecwAKAAA +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-000204/tests/test.sh b/tasks/format-code-task-000204/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..03df83eb3add0ea21ee1c756102cb24f6c5b69bf --- /dev/null +++ b/tasks/format-code-task-000204/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/circuit_graph/test_circuit_graph.py +tests/resource/test_resource.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-000204/tests/test_command.sh b/tasks/format-code-task-000204/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000204/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-000232/environment/Dockerfile b/tasks/format-code-task-000232/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8ae32d06e3d875c84b4b29c13fe1249184b0ec56 --- /dev/null +++ b/tasks/format-code-task-000232/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:c6fe309a04c12ac97db65bf11a31c8a811db4e3aae55a588823cc4ceb3cad3b8 diff --git a/tasks/format-code-task-000232/environment/setup/files/blocklist b/tasks/format-code-task-000232/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000232/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-000232/environment/setup/setup.sh b/tasks/format-code-task-000232/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000232/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-000232/tests/test.patch b/tasks/format-code-task-000232/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..19ec37f4369a746ba474e6246924057a95ce4f83 --- /dev/null +++ b/tasks/format-code-task-000232/tests/test.patch @@ -0,0 +1,91 @@ +diff --git a/quantecon/tests/test_gridtools.py b/quantecon/tests/test_gridtools.py +index 4e965c151..938379352 100644 +--- a/quantecon/tests/test_gridtools.py ++++ b/quantecon/tests/test_gridtools.py +@@ -5,11 +5,13 @@ + import numpy as np + import time + import pytest +-from numpy.testing import assert_array_equal, assert_, assert_raises ++from numpy.testing import ( ++ assert_array_equal, assert_equal, assert_, assert_raises ++) + + from quantecon.gridtools import ( + cartesian, mlinspace, _repeat_1d, simplex_grid, simplex_index, +- num_compositions, num_compositions_jit ++ num_compositions, num_compositions_jit, cartesian_nearest_index + ) + + +@@ -165,6 +167,49 @@ def test_repeat(): + assert_(abs(t_numpy-t_repeat).max()) + + ++class TestCartesianNearestIndex: ++ def setup_method(self): ++ nums = (5, 6) ++ self.nodes = [list(range(nums[0])), np.linspace(0, 1, nums[1])] ++ self.orders = ['C', 'F'] ++ self.prod_dict = \ ++ {order:cartesian(self.nodes, order=order) for order in self.orders} ++ ++ def linear_search(self, x, order='C'): ++ x = np.asarray(x) ++ return ((self.prod_dict[order] - x)**2).sum(1).argmin() ++ ++ def test_1d(self): ++ x = (1.2, 0.3) ++ for order in self.orders: ++ ind_expected = self.linear_search(x, order) ++ ind_computed = cartesian_nearest_index(x, self.nodes, order) ++ assert_equal(ind_computed, ind_expected) ++ ++ assert_raises( ++ ValueError, cartesian_nearest_index, x, self.prod_dict['C'] ++ ) ++ ++ def test_2d(self): ++ T = 10 ++ rng = np.random.default_rng(1234) ++ X = np.column_stack(( ++ rng.uniform(self.nodes[0][0]-1, self.nodes[0][-1]+1, size=T), ++ rng.standard_normal(T) + 0.5 ++ )) ++ ind_expected = np.empty(T, dtype=np.intp) ++ ++ for order in self.orders: ++ for t in range(T): ++ ind_expected[t] = self.linear_search(X[t], order) ++ ind_computed = cartesian_nearest_index(X, self.nodes, order) ++ assert_array_equal(ind_computed, ind_expected) ++ ++ assert_raises( ++ ValueError, cartesian_nearest_index, X, self.prod_dict['C'] ++ ) ++ ++ + class TestSimplexGrid: + def setup_method(self): + self.simplex_grid_3_4 = np.array([[0, 0, 4], +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+3S32rCMBQG8Fz3KY54bZKqaR9H0iSsBZu4Ji369qYdY2PgvFHGtu93cwL5z3d4 ++M3ZHe3B+EuxZZFYrtdTsa13GpdrKbb2rZLlnsixzZaSe9qJPxpj0QMSGENJ36+7N/1L8I//kYjqY ++0PfaWx7bx91xL/+c9nv+qqrrnP++2klG8nFPuO2f579eiabzotGxLYylpQkaZ4sYxsE4EvO3BZ/m ++/pjXaZO6SSdXnC6pDZ42PeVR3kOb8xTpddQ+ORP8ck58a6mXobMphGPkp0vx0/8FAAAAAAAAAAAA ++AAAAAAAAAPhLrvYHyi8AKAAA +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-000232/tests/test.sh b/tasks/format-code-task-000232/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a9dd8d6e9bea90a7f7295fb20eaf80fa51bd393d --- /dev/null +++ b/tasks/format-code-task-000232/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' +quantecon/tests/test_gridtools.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-000232/tests/test_command.sh b/tasks/format-code-task-000232/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000232/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-000235/environment/Dockerfile b/tasks/format-code-task-000235/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5f35ca0ab009a377daf687ca4243de5bcf5333ea --- /dev/null +++ b/tasks/format-code-task-000235/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:f4b7bcfe4e215af38f06df8c5c3963e972325d156a7d31571ea440b62b050fc0 diff --git a/tasks/format-code-task-000235/environment/setup/files/blocklist b/tasks/format-code-task-000235/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000235/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-000235/environment/setup/setup.sh b/tasks/format-code-task-000235/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000235/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-000235/tests/test.patch b/tasks/format-code-task-000235/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2b4246f45a1947fb1d72e350d901b926a671cb03 --- /dev/null +++ b/tasks/format-code-task-000235/tests/test.patch @@ -0,0 +1,60 @@ +diff --git a/tests/base/test_server.py b/tests/base/test_server.py +index 3c6d82013263..0dd245c69daf 100644 +--- a/tests/base/test_server.py ++++ b/tests/base/test_server.py +@@ -7,14 +7,12 @@ + import io + import json + import tempfile +-import time + + import pytest ++import time + import yaml + from treq.testing import StubTreq + +-from rasa_nlu import utils +-from rasa_nlu.config import RasaNLUModelConfig + from rasa_nlu.data_router import DataRouter + from rasa_nlu.server import RasaNLU + from tests import utilities +@@ -236,6 +234,7 @@ def test_evaluate(app, rasa_default_train_data): + rjs = yield response.json() + assert response.code == 200, "Evaluation should start" + assert "intent_evaluation" in rjs ++ assert "entity_evaluation" in rjs + assert all(prop in rjs["intent_evaluation"] for prop in ["report", + "predictions", + "precision", +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,16 @@ ++H4sIAAAAAAAAA+1W3Y/aOBDnOX+FlatU0F1YAqU8tFRaVXvXVb9W3fbh1DshkwzEh2O79oTd/Pcd ++J8DCCrYvrarq/HsgTmbmNzOZj9CfV0LmM1Drs86PwoAwGY+bK+H+tTmn42GaTkaTJ5NhZ5CmT9Nh ++h41/WER7qBxyy1jHao0P6X1L/ouif1d/BIezTJclV3nfFd/PxzfqPxqOhrv6Dycjqv+Tp8Nxhw2+ ++Xwin8T+vf5azpvBzyKPoN3Z9IzArGGp2VWOhFRv105R1qSsMRzGXwEiB5IVwTMucfeCOs3dvPrFM ++5zDnDnpRDuvEtTSm4Rg1JJ79QrnKAulKCRkKrVz/FXcF97ytC1ZqtYI6oSPZL7SlOP4+f/uGKG4Z ++hXMX1eB3ItwTWliABZWBO85/UwhivOGONEu9hpyJA7ro+vLjxezq/OXr878urqePutvgk4zFojTa ++InMC4RkzVijs+nN/CeivhmcrvgTX7X0e/NuLe1FGmbxg8aMDzrO9uGZturOFuO0bLGL2/Dl7fPXx ++1cX7Px9HG2976n8c5MTn2bPjSU7v6+1EhwZvuTFCLY/obyT31Cv0HA9YHSgcGl8i2BPBbUVHDJBK ++f8KARIcGL7mUJzxsRUfzuYYvle+Y0wltNQ7NH7A7brBjw4dc4X0vx7TpadT2iR+oS0XbS0rSorHK ++wYDKybugGaD2rXkpGdVDUa/TQFOTj5qJ2g6zkALrdp79KFs/yn6Me5ERhqajpU4SpROhTIXsn4ix ++WFWlqV9MU2KLWdx6mU5H7a2j1pXwn9Oqubml30WFNPN0wNr3RtyyWP+eHDp67rVdVkDJ6YbSpVRy ++qZdehF/y0jtpxqsxjjOpq9yIbCVhQ0W5FFLMSUbPhHeMN8Ih5P5EfuhS1AasFGpFZ45o3da09qsv ++3h6SO0MLzlBY4KMoEI0FxHpj5TJh6ri5rgQmErht0l01pySzC1fRUvCPKHKvuYQ1KO9nrlGPNjSl ++W/rEknbPkLDkaKRGn8vestytOKoeLV2HgoqyKQ4VtktbLKO9y7giHj+dlVlanvv9hicreVi3/U7y ++XTBTsvLbkTY5SG1Kip32cg6n2BJg/faeWtB5tg+Vom8EMPq00opk/uW6aLdQS9a+7/b5mf9stH8+ ++HNg12L6pWbKOfvaXMSAgICAgICAgICAgICAgICAgICAgICAgICAgIODXwldyiPNiACgAAA== +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-000235/tests/test.sh b/tasks/format-code-task-000235/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..732902643262de21fdc416dbc469bb447b9a4c20 --- /dev/null +++ b/tasks/format-code-task-000235/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/base/test_server.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-000235/tests/test_command.sh b/tasks/format-code-task-000235/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000235/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-000268/environment/Dockerfile b/tasks/format-code-task-000268/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e7d1f7bbc200cd2d3a84e2223b6c8d16ca503735 --- /dev/null +++ b/tasks/format-code-task-000268/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:b1083d3533ac3196f5f5bc59bca2504143e9154657e8fc81827152e530c08e21 diff --git a/tasks/format-code-task-000268/environment/setup/files/blocklist b/tasks/format-code-task-000268/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000268/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-000268/environment/setup/setup.sh b/tasks/format-code-task-000268/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000268/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-000268/tests/test.patch b/tasks/format-code-task-000268/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7283d5f8f298426f0c38d58d45ea303366d6bf76 --- /dev/null +++ b/tasks/format-code-task-000268/tests/test.patch @@ -0,0 +1,191 @@ +diff --git a/apps/comments-ui/src/AppContext.null-member.test.ts b/apps/comments-ui/src/AppContext.null-member.test.ts +new file mode 100644 +index 0000000000..0fc8803ff9 +--- /dev/null ++++ b/apps/comments-ui/src/AppContext.null-member.test.ts +@@ -0,0 +1,42 @@ ++import type {Comment} from './AppContext'; ++import path from 'path'; ++import ts from 'typescript'; ++ ++const commentMemberTypeIncludesNull = () => { ++ const fileName = path.resolve(process.cwd(), 'src/AppContext.ts'); ++ const program = ts.createProgram([fileName], { ++ jsx: ts.JsxEmit.ReactJSX, ++ lib: ['lib.dom.d.ts', 'lib.dom.iterable.d.ts', 'lib.esnext.d.ts'], ++ module: ts.ModuleKind.ESNext, ++ moduleResolution: ts.ModuleResolutionKind.Bundler, ++ skipLibCheck: true, ++ strictNullChecks: true, ++ target: ts.ScriptTarget.ESNext ++ }); ++ const checker = program.getTypeChecker(); ++ const source = program.getSourceFile(fileName); ++ const moduleSymbol = source && checker.getSymbolAtLocation(source); ++ const exportedCommentSymbol = moduleSymbol && checker.getExportsOfModule(moduleSymbol).find((symbol) => { ++ return symbol.getName() === 'Comment'; ++ }); ++ const commentSymbol = exportedCommentSymbol && (exportedCommentSymbol.flags & ts.SymbolFlags.Alias ? ++ checker.getAliasedSymbol(exportedCommentSymbol) : ++ exportedCommentSymbol); ++ const commentType = commentSymbol && checker.getDeclaredTypeOfSymbol(commentSymbol); ++ const memberSymbol = commentType && commentType.getProperty('member'); ++ const memberType = memberSymbol && checker.getTypeOfSymbolAtLocation(memberSymbol, source!); ++ ++ return Boolean(memberType?.isUnion() && memberType.types.some((type) => { ++ return Boolean(type.flags & ts.TypeFlags.Null); ++ })); ++}; ++ ++describe('Comment deleted member contract', function () { ++ it('allows deleted comment authors to be represented as member null', function () { ++ type MemberCanBeNull = null extends Comment['member'] ? true : false; ++ const memberCanBeNull: MemberCanBeNull = true; ++ ++ expect(memberCanBeNull).to.equal(true); ++ expect(commentMemberTypeIncludesNull()).to.equal(true); ++ }); ++}); +diff --git a/apps/comments-ui/src/components/content/Avatar.null-member.test.tsx b/apps/comments-ui/src/components/content/Avatar.null-member.test.tsx +new file mode 100644 +index 0000000000..a1cb09ae4f +--- /dev/null ++++ b/apps/comments-ui/src/components/content/Avatar.null-member.test.tsx +@@ -0,0 +1,105 @@ ++import {cleanup, render, screen} from '@testing-library/react'; ++import {afterEach, describe, expect, it, vi} from 'vitest'; ++import type {Comment, Member} from '../../AppContext'; ++import {Avatar} from './Avatar'; ++ ++const contextState = vi.hoisted(() => ({ ++ memberName: 'Current User' ++})); ++ ++vi.mock('../../AppContext', async () => { ++ const actual = await vi.importActual('../../AppContext'); ++ ++ return { ++ ...actual, ++ useAppContext: () => ({ ++ member: makeMember(contextState.memberName), ++ t: (value: string) => value ++ }) ++ }; ++}); ++ ++afterEach(() => { ++ contextState.memberName = 'Current User'; ++ cleanup(); ++}); ++ ++const makeMember = (name: string): Member => { ++ return { ++ id: `${name || 'anonymous'}-id`, ++ uuid: `${name || 'anonymous'}-uuid`, ++ name, ++ avatar: '', ++ expertise: '' ++ }; ++}; ++ ++const makeComment = (member: Comment['member'], override: Partial = {}): Comment => { ++ return { ++ id: 'comment-under-test', ++ post_id: 'post-under-test', ++ replies: [], ++ status: 'published', ++ liked: false, ++ count: { ++ replies: 0, ++ likes: 0 ++ }, ++ member, ++ edited_at: '', ++ created_at: '2024-01-01T00:00:00.000Z', ++ html: '

Comment body

', ++ ...override ++ }; ++}; ++ ++const getRenderedAvatarText = () => { ++ return screen.getByTestId('avatar-background').textContent?.trim(); ++}; ++ ++describe('Avatar comment author initials', function () { ++ it('does not use the current member initials when no comment is bound', function () { ++ render(); ++ ++ const background = screen.getByTestId('avatar-background'); ++ expect(background.textContent).not.toBe('CU'); ++ expect(background.textContent?.trim().length ?? 0).toBe(0); ++ }); ++ ++ it('does not use any current member initials when no comment is bound', function () { ++ contextState.memberName = 'Different Reader'; ++ ++ render(); ++ ++ const background = screen.getByTestId('avatar-background'); ++ expect(background.textContent).not.toBe('DR'); ++ expect(background.textContent?.trim().length ?? 0).toBe(0); ++ }); ++ ++ it('uses the bound comment author instead of the current member', function () { ++ render(); ++ ++ const background = screen.getByTestId('avatar-background'); ++ expect(background.textContent).toBe('EA'); ++ expect(background.textContent).not.toBe('CU'); ++ }); ++ ++ it('keeps deleted and anonymous comment author fallbacks distinct', function () { ++ render(); ++ const deletedAuthorText = getRenderedAvatarText(); ++ expect(deletedAuthorText).toBeTruthy(); ++ ++ cleanup(); ++ ++ const reply = makeComment(makeMember('Reply Author'), {id: 'reply-comment'}); ++ render(); ++ expect(getRenderedAvatarText()).toBe(deletedAuthorText); ++ ++ cleanup(); ++ ++ render(); ++ const anonymousAuthorText = getRenderedAvatarText(); ++ expect(anonymousAuthorText).toBeTruthy(); ++ expect(anonymousAuthorText).not.toBe(deletedAuthorText); ++ }); ++}); +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,27 @@ ++#!/bin/bash ++set -euo pipefail ++ ++cd /testbed ++ ++ ++export PATH="/opt/node-22/bin:$PATH" ++ ++if [ ! -x /testbed/node_modules/.bin/vitest ] || [ ! -d /testbed/node_modules/typescript ]; then ++ yarn install --frozen-lockfile --ignore-engines --ignore-scripts --silent ++fi ++ ++cd apps/comments-ui ++ ++case "${1:-}" in ++ base) ++ /testbed/node_modules/.bin/vitest run src/utils/helpers.test.ts ++ ;; ++ new) ++ /testbed/node_modules/.bin/vitest run src/AppContext.null-member.test.ts src/components/content/Avatar.null-member.test.tsx ++ /testbed/node_modules/.bin/vitest run --mode production src/components/content/Avatar.null-member.test.tsx ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000268/tests/test.sh b/tasks/format-code-task-000268/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5dc93686ccbed710385187ebf190988f075cecb2 --- /dev/null +++ b/tasks/format-code-task-000268/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' +apps/comments-ui/src/AppContext.null-member.test.ts +apps/comments-ui/src/components/content/Avatar.null-member.test.tsx +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-000268/tests/test_command.sh b/tasks/format-code-task-000268/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000268/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-000292/environment/Dockerfile b/tasks/format-code-task-000292/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7b627ecd183b1620c1e00ddc0d50a8e9cb1899b6 --- /dev/null +++ b/tasks/format-code-task-000292/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:0f03fbba80e4331565dd20b6fcb994210f0bebf495ece528e5a59636cb83c41c diff --git a/tasks/format-code-task-000292/environment/setup/files/blocklist b/tasks/format-code-task-000292/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000292/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-000292/environment/setup/setup.sh b/tasks/format-code-task-000292/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000292/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-000292/tests/test.patch b/tasks/format-code-task-000292/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4ca847c638c80ee4a8ce9749b2ffc89c07c11fa4 --- /dev/null +++ b/tasks/format-code-task-000292/tests/test.patch @@ -0,0 +1,274 @@ +diff --git a/pkg/apis/internal.acorn.io/v1/permissions_grant_test.go b/pkg/apis/internal.acorn.io/v1/permissions_grant_test.go +new file mode 100644 +index 00000000..69e02de9 +--- /dev/null ++++ b/pkg/apis/internal.acorn.io/v1/permissions_grant_test.go +@@ -0,0 +1,230 @@ ++package v1 ++ ++import ( ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++ rbacv1 "k8s.io/api/rbac/v1" ++) ++ ++ ++func rule(scopes []string, r rbacv1.PolicyRule) PolicyRule { ++ return PolicyRule{PolicyRule: r, Scopes: scopes} ++} ++ ++func TestGrantsExactAndMissing(t *testing.T) { ++ const ns = "acorn" ++ ++ tests := []struct { ++ name string ++ granted Permissions ++ requested Permissions ++ wantOK bool ++ wantMissing []PolicyRule ++ }{ ++ { ++ name: "exact match grants everything", ++ granted: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }}, ++ requested: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }}, ++ wantOK: true, ++ }, ++ { ++ name: "missing verb is reported", ++ granted: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }}, ++ requested: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get", "list"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }}, ++ wantOK: false, ++ wantMissing: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get", "list"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }, ++ }, ++ { ++ name: "star verb covers any verb", ++ granted: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"*"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }}, ++ requested: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get", "list", "delete"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }}, ++ wantOK: true, ++ }, ++ { ++ name: "suffix wildcard on resources", ++ granted: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"secret*"}}), ++ }}, ++ requested: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"secrets"}}), ++ }}, ++ wantOK: true, ++ }, ++ { ++ name: "suffix wildcard does not match different prefix", ++ granted: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"secret*"}}), ++ }}, ++ requested: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"configmaps"}}), ++ }}, ++ wantOK: false, ++ wantMissing: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"configmaps"}}), ++ }, ++ }, ++ { ++ name: "empty granted resourceNames allows any requested resourceName", ++ granted: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"secrets"}}), ++ }}, ++ requested: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"secrets"}, ResourceNames: []string{"db-creds"}}), ++ }}, ++ wantOK: true, ++ }, ++ { ++ name: "specific granted resourceName does not cover an extra requested one", ++ granted: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"secrets"}, ResourceNames: []string{"db-creds"}}), ++ }}, ++ requested: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"secrets"}, ResourceNames: []string{"db-creds", "api-key"}}), ++ }}, ++ wantOK: false, ++ wantMissing: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"secrets"}, ResourceNames: []string{"db-creds", "api-key"}}), ++ }, ++ }, ++ { ++ name: "requested empty resourceNames is not narrowed by specific granted resourceName", ++ granted: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"secrets"}, ResourceNames: []string{"db-creds"}}), ++ }}, ++ requested: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"secrets"}}), ++ }}, ++ wantOK: true, ++ }, ++ { ++ name: "service name mismatch grants nothing", ++ granted: Permissions{ServiceName: "other", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"*"}, APIGroups: []string{"*"}, Resources: []string{"*"}}), ++ }}, ++ requested: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }}, ++ wantOK: false, ++ wantMissing: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }, ++ }, ++ { ++ name: "no requested rules is trivially granted", ++ granted: Permissions{ServiceName: "svc"}, ++ requested: Permissions{ServiceName: "svc"}, ++ wantOK: true, ++ }, ++ { ++ name: "only some requested rules are missing", ++ granted: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }}, ++ requested: Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"delete"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }}, ++ wantOK: false, ++ wantMissing: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"delete"}, APIGroups: []string{""}, Resources: []string{"pods"}}), ++ }, ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ missing, ok := Grants(tt.granted, ns, tt.requested) ++ assert.Equal(t, tt.wantOK, ok) ++ assert.Equal(t, tt.requested.ServiceName, missing.ServiceName, "missing must carry the requested service name") ++ assert.Equal(t, tt.wantMissing, missing.Rules) ++ }) ++ } ++} ++ ++func TestGrantsNamespaceScoping(t *testing.T) { ++ const ns = "acorn" ++ ++ ++ ++ ++ missing, ok := Grants( ++ Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{Verbs: []string{"*"}, APIGroups: []string{"*"}, Resources: []string{"*"}}), ++ }}, ++ ns, ++ Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule([]string{"cluster"}, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"nodes"}}), ++ }}, ++ ) ++ assert.False(t, ok) ++ assert.Len(t, missing.Rules, 1) ++ ++ ++ ++ _, ok = Grants( ++ Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule([]string{"cluster"}, rbacv1.PolicyRule{Verbs: []string{"*"}, APIGroups: []string{"*"}, Resources: []string{"*"}}), ++ }}, ++ ns, ++ Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule([]string{"cluster"}, rbacv1.PolicyRule{Verbs: []string{"get"}, APIGroups: []string{""}, Resources: []string{"nodes"}}), ++ }}, ++ ) ++ assert.True(t, ok) ++} ++ ++func TestGrantsNonResourceURLs(t *testing.T) { ++ const ns = "acorn" ++ ++ ++ _, ok := Grants( ++ Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{NonResourceURLs: []string{"/metrics"}}), ++ }}, ++ ns, ++ Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{NonResourceURLs: []string{"/metrics"}}), ++ }}, ++ ) ++ assert.True(t, ok) ++ ++ ++ _, ok = Grants( ++ Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{NonResourceURLs: []string{"/api/*"}}), ++ }}, ++ ns, ++ Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{NonResourceURLs: []string{"/api/v1"}}), ++ }}, ++ ) ++ assert.True(t, ok) ++ ++ ++ missing, ok := Grants( ++ Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{NonResourceURLs: []string{"/metrics"}, Resources: []string{"pods"}, Verbs: []string{"get"}}), ++ }}, ++ ns, ++ Permissions{ServiceName: "svc", Rules: []PolicyRule{ ++ rule(nil, rbacv1.PolicyRule{NonResourceURLs: []string{"/metrics"}}), ++ }}, ++ ) ++ assert.False(t, ok) ++ assert.Len(t, missing.Rules, 1) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,33 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++export GOFLAGS=-mod=mod ++export GOPROXY=off ++export GOSUMDB=off ++MODCACHE="$(go env GOMODCACHE)" ++for mod in aml baaah; do ++ ver="$(ls "$MODCACHE/github.com/acorn-io/" 2>/dev/null | grep -E "^${mod}@" | head -n1 | sed "s/^${mod}@//")" ++ if [ -n "$ver" ]; then ++ go mod edit -require="github.com/acorn-io/${mod}@${ver}" ++ fi ++done ++ ++PKG=./pkg/apis/internal.acorn.io/v1/ ++ ++ ++go test "$PKG" -run 'Test' -skip 'TestGrants' ++ ++ ++go test "$PKG" -run 'TestGrants' diff --git a/tasks/format-code-task-000292/tests/test.sh b/tasks/format-code-task-000292/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..220578a8e8ae3e8e02439ae1dbff5bfbae278225 --- /dev/null +++ b/tasks/format-code-task-000292/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/apis/internal.acorn.io/v1/permissions_grant_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-000292/tests/test_command.sh b/tasks/format-code-task-000292/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000292/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-000340/environment/Dockerfile b/tasks/format-code-task-000340/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f0257635ad35cc80caaa0d3cfca1c7ce632155ac --- /dev/null +++ b/tasks/format-code-task-000340/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:33810a957b2c8d0fd27fba789541a6832f531e483be9a70071ef3ef4fe334e5d diff --git a/tasks/format-code-task-000340/environment/setup/files/blocklist b/tasks/format-code-task-000340/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000340/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-000340/environment/setup/setup.sh b/tasks/format-code-task-000340/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000340/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-000340/tests/test.patch b/tasks/format-code-task-000340/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..eee83e9cfb9122627c70578d96c76cd5b71f0f7a --- /dev/null +++ b/tasks/format-code-task-000340/tests/test.patch @@ -0,0 +1,69 @@ +diff --git a/pkg/get/get_test.go b/pkg/get/get_test.go +index 65d971d..6dca023 100644 +--- a/pkg/get/get_test.go ++++ b/pkg/get/get_test.go +@@ -1464,23 +1464,38 @@ func Test_DownloadHelmfile(t *testing.T) { + + tool := getTool(name, tools) + +- const toolVersion = "v0.132.1" ++ const toolVersion = "v0.144.0" + + tests := []test{ + {os: "mingw64_nt-10.0-18362", + arch: arch64bit, + version: toolVersion, +- url: `https://github.com/roboll/helmfile/releases/download/v0.132.1/helmfile_windows_amd64.exe`, ++ url: `https://github.com/helmfile/helmfile/releases/download/v0.144.0/helmfile_0.144.0_windows_amd64.tar.gz`, + }, + {os: "linux", + arch: arch64bit, + version: toolVersion, +- url: `https://github.com/roboll/helmfile/releases/download/v0.132.1/helmfile_linux_amd64`, ++ url: `https://github.com/helmfile/helmfile/releases/download/v0.144.0/helmfile_0.144.0_linux_amd64.tar.gz`, ++ }, ++ {os: "linux", ++ arch: archARM64, ++ version: toolVersion, ++ url: `https://github.com/helmfile/helmfile/releases/download/v0.144.0/helmfile_0.144.0_linux_arm64.tar.gz`, + }, + {os: "darwin", + arch: arch64bit, + version: toolVersion, +- url: `https://github.com/roboll/helmfile/releases/download/v0.132.1/helmfile_darwin_amd64`, ++ url: `https://github.com/helmfile/helmfile/releases/download/v0.144.0/helmfile_0.144.0_darwin_amd64.tar.gz`, ++ }, ++ {os: "darwin", ++ arch: archDarwinARM64, ++ version: toolVersion, ++ url: `https://github.com/helmfile/helmfile/releases/download/v0.144.0/helmfile_0.144.0_darwin_arm64.tar.gz`, ++ }, ++ {os: "darwin", ++ arch: archARM64, ++ version: toolVersion, ++ url: `https://github.com/helmfile/helmfile/releases/download/v0.144.0/helmfile_0.144.0_darwin_arm64.tar.gz`, + }, + } + +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..7a66393 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./pkg/get/ -run Test_DownloadHelmfile -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test ./pkg/get/ -run Test_DownloadHelmfile -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000340/tests/test.sh b/tasks/format-code-task-000340/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7149dede1a1056ff12810c82a19582eb77bfb8a7 --- /dev/null +++ b/tasks/format-code-task-000340/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/get/get_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-000340/tests/test_command.sh b/tasks/format-code-task-000340/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000340/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-000349/environment/Dockerfile b/tasks/format-code-task-000349/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f60b780d587fef547466ef0479c22951d4384497 --- /dev/null +++ b/tasks/format-code-task-000349/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:c4c8a1de5ee7c32269af98da665324349deb312af84e72f9d3a6a2e962c2734d diff --git a/tasks/format-code-task-000349/environment/setup/files/blocklist b/tasks/format-code-task-000349/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000349/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-000349/environment/setup/setup.sh b/tasks/format-code-task-000349/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000349/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-000349/tests/test.patch b/tasks/format-code-task-000349/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3542e8827b3c52ff93659f40eae3ab69b8d5d498 --- /dev/null +++ b/tasks/format-code-task-000349/tests/test.patch @@ -0,0 +1,497 @@ +diff --git a/usercase-test-coderl/fixtures/registry_mock.py b/usercase-test-coderl/fixtures/registry_mock.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/registry_mock.py +@@ -0,0 +1,164 @@ ++#!/usr/bin/env python3 ++import hashlib ++import http.server ++import json ++import socketserver ++import sys ++ ++ ++MODE = sys.argv[1] ++LOG_PATH = sys.argv[2] ++ ++ ++LINUX_MANIFEST = json.dumps( ++ { ++ "schemaVersion": 2, ++ "mediaType": "application/vnd.docker.distribution.manifest.v2+json", ++ "config": { ++ "mediaType": "application/vnd.docker.container.image.v1+json", ++ "size": 2, ++ "digest": "sha256:" + "1" * 64, ++ }, ++ "layers": [], ++ }, ++ separators=(",", ":"), ++).encode() ++ ++WINDOWS_MANIFEST = json.dumps( ++ { ++ "schemaVersion": 2, ++ "mediaType": "application/vnd.docker.distribution.manifest.v2+json", ++ "config": { ++ "mediaType": "application/vnd.docker.container.image.v1+json", ++ "size": 2, ++ "digest": "sha256:" + "2" * 64, ++ }, ++ "layers": [], ++ }, ++ separators=(",", ":"), ++).encode() ++ ++LINUX_DIGEST = "sha256:" + hashlib.sha256(LINUX_MANIFEST).hexdigest() ++WINDOWS_DIGEST = "sha256:" + hashlib.sha256(WINDOWS_MANIFEST).hexdigest() ++ ++MANIFEST_LIST = json.dumps( ++ { ++ "schemaVersion": 2, ++ "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json", ++ "manifests": [ ++ { ++ "mediaType": "application/vnd.docker.distribution.manifest.v2+json", ++ "size": len(LINUX_MANIFEST), ++ "digest": LINUX_DIGEST, ++ "platform": {"architecture": "amd64", "os": "linux"}, ++ }, ++ { ++ "mediaType": "application/vnd.docker.distribution.manifest.v2+json", ++ "size": len(WINDOWS_MANIFEST), ++ "digest": WINDOWS_DIGEST, ++ "platform": {"architecture": "arm64", "os": "windows"}, ++ }, ++ ], ++ }, ++ separators=(",", ":"), ++).encode() ++ ++ ++class Handler(http.server.BaseHTTPRequestHandler): ++ def log_message(self, fmt, *args): ++ pass ++ ++ def record(self): ++ with open(LOG_PATH, "a", encoding="utf-8") as f: ++ f.write( ++ f"{self.command} {self.path} AUTH={self.headers.get('Authorization')}\n" ++ ) ++ ++ def do_GET(self): ++ self.record() ++ if MODE == "auth401": ++ self.send_response(401) ++ self.send_header("WWW-Authenticate", 'Basic realm="mock"') ++ self.end_headers() ++ return ++ ++ if self.path in {"/v2/", "/v2"}: ++ self.send_response(200) ++ self.end_headers() ++ return ++ ++ if self.path.endswith("/manifests/v1"): ++ self.send_body( ++ MANIFEST_LIST, ++ "application/vnd.docker.distribution.manifest.list.v2+json", ++ ) ++ return ++ if self.path.endswith("/manifests/" + LINUX_DIGEST): ++ self.send_body( ++ LINUX_MANIFEST, ++ "application/vnd.docker.distribution.manifest.v2+json", ++ ) ++ return ++ if self.path.endswith("/manifests/" + WINDOWS_DIGEST): ++ self.send_body( ++ WINDOWS_MANIFEST, ++ "application/vnd.docker.distribution.manifest.v2+json", ++ ) ++ return ++ if "/blobs/" in self.path: ++ self.send_body(b"{}", "application/octet-stream") ++ return ++ ++ self.send_response(404) ++ self.end_headers() ++ ++ def do_HEAD(self): ++ ++ self.record() ++ self.send_response(404) ++ self.end_headers() ++ ++ def do_POST(self): ++ ++ self.record() ++ self.send_response(202) ++ self.send_header("Location", self.path.rstrip("/") + "/localb-upload") ++ self.send_header("Docker-Upload-UUID", "localb-upload") ++ self.send_header("Range", "0-0") ++ self.end_headers() ++ ++ def do_PATCH(self): ++ ++ self.record() ++ length = int(self.headers.get("Content-Length", "0")) ++ if length: ++ self.rfile.read(length) ++ self.send_response(202) ++ self.send_header("Location", self.path) ++ self.send_header("Docker-Upload-UUID", "localb-upload") ++ self.send_header("Range", "0-0") ++ self.end_headers() ++ ++ def do_PUT(self): ++ self.record() ++ length = int(self.headers.get("Content-Length", "0")) ++ if length: ++ self.rfile.read(length) ++ self.send_response(201) ++ self.end_headers() ++ ++ def send_body(self, body, media_type): ++ self.send_response(200) ++ self.send_header("Content-Type", media_type) ++ self.send_header("Content-Length", str(len(body))) ++ self.end_headers() ++ self.wfile.write(body) ++ ++ ++class ReusableTCPServer(socketserver.TCPServer): ++ allow_reuse_address = True ++ ++ ++with ReusableTCPServer(("127.0.0.1", 0), Handler) as httpd: ++ print(httpd.server_address[1], flush=True) ++ httpd.serve_forever() +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,302 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++( cd /workspace/repo && make cmd ) || { echo "FAIL: build" >&2; exit 1; } ++BIN=/workspace/repo/image-syncer ++FIXTURES=/workspace/repo/usercase-test-coderl/fixtures ++ ++TMP=$(mktemp -d) ++SERVER_PIDS=() ++cleanup() { ++ for pid in "${SERVER_PIDS[@]}"; do ++ kill "$pid" >/dev/null 2>&1 || true ++ done ++ rm -rf "$TMP" ++} ++trap cleanup EXIT ++cd "$TMP" || exit 1 ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++assert_empty() { ++ [ ! -s "$1" ] || fail "$2: expected empty, got $(cat "$1")" ++} ++ ++assert_exact() { ++ local file=$1 ++ local expected=$2 ++ local label=$3 ++ local actual ++ actual=$(cat "$file") ++ [ "$actual" = "$expected" ] || fail "$label: got [$actual], want [$expected]" ++} ++ ++assert_contains() { ++ local file=$1 ++ local needle=$2 ++ local label=$3 ++ grep -Fq -- "$needle" "$file" || fail "$label: missing [$needle] in $(cat "$file" 2>/dev/null)" ++} ++ ++assert_contains_ci() { ++ local file=$1 ++ local needle=$2 ++ local label=$3 ++ grep -Fiq -- "$needle" "$file" || fail "$label: missing case-insensitive [$needle] in $(cat "$file" 2>/dev/null)" ++} ++ ++assert_not_contains() { ++ local file=$1 ++ local needle=$2 ++ local label=$3 ++ ! grep -Fq -- "$needle" "$file" || fail "$label: unexpected [$needle] in $(cat "$file" 2>/dev/null)" ++} ++ ++assert_count() { ++ local file=$1 ++ local needle=$2 ++ local expected=$3 ++ local label=$4 ++ local actual ++ actual=$(grep -F -- "$needle" "$file" | wc -l | tr -d ' ') ++ [ "$actual" = "$expected" ] || fail "$label: count $actual, want $expected for [$needle]" ++} ++ ++start_registry() { ++ local mode=$1 ++ local log=$2 ++ local portfile=$3 ++ python3 "$FIXTURES/registry_mock.py" "$mode" "$log" >"$portfile" 2>"$log.stderr" & ++ local pid=$! ++ SERVER_PIDS+=("$pid") ++ for _ in $(seq 1 50); do ++ [ -s "$portfile" ] && return 0 ++ sleep 0.1 ++ done ++ fail "mock registry did not start" ++} ++ ++ ++ ++ ++"$BIN" --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++cat out err >combined ++assert_contains combined "--config" "F1 --config" ++assert_contains combined "--auth" "F1 --auth" ++assert_contains combined "--images" "F1 --images" ++assert_contains combined "--os" "F1 --os" ++assert_contains combined "--arch" "F1 --arch" ++ ++ ++ ++ ++"$BIN" --proc 1 --retries 0 --log no-input.log >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F2 expected non-zero exit" ++ ++cat out err >combined ++assert_contains combined "neither config.json nor images.json is provided" "F2 missing-input error" ++assert_contains_ci combined "init" "F2 initialization error" ++ ++ ++ ++ ++printf '{}\n' > rules.txt ++"$BIN" --images rules.txt --proc 1 --retries 0 --log bad-image-ext.log >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F3 expected non-zero exit" ++ ++cat out err >combined ++assert_contains combined "decode image file rules.txt error: only one of yaml/yml/json format is supported" "F3 image extension error" ++assert_contains_ci combined "init" "F3 initialization error" ++ ++ ++ ++ ++printf '{}\n' > images.json ++printf '{}\n' > auth.txt ++"$BIN" --images images.json --auth auth.txt --proc 1 --retries 0 --log bad-auth-ext.log >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F4 expected non-zero exit" ++ ++cat out err >combined ++assert_contains combined "auth.txt" "F4 auth path in error" ++assert_contains combined "yaml/yml/json" "F4 supported formats in error" ++ ++ ++ ++ ++printf '{"images":{}}\n' > combined.toml ++"$BIN" --config combined.toml --proc 1 --retries 0 --log bad-config-ext.log >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F5 expected non-zero exit" ++ ++cat out err >combined ++assert_contains combined "combined.toml" "F5 config path in error" ++assert_contains combined "yaml/yml/json" "F5 supported formats in error" ++ ++ ++ ++ ++printf '{}\n' > images-only.yml ++"$BIN" --images images-only.yml --proc 1 --retries 0 --log images-only.log >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F6 exit $ec; want 0" ++ ++assert_contains_ci images-only.log "warning" "F6 warning level" ++assert_contains images-only.log "config.json" "F6 warning mentions config.json" ++assert_contains images-only.log "auth.json" "F6 warning mentions auth.json" ++ ++ ++ ++ ++start_registry manifest-list config-yaml.registry.log config-yaml.port ++PORT=$(cat config-yaml.port) ++cat > config.yaml <out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F7 exit $ec; want 0" ++ ++assert_contains config-yaml.registry.log "/v2/team/source/manifests/v1" "F7 source manifest fetched from combined config" ++ ++ ++ ++ ++start_registry manifest-list list-images.registry.log list-images.port ++PORT=$(cat list-images.port) ++cat > list-images.yaml < list-images-auth.json <out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F8 exit $ec; want 0" ++ ++assert_count list-images.registry.log "PUT /v2/ns/one/manifests/v1" 1 "F8 unique expanded first destination" ++assert_count list-images.registry.log "PUT /v2/ns/two/manifests/v1" 1 "F8 unique expanded second destination" ++ ++ ++ ++ ++cat > empty-dest-string.json <<'EOF' ++{"registry.example.com/ns/src:v1":""} ++EOF ++"$BIN" --images empty-dest-string.json --proc 1 --retries 0 --log empty-dest-string.log >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F9 expected non-zero exit" ++ ++cat out err >combined ++assert_contains combined "empty destination is not supported for source: registry.example.com/ns/src:v1" "F9 empty destination error" ++ ++ ++ ++ ++cat > empty-dest-list.json <<'EOF' ++{"registry.example.com/ns/src:v1":[]} ++EOF ++"$BIN" --images empty-dest-list.json --proc 1 --retries 0 --log empty-dest-list.log >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F10 expected non-zero exit" ++ ++cat out err >combined ++assert_contains combined "empty destination is not supported for source: registry.example.com/ns/src:v1" "F10 empty list error" ++ ++ ++ ++ ++cat > non-string-dest.json <<'EOF' ++{"registry.example.com/ns/src:v1":["registry.example.com/ns/dst:v1",42]} ++EOF ++"$BIN" --images non-string-dest.json --proc 1 --retries 0 --log non-string-dest.log >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F11 expected non-zero exit" ++ ++cat out err >combined ++assert_contains combined "registry.example.com/ns/src:v1" "F11 source in non-string destination error" ++assert_contains_ci combined "destination" "F11 destination-context error" ++ ++ ++ ++ ++start_registry auth401 auth-longest.registry.log auth-longest.port ++PORT=$(cat auth-longest.port) ++cat > auth-longest-images.json < auth-longest.json <out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F12 expected non-zero exit from mock auth challenge" ++ ++ ++assert_contains auth-longest.registry.log "/v2/team/app/source/manifests/v1 AUTH=Basic c3BlY2lmaWMtdXNlcjpzcGVjaWZpYy1wYXNz" "F12 specific expanded auth" ++assert_not_contains auth-longest.log "Auth information not found for 127.0.0.1:$PORT/team/app/source" "F12 source matched auth" ++ ++ ++ ++ ++cat > auth-boundary-images.json <<'EOF' ++{"127.0.0.1:1/team/application/source:v1":"127.0.0.1:1/team/dest:v1"} ++EOF ++cat > auth-boundary.json <<'EOF' ++{ ++ "127.0.0.1:1/team/app": {"username":"wrong-user","password":"wrong-pass","insecure":true} ++} ++EOF ++"$BIN" --images auth-boundary-images.json --auth auth-boundary.json --proc 1 --retries 0 --log auth-boundary.log >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F13 expected non-zero exit from unreachable registry" ++ ++assert_contains auth-boundary.log "127.0.0.1:1/team/application/source" "F13 source repository logged" ++assert_contains auth-boundary.log "127.0.0.1:1/team/dest" "F13 destination repository logged" ++assert_contains_ci auth-boundary.log "anonymous" "F13 anonymous fallback logged" ++ ++ ++ ++ ++start_registry manifest-list filters-empty.registry.log filters-empty.port ++PORT=$(cat filters-empty.port) ++cat > filters-empty-images.json < filters-empty-auth.json <out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F14 exit $ec; want 0" ++ ++assert_contains filters-empty.registry.log "PUT /v2/team/dest/manifests/sha256:4b4ba550b7333dc29f7b3d1182efd4194e54b82d21e7ba7da8f232a33527757d" "F14 linux manifest copied" ++assert_contains filters-empty.registry.log "PUT /v2/team/dest/manifests/sha256:a2b9eb2c854c6aae675fd9b3a6471ff4933a390c3f53f88c4b03cd77424f16cf" "F14 windows manifest copied" ++ ++ ++ ++ ++start_registry manifest-list filters-linux.registry.log filters-linux.port ++PORT=$(cat filters-linux.port) ++cat > filters-linux-images.json < filters-linux-auth.json <out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F15 exit $ec; want 0" ++ ++assert_contains filters-linux.registry.log "PUT /v2/team/dest/manifests/sha256:4b4ba550b7333dc29f7b3d1182efd4194e54b82d21e7ba7da8f232a33527757d" "F15 linux manifest copied" ++assert_not_contains filters-linux.registry.log "PUT /v2/team/dest/manifests/sha256:a2b9eb2c854c6aae675fd9b3a6471ff4933a390c3f53f88c4b03cd77424f16cf" "F15 windows manifest filtered out" ++ ++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,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000349/tests/test.sh b/tasks/format-code-task-000349/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..aaf0be9b1580549d9bebbffadaa98797cd9b4b8d --- /dev/null +++ b/tasks/format-code-task-000349/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/registry_mock.py +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-000349/tests/test_command.sh b/tasks/format-code-task-000349/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000349/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-000382/environment/Dockerfile b/tasks/format-code-task-000382/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2fa0c8124c75308872c2565cd997ad89a114af39 --- /dev/null +++ b/tasks/format-code-task-000382/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:7399361eabb5d7d19d765e541c52eb40efd7a043e01d95c71bc05b4b392b466f diff --git a/tasks/format-code-task-000382/environment/setup/files/blocklist b/tasks/format-code-task-000382/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000382/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-000382/environment/setup/setup.sh b/tasks/format-code-task-000382/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000382/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-000382/tests/test.patch b/tasks/format-code-task-000382/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..21d0ab165e5ab7a78ff28397f71b980edd47e94f --- /dev/null +++ b/tasks/format-code-task-000382/tests/test.patch @@ -0,0 +1,173 @@ +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,151 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++ ++python3 -m venv --system-site-packages "$TMP/venv" \ ++ || fail "could not create virtualenv" ++ ++ ++PIP_NO_INDEX=1 PIP_DISABLE_PIP_VERSION_CHECK=1 \ ++"$TMP/venv/bin/python" -m pip install --no-index --no-build-isolation --no-deps -e /workspace/repo \ ++ >"$TMP/pip.out" 2>"$TMP/pip.err" \ ++ || { cat "$TMP/pip.err" >&2; fail "build/install"; } ++ ++BIN="$TMP/venv/bin/trash-rm" ++[ -x "$BIN" ] || fail "trash-rm command was not installed" ++ ++RUN="$TMP/run" ++mkdir -p "$RUN" ++cd "$RUN" || fail "cd run dir" ++ ++UID_NOW=$(id -u) ++ ++assert_empty() { ++ local file="$1" label="$2" ++ [ ! -s "$file" ] || fail "$label: $(cat "$file")" ++} ++ ++assert_exists() { ++ local path="$1" label="$2" ++ [ -e "$path" ] || fail "$label missing: $path" ++} ++ ++assert_absent() { ++ local path="$1" label="$2" ++ [ ! -e "$path" ] || fail "$label still exists: $path" ++} ++ ++make_entry() { ++ local trashdir="$1" name="$2" original_path="$3" payload="$4" ++ mkdir -p "$trashdir/files" "$trashdir/info" ++ printf '%s' "$payload" >"$trashdir/files/$name" ++ printf '[Trash Info]\nPath=%s\nDeletionDate=2026-07-23T00:00:00\n' \ ++ "$original_path" >"$trashdir/info/$name.trashinfo" ++} ++ ++ ++ ++ ++DATA="$RUN/f1-data" ++VOL="$RUN/f1-volume" ++HOME_TRASH="$DATA/Trash" ++VOL_TRASH="$VOL/.Trash/$UID_NOW" ++mkdir -p "$VOL_TRASH/files" "$VOL_TRASH/info" ++chmod 1777 "$VOL/.Trash" ++make_entry "$HOME_TRASH" home_foo_o tmp/foo.o "home foo object" ++make_entry "$HOME_TRASH" home_bar_o home/me/bar.o "home bar object" ++make_entry "$HOME_TRASH" home_foo_c tmp/foo.c "home c source" ++make_entry "$VOL_TRASH" vol_obj project/vol.o "volume object" ++ ++XDG_DATA_HOME="$DATA" TRASH_VOLUMES="$VOL" "$BIN" '*.o' >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_empty out "F1 unexpected stdout" ++assert_empty err "F1 unexpected stderr" ++assert_absent "$HOME_TRASH/files/home_foo_o" "F1 /tmp/foo.o backup" ++assert_absent "$HOME_TRASH/info/home_foo_o.trashinfo" "F1 /tmp/foo.o trashinfo" ++assert_absent "$HOME_TRASH/files/home_bar_o" "F1 /home/me/bar.o backup" ++assert_absent "$HOME_TRASH/info/home_bar_o.trashinfo" "F1 /home/me/bar.o trashinfo" ++assert_absent "$VOL_TRASH/files/vol_obj" "F1 volume .o backup" ++assert_absent "$VOL_TRASH/info/vol_obj.trashinfo" "F1 volume .o trashinfo" ++assert_exists "$HOME_TRASH/files/home_foo_c" "F1 /tmp/foo.c backup" ++assert_exists "$HOME_TRASH/info/home_foo_c.trashinfo" "F1 /tmp/foo.c trashinfo" ++ ++ ++ ++ ++DATA="$RUN/f2-data" ++HOME_TRASH="$DATA/Trash" ++make_entry "$HOME_TRASH" project_app_log home/me/project/app.log "project log" ++make_entry "$HOME_TRASH" other_app_log home/me/other/app.log "other log" ++make_entry "$HOME_TRASH" project_notes home/me/project/notes.txt "project notes" ++ ++XDG_DATA_HOME="$DATA" TRASH_VOLUMES="" "$BIN" '/home/me/project/*.log' >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++assert_empty out "F2 unexpected stdout" ++assert_empty err "F2 unexpected stderr" ++assert_absent "$HOME_TRASH/files/project_app_log" "F2 project app.log backup" ++assert_absent "$HOME_TRASH/info/project_app_log.trashinfo" "F2 project app.log trashinfo" ++assert_exists "$HOME_TRASH/files/other_app_log" "F2 other app.log backup" ++assert_exists "$HOME_TRASH/info/other_app_log.trashinfo" "F2 other app.log trashinfo" ++assert_exists "$HOME_TRASH/files/project_notes" "F2 project notes backup" ++assert_exists "$HOME_TRASH/info/project_notes.trashinfo" "F2 project notes trashinfo" ++ ++ ++ ++ ++DATA="$RUN/f3-data" ++HOME_TRASH="$DATA/Trash" ++make_entry "$HOME_TRASH" keep_one tmp/keep.txt "keep" ++ ++XDG_DATA_HOME="$DATA" TRASH_VOLUMES="" "$BIN" '*.nomatch' >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++assert_empty out "F3 unexpected stdout" ++assert_empty err "F3 unexpected stderr" ++assert_exists "$HOME_TRASH/files/keep_one" "F3 no-match backup" ++assert_exists "$HOME_TRASH/info/keep_one.trashinfo" "F3 no-match trashinfo" ++ ++ ++ ++ ++XDG_DATA_HOME="$RUN/f4-data" TRASH_VOLUMES="" "$BIN" >out 2>err; ec=$? ++cat >expected_usage <<'EOF' ++Usage: ++ trash-rm PATTERN ++ ++Please specify PATTERN. ++trash-rm uses fnmatch.fnmatchcase to match patterns, see https://docs.python.org/3/library/fnmatch.html for more details. ++EOF ++[ "$ec" -eq 8 ] || fail "F4 exit $ec; want 8" ++assert_empty out "F4 unexpected stdout" ++cmp -s expected_usage err || fail "F4 stderr: $(cat err)" ++ ++ ++ ++ ++DATA="$RUN/f5-data" ++HOME_TRASH="$DATA/Trash" ++make_entry "$HOME_TRASH" good tmp/delete.me "delete me" ++mkdir -p "$HOME_TRASH/files" "$HOME_TRASH/info" ++printf 'bad payload' >"$HOME_TRASH/files/bad" ++printf '[Trash Info]\nDeletionDate=2026-07-23T00:00:00\n' \ ++ >"$HOME_TRASH/info/bad.trashinfo" ++ ++XDG_DATA_HOME="$DATA" TRASH_VOLUMES="" "$BIN" '*.me' >out 2>err; ec=$? ++EXPECTED_PARSE_ERR="trash-rm: $HOME_TRASH/info/bad.trashinfo: unable to parse 'Path'" ++printf '%s\n' "$EXPECTED_PARSE_ERR" >expected_parse_err ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++assert_empty out "F5 unexpected stdout" ++cmp -s expected_parse_err err || fail "F5 stderr: $(cat err)" ++assert_absent "$HOME_TRASH/files/good" "F5 valid matching backup" ++assert_absent "$HOME_TRASH/info/good.trashinfo" "F5 valid matching trashinfo" ++assert_exists "$HOME_TRASH/files/bad" "F5 malformed backup" ++assert_exists "$HOME_TRASH/info/bad.trashinfo" "F5 malformed trashinfo" ++ ++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-000382/tests/test.sh b/tasks/format-code-task-000382/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000382/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-000382/tests/test_command.sh b/tasks/format-code-task-000382/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000382/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-000401/environment/Dockerfile b/tasks/format-code-task-000401/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4286d5eecdcc3568acde6b8c013ff1119637fcfc --- /dev/null +++ b/tasks/format-code-task-000401/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:a0663ff1ba4e215f9e4c727e89589258d8963ffd623d2f36d13b45cbbefea3c8 diff --git a/tasks/format-code-task-000401/environment/setup/files/blocklist b/tasks/format-code-task-000401/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000401/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-000401/environment/setup/setup.sh b/tasks/format-code-task-000401/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000401/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-000401/tests/test.sh b/tasks/format-code-task-000401/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..de720d275e994cfe4ef67678145a7261a2abb184 --- /dev/null +++ b/tasks/format-code-task-000401/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/calendar_data_view.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-000401/tests/test_command.sh b/tasks/format-code-task-000401/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000401/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-000430/environment/Dockerfile b/tasks/format-code-task-000430/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..994e39fe67cc94ae5e016caf87861bb21b96d1dc --- /dev/null +++ b/tasks/format-code-task-000430/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:f1436edc487a7a34496f2bf32f68e6304d5cb2bd30dc0eb8e2ce900b5031b872 diff --git a/tasks/format-code-task-000430/environment/setup/files/blocklist b/tasks/format-code-task-000430/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000430/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-000430/environment/setup/setup.sh b/tasks/format-code-task-000430/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000430/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-000430/tests/test.patch b/tasks/format-code-task-000430/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5ff302501c4b4bbcb62dfd1cc8929ca96f408d84 --- /dev/null +++ b/tasks/format-code-task-000430/tests/test.patch @@ -0,0 +1,163 @@ +diff --git a/pkg/node/replica_test.go b/pkg/node/replica_test.go +new file mode 100644 +index 00000000..ab630b12 +--- /dev/null ++++ b/pkg/node/replica_test.go +@@ -0,0 +1,132 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package node ++ ++import ( ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++ ++ commonv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/common/v1" ++ databasev1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1" ++ "github.com/apache/skywalking-banyandb/banyand/metadata/schema" ++) ++ ++var replicaGroupSchema = schema.Metadata{ ++ TypeMeta: schema.TypeMeta{ ++ Kind: schema.KindGroup, ++ }, ++ Spec: &commonv1.Group{ ++ Metadata: &commonv1.Metadata{ ++ Name: "rgroup", ++ }, ++ Catalog: commonv1.Catalog_CATALOG_MEASURE, ++ ResourceOpts: &commonv1.ResourceOpts{ ++ ShardNum: 3, ++ }, ++ }, ++} ++ ++func setupReplicaSelector(nodeNames ...string) Selector { ++ selector := NewRoundRobinSelector("test", nil) ++ selector.(*roundRobinSelector).OnAddOrUpdate(replicaGroupSchema) ++ for _, n := range nodeNames { ++ selector.AddNode(&databasev1.Node{Metadata: &commonv1.Metadata{Name: n}}) ++ } ++ return selector ++} ++ ++ ++func TestReplicaOmittedEqualsPrimary(t *testing.T) { ++ selector := setupReplicaSelector("node1", "node2", "node3") ++ for shardID := uint32(0); shardID < 3; shardID++ { ++ primary, err := selector.Pick("rgroup", "", shardID) ++ require.NoError(t, err) ++ explicit, err := selector.Pick("rgroup", "", shardID, 0) ++ require.NoError(t, err) ++ assert.Equal(t, primary, explicit, ++ "picking shard %d without a replica must equal replica 0", shardID) ++ } ++} ++ ++ ++ ++func TestReplicaCopiesAreDistinct(t *testing.T) { ++ nodes := []string{"node1", "node2", "node3"} ++ selector := setupReplicaSelector(nodes...) ++ for shardID := uint32(0); shardID < 3; shardID++ { ++ seen := make(map[string]uint32) ++ for replicaID := uint32(0); replicaID < uint32(len(nodes)); replicaID++ { ++ n, err := selector.Pick("rgroup", "", shardID, replicaID) ++ require.NoError(t, err) ++ assert.Contains(t, nodes, n) ++ if prev, ok := seen[n]; ok { ++ t.Fatalf("shard %d: replica %d and replica %d both mapped to node %s", ++ shardID, prev, replicaID, n) ++ } ++ seen[n] = replicaID ++ } ++ assert.Len(t, seen, len(nodes), ++ "shard %d: expected %d distinct nodes across its copies", shardID, len(nodes)) ++ } ++} ++ ++ ++ ++func TestReplicaSelectionIsDeterministic(t *testing.T) { ++ selector := setupReplicaSelector("node1", "node2", "node3") ++ ++ want := make(map[[2]uint32]string) ++ for shardID := uint32(0); shardID < 3; shardID++ { ++ for replicaID := uint32(0); replicaID < 3; replicaID++ { ++ n, err := selector.Pick("rgroup", "", shardID, replicaID) ++ require.NoError(t, err) ++ want[[2]uint32{shardID, replicaID}] = n ++ } ++ } ++ ++ ++ for i := 0; i < 50; i++ { ++ for shardID := int(2); shardID >= 0; shardID-- { ++ for replicaID := int(2); replicaID >= 0; replicaID-- { ++ n, err := selector.Pick("rgroup", "", uint32(shardID), uint32(replicaID)) ++ require.NoError(t, err) ++ assert.Equal(t, want[[2]uint32{uint32(shardID), uint32(replicaID)}], n) ++ } ++ } ++ } ++} ++ ++ ++func TestReplicaErrorBehavior(t *testing.T) { ++ ++ empty := setupReplicaSelector() ++ _, err := empty.Pick("rgroup", "", 0, 1) ++ assert.Error(t, err, "no nodes available must error for any replica") ++ ++ selector := setupReplicaSelector("node1", "node2", "node3") ++ ++ ++ _, err = selector.Pick("does-not-exist", "", 0, 1) ++ assert.Error(t, err, "unknown group must error for any replica") ++ ++ ++ _, err = selector.Pick("rgroup", "", 100, 1) ++ assert.Error(t, err, "unknown shard must error for any replica") ++} +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 ++ ++ ++ ++ ++ ++( cd api && PATH="/testbed/bin:/testbed/api/proto:$PATH" /testbed/bin/buf generate ) ++ ++ ++go test ./pkg/node/ -run 'TestPickEmptySelector|TestPickUnknownGroup|TestPickSingleSelection|TestPickMultipleSelections|TestPickNodeRemoval|TestPickConsistentSelectionAfterRemoval|TestCleanupGroup|TestSortNodeEntries|TestStringer|TestChangeShard|TestMaglevSelector|TestMaglevSelector_EvenDistribution|TestMaglevSelector_DiffNode' -count=1 -v ++ ++ ++go test ./pkg/node/ -run 'TestReplicaOmittedEqualsPrimary|TestReplicaCopiesAreDistinct|TestReplicaSelectionIsDeterministic|TestReplicaErrorBehavior' -count=1 -v diff --git a/tasks/format-code-task-000430/tests/test.sh b/tasks/format-code-task-000430/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0f34d12013e3588b626214928e7dee4642881dc4 --- /dev/null +++ b/tasks/format-code-task-000430/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/node/replica_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-000430/tests/test_command.sh b/tasks/format-code-task-000430/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000430/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-000452/environment/Dockerfile b/tasks/format-code-task-000452/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f2f3830c7b8b526cb9e152402148ebeb557e01dd --- /dev/null +++ b/tasks/format-code-task-000452/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:06bbee3c31e3c218a96f92571322db6a1728016459e3dfa36bf47ddf8639a525 diff --git a/tasks/format-code-task-000452/environment/setup/files/blocklist b/tasks/format-code-task-000452/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000452/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-000452/environment/setup/setup.sh b/tasks/format-code-task-000452/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000452/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-000452/tests/test.patch b/tasks/format-code-task-000452/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a8a12178d9b9e68c85e95874da660abf4b80d40d --- /dev/null +++ b/tasks/format-code-task-000452/tests/test.patch @@ -0,0 +1,119 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..ba7b200a9 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./workflow/validate/ -run 'TestEmptyContainerImageRejected|TestEmptyScriptImageRejected|TestValidContainerImagePasses|TestValidScriptImagePasses' -count=1"] ++} +diff --git a/workflow/validate/validate_test.go b/workflow/validate/validate_test.go +index e66aa948b..52165f23f 100644 +--- a/workflow/validate/validate_test.go ++++ b/workflow/validate/validate_test.go +@@ -2490,3 +2490,92 @@ func TestValidateFieldsWithWFTRef(t *testing.T) { + _, err = validate(invalidWFWithWFTRef) + assert.Error(t, err) + } ++ ++ ++ ++ ++ ++ ++var emptyContainerImageWf = ` ++apiVersion: argoproj.io/v1alpha1 ++kind: Workflow ++metadata: ++ generateName: hello-world- ++spec: ++ entrypoint: whalesay ++ templates: ++ - name: whalesay ++ container: ++ command: [cowsay] ++ args: ["hello world"] ++` ++ ++func TestEmptyContainerImageRejected(t *testing.T) { ++ _, err := validate(emptyContainerImageWf) ++ if assert.Error(t, err) { ++ assert.Contains(t, err.Error(), "templates.whalesay.container.image") ++ } ++} ++ ++var emptyScriptImageWf = ` ++apiVersion: argoproj.io/v1alpha1 ++kind: Workflow ++metadata: ++ generateName: script-no-image- ++spec: ++ entrypoint: hello ++ templates: ++ - name: hello ++ script: ++ command: [bash] ++ source: | ++ echo hello ++` ++ ++func TestEmptyScriptImageRejected(t *testing.T) { ++ _, err := validate(emptyScriptImageWf) ++ if assert.Error(t, err) { ++ assert.Contains(t, err.Error(), "templates.hello.script.image") ++ } ++} ++ ++var validContainerImageWf = ` ++apiVersion: argoproj.io/v1alpha1 ++kind: Workflow ++metadata: ++ generateName: hello-world- ++spec: ++ entrypoint: whalesay ++ templates: ++ - name: whalesay ++ container: ++ image: docker/whalesay:latest ++ command: [cowsay] ++ args: ["hello world"] ++` ++ ++func TestValidContainerImagePasses(t *testing.T) { ++ _, err := validate(validContainerImageWf) ++ assert.NoError(t, err) ++} ++ ++var validScriptImageWf = ` ++apiVersion: argoproj.io/v1alpha1 ++kind: Workflow ++metadata: ++ generateName: script-with-image- ++spec: ++ entrypoint: hello ++ templates: ++ - name: hello ++ script: ++ image: python:alpine3.6 ++ command: [python] ++ source: | ++ print("hi") ++` ++ ++func TestValidScriptImagePasses(t *testing.T) { ++ _, err := validate(validScriptImageWf) ++ assert.NoError(t, err) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test ./workflow/validate/ -run 'TestEmptyContainerImageRejected|TestEmptyScriptImageRejected|TestValidContainerImagePasses|TestValidScriptImagePasses' -count=1 ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000452/tests/test.sh b/tasks/format-code-task-000452/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..795249e0005463f076e7aff18015d08d769c5a48 --- /dev/null +++ b/tasks/format-code-task-000452/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 +workflow/validate/validate_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-000452/tests/test_command.sh b/tasks/format-code-task-000452/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000452/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-000455/environment/Dockerfile b/tasks/format-code-task-000455/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d4a7580e293270c10c0dc908c7fdbea00381c3df --- /dev/null +++ b/tasks/format-code-task-000455/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:80f81b5defc61ce17e39414d96c91d5987c0e60d65842848307712c7cfa4ec6d diff --git a/tasks/format-code-task-000455/environment/setup/files/blocklist b/tasks/format-code-task-000455/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000455/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-000455/environment/setup/setup.sh b/tasks/format-code-task-000455/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000455/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-000455/tests/test.patch b/tasks/format-code-task-000455/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..34b58c4f962417000e0e01edcd6bfc1bac5cbac5 --- /dev/null +++ b/tasks/format-code-task-000455/tests/test.patch @@ -0,0 +1,52 @@ +diff --git a/sql/postgres/diff_test.go b/sql/postgres/diff_test.go +index 02515d6bebe..e8763f844d5 100644 +--- a/sql/postgres/diff_test.go ++++ b/sql/postgres/diff_test.go +@@ -484,6 +484,27 @@ func TestDiff_TableDiff(t *testing.T) { + } + } + ++func TestDiff_RealmDiff(t *testing.T) { ++ db, m, err := sqlmock.New() ++ require.NoError(t, err) ++ mock{m}.version("130000") ++ drv, err := Open(db) ++ to := schema.New("public"). ++ AddTables( ++ schema.NewTable("users").AddColumns(schema.NewIntColumn("t2_id", "int")), ++ ). ++ AddObjects( ++ &schema.EnumType{T: "e", Values: []string{"b"}}, ++ ) ++ changes, err := drv.RealmDiff(schema.NewRealm(), schema.NewRealm(to)) ++ require.NoError(t, err) ++ require.EqualValues(t, []schema.Change{ ++ &schema.AddSchema{S: to}, ++ &schema.AddObject{O: to.Objects[0]}, ++ &schema.AddTable{T: to.Tables[0]}, ++ }, changes) ++} ++ + func TestDiff_SchemaDiff(t *testing.T) { + db, m, err := sqlmock.New() + require.NoError(t, err) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RQU7DMBCF4ax7irlAEk+pyYodJ0DsozRxS6Ukhtjp+XGzoUKCbloh1P/bzEgz ++ksd6xXY+9F3txmOZ3YpJKmuXmnyvS692rVo9GN2sM6NqK5uJvdlFZ+YQm0kkm7yPv+1dmv9TxVf+ ++0YVYt34YmrErwtv13riUv+pZ/ibt6eYxjcVc74Sf3Xn+bSdL8FvXrfZeTq0UZfjoy3cf4n5yoZR8 ++mkd5TZPnw25Xv7imH06d5EfJWz+P8UlXf/0PAAAAAAAAAAAAAAAA4B59AugLX4kAKAAA +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-000455/tests/test.sh b/tasks/format-code-task-000455/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8e1c7b5052e2b4db4e482d5d9441969b89ea95ec --- /dev/null +++ b/tasks/format-code-task-000455/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' +sql/postgres/diff_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-000455/tests/test_command.sh b/tasks/format-code-task-000455/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000455/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-000463/environment/Dockerfile b/tasks/format-code-task-000463/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..58f3cb6a96f78ea94a479b5aba073a2a1cd28bfe --- /dev/null +++ b/tasks/format-code-task-000463/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:332021f84f2f999c3acd182ac371153e50cc38fe4df83d3b6a5e4a351f50598c diff --git a/tasks/format-code-task-000463/environment/setup/files/blocklist b/tasks/format-code-task-000463/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000463/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-000463/environment/setup/setup.sh b/tasks/format-code-task-000463/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000463/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-000463/tests/test.patch b/tasks/format-code-task-000463/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ec1ffd6bf12a09606177f16161fdc16724feb6ac --- /dev/null +++ b/tasks/format-code-task-000463/tests/test.patch @@ -0,0 +1,142 @@ +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,114 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++ ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOFLAGS="${GOFLAGS:-} -mod=readonly -buildvcs=false" ++ ++if ! ( cd /workspace/repo && make build ); then ++ echo "FAIL: build" >&2 ++ exit 1 ++fi ++BIN=/workspace/repo/asdf ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || exit 1 ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++assert_provider_lines_match() { ++ local actual=$1 ++ local expected=$2 ++ ++ awk 'NF == 2 { print $1 " " $2 }' "$actual" | sort >actual_providers ++ sort "$expected" >expected_providers ++ cmp -s actual_providers expected_providers || fail "$3 provider lines: $(cat "$actual")" ++} ++ ++assert_no_provider_lines() { ++ local actual=$1 ++ ++ ! awk 'NF == 2 { found = 1 } END { exit found ? 0 : 1 }' "$actual" || fail "$2 provider stdout should not contain provider lines, got: $(cat "$actual")" ++} ++ ++make_dummy_install() { ++ local data_dir=$1 ++ local version=$2 ++ mkdir -p "$data_dir/plugins/dummy" "$data_dir/installs/dummy/$version/bin" ++ printf '#!/usr/bin/env bash\necho dummy-%s\n' "$version" > "$data_dir/installs/dummy/$version/bin/dummy" ++ chmod +x "$data_dir/installs/dummy/$version/bin/dummy" ++} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++DATA_F1="$TMP/data-f1" ++make_dummy_install "$DATA_F1" "3.0" ++make_dummy_install "$DATA_F1" "1.0" ++HOME="$TMP/home-f1" ASDF_DATA_DIR="$DATA_F1" "$BIN" reshim dummy >reshim_out 2>reshim_err ++reshim_ec=$? ++[ "$reshim_ec" -eq 0 ] || fail "F1 reshim exit $reshim_ec; want 0; stderr: $(cat reshim_err)" ++ ++HOME="$TMP/home-f1" ASDF_DATA_DIR="$DATA_F1" "$BIN" shimversions dummy >out 2>err ++ec=$? ++printf 'dummy 3.0\ndummy 1.0\n' >expected ++[ "$ec" -eq 0 ] || fail "F1 shimversions exit $ec; want 0; stderr: $(cat err)" ++assert_provider_lines_match out expected "F1" ++ ++ ++ ++ ++DATA_F2="$TMP/data-f2" ++mkdir -p "$DATA_F2/shims" ++printf '#!/usr/bin/env bash\n# asdf-plugin: solo 9.9\nexec asdf exec "solo" "$@"' >"$DATA_F2/shims/solo" ++HOME="$TMP/home-f2" ASDF_DATA_DIR="$DATA_F2" "$BIN" shimversions solo >out 2>err ++ec=$? ++printf 'solo 9.9\n' >expected ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0; stderr: $(cat err)" ++assert_provider_lines_match out expected "F2" ++ ++ ++ ++ ++HOME="$TMP/home-f3" ASDF_DATA_DIR="$TMP/data-f3" "$BIN" shimversions >out 2>err ++ec=$? ++printf 'usage: asdf shimversions \n' >expected_err ++[ "$ec" -ne 0 ] || fail "F3 exit $ec; want nonzero" ++assert_no_provider_lines out "F3" ++cmp -s err expected_err || fail "F3 stderr: $(cat err)" ++ ++ ++ ++ ++env -u HOME ASDF_DATA_DIR="$TMP/data-f4" "$BIN" shimversions dummy >out 2>err ++ec=$? ++[ "$ec" -ne 0 ] || fail "F4 exit $ec; want nonzero" ++assert_no_provider_lines out "F4" ++ ++case "$(cat err)" in ++ "error loading config: "?*) ;; ++ *) fail "F4 stderr: $(cat err)" ;; ++esac ++ ++ ++ ++ ++DATA_F5="$TMP/data-f5" ++mkdir -p "$DATA_F5/shims" ++HOME="$TMP/home-f5" ASDF_DATA_DIR="$DATA_F5" "$BIN" shimversions absent >out 2>err ++ec=$? ++[ "$ec" -ne 0 ] || fail "F5 exit $ec; want nonzero" ++assert_no_provider_lines out "F5" ++ ++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,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 GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOFLAGS="${GOFLAGS:-} -mod=readonly -buildvcs=false" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000463/tests/test.sh b/tasks/format-code-task-000463/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000463/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-000463/tests/test_command.sh b/tasks/format-code-task-000463/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000463/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-000464/environment/Dockerfile b/tasks/format-code-task-000464/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..baf7f23350e7c79538bc10abed12e529968aa64c --- /dev/null +++ b/tasks/format-code-task-000464/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:ebcbde0d4f0c8dc030eb41d89c6981e55364dc163859e0c5de9af82e626d987b diff --git a/tasks/format-code-task-000464/environment/setup/files/blocklist b/tasks/format-code-task-000464/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000464/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-000464/environment/setup/setup.sh b/tasks/format-code-task-000464/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000464/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-000464/tests/test.patch b/tasks/format-code-task-000464/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d53dd7b5c4160f4dab29a2f32f398b2a0cc2364b --- /dev/null +++ b/tasks/format-code-task-000464/tests/test.patch @@ -0,0 +1,272 @@ +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,246 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++ ++( cd /workspace/repo && make build ) >/dev/null \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN=/workspace/repo/asdf ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++ ++export HOME="$TMP/home" ++export ASDF_DATA_DIR="$TMP/asdf-data" ++export ASDF_CONFIG_FILE="$TMP/asdfrc" ++unset ASDF_TOOL_VERSIONS_FILENAME ASDF_DEFAULT_TOOL_VERSIONS_FILENAME ++mkdir -p "$HOME" "$ASDF_DATA_DIR" ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++run_asdf() { ++ "$BIN" "$@" >out 2>err ++ ec=$? ++} ++ ++assert_empty_stdout() { ++ [ ! -s out ] || fail "$1 stdout: $(cat out)" ++} ++ ++assert_empty_stderr() { ++ [ ! -s err ] || fail "$1 stderr: $(cat err)" ++} ++ ++assert_success_stderr_unspecified() { ++ ++ : ++} ++ ++assert_failure_stdout_unspecified() { ++ ++ : ++} ++ ++assert_stdout_literal() { ++ printf '%s' "$2" > "$TMP/expected" ++ cmp -s out "$TMP/expected" || fail "$1 stdout: $(cat out)" ++} ++ ++assert_stderr_literal() { ++ printf '%s' "$2" > "$TMP/expected" ++ cmp -s err "$TMP/expected" || fail "$1 stderr: $(cat err)" ++} ++ ++assert_file_literal() { ++ printf '%s' "$3" > "$TMP/expected" ++ cmp -s "$2" "$TMP/expected" || fail "$1 file $2: $(cat "$2")" ++} ++ ++ ++ ++ ++mkdir -p "$TMP/f1" ++cd "$TMP/f1" || exit 1 ++run_asdf set lua 5.2.3 ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_empty_stdout F1 ++assert_success_stderr_unspecified F1 ++assert_file_literal F1 .tool-versions $'lua 5.2.3\n' ++[ "$(wc -c < .tool-versions)" -eq 10 ] || fail "F1 file should include trailing newline" ++ ++ ++ ++ ++mkdir -p "$TMP/f2" ++cd "$TMP/f2" || exit 1 ++printf 'lua 1.1.1\n' > .tool-versions ++run_asdf set lua 5.2.3 ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++assert_empty_stdout F2 ++assert_success_stderr_unspecified F2 ++assert_file_literal F2 .tool-versions $'lua 5.2.3\n' ++ ++ ++ ++ ++mkdir -p "$TMP/f3" ++cd "$TMP/f3" || exit 1 ++printf 'nodejs 20.11.1\n# keep this note\n' > .tool-versions ++run_asdf set lua 5.2.3 ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++assert_empty_stdout F3 ++assert_success_stderr_unspecified F3 ++assert_file_literal F3 .tool-versions $'nodejs 20.11.1\n# keep this note\nlua 5.2.3\n' ++ ++ ++ ++ ++mkdir -p "$TMP/f4" ++cd "$TMP/f4" || exit 1 ++printf 'lua 1.1.1 # production lua\n# unrelated note\nruby 3.3.0 # ruby stays\n' > .tool-versions ++run_asdf set lua 5.2.3 ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++assert_empty_stdout F4 ++assert_success_stderr_unspecified F4 ++assert_file_literal F4 .tool-versions $'lua 5.2.3 # production lua\n# unrelated note\nruby 3.3.0 # ruby stays\n' ++ ++ ++ ++ ++mkdir -p "$TMP/f5" ++cd "$TMP/f5" || exit 1 ++run_asdf set python 3.12.1 3.11.8 ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++assert_empty_stdout F5 ++assert_success_stderr_unspecified F5 ++assert_file_literal F5 .tool-versions $'python 3.12.1 3.11.8\n' ++ ++ ++ ++ ++mkdir -p "$TMP/f6" ++cd "$TMP/f6" || exit 1 ++run_asdf set custom system ref:v1 path:/opt/custom ++[ "$ec" -eq 0 ] || fail "F6 exit $ec; want 0" ++assert_empty_stdout F6 ++assert_success_stderr_unspecified F6 ++assert_file_literal F6 .tool-versions $'custom system ref:v1 path:/opt/custom\n' ++ ++ ++ ++ ++mkdir -p "$TMP/f7/work" ++cd "$TMP/f7/work" || exit 1 ++run_asdf set --home lua 5.2.3 ++[ "$ec" -eq 0 ] || fail "F7a exit $ec; want 0" ++assert_empty_stdout F7a ++assert_success_stderr_unspecified F7a ++assert_file_literal F7a "$HOME/.tool-versions" $'lua 5.2.3\n' ++[ ! -e .tool-versions ] || fail "F7a should not write current directory file" ++run_asdf set -u lua 5.2.4 ++[ "$ec" -eq 0 ] || fail "F7b exit $ec; want 0" ++assert_empty_stdout F7b ++assert_success_stderr_unspecified F7b ++assert_file_literal F7b "$HOME/.tool-versions" $'lua 5.2.4\n' ++ ++ ++ ++ ++mkdir -p "$TMP/f8/root/sub/deep" ++printf 'nodejs 18.0.0\nlua 1.1.1 # parent comment\n' > "$TMP/f8/root/.tool-versions" ++printf 'lua 9.9.9\n' > "$TMP/f8/root/sub/.tool-versions" ++cd "$TMP/f8/root/sub/deep" || exit 1 ++run_asdf set --parent lua 5.2.3 ++[ "$ec" -eq 0 ] || fail "F8a exit $ec; want 0" ++assert_empty_stdout F8a ++assert_success_stderr_unspecified F8a ++assert_file_literal F8a "$TMP/f8/root/sub/.tool-versions" $'lua 5.2.3\n' ++assert_file_literal F8a-higher "$TMP/f8/root/.tool-versions" $'nodejs 18.0.0\nlua 1.1.1 # parent comment\n' ++rm "$TMP/f8/root/sub/.tool-versions" ++run_asdf set -p ruby 3.3.1 ++[ "$ec" -eq 0 ] || fail "F8b exit $ec; want 0" ++assert_empty_stdout F8b ++assert_success_stderr_unspecified F8b ++assert_file_literal F8b "$TMP/f8/root/.tool-versions" $'nodejs 18.0.0\nlua 1.1.1 # parent comment\nruby 3.3.1\n' ++ ++ ++ ++ ++mkdir -p "$TMP/f9" ++cd "$TMP/f9" || exit 1 ++run_asdf set ++[ "$ec" -ne 0 ] || fail "F9a exit $ec; want non-zero" ++assert_failure_stdout_unspecified F9a ++assert_stderr_literal F9a $'tool and version must be provided as arguments\n' ++run_asdf set lua ++[ "$ec" -ne 0 ] || fail "F9b exit $ec; want non-zero" ++assert_failure_stdout_unspecified F9b ++assert_stderr_literal F9b $'version must be provided as an argument\n' ++run_asdf set --home --parent lua 5.2.3 ++[ "$ec" -ne 0 ] || fail "F9c exit $ec; want non-zero" ++assert_failure_stdout_unspecified F9c ++assert_stderr_literal F9c $'home and parent flags cannot both be specified; must be one location or the other\n' ++run_asdf set -u -p lua 5.2.3 ++[ "$ec" -ne 0 ] || fail "F9d exit $ec; want non-zero" ++assert_failure_stdout_unspecified F9d ++assert_stderr_literal F9d $'home and parent flags cannot both be specified; must be one location or the other\n' ++ ++ ++ ++ ++mkdir -p "$TMP/f10/a/b" ++cd "$TMP/f10/a/b" || exit 1 ++run_asdf set --parent lua 5.2.3 ++[ "$ec" -ne 0 ] || fail "F10 exit $ec; want non-zero" ++assert_failure_stdout_unspecified F10 ++assert_stderr_literal F10 $'No .tool-versions version file found in parent directory\n' ++[ ! -e .tool-versions ] || fail "F10 should not create current directory file" ++ ++ ++ ++ ++mkdir -p "$ASDF_DATA_DIR/plugins/elixir/bin" "$TMP/f11" ++cat > "$ASDF_DATA_DIR/plugins/elixir/bin/latest-stable" <<'PLUGIN' ++#!/usr/bin/env bash ++case "${1-}" in ++ 1.15) printf '1.15.9\n' ;; ++ '') printf '1.16.3\n' ;; ++ *) exit 1 ;; ++esac ++PLUGIN ++chmod +x "$ASDF_DATA_DIR/plugins/elixir/bin/latest-stable" ++cd "$TMP/f11" || exit 1 ++run_asdf set elixir latest ++[ "$ec" -eq 0 ] || fail "F11a exit $ec; want 0" ++assert_empty_stdout F11a ++assert_success_stderr_unspecified F11a ++assert_file_literal F11a .tool-versions $'elixir 1.16.3\n' ++run_asdf set elixir latest:1.15 ++[ "$ec" -eq 0 ] || fail "F11b exit $ec; want 0" ++assert_empty_stdout F11b ++assert_success_stderr_unspecified F11b ++assert_file_literal F11b .tool-versions $'elixir 1.15.9\n' ++ ++ ++ ++ ++mkdir -p "$ASDF_DATA_DIR/plugins/empty/bin" "$TMP/f12" ++cat > "$ASDF_DATA_DIR/plugins/empty/bin/latest-stable" <<'PLUGIN' ++#!/usr/bin/env bash ++exit 0 ++PLUGIN ++chmod +x "$ASDF_DATA_DIR/plugins/empty/bin/latest-stable" ++cd "$TMP/f12" || exit 1 ++printf 'empty 0.0.1\n' > .tool-versions ++run_asdf set empty latest ++[ "$ec" -ne 0 ] || fail "F12 exit $ec; want non-zero" ++assert_failure_stdout_unspecified F12 ++assert_file_literal F12 .tool-versions $'empty 0.0.1\n' ++! grep -q 'latest' .tool-versions || fail "F12 wrote unresolved latest token" ++ ++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,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++ ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000464/tests/test.sh b/tasks/format-code-task-000464/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000464/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-000464/tests/test_command.sh b/tasks/format-code-task-000464/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000464/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-000490/environment/Dockerfile b/tasks/format-code-task-000490/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0d6f8ad27311e0ac58525ef7236dd2228c95e65e --- /dev/null +++ b/tasks/format-code-task-000490/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:59add9cef4c6148f00c698ba54ff77840b915f739d5b3cd88bbb133029a3449e diff --git a/tasks/format-code-task-000490/environment/setup/files/blocklist b/tasks/format-code-task-000490/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000490/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-000490/environment/setup/setup.sh b/tasks/format-code-task-000490/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000490/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-000490/tests/test.patch b/tasks/format-code-task-000490/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d09517c11d9e346315c1ed2c6914a7872b1d64f5 --- /dev/null +++ b/tasks/format-code-task-000490/tests/test.patch @@ -0,0 +1,71 @@ +diff --git a/test-tap/assert.js b/test-tap/assert.js +index 48ab73d2..72ddb56a 100644 +--- a/test-tap/assert.js ++++ b/test-tap/assert.js +@@ -764,6 +764,44 @@ test('.like()', t => { + t.end(); + }); + ++test('.like() with arrays', t => { ++ ++ ++ passes(t, () => assertions.like({a: [{a: 1, b: 2}]}, {a: [{a: 1}]})); ++ ++ ++ ++ passes(t, () => assertions.like({x: [[1, 2, 3]]}, {x: [[1, 2]]})); ++ ++ ++ ++ passes(t, () => assertions.like( ++ {a: [{a: 1, b: 2}, {a: 3, b: 4}]}, ++ {a: [{a: 1}, {a: 3}]}, ++ )); ++ ++ ++ fails(t, () => assertions.like( ++ {a: [{a: 1, b: 2}, {a: 3, b: 4}]}, ++ {a: [{a: 1}, {a: 999}]}, ++ )); ++ ++ ++ fails(t, () => assertions.like({a: [{a: 1, b: 2}]}, {a: [{a: 999}]})); ++ ++ ++ fails(t, () => assertions.like([1, 2, 3], [1, 2, 3, 4])); ++ ++ ++ failsWith(t, () => assertions.like({a: 1}, []), { ++ assertion: 'like', ++ message: '`t.like()` selector must be a non-empty object', ++ values: [{label: 'Called with:', formatted: '[]'}], ++ }); ++ ++ t.end(); ++}); ++ + test('.throws()', gather(t => { + // Fails because function doesn't throw. + failsWith(t, () => assertions.throws(() => {}), { +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..200aee92 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx tap test-tap/assert.js --no-coverage -g \"with arrays\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx tap test-tap/assert.js --no-coverage -g "with arrays" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000490/tests/test.sh b/tasks/format-code-task-000490/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..93045bf3a5c292ea526e4963e3217c63a1a60811 --- /dev/null +++ b/tasks/format-code-task-000490/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-tap/assert.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-000490/tests/test_command.sh b/tasks/format-code-task-000490/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000490/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-000497/environment/Dockerfile b/tasks/format-code-task-000497/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4fb89c6f4142bfac83033346bbf98c1d29307294 --- /dev/null +++ b/tasks/format-code-task-000497/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:423b2510ad176a48c1b7933a8e4fc0c4f85c64dac4552a797e64b4d4687390e3 diff --git a/tasks/format-code-task-000497/environment/setup/files/blocklist b/tasks/format-code-task-000497/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000497/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-000497/environment/setup/setup.sh b/tasks/format-code-task-000497/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000497/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-000497/tests/test.patch b/tasks/format-code-task-000497/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4d408b75652dadd6141395be4ce38adfaddb6116 --- /dev/null +++ b/tasks/format-code-task-000497/tests/test.patch @@ -0,0 +1,168 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..92c55fc06 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,5 @@ ++{ ++ "test_commands": [ ++ "PYTHONPATH=$PWD /root/.cache/pypoetry/virtualenvs/aws-lambda-powertools-QnKYwBMZ-py3.9/bin/python -m pytest tests/functional/test_utilities_batch.py -k \"lambda_context or backward_compatible\" -v" ++ ] ++} +diff --git a/tests/functional/test_utilities_batch.py b/tests/functional/test_utilities_batch.py +index a5e1e7064..5d1184809 100644 +--- a/tests/functional/test_utilities_batch.py ++++ b/tests/functional/test_utilities_batch.py +@@ -908,3 +908,139 @@ def test_batch_processor_error_when_entire_batch_fails(sqs_event_factory, record + + # THEN raise BatchProcessingError + assert "All records failed processing. " in str(e.value) ++ ++ ++@pytest.fixture(scope="module") ++def lambda_context(): ++ from aws_lambda_powertools.utilities.typing import LambdaContext ++ ++ ctx = LambdaContext() ++ ctx._function_name = "test-fn" ++ ctx._function_version = "$LATEST" ++ ctx._invoked_function_arn = "arn:aws:lambda:us-east-1:123456789012:function:test-fn" ++ ctx._memory_limit_in_mb = 128 ++ ctx._aws_request_id = "abc-123-fixture" ++ ctx._log_group_name = "/aws/lambda/test-fn" ++ ctx._log_stream_name = "stream-1" ++ return ctx ++ ++ ++def test_batch_processor_decorator_injects_lambda_context_when_handler_accepts_it( ++ sqs_event_factory, lambda_context ++): ++ ++ seen = {} ++ ++ def record_handler(record, lambda_context): ++ seen["aws_request_id"] = lambda_context.aws_request_id ++ return record["body"] ++ ++ first_record = sqs_event_factory("success") ++ second_record = sqs_event_factory("success") ++ event = {"Records": [first_record, second_record]} ++ processor = BatchProcessor(event_type=EventType.SQS) ++ ++ @batch_processor(record_handler=record_handler, processor=processor) ++ def lambda_handler(event, context): ++ return processor.response() ++ ++ ++ result = lambda_handler(event, lambda_context) ++ ++ ++ assert seen["aws_request_id"] == "abc-123-fixture" ++ assert result["batchItemFailures"] == [] ++ ++ ++def test_batch_processor_decorator_with_handler_without_lambda_context_param_is_backward_compatible( ++ sqs_event_factory, lambda_context ++): ++ ++ def record_handler(record): ++ return record["body"] ++ ++ first_record = sqs_event_factory("success") ++ second_record = sqs_event_factory("success") ++ event = {"Records": [first_record, second_record]} ++ processor = BatchProcessor(event_type=EventType.SQS) ++ ++ @batch_processor(record_handler=record_handler, processor=processor) ++ def lambda_handler(event, context): ++ return processor.response() ++ ++ ++ result = lambda_handler(event, lambda_context) ++ ++ ++ assert result["batchItemFailures"] == [] ++ ++ ++def test_batch_processor_context_manager_injects_lambda_context_when_handler_accepts_it( ++ sqs_event_factory, lambda_context ++): ++ ++ seen = {} ++ ++ def record_handler(record, lambda_context): ++ seen["request_id"] = lambda_context.aws_request_id ++ return record["body"] ++ ++ first_record = sqs_event_factory("success") ++ records = [first_record] ++ processor = BatchProcessor(event_type=EventType.SQS) ++ ++ ++ with processor(records, record_handler, lambda_context=lambda_context) as batch: ++ processed = batch.process() ++ ++ ++ assert seen["request_id"] == "abc-123-fixture" ++ assert processor.response() == {"batchItemFailures": []} ++ assert processed[0][0] == "success" ++ ++ ++def test_batch_processor_context_manager_without_lambda_context_remains_backward_compatible( ++ sqs_event_factory, record_handler ++): ++ ++ first_record = SQSRecord(sqs_event_factory("success")) ++ records = [first_record.raw_event] ++ processor = BatchProcessor(event_type=EventType.SQS) ++ ++ ++ with processor(records, record_handler) as batch: ++ processed = batch.process() ++ ++ ++ assert processed[0][0] == "success" ++ assert processor.response() == {"batchItemFailures": []} ++ ++ ++def test_batch_processor_handler_uses_lambda_context_for_partial_failure( ++ sqs_event_factory, lambda_context ++): ++ ++ call_count = {"n": 0} ++ ++ def record_handler(record, lambda_context): ++ ++ assert lambda_context.aws_request_id == "abc-123-fixture" ++ call_count["n"] += 1 ++ if call_count["n"] == 1: ++ raise Exception("simulated fail using context info") ++ return record["body"] ++ ++ first_record = sqs_event_factory("a") ++ second_record = sqs_event_factory("b") ++ event = {"Records": [first_record, second_record]} ++ processor = BatchProcessor(event_type=EventType.SQS) ++ ++ @batch_processor(record_handler=record_handler, processor=processor) ++ def lambda_handler(event, context): ++ return processor.response() ++ ++ ++ result = lambda_handler(event, lambda_context) ++ ++ ++ assert result["batchItemFailures"] == [{"itemIdentifier": first_record["messageId"]}] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=$PWD /root/.cache/pypoetry/virtualenvs/aws-lambda-powertools-QnKYwBMZ-py3.9/bin/python -m pytest tests/functional/test_utilities_batch.py -k "lambda_context or backward_compatible" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000497/tests/test.sh b/tasks/format-code-task-000497/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b7d5ef25781dbef5b4b01bbbd0a5d0f3c5b0d743 --- /dev/null +++ b/tasks/format-code-task-000497/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/functional/test_utilities_batch.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-000497/tests/test_command.sh b/tasks/format-code-task-000497/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000497/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-000499/environment/Dockerfile b/tasks/format-code-task-000499/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fdf8d9a70a1157e13a409ec06c9129311ace1897 --- /dev/null +++ b/tasks/format-code-task-000499/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:f2916e88c2637edcb29767fc08f17c9bf59e54b8897d46bc62400090654e7bb1 diff --git a/tasks/format-code-task-000499/environment/setup/files/blocklist b/tasks/format-code-task-000499/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000499/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-000499/environment/setup/setup.sh b/tasks/format-code-task-000499/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000499/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-000499/tests/test.patch b/tasks/format-code-task-000499/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..58bfb68aa1133d59dac8cd1bcc4561192f67cc5c --- /dev/null +++ b/tasks/format-code-task-000499/tests/test.patch @@ -0,0 +1,205 @@ +diff --git a/agent/acs/handler/acs_handler_test.go b/agent/acs/handler/acs_handler_test.go +index 161996390dc..2a6652e2558 100644 +--- a/agent/acs/handler/acs_handler_test.go ++++ b/agent/acs/handler/acs_handler_test.go +@@ -215,6 +215,7 @@ func TestHandlerReconnectsOnConnectErrors(t *testing.T) { + mockWsClient := mock_wsclient.NewMockClientServer(ctrl) + mockWsClient.EXPECT().SetAnyRequestHandler(gomock.Any()).AnyTimes() + mockWsClient.EXPECT().AddRequestHandler(gomock.Any()).AnyTimes() ++ mockWsClient.EXPECT().Serve().AnyTimes() + mockWsClient.EXPECT().Close().Return(nil).AnyTimes() + gomock.InOrder( + // Connect fails 10 times +@@ -224,7 +225,7 @@ func TestHandlerReconnectsOnConnectErrors(t *testing.T) { + // test to time out as the context is never cancelled + mockWsClient.EXPECT().Connect().Do(func() { + cancel() +- }).Return(io.EOF).MinTimes(1), ++ }).Return(nil).MinTimes(1), + ) + acsSession := session{ + containerInstanceARN: "myArn", +@@ -616,7 +617,7 @@ func TestHandlerReconnectsOnServeErrors(t *testing.T) { + // test to time out as the context is never cancelled + mockWsClient.EXPECT().Serve().Do(func() { + cancel() +- }).Return(io.EOF), ++ }), + ) + + acsSession := session{ +@@ -711,12 +712,12 @@ func TestHandlerReconnectsOnDiscoverPollEndpointError(t *testing.T) { + mockWsClient := mock_wsclient.NewMockClientServer(ctrl) + mockWsClient.EXPECT().SetAnyRequestHandler(gomock.Any()).AnyTimes() + mockWsClient.EXPECT().AddRequestHandler(gomock.Any()).AnyTimes() +- mockWsClient.EXPECT().Connect().Return(nil).AnyTimes() ++ mockWsClient.EXPECT().Serve().AnyTimes() + mockWsClient.EXPECT().Close().Return(nil).AnyTimes() +- mockWsClient.EXPECT().Serve().Do(func() { ++ mockWsClient.EXPECT().Connect().Do(func() { + // Serve() cancels the context + cancel() +- }).Return(io.EOF).MinTimes(1) ++ }).Return(nil).MinTimes(1) + + gomock.InOrder( + // DiscoverPollEndpoint returns an error on its first invocation +@@ -761,7 +762,6 @@ func TestHandlerReconnectsOnDiscoverPollEndpointError(t *testing.T) { + if timeSinceStart > 2*connectionBackoffMin { + t.Errorf("Duration since start is greater than maximum anticipated wait time: %v", timeSinceStart.String()) + } +- + } + + // TestConnectionIsClosedOnIdle tests if the connection to ACS is closed +diff --git a/agent/engine/docker_image_manager_test.go b/agent/engine/docker_image_manager_test.go +index c21d9a23f94..c64d7eb87fc 100644 +--- a/agent/engine/docker_image_manager_test.go ++++ b/agent/engine/docker_image_manager_test.go +@@ -1065,7 +1065,7 @@ func TestDeleteImage(t *testing.T) { + } + + // This test tests that we detect correctly in agent when the agent is trying to delete image that +-// does not exist for older version of docker. ++ + func TestDeleteImageNotFoundOldDockerMessageError(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() +diff --git a/agent/engine/ordering_integ_test.go b/agent/engine/ordering_integ_test.go +index ebb54920896..f7c2906298a 100644 +--- a/agent/engine/ordering_integ_test.go ++++ b/agent/engine/ordering_integ_test.go +@@ -432,7 +432,6 @@ func TestShutdownOrder(t *testing.T) { + waitFinished(t, finished, shutdownOrderingTimeout) + } + +- + func waitFinished(t *testing.T, finished <-chan interface{}, duration time.Duration) { + select { + case <-finished: +diff --git a/agent/engine/ordering_integ_unix_test.go b/agent/engine/ordering_integ_unix_test.go +index b392c43d42e..09f19a60d1d 100644 +--- a/agent/engine/ordering_integ_unix_test.go ++++ b/agent/engine/ordering_integ_unix_test.go +@@ -49,11 +49,11 @@ func TestGranularStopTimeout(t *testing.T) { + parent.DependsOn = []apicontainer.DependsOn{ + { + ContainerName: "dependency1", +- Condition: "START", ++ Condition: "START", + }, + { + ContainerName: "dependency2", +- Condition: "START", ++ Condition: "START", + }, + } + +diff --git a/agent/engine/task_manager_test.go b/agent/engine/task_manager_test.go +index f7acc4eca9d..c3e5923ea39 100644 +--- a/agent/engine/task_manager_test.go ++++ b/agent/engine/task_manager_test.go +@@ -44,6 +44,7 @@ import ( + "github.com/aws/amazon-ecs-agent/agent/engine/mocks" + "github.com/aws/amazon-ecs-agent/agent/engine/testdata" + "github.com/aws/amazon-ecs-agent/agent/eventstream" ++ "github.com/aws/amazon-ecs-agent/agent/sighandlers/exitcodes" + "github.com/aws/amazon-ecs-agent/agent/statechange" + "github.com/aws/amazon-ecs-agent/agent/statemanager" + "github.com/aws/amazon-ecs-agent/agent/statemanager/mocks" +@@ -1512,7 +1513,7 @@ func TestHandleContainerChangeUpdateContainerHealth(t *testing.T) { + containerChangeEventStream: containerChangeEventStream, + stateChangeEvents: make(chan statechange.Event), + } +- // Disgard all the statechange events ++ + defer discardEvents(mTask.stateChangeEvents)() + + mTask.SetKnownStatus(apitaskstatus.TaskRunning) +@@ -1537,8 +1538,59 @@ func TestHandleContainerChangeUpdateContainerHealth(t *testing.T) { + mTask.handleContainerChange(containerChange) + + containerHealth := container.GetHealthStatus() +- assert.Equal(t, containerHealth.Status, apicontainerstatus.ContainerHealthy) +- assert.Equal(t, containerHealth.Output, "health check succeed") ++ assert.Equal(t, apicontainerstatus.ContainerHealthy, containerHealth.Status) ++ assert.Equal(t, "health check succeed", containerHealth.Output) ++} ++ ++func TestHandleContainerChangeUpdateMetadataRedundant(t *testing.T) { ++ eventStreamName := "TestHandleContainerChangeUpdateContainerHealth" ++ ctx, cancel := context.WithCancel(context.Background()) ++ defer cancel() ++ containerChangeEventStream := eventstream.NewEventStream(eventStreamName, ctx) ++ containerChangeEventStream.StartListening() ++ ++ mTask := &managedTask{ ++ Task: testdata.LoadTask("sleep5TaskCgroup"), ++ containerChangeEventStream: containerChangeEventStream, ++ stateChangeEvents: make(chan statechange.Event), ++ } ++ ++ defer discardEvents(mTask.stateChangeEvents)() ++ ++ mTask.SetKnownStatus(apitaskstatus.TaskRunning) ++ mTask.SetSentStatus(apitaskstatus.TaskRunning) ++ container := mTask.Containers[0] ++ container.HealthCheckType = "docker" ++ ++ container.SetKnownStatus(apicontainerstatus.ContainerRunning) ++ ++ timeNow := time.Now() ++ exitCode := exitcodes.ExitError ++ containerChange := dockerContainerChange{ ++ container: container, ++ event: dockerapi.DockerContainerChangeEvent{ ++ Status: apicontainerstatus.ContainerRunning, ++ DockerContainerMetadata: dockerapi.DockerContainerMetadata{ ++ DockerID: "dockerID", ++ Health: apicontainer.HealthStatus{ ++ Status: apicontainerstatus.ContainerHealthy, ++ Output: "health check succeed", ++ }, ++ ExitCode: &exitCode, ++ CreatedAt: timeNow, ++ }, ++ }, ++ } ++ ++ mTask.handleContainerChange(containerChange) ++ ++ containerHealth := container.GetHealthStatus() ++ assert.Equal(t, apicontainerstatus.ContainerHealthy, containerHealth.Status) ++ assert.Equal(t, "health check succeed", containerHealth.Output) ++ containerExitCode := container.GetKnownExitCode() ++ assert.Equal(t, exitCode, *containerExitCode) ++ containerCreateTime := container.GetCreatedAt() ++ assert.Equal(t, timeNow, containerCreateTime) + } + + func TestWaitForHostResources(t *testing.T) { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+3TTW/TMBgH8JzzKR60C0gkjttmPfWAAI0DaIiXc+Q4jmPa2JXtdAXtw+OE0lad ++umraKgQ8v0Nd2Y7991tadmpRFUKvSHQuWTDN86EMDsvhP81HlF5mdJLRKKM0n2YR5GdLtKdznlmA ++yBrj7+t3qv0vle7O3wvnC27alukqdc3TzXHi/Gk+mW7Pf5SNw/lPLuk4guzpIhz3n5//xTNSKk1K ++5pqYVzBcglJUcXwBn4WHbglXBsLtUNboVmgfV2KVuBvleQPSAE1H41isl8Z6uLqmlH64fvP1/duZ ++qetd9cdXX97NSL+BRJp+5NdWMC82LeC+twul51AbC74RsLTmm+A+bueVspAs4fenxFlOpPJNV6bh ++nhJ242LbQlLf14Owlv0wOhHcJUz2K1hoSFy9XerDPg7pP3UaOq089AO4ITbjjjTh2SyEhefcrIR1 ++fV2xqSv6nqk0L+KDPeq3sG+DZAWJZ9L9GjjhptN+RuFEGrL53Zv99hbEOgxBjyQVWiottiErw+ch ++n2rDSEV4+KHYpn0Jnrn5Ye2Z1rDJdSe+0l5Iy7wy+vgqjK2EVVoWQ+9d/oP6kGv9gGXsT/3Y1fzp ++Z44QQgghhBBCCCGEEEIIIYQQQgihf9hPDvat2gAoAAA= +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-000499/tests/test.sh b/tasks/format-code-task-000499/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..08a72d10f022d1bca49a6999cb5f3fdb255d0c54 --- /dev/null +++ b/tasks/format-code-task-000499/tests/test.sh @@ -0,0 +1,43 @@ +#!/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' +agent/acs/handler/acs_handler_test.go +agent/engine/docker_image_manager_test.go +agent/engine/ordering_integ_test.go +agent/engine/ordering_integ_unix_test.go +agent/engine/task_manager_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-000499/tests/test_command.sh b/tasks/format-code-task-000499/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000499/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-000516/environment/Dockerfile b/tasks/format-code-task-000516/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eccb1270c0a01ae6f85bd91fb679c4bea2b0e77c --- /dev/null +++ b/tasks/format-code-task-000516/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:161c27c7c4bd672e5578b21ee7934018b981abed5d2313ebe8087a0e6dc4317e diff --git a/tasks/format-code-task-000516/environment/setup/files/blocklist b/tasks/format-code-task-000516/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000516/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-000516/environment/setup/setup.sh b/tasks/format-code-task-000516/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000516/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-000516/tests/test.patch b/tasks/format-code-task-000516/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7ff2630b24388125662982fe95791a1e102717db --- /dev/null +++ b/tasks/format-code-task-000516/tests/test.patch @@ -0,0 +1,60 @@ +diff --git a/test/module/typings/esm/test_h.ts b/test/module/typings/esm/test_h.ts +new file mode 100644 +index 0000000..4454471 +--- /dev/null ++++ b/test/module/typings/esm/test_h.ts +@@ -0,0 +1,32 @@ ++ ++import axios, { AxiosResponse } from 'axios'; ++ ++ ++const r0: AxiosResponse = { data: 1, status: 200, statusText: 'OK', headers: { 'x-foo': 'bar' }, config: {} as any }; ++const r1: AxiosResponse<{id:number}> = { data: {id:1}, status: 200, statusText: 'OK', headers: { 'x-foo': 'bar' }, config: {} as any }; ++const r2: AxiosResponse<{id:number}, any> = { data: {id:1}, status: 200, statusText: 'OK', headers: { 'x-foo': 'bar' }, config: {} as any }; ++ ++ ++type RLHeaders = { 'x-rate-limit-remaining': string; 'x-rate-limit-reset': string }; ++ ++ ++ ++const r3: AxiosResponse<{id:number}, any, RLHeaders> = { ++ data: {id:1}, status: 200, statusText: 'OK', ++ headers: { 'x-rate-limit-remaining': '99', 'x-rate-limit-reset': '60', 'content-type': 'application/json' }, ++ config: {} as any ++}; ++ ++ ++function getSomeResource(): Promise> { ++ return axios.get('/foo'); ++} ++const _check: typeof getSomeResource = getSomeResource; ++ ++ ++const r_bad: AxiosResponse = { ++ data: 1, status: 200, statusText: 'OK', ++ // @ts-expect-error - headers literal missing 'x-rate-limit-remaining' / 'x-rate-limit-reset' ++ headers: {}, ++ config: {} as any ++}; +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..577b940 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd test/module/typings/esm && ./node_modules/.bin/tsc --noEmit"] ++} +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 test/module/typings/esm && ./node_modules/.bin/tsc --noEmit ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000516/tests/test.sh b/tasks/format-code-task-000516/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9cad9c44072b86bc9635d8fe0e1751e2eb71d79e --- /dev/null +++ b/tasks/format-code-task-000516/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/module/typings/esm/test_h.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-000516/tests/test_command.sh b/tasks/format-code-task-000516/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000516/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-000520/environment/Dockerfile b/tasks/format-code-task-000520/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..96105f0cd2d6e8bee9e6586a0a112f53bdbeaae4 --- /dev/null +++ b/tasks/format-code-task-000520/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:7347126ba72ff94faa50eb29651bd5136dba5b0730308c134edd2736bb13ef13 diff --git a/tasks/format-code-task-000520/environment/setup/files/blocklist b/tasks/format-code-task-000520/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000520/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-000520/environment/setup/setup.sh b/tasks/format-code-task-000520/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000520/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-000520/tests/test.patch b/tasks/format-code-task-000520/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ee94e84a5da71c40e093859706db3a3c2ee7eee0 --- /dev/null +++ b/tasks/format-code-task-000520/tests/test.patch @@ -0,0 +1,478 @@ +diff --git a/usercase-test-coderl/test_rasterized_source_acceptance.py b/usercase-test-coderl/test_rasterized_source_acceptance.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_rasterized_source_acceptance.py +@@ -0,0 +1,448 @@ ++import sys ++ ++import numpy as np ++import pytest ++ ++sys.path.insert(0, "/workspace/repo/rastervision_core") ++sys.path.insert(0, "/workspace/repo/rastervision_pipeline") ++ ++from rastervision.core import Box ++from rastervision.core.data import ( ++ BufferTransformerConfig, ++ ClassConfig, ++ ClassInferenceTransformerConfig, ++ GeoJSONVectorSourceConfig, ++ IdentityCRSTransformer, ++ RasterizedSource, ++ RasterizedSourceConfig, ++ RasterizerConfig, ++ VectorSource, ++) ++from rastervision.pipeline.file_system import json_to_file ++ ++ ++class InlineVectorSource(VectorSource): ++ def __init__(self, geojson, crs_transformer=None, bbox=None): ++ self._raw_geojson = geojson ++ super().__init__( ++ crs_transformer or IdentityCRSTransformer(), bbox=bbox) ++ ++ def _get_geojson(self): ++ return self._raw_geojson ++ ++ ++def feature_collection(features): ++ return {"type": "FeatureCollection", "features": features} ++ ++ ++def feature(geometry, properties=None): ++ return { ++ "type": "Feature", ++ "geometry": geometry, ++ "properties": properties or {}, ++ } ++ ++ ++def polygon(coords): ++ return {"type": "Polygon", "coordinates": [coords]} ++ ++ ++def point(coords): ++ return {"type": "Point", "coordinates": coords} ++ ++ ++def line(coords): ++ return {"type": "LineString", "coordinates": coords} ++ ++ ++def ten_by_ten_extent(): ++ return Box.make_square(0, 0, 10) ++ ++ ++def five_by_five_label(class_id=0): ++ return feature( ++ polygon([[0.0, 0.0], [0.0, 5.0], [5.0, 5.0], [5.0, 0.0], ++ [0.0, 0.0]]), ++ {"class_id": class_id}, ++ ) ++ ++ ++def direct_source(features, background_class_id=1, all_touched=False): ++ extent = ten_by_ten_extent() ++ vector_source = InlineVectorSource( ++ feature_collection(features), bbox=extent) ++ return RasterizedSource( ++ vector_source=vector_source, ++ background_class_id=background_class_id, ++ bbox=extent, ++ all_touched=all_touched, ++ ) ++ ++ ++def write_geojson(path, geojson): ++ json_to_file(geojson, str(path)) ++ return str(path) ++ ++ ++EXPECTED_FIVE_BY_FIVE_ONES = [ ++ [0, 0, 0, 0, 0, 1, 1, 1, 1, 1], ++ [0, 0, 0, 0, 0, 1, 1, 1, 1, 1], ++ [0, 0, 0, 0, 0, 1, 1, 1, 1, 1], ++ [0, 0, 0, 0, 0, 1, 1, 1, 1, 1], ++ [0, 0, 0, 0, 0, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++] ++ ++EXPECTED_FIVE_BY_FIVE_THREES = [ ++ [2, 2, 2, 2, 2, 3, 3, 3, 3, 3], ++ [2, 2, 2, 2, 2, 3, 3, 3, 3, 3], ++ [2, 2, 2, 2, 2, 3, 3, 3, 3, 3], ++ [2, 2, 2, 2, 2, 3, 3, 3, 3, 3], ++ [2, 2, 2, 2, 2, 3, 3, 3, 3, 3], ++ [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], ++ [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], ++ [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], ++ [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], ++ [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], ++] ++ ++def assert_geometry_error_mentions_buffering(error, geom_type): ++ message = str(error.value).lower() ++ ++ assert geom_type.lower() in message ++ assert "buffer" in message ++ assert "polygon" in message ++ ++ ++def test_direct_source_rasterizes_polygon_and_keeps_source_state(): ++ ++ ++ ++ ++ extent = ten_by_ten_extent() ++ vector_source = InlineVectorSource( ++ feature_collection([five_by_five_label()]), bbox=extent) ++ source = RasterizedSource( ++ vector_source=vector_source, ++ background_class_id=1, ++ bbox=extent, ++ ) ++ ++ assert source.dtype == np.uint8 ++ ++ assert source.crs_transformer is vector_source.crs_transformer ++ ++ first_chip = source.get_chip(Box.make_square(0, 0, 10)) ++ assert first_chip.shape == (10, 10, 1) ++ assert first_chip.dtype == np.dtype("uint8") ++ assert int(first_chip.sum()) == 75 ++ assert first_chip[:, :, 0].tolist() == EXPECTED_FIVE_BY_FIVE_ONES ++ ++ second_chip = source.get_chip(Box.make_square(0, 0, 10)) ++ assert second_chip.shape == (10, 10, 1) ++ assert int(second_chip.sum()) == 75 ++ assert second_chip[:, :, 0].tolist() == EXPECTED_FIVE_BY_FIVE_ONES ++ ++ ++def test_empty_vector_source_returns_background_only_chip(): ++ ++ ++ ++ ++ source = direct_source([], background_class_id=7) ++ ++ chip = source.get_chip(Box.make_square(0, 0, 10)) ++ ++ assert chip.shape == (10, 10, 1) ++ assert chip.dtype == np.dtype("uint8") ++ assert int(chip.sum()) == 700 ++ assert chip[:, :, 0].tolist() == [[7, 7, 7, 7, 7, 7, 7, 7, 7, 7], ++ [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], ++ [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], ++ [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], ++ [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], ++ [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], ++ [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], ++ [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], ++ [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], ++ [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]] ++ ++ ++def test_all_touched_false_ignores_tiny_polygon_without_center(): ++ ++ ++ ++ ++ tiny_label = feature( ++ polygon([[0.0, 0.0], [0.0, 0.4], [0.4, 0.4], [0.4, 0.0], ++ [0.0, 0.0]]), ++ {"class_id": 0}, ++ ) ++ source = direct_source([tiny_label], background_class_id=1, ++ all_touched=False) ++ ++ chip = source.get_chip(Box.make_square(0, 0, 10)) ++ ++ assert int(chip.sum()) == 100 ++ assert int(chip[0, 0, 0]) == 1 ++ assert chip[:, :, 0].tolist() == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] ++ ++ ++def test_all_touched_true_burns_tiny_touched_pixel(): ++ ++ ++ ++ ++ tiny_label = feature( ++ polygon([[0.0, 0.0], [0.0, 0.4], [0.4, 0.4], [0.4, 0.0], ++ [0.0, 0.0]]), ++ {"class_id": 0}, ++ ) ++ source = direct_source([tiny_label], background_class_id=1, ++ all_touched=True) ++ ++ chip = source.get_chip(Box.make_square(0, 0, 10)) ++ ++ assert int(chip.sum()) == 99 ++ assert int(chip[0, 0, 0]) == 0 ++ assert chip[:, :, 0].tolist() == [[0, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ++ [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]] ++ ++ ++def test_construction_rejects_unbuffered_point_and_line_labels(): ++ ++ ++ ++ ++ extent = ten_by_ten_extent() ++ ++ with pytest.raises(ValueError) as point_error: ++ RasterizedSource( ++ InlineVectorSource( ++ feature_collection( ++ [feature(point([1.0, 1.0]), {"class_id": 0})]), ++ bbox=extent, ++ ), ++ background_class_id=1, ++ bbox=extent, ++ ) ++ assert_geometry_error_mentions_buffering(point_error, "Point") ++ ++ with pytest.raises(ValueError) as line_error: ++ RasterizedSource( ++ InlineVectorSource( ++ feature_collection([ ++ feature(line([[1.0, 1.0], [3.0, 3.0]]), {"class_id": 0}) ++ ]), ++ bbox=extent, ++ ), ++ background_class_id=1, ++ bbox=extent, ++ ) ++ assert_geometry_error_mentions_buffering(line_error, "LineString") ++ ++ ++def test_construction_rejects_nonempty_polygons_without_class_id(): ++ ++ ++ ++ ++ extent = ten_by_ten_extent() ++ ++ with pytest.raises(ValueError) as missing_class_error: ++ RasterizedSource( ++ InlineVectorSource( ++ feature_collection([ ++ feature( ++ polygon([[0.0, 0.0], [0.0, 5.0], [5.0, 5.0], ++ [5.0, 0.0], [0.0, 0.0]]), {}) ++ ]), ++ bbox=extent, ++ ), ++ background_class_id=1, ++ bbox=extent, ++ ) ++ message = str(missing_class_error.value).lower() ++ ++ assert "polygon" in message ++ assert "class" in message ++ assert "id" in message ++ ++ ++def test_two_sources_keep_independent_class_and_background_state(): ++ ++ ++ ++ ++ a = direct_source([five_by_five_label(class_id=0)], background_class_id=1) ++ b = direct_source([five_by_five_label(class_id=2)], background_class_id=3) ++ ++ a_chip = a.get_chip(Box.make_square(0, 0, 10)) ++ b_chip = b.get_chip(Box.make_square(0, 0, 10)) ++ ++ assert int(a_chip.sum()) == 75 ++ assert a_chip[:, :, 0].tolist() == EXPECTED_FIVE_BY_FIVE_ONES ++ assert int(b_chip.sum()) == 275 ++ assert b_chip[:, :, 0].tolist() == EXPECTED_FIVE_BY_FIVE_THREES ++ ++ ++def test_config_registers_defaults_and_builds_rasterized_source(tmp_path): ++ ++ ++ ++ ++ geojson_path = write_geojson( ++ tmp_path / "labels.geojson", ++ feature_collection([ ++ feature( ++ polygon([[0.0, 0.0], [0.0, 5.0], [5.0, 5.0], [5.0, 0.0], ++ [0.0, 0.0]]), ++ {"class_name": "building"}, ++ ), ++ feature(line([[7.0, 0.0], [7.0, 9.0]]), ++ {"class_name": "building"}), ++ ]), ++ ) ++ ++ config = RasterizedSourceConfig( ++ vector_source=GeoJSONVectorSourceConfig(uris=geojson_path), ++ rasterizer_config=RasterizerConfig( ++ background_class_id=9, all_touched=True), ++ ) ++ ++ assert config.type_hint == "rasterized_source" ++ assert config.rasterizer_config.type_hint == "rasterizer" ++ ++ transformer_types = [ ++ type(tf).__name__ for tf in config.vector_source.transformers ++ ] ++ assert "ClassInferenceTransformerConfig" in transformer_types ++ buffer_geom_types = { ++ tf.geom_type for tf in config.vector_source.transformers ++ if isinstance(tf, BufferTransformerConfig) ++ } ++ assert {"Point", "LineString"}.issubset(buffer_geom_types) ++ assert any( ++ isinstance(tf, ClassInferenceTransformerConfig) ++ for tf in config.vector_source.transformers) ++ assert sum( ++ isinstance(tf, BufferTransformerConfig) ++ for tf in config.vector_source.transformers) == 2 ++ ++ built = config.build( ++ ClassConfig(names=["building"]), ++ IdentityCRSTransformer(), ++ bbox=Box.make_square(0, 0, 10), ++ ) ++ chip = built.get_chip(Box.make_square(0, 0, 10)) ++ ++ assert type(built).__name__ == "RasterizedSource" ++ assert built.background_class_id == 9 ++ assert built.all_touched is True ++ assert built.bbox.tuple_format() == (0, 0, 10, 10) ++ assert built.dtype == np.uint8 ++ ++ assert chip.shape == (10, 10, 1) ++ assert chip.dtype == np.dtype("uint8") ++ assert int(chip[0, 0, 0]) == 0 ++ assert int(chip[9, 9, 0]) == 9 ++ assert np.any(chip[:, 6:9, 0] == 0) ++ ++ ++def test_config_preserves_existing_required_transformers(tmp_path): ++ ++ ++ ++ ++ geojson_path = write_geojson( ++ tmp_path / "labels.geojson", ++ feature_collection([five_by_five_label(class_id=4)]), ++ ) ++ vector_config = GeoJSONVectorSourceConfig( ++ uris=geojson_path, ++ transformers=[ ++ ClassInferenceTransformerConfig(default_class_id=6), ++ BufferTransformerConfig(geom_type="Point", default_buf=2), ++ ], ++ ) ++ ++ config = RasterizedSourceConfig( ++ vector_source=vector_config, ++ rasterizer_config=RasterizerConfig(background_class_id=5), ++ ) ++ ++ ++ class_tfs = [ ++ tf for tf in config.vector_source.transformers ++ if isinstance(tf, ClassInferenceTransformerConfig) ++ ] ++ assert len(class_tfs) == 1 ++ assert class_tfs[0].default_class_id == 6 ++ point_tfs = [ ++ tf for tf in config.vector_source.transformers ++ if isinstance(tf, BufferTransformerConfig) and tf.geom_type == "Point" ++ ] ++ assert len(point_tfs) == 1 ++ assert point_tfs[0].default_buf == 2 ++ ++ ++def test_drop_lifecycle_keeps_python_heap_bounded(): ++ ++ ++ ++ ++ chip_sums = [] ++ for _ in range(5): ++ source = direct_source( ++ [five_by_five_label(class_id=0)], background_class_id=1) ++ chip = source.get_chip(Box.make_square(0, 0, 10)) ++ chip_sums.append(int(chip.sum())) ++ ++ assert chip_sums == [75, 75, 75, 75, 75] ++ ++ ++def test_repeated_drop_lifecycle_is_idempotent(): ++ ++ ++ ++ ++ source = direct_source([five_by_five_label(class_id=0)], ++ background_class_id=1) ++ chip = source.get_chip(Box.make_square(0, 0, 10)) ++ ++ assert source.dtype == np.uint8 ++ assert int(chip.sum()) == 75 ++ ++ ++ assert chip[:, :, 0].tolist() == EXPECTED_FIVE_BY_FIVE_ONES ++ ++ ++def test_public_exports_are_available_from_rastervision_core_data(): ++ ++ ++ ++ ++ assert RasterizedSource.__name__ == "RasterizedSource" ++ assert RasterizedSourceConfig.__name__ == "RasterizedSourceConfig" ++ assert RasterizerConfig.__name__ == "RasterizerConfig" +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export AWS_EC2_METADATA_DISABLED=true ++export PROJ_NETWORK=OFF ++export PIP_NO_INDEX=1 ++ ++/opt/stage4a-venv/bin/python -m pytest /workspace/repo/usercase-test-coderl/test_rasterized_source_acceptance.py -v diff --git a/tasks/format-code-task-000520/tests/test.sh b/tasks/format-code-task-000520/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8686980b94ad4e678fca112261e3c7e57d6bc552 --- /dev/null +++ b/tasks/format-code-task-000520/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_rasterized_source_acceptance.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000520/tests/test_command.sh b/tasks/format-code-task-000520/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000520/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-000529/environment/Dockerfile b/tasks/format-code-task-000529/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..87c628cff26820e32b09d8d4adba6eda376b12c9 --- /dev/null +++ b/tasks/format-code-task-000529/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:db5aef05968e7c72c636c30384e721f320b00016c7f4130a512485b60b1b2cdb diff --git a/tasks/format-code-task-000529/environment/setup/files/blocklist b/tasks/format-code-task-000529/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000529/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-000529/environment/setup/setup.sh b/tasks/format-code-task-000529/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000529/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-000529/tests/test.patch b/tasks/format-code-task-000529/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3abebf23400743988c0d632265b93948ba3c8268 --- /dev/null +++ b/tasks/format-code-task-000529/tests/test.patch @@ -0,0 +1,93 @@ +diff --git a/arch/univariate/tests/test_mean.py b/arch/univariate/tests/test_mean.py +index dd8555cb92..c0a15483c6 100644 +--- a/arch/univariate/tests/test_mean.py ++++ b/arch/univariate/tests/test_mean.py +@@ -821,6 +821,66 @@ class TestMeanModel(TestCase): + assert_almost_equal(res.params.values, res4.params.values, decimal=4) + assert am.hold_back == 100 + ++ def test_fix_on_fresh_model_does_not_raise(self): ++ ++ ++ ++ am = arch_model(self.y_series) ++ res = am.fit(disp=DISPLAY) ++ ++ am_fresh = arch_model(self.y_series) ++ fixed_res = am_fresh.fix(res.params) ++ ++ assert_series_equal(res.params, fixed_res.params) ++ assert_almost_equal(res.loglikelihood, fixed_res.loglikelihood) ++ ++ def test_fix_on_fresh_model_matches_fit_then_fix(self): ++ ++ ++ am_fit = arch_model(self.y_series) ++ res = am_fit.fit(disp=DISPLAY) ++ fixed_after_fit = am_fit.fix(res.params) ++ ++ am_fresh = arch_model(self.y_series) ++ fixed_fresh = am_fresh.fix(res.params) ++ ++ assert_almost_equal(fixed_after_fit.loglikelihood, ++ fixed_fresh.loglikelihood) ++ assert_series_equal(fixed_after_fit.params, fixed_fresh.params) ++ assert_almost_equal( ++ np.asarray(fixed_after_fit.conditional_volatility), ++ np.asarray(fixed_fresh.conditional_volatility)) ++ ++ def test_fix_accepts_first_last_obs_kwargs(self): ++ ++ ++ am = arch_model(self.y_series) ++ res = am.fit(disp=DISPLAY) ++ ++ am_fresh = arch_model(self.y_series) ++ ++ fixed_res = am_fresh.fix(res.params, first_obs=100, last_obs=900) ++ assert fixed_res is not None ++ ++ def test_fix_first_last_obs_subset_matches_fit_subset(self): ++ ++ ++ ++ am_fit = arch_model(self.y_series) ++ res_subset = am_fit.fit(disp=DISPLAY, first_obs=100, last_obs=900) ++ ++ am_fix = arch_model(self.y_series) ++ fixed_subset = am_fix.fix(res_subset.params, ++ first_obs=100, last_obs=900) ++ assert_almost_equal(res_subset.loglikelihood, ++ fixed_subset.loglikelihood) ++ ++ ++ ++ am_full = arch_model(self.y_series) ++ fixed_full = am_full.fix(res_subset.params) ++ assert fixed_subset.loglikelihood != fixed_full.loglikelihood ++ + def test_constant_mean_fixed_variance(self): + variance = 2 + np.random.standard_normal(self.y.shape[0]) ** 2.0 + mod = ConstantMean(self.y_series, volatility=FixedVariance(variance)) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..e3f0799ccf +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest arch/univariate/tests/test_mean.py -k \"test_fix_on_fresh_model_does_not_raise or test_fix_on_fresh_model_matches_fit_then_fix or test_fix_accepts_first_last_obs_kwargs or test_fix_first_last_obs_subset_matches_fit_subset\" -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest arch/univariate/tests/test_mean.py -k "test_fix_on_fresh_model_does_not_raise or test_fix_on_fresh_model_matches_fit_then_fix or test_fix_accepts_first_last_obs_kwargs or test_fix_first_last_obs_subset_matches_fit_subset" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000529/tests/test.sh b/tasks/format-code-task-000529/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..72785dbcd8eac0daf08c2f8e0befbf75b764baf9 --- /dev/null +++ b/tasks/format-code-task-000529/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' +arch/univariate/tests/test_mean.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000529/tests/test_command.sh b/tasks/format-code-task-000529/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000529/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-000602/environment/Dockerfile b/tasks/format-code-task-000602/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6a6be5ebd3628f3ddccbc83b9b8653b79d7647a5 --- /dev/null +++ b/tasks/format-code-task-000602/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:5b073219bb1a57efd3cc226a1dc468cc788e38ee98cc915fcb29bc84db2f8ca5 diff --git a/tasks/format-code-task-000602/environment/setup/files/blocklist b/tasks/format-code-task-000602/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000602/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-000602/environment/setup/setup.sh b/tasks/format-code-task-000602/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000602/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-000602/tests/test.patch b/tasks/format-code-task-000602/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5da0533b05b42da43aaa7a2661ae9143fed90b57 --- /dev/null +++ b/tasks/format-code-task-000602/tests/test.patch @@ -0,0 +1,84 @@ +diff --git a/faker_test.go b/faker_test.go +index 6eecddd..87e8116 100644 +--- a/faker_test.go ++++ b/faker_test.go +@@ -1266,7 +1266,7 @@ func TestTagWithPointer(t *testing.T) { + t.Error("Expected Not Error, But Got: ", err) + } + +- //Assert ++ + if sample.FirstName == nil || *sample.FirstName == "" { + t.Error("Expected filled but got empty") + } +@@ -2245,3 +2245,50 @@ func TestRandomMapSliceSize(t *testing.T) { + } + } + } ++ ++func TestWithFieldsToIgnore(t *testing.T) { ++ a := AStruct{} ++ if err := FakeData(&a, WithFieldsToIgnore("Height", "Name")); err != nil { ++ t.Error(err) ++ } ++ ++ if a.Height != 0 { ++ t.Errorf("Height expected to be ignored") ++ } ++ if a.AnotherStruct.Name != "" { ++ t.Errorf("Name expected to be ignored") ++ } ++ if a.AnotherStruct.Image == "" { ++ t.Errorf("other fields are affected") ++ } ++} ++ ++func TestWithFieldProvider(t *testing.T) { ++ a := AStruct{} ++ const heightVal = int64(123) ++ const nameVal = "some string" ++ if err := FakeData(&a, ++ WithCustomFieldProvider("Height", func() (interface{}, error) { ++ return heightVal, nil ++ }), ++ WithCustomFieldProvider("Name", func() (interface{}, error) { ++ return nameVal, nil ++ }), ++ ); err != nil { ++ t.Error(err) ++ } ++ ++ if a.Height != heightVal { ++ t.Errorf("expected Height %d, got %d", heightVal, a.Height) ++ } ++ if a.AnotherStruct.Name != nameVal { ++ t.Errorf("expected Name %q, got %q", nameVal, a.AnotherStruct.Name) ++ } ++ ++ ++ if err := FakeData(&a, WithCustomFieldProvider("Height", func() (interface{}, error) { ++ return nil, fmt.Errorf("test") ++ })); err == nil { ++ t.Errorf("expected an error, but got nil") ++ } ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3R0QqCMBTGca99ivMCzs1Sr3qWMDcqSAc5e/7MLoygvDEi+v8udg5ssA8+teuP ++J7t17SWNPkUPyjwf5+B5jrvJM52Vw1mWkTamMCaS/GOJHvRdqM4i0dn78O7d3P2PUlP/wXVhW/um ++qVqrusNyf8z2X6yn/le3/tdFNvSvl4vw2p/3X1sZi985G++93FZJLpLUvm/DxkgSjo3zfRCT6U5U ++qpSKv50ZAAAAAAAAAAAAAAAAwN0VNqea3QAoAAA= +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-000602/tests/test.sh b/tasks/format-code-task-000602/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e482ad9f041ab2636291feb94d81c7360db65fc0 --- /dev/null +++ b/tasks/format-code-task-000602/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' +faker_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-000602/tests/test_command.sh b/tasks/format-code-task-000602/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000602/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-000633/environment/Dockerfile b/tasks/format-code-task-000633/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a0f1dcf90bfb2606d4652e42d407e205aaf4e2a5 --- /dev/null +++ b/tasks/format-code-task-000633/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:7d13b956a7ab2d7e924a962fb4d305d8436733771659285315f30d9f81de047e diff --git a/tasks/format-code-task-000633/environment/setup/files/blocklist b/tasks/format-code-task-000633/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000633/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-000633/environment/setup/setup.sh b/tasks/format-code-task-000633/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000633/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-000633/tests/test.patch b/tasks/format-code-task-000633/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0292bbde98191979148002cac4f60f130aee5160 --- /dev/null +++ b/tasks/format-code-task-000633/tests/test.patch @@ -0,0 +1,235 @@ +diff --git a/usercase-test-coderl/test_crontab_from_string.py b/usercase-test-coderl/test_crontab_from_string.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_crontab_from_string.py +@@ -0,0 +1,209 @@ ++ ++ ++ ++ ++ ++ ++ ++from __future__ import annotations ++ ++import copy ++import json ++import os ++import socket ++import subprocess ++import sys ++ ++import pytest ++ ++from celery.schedules import crontab ++ ++ ++def schedule_snapshot(schedule: crontab) -> dict[str, object]: ++ ++ ++ return { ++ "minute": sorted(schedule.minute), ++ "hour": sorted(schedule.hour), ++ "day_of_month": sorted(schedule.day_of_month), ++ "month_of_year": sorted(schedule.month_of_year), ++ "day_of_week": sorted(schedule.day_of_week), ++ } ++ ++ ++def test_every_field_wildcard_matches_default_crontab(): ++ ++ ++ ++ ++ actual = crontab.from_string("* * * * *") ++ expected = crontab() ++ ++ assert actual == expected ++ ++ ++ assert schedule_snapshot(actual) == schedule_snapshot(expected) ++ ++ ++def test_named_weekday_is_interpreted_as_fifth_cron_field(): ++ ++ ++ ++ ++ actual = crontab.from_string("* * * * SUN") ++ expected = crontab(day_of_week="SUN") ++ ++ assert actual == expected ++ ++ ++ assert schedule_snapshot(actual) == schedule_snapshot(expected) ++ ++ ++def test_numeric_minute_hour_and_day_of_month_keep_cron_field_order(): ++ ++ ++ ++ ++ actual = crontab.from_string("0 8 5 * *") ++ expected = crontab(minute="0", hour="8", day_of_month="5") ++ ++ assert actual == expected ++ ++ ++ assert schedule_snapshot(actual) == schedule_snapshot(expected) ++ ++ ++def test_all_five_fields_can_be_specific_values(): ++ ++ ++ ++ ++ actual = crontab.from_string("15 0 1 1 MON") ++ expected = crontab(minute="15", hour="0", day_of_week="MON", day_of_month="1", month_of_year="1") ++ ++ assert actual == expected ++ ++ ++ assert schedule_snapshot(actual) == schedule_snapshot(expected) ++ ++ ++def test_cron_steps_and_ranges_are_passed_to_normal_constructor_fields(): ++ ++ ++ ++ ++ actual = crontab.from_string("*/20 9-17 * * MON-FRI") ++ expected = crontab(minute="*/20", hour="9-17", day_of_week="MON-FRI") ++ ++ assert actual == expected ++ ++ ++ assert schedule_snapshot(actual) == schedule_snapshot(expected) ++ ++ ++def test_upper_bound_values_map_to_their_own_fields(): ++ ++ ++ ++ ++ actual = crontab.from_string("59 23 31 12 SAT") ++ expected = crontab(minute="59", hour="23", day_of_week="SAT", day_of_month="31", month_of_year="12") ++ ++ assert actual == expected ++ ++ ++ assert schedule_snapshot(actual) == schedule_snapshot(expected) ++ ++ ++ ++ ++@pytest.mark.parametrize("expression", ["", "*", "* * * *", "* * * * * *"]) ++def test_rejects_inputs_without_exactly_five_space_separated_fields(expression: str): ++ ++ ++ ++ ++ with pytest.raises(ValueError): ++ crontab.from_string(expression) ++ ++ ++def test_referential_transparency_for_same_cron_string(): ++ first = crontab.from_string("0 8 5 * *") ++ second = crontab.from_string("0 8 5 * *") ++ ++ assert first == second ++ ++ assert schedule_snapshot(first) == schedule_snapshot(second) ++ ++ ++def test_does_not_mutate_caller_input(): ++ expression = "* * * * SUN" ++ before = copy.deepcopy(expression) ++ ++ actual = crontab.from_string(expression) ++ expected = crontab(day_of_week="SUN") ++ ++ ++ ++ assert schedule_snapshot(actual) == schedule_snapshot(expected) ++ assert expression == before ++ ++ ++def test_same_input_matches_fresh_process_result_after_other_calls(): ++ expression = "*/20 9-17 * * MON-FRI" ++ in_process = schedule_snapshot(crontab.from_string(expression)) ++ ++ ++ ++ assert schedule_snapshot(crontab.from_string("* * * * *")) == schedule_snapshot(crontab()) ++ ++ ++ assert schedule_snapshot(crontab.from_string("59 23 31 12 SAT")) == schedule_snapshot( ++ crontab(minute="59", hour="23", day_of_week="SAT", day_of_month="31", month_of_year="12") ++ ) ++ ++ script = f""" ++import json ++import sys ++sys.path.insert(0, {os.fsdecode('/workspace/repo')!r}) ++from celery.schedules import crontab ++ ++def schedule_snapshot(schedule): ++ return {{ ++ "minute": sorted(schedule.minute), ++ "hour": sorted(schedule.hour), ++ "day_of_month": sorted(schedule.day_of_month), ++ "month_of_year": sorted(schedule.month_of_year), ++ "day_of_week": sorted(schedule.day_of_week), ++ }} ++ ++sys.stdout.write(json.dumps(schedule_snapshot(crontab.from_string({expression!r})), sort_keys=True)) ++""" ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ capture_output=True, ++ text=True, ++ ) ++ fresh_process = json.loads(completed.stdout) ++ ++ ++ assert in_process == fresh_process ++ ++ ++def test_no_filesystem_or_network_side_effects(tmp_path, monkeypatch): ++ def fail_socket(*args, **kwargs): ++ raise AssertionError("network access is not part of crontab.from_string") ++ ++ monkeypatch.setattr(socket, "socket", fail_socket) ++ monkeypatch.chdir(tmp_path) ++ before = sorted(path.relative_to(tmp_path).as_posix() for path in tmp_path.rglob("*")) ++ ++ actual = crontab.from_string("0 8 5 * *") ++ expected = crontab(minute="0", hour="8", day_of_month="5") ++ ++ after = sorted(path.relative_to(tmp_path).as_posix() for path in tmp_path.rglob("*")) ++ ++ ++ assert schedule_snapshot(actual) == schedule_snapshot(expected) ++ assert after == before +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_crontab_from_string.py -v diff --git a/tasks/format-code-task-000633/tests/test.sh b/tasks/format-code-task-000633/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a014ee636d8eb662cc09d56a59978b11f67cb303 --- /dev/null +++ b/tasks/format-code-task-000633/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_crontab_from_string.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-000633/tests/test_command.sh b/tasks/format-code-task-000633/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000633/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-000651/environment/Dockerfile b/tasks/format-code-task-000651/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..823e448a13b57412b59e170aa6ade9894dc2b777 --- /dev/null +++ b/tasks/format-code-task-000651/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:65a455484d275ff35b7fd4f5fdaf9e9341c33935f83abcdb43a214c8cbbacda3 diff --git a/tasks/format-code-task-000651/environment/setup/files/blocklist b/tasks/format-code-task-000651/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000651/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-000651/environment/setup/setup.sh b/tasks/format-code-task-000651/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000651/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-000651/tests/test.patch b/tasks/format-code-task-000651/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c51dff55a8dcbc1457161e2e569a52ee535162fe --- /dev/null +++ b/tasks/format-code-task-000651/tests/test.patch @@ -0,0 +1,56 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..a7c98fca8 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m unittest tests.chainer_tests.test_variable.TestUninitializedVariableToString -v"] ++} +diff --git a/tests/chainer_tests/test_variable.py b/tests/chainer_tests/test_variable.py +index 3052447d4..a5276ad3a 100644 +--- a/tests/chainer_tests/test_variable.py ++++ b/tests/chainer_tests/test_variable.py +@@ -1266,4 +1266,29 @@ class TestNamedVariableDim2Size0ToString(unittest.TestCase): + self.assertEqual(str(self.x), self.str) + + ++class TestUninitializedVariableToString(unittest.TestCase): ++ ++ def test_unnamed_uninitialized_repr(self): ++ a = chainer.Variable() ++ self.assertIsNone(a.data) ++ self.assertEqual(repr(a), 'variable(None)') ++ ++ def test_unnamed_uninitialized_str(self): ++ a = chainer.Variable() ++ self.assertIsNone(a.data) ++ self.assertEqual(str(a), 'variable(None)') ++ ++ def test_named_uninitialized_repr(self): ++ a = chainer.Variable() ++ a.name = 'x' ++ self.assertIsNone(a.data) ++ self.assertEqual(repr(a), 'variable x(None)') ++ ++ def test_named_uninitialized_str(self): ++ a = chainer.Variable() ++ a.name = 'x' ++ self.assertIsNone(a.data) ++ self.assertEqual(str(a), 'variable x(None)') ++ ++ + testing.run_module(__name__, __file__) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m unittest tests.chainer_tests.test_variable.TestUninitializedVariableToString -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000651/tests/test.sh b/tasks/format-code-task-000651/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a70ab06d870afd0864a3dc7c8255fd6f623206d0 --- /dev/null +++ b/tasks/format-code-task-000651/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/chainer_tests/test_variable.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-000651/tests/test_command.sh b/tasks/format-code-task-000651/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000651/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-000656/environment/Dockerfile b/tasks/format-code-task-000656/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b442db2e9be92406e4024858485d9a793d147ef3 --- /dev/null +++ b/tasks/format-code-task-000656/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:4db676212c8422eae67a09655f566b101527eb7cdb7179e36dc829f69a279c93 diff --git a/tasks/format-code-task-000656/environment/setup/files/blocklist b/tasks/format-code-task-000656/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000656/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-000656/environment/setup/setup.sh b/tasks/format-code-task-000656/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000656/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-000656/tests/test.patch b/tasks/format-code-task-000656/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1838c2e553fc8e3a4e0d04f04d7a7874e3461746 --- /dev/null +++ b/tasks/format-code-task-000656/tests/test.patch @@ -0,0 +1,376 @@ +diff --git a/usercase-test-coderl/update_dimensions.test.ts b/usercase-test-coderl/update_dimensions.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/update_dimensions.test.ts +@@ -0,0 +1,317 @@ ++const HanziWriter = require('../dist/index.cjs.js'); ++const ren = require('hanzi-writer-data/人.json'); ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++const charDataLoader = () => ren; ++ ++const resolvePromises = async (num = 10) => { ++ for (let i = 0; i < num; i++) await Promise.resolve(); ++}; ++ ++const currentGroup = (targetId) => { ++ const groups = document.querySelectorAll(`#${targetId} svg > g`); ++ return groups[groups.length - 1]; ++}; ++ ++const currentTransform = (targetId) => currentGroup(targetId)?.getAttribute('transform'); ++ ++const expectVisibleCharacter = (targetId) => { ++ expect(currentGroup(targetId)).toBeTruthy(); ++ expect(document.querySelectorAll(`#${targetId} svg path`).length).toBeGreaterThan(0); ++}; ++ ++const expectMountedTransform = (targetId) => { ++ const transform = currentTransform(targetId); ++ expect(transform).toEqual(expect.stringContaining('translate(')); ++ expect(transform).toEqual(expect.stringContaining('scale(')); ++ return transform; ++}; ++ ++describe('HanziWriter updateDimensions acceptance', () => { ++ test('svg updateDimensions resizes the target and remounts the visible character with new geometry', async () => { ++ ++ ++ document.body.innerHTML = '
'; ++ const writer = HanziWriter.create('target', '人', { ++ width: 200, ++ height: 200, ++ padding: 10, ++ charDataLoader, ++ }); ++ ++ await writer.setCharacter('人'); ++ await resolvePromises(); ++ ++ expect(document.querySelectorAll('#target svg').length).toBe(1); ++ expect(document.querySelector('#target svg')?.getAttribute('width')).toBe('200'); ++ expect(document.querySelector('#target svg')?.getAttribute('height')).toBe('200'); ++ ++ const beforeTransform = expectMountedTransform('target'); ++ expectVisibleCharacter('target'); ++ ++ writer.updateDimensions({ width: 300, height: 350, padding: 20 }); ++ await resolvePromises(); ++ ++ expect(document.querySelector('#target svg')?.getAttribute('width')).toBe('300'); ++ expect(document.querySelector('#target svg')?.getAttribute('height')).toBe('350'); ++ ++ expect(expectMountedTransform('target')).not.toBe(beforeTransform); ++ expectVisibleCharacter('target'); ++ }); ++ ++ test('canvas updateDimensions updates the canvas backing element dimensions', () => { ++ ++ ++ document.body.innerHTML = '
'; ++ const writer = HanziWriter.create('target', '人', { ++ renderer: 'canvas', ++ width: 200, ++ height: 200, ++ padding: 10, ++ charDataLoader, ++ }); ++ ++ expect(document.querySelectorAll('#target canvas').length).toBe(1); ++ expect(document.querySelector('#target canvas')?.getAttribute('width')).toBe('200'); ++ expect(document.querySelector('#target canvas')?.getAttribute('height')).toBe('200'); ++ ++ writer.updateDimensions({ width: 300, height: 350, padding: 20 }); ++ ++ expect(document.querySelector('#target canvas')?.getAttribute('width')).toBe('300'); ++ expect(document.querySelector('#target canvas')?.getAttribute('height')).toBe('350'); ++ }); ++ ++ test('partial dimension updates retain omitted width height and padding values', async () => { ++ ++ ++ document.body.innerHTML = '
'; ++ const writer = HanziWriter.create('target', '人', { ++ width: 200, ++ height: 200, ++ padding: 10, ++ charDataLoader, ++ }); ++ await writer.setCharacter('人'); ++ await resolvePromises(); ++ ++ let beforeTransform = expectMountedTransform('target'); ++ writer.updateDimensions({ width: 250 }); ++ await resolvePromises(); ++ expect(document.querySelector('#target svg')?.getAttribute('width')).toBe('250'); ++ expect(document.querySelector('#target svg')?.getAttribute('height')).toBe('200'); ++ ++ let afterTransform = expectMountedTransform('target'); ++ expect(afterTransform).not.toBe(beforeTransform); ++ ++ beforeTransform = afterTransform; ++ writer.updateDimensions({ height: 260 }); ++ await resolvePromises(); ++ expect(document.querySelector('#target svg')?.getAttribute('width')).toBe('250'); ++ expect(document.querySelector('#target svg')?.getAttribute('height')).toBe('260'); ++ ++ afterTransform = expectMountedTransform('target'); ++ expect(afterTransform).not.toBe(beforeTransform); ++ ++ beforeTransform = afterTransform; ++ writer.updateDimensions({ padding: 30 }); ++ await resolvePromises(); ++ expect(document.querySelector('#target svg')?.getAttribute('width')).toBe('250'); ++ expect(document.querySelector('#target svg')?.getAttribute('height')).toBe('260'); ++ ++ afterTransform = expectMountedTransform('target'); ++ expect(afterTransform).not.toBe(beforeTransform); ++ }); ++ ++ test('active quiz keeps using resized character coordinates for later pointer input', async () => { ++ ++ ++ document.body.innerHTML = '
'; ++ const onMistake = jest.fn(); ++ const writer = HanziWriter.create('target', '人', { ++ width: 200, ++ height: 200, ++ padding: 10, ++ charDataLoader, ++ }); ++ await writer.setCharacter('人'); ++ await resolvePromises(); ++ await writer.quiz({ onMistake }); ++ await resolvePromises(); ++ ++ writer.updateDimensions({ width: 300, height: 350, padding: 20 }); ++ await resolvePromises(); ++ ++ const svg = document.querySelector('#target svg'); ++ svg.getBoundingClientRect = () => ({ left: 50, top: 60 }); ++ svg.dispatchEvent( ++ new MouseEvent('mousedown', { ++ bubbles: true, ++ cancelable: true, ++ clientX: 170, ++ clientY: 127, ++ }), ++ ); ++ svg.dispatchEvent( ++ new MouseEvent('mousemove', { ++ bubbles: true, ++ cancelable: true, ++ clientX: 190, ++ clientY: 147, ++ }), ++ ); ++ document.dispatchEvent( ++ new MouseEvent('mouseup', { bubbles: true, cancelable: true }), ++ ); ++ await resolvePromises(); ++ ++ expect(onMistake).toHaveBeenCalledTimes(1); ++ ++ const mistake = onMistake.mock.calls[0][0]; ++ expect(mistake.drawnPath.points.length).toBe(2); ++ expect(mistake.drawnPath.points[0].x).toBeGreaterThan(350); ++ expect(mistake.drawnPath.points[0].x).toBeLessThan(450); ++ expect(mistake.drawnPath.points[0].y).toBeGreaterThan(750); ++ expect(mistake.drawnPath.points[0].y).toBeLessThan(870); ++ }); ++ ++ test('two writer instances keep their own dimensions and transforms', async () => { ++ ++ ++ document.body.innerHTML = '
'; ++ const a = HanziWriter.create('a', '人', { ++ width: 200, ++ height: 200, ++ padding: 10, ++ charDataLoader, ++ }); ++ const b = HanziWriter.create('b', '人', { ++ width: 180, ++ height: 220, ++ padding: 15, ++ charDataLoader, ++ }); ++ await a.setCharacter('人'); ++ await b.setCharacter('人'); ++ await resolvePromises(); ++ const beforeATransform = expectMountedTransform('a'); ++ const beforeBTransform = expectMountedTransform('b'); ++ ++ a.updateDimensions({ width: 300, height: 350, padding: 20 }); ++ await resolvePromises(); ++ ++ expect(document.querySelector('#a svg')?.getAttribute('width')).toBe('300'); ++ expect(document.querySelector('#a svg')?.getAttribute('height')).toBe('350'); ++ ++ expect(expectMountedTransform('a')).not.toBe(beforeATransform); ++ expect(document.querySelector('#b svg')?.getAttribute('width')).toBe('180'); ++ expect(document.querySelector('#b svg')?.getAttribute('height')).toBe('220'); ++ ++ expect(expectMountedTransform('b')).toBe(beforeBTransform); ++ }); ++ ++ test('repeated SVG dimension updates keep renderer DOM nodes bounded', async () => { ++ ++ ++ document.body.innerHTML = '
'; ++ const writer = HanziWriter.create('target', '人', { ++ width: 200, ++ height: 200, ++ padding: 10, ++ charDataLoader, ++ }); ++ await writer.setCharacter('人'); ++ await resolvePromises(); ++ ++ ++ expectVisibleCharacter('target'); ++ const beforeTransform = expectMountedTransform('target'); ++ ++ for (let i = 0; i < 120; i++) { ++ writer.updateDimensions({ ++ width: 220 + (i % 3), ++ height: 230 + (i % 5), ++ padding: 12 + (i % 4), ++ }); ++ } ++ await resolvePromises(); ++ ++ ++ expectVisibleCharacter('target'); ++ expect(document.querySelector('#target svg')?.getAttribute('width')).toBe('222'); ++ expect(document.querySelector('#target svg')?.getAttribute('height')).toBe('234'); ++ expect(expectMountedTransform('target')).not.toBe(beforeTransform); ++ }); ++ ++ test('created writer exposes the public updateDimensions method', () => { ++ ++ ++ document.body.innerHTML = '
'; ++ ++ const writer = HanziWriter.create('target', '人', { ++ width: 200, ++ height: 200, ++ padding: 10, ++ charDataLoader, ++ }); ++ ++ ++ expect(typeof writer.updateDimensions).toBe('function'); ++ }); ++ ++ test('quiz cleanup is idempotent after a resized active quiz', async () => { ++ ++ ++ document.body.innerHTML = '
'; ++ const onMistake = jest.fn(); ++ const writer = HanziWriter.create('target', '人', { ++ width: 200, ++ height: 200, ++ padding: 10, ++ charDataLoader, ++ }); ++ await writer.setCharacter('人'); ++ await resolvePromises(); ++ await writer.quiz({ onMistake }); ++ await resolvePromises(); ++ writer.updateDimensions({ width: 300, height: 350, padding: 20 }); ++ await resolvePromises(); ++ ++ expect(() => { ++ writer.cancelQuiz(); ++ writer.cancelQuiz(); ++ }).not.toThrow(); ++ ++ const svg = document.querySelector('#target svg'); ++ svg.getBoundingClientRect = () => ({ left: 50, top: 60 }); ++ svg.dispatchEvent( ++ new MouseEvent('mousedown', { ++ bubbles: true, ++ cancelable: true, ++ clientX: 170, ++ clientY: 127, ++ }), ++ ); ++ svg.dispatchEvent( ++ new MouseEvent('mousemove', { ++ bubbles: true, ++ cancelable: true, ++ clientX: 190, ++ clientY: 147, ++ }), ++ ); ++ document.dispatchEvent( ++ new MouseEvent('mouseup', { bubbles: true, cancelable: true }), ++ ); ++ await resolvePromises(); ++ ++ expect(onMistake).toHaveBeenCalledTimes(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,49 @@ ++#!/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 BROWSERSLIST_IGNORE_OLD_DATA=1 ++export NO_UPDATE_NOTIFIER=1 ++export npm_config_audit=false ++export npm_config_fund=false ++export npm_config_offline=true ++ ++for path in \ ++ node_modules/.bin/rollup \ ++ node_modules/.bin/jest \ ++ node_modules/@babel/core \ ++ node_modules/@babel/preset-env \ ++ node_modules/@babel/preset-typescript \ ++ node_modules/@rollup/plugin-babel \ ++ node_modules/@rollup/plugin-node-resolve \ ++ node_modules/@wessberg/rollup-plugin-ts \ ++ node_modules/hanzi-writer-data/人.json \ ++ node_modules/jest-canvas-mock \ ++ node_modules/jest-environment-jsdom \ ++ node_modules/jest-fetch-mock \ ++ node_modules/rollup-plugin-filesize \ ++ node_modules/rollup-plugin-license \ ++ node_modules/rollup-plugin-terser \ ++ node_modules/typescript ++do ++ test -e "$path" ++done ++ ++rm -rf dist ++./node_modules/.bin/rollup -c >/dev/null ++ ++exec ./node_modules/.bin/jest \ ++ --config '{"rootDir":"/workspace/repo","testEnvironment":"/jest-jsdom-env.js","setupFiles":["jest-canvas-mock"],"setupFilesAfterEnv":["/jest-setup.js"],"testURL":"https://test.com/url#tag"}' \ ++ /workspace/repo/usercase-test-coderl/update_dimensions.test.ts \ ++ --runInBand diff --git a/tasks/format-code-task-000656/tests/test.sh b/tasks/format-code-task-000656/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9ce87b771629e30c852c420c95a672d97d0b2bf8 --- /dev/null +++ b/tasks/format-code-task-000656/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/update_dimensions.test.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-000656/tests/test_command.sh b/tasks/format-code-task-000656/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000656/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-000658/environment/Dockerfile b/tasks/format-code-task-000658/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b7536af87f5aa2f4fb6830c574d9d409ad8c3d2b --- /dev/null +++ b/tasks/format-code-task-000658/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:af7ea3afb72308b57b186bbcc1488fbac77216accbc8f8a4cd99d2f1ef316a65 diff --git a/tasks/format-code-task-000658/environment/setup/files/blocklist b/tasks/format-code-task-000658/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000658/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-000658/environment/setup/setup.sh b/tasks/format-code-task-000658/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000658/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-000658/tests/test.patch b/tasks/format-code-task-000658/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..11f871a53eca61c005d7456884bd36eb13fe4786 --- /dev/null +++ b/tasks/format-code-task-000658/tests/test.patch @@ -0,0 +1,480 @@ +diff --git a/apply/apply_test.go b/apply/apply_test.go +index 336586f9..0bfd4abf 100644 +--- a/apply/apply_test.go ++++ b/apply/apply_test.go +@@ -26,6 +26,16 @@ func init() { + logrus.SetFormatter(formatter) + } + ++func warningsMentionDockerDeprecation(warnings []string) bool { ++ for _, warning := range warnings { ++ lower := strings.ToLower(warning) ++ if strings.Contains(lower, "docker") && strings.Contains(lower, "deprecat") { ++ return true ++ } ++ } ++ return false ++} ++ + func randomString(n int) string { + var letter = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") + +@@ -271,8 +281,9 @@ func TestApplySmokeTest(t *testing.T) { + c2, e := config.UpgradeConfigVersion(c) + r.NoError(e) + +- e = c2.Validate() ++ w, e := c2.Validate() + r.NoError(e) ++ r.True(warningsMentionDockerDeprecation(w), "expected Docker deprecation warning in %#v", w) + + e = Apply(fs, c2, templates.Templates, false) + r.NoError(e) +diff --git a/apply/golden_file_test.go b/apply/golden_file_test.go +index c2fd4101..def3e521 100644 +--- a/apply/golden_file_test.go ++++ b/apply/golden_file_test.go +@@ -1,3 +1,4 @@ ++//go:build !offline + // +build !offline + + package apply_test +@@ -7,6 +8,7 @@ import ( + "fmt" + "os" + "path/filepath" ++ "strings" + "testing" + + "github.com/chanzuckerberg/fogg/apply" +@@ -21,6 +23,16 @@ import ( + + var updateGoldenFiles = flag.Bool("update", false, "when set, rewrite the golden files") + ++func warningsMentionDockerDeprecation(warnings []string) bool { ++ for _, warning := range warnings { ++ lower := strings.ToLower(warning) ++ if strings.Contains(lower, "docker") && strings.Contains(lower, "deprecat") { ++ return true ++ } ++ } ++ return false ++} ++ + func TestIntegration(t *testing.T) { + + var testCases = []struct { +@@ -54,8 +66,9 @@ func TestIntegration(t *testing.T) { + a.NoError(e) + fmt.Printf("conf %#v\n", conf) + +- e = conf.Validate() ++ w, e := conf.Validate() + a.NoError(e) ++ a.False(warningsMentionDockerDeprecation(w), "did not expect Docker deprecation warning in %#v", w) + + e = apply.Apply(testdataFs, conf, templates.Templates, true) + a.NoError(e) +@@ -75,8 +88,9 @@ func TestIntegration(t *testing.T) { + a.NoError(e) + fmt.Printf("conf %#v\n", conf) + +- e = conf.Validate() ++ w, e := conf.Validate() + a.NoError(e) ++ a.False(warningsMentionDockerDeprecation(w), "did not expect Docker deprecation warning in %#v", w) + + e = apply.Apply(fs, conf, templates.Templates, true) + a.NoError(e) +diff --git a/cmd/docker_warning_cli_test.go b/cmd/docker_warning_cli_test.go +new file mode 100644 +index 00000000..f2a25f92 +--- /dev/null ++++ b/cmd/docker_warning_cli_test.go +@@ -0,0 +1,160 @@ ++package cmd ++ ++import ( ++ "bytes" ++ "encoding/json" ++ "io" ++ "os" ++ "os/exec" ++ "path/filepath" ++ "sync" ++ "testing" ++ ++ "github.com/chanzuckerberg/fogg/util" ++ "github.com/sirupsen/logrus" ++ "github.com/stretchr/testify/require" ++) ++ ++ ++const dockerWarningText = "Docker support is deprecated and will be removed in a future version of fogg." ++ ++func minimalConfigWithDocker(t *testing.T, docker bool) []byte { ++ t.Helper() ++ ++ b, err := util.TestFile("v2_minimal_valid") ++ require.NoError(t, err) ++ ++ var conf map[string]interface{} ++ require.NoError(t, json.Unmarshal(b, &conf)) ++ conf["docker"] = docker ++ ++ out, err := json.Marshal(conf) ++ require.NoError(t, err) ++ return out ++} ++ ++func runFoggCommandWithConfig(t *testing.T, command string, config []byte) (string, error) { ++ t.Helper() ++ ++ dir := t.TempDir() ++ require.NoError(t, exec.Command("git", "init", dir).Run()) ++ ++ configPath := filepath.Join(dir, "fogg.yml") ++ require.NoError(t, os.WriteFile(configPath, config, 0600)) ++ ++ oldWd, err := os.Getwd() ++ require.NoError(t, err) ++ require.NoError(t, os.Chdir(dir)) ++ defer func() { ++ require.NoError(t, os.Chdir(oldWd)) ++ }() ++ ++ var logOutput bytes.Buffer ++ ++ previousLogOutput := logrus.StandardLogger().Out ++ previousFormatter := logrus.StandardLogger().Formatter ++ defer func() { ++ logrus.SetOutput(previousLogOutput) ++ logrus.SetFormatter(previousFormatter) ++ }() ++ logrus.SetOutput(&logOutput) ++ logrus.SetFormatter(&logrus.TextFormatter{DisableTimestamp: true}) ++ ++ rootCmd.SetArgs([]string{command, "--config", "fogg.yml"}) ++ ++ output, err := captureStdoutStderr(t, rootCmd.Execute) ++ return logOutput.String() + output, err ++} ++ ++func captureStdoutStderr(t *testing.T, run func() error) (string, error) { ++ t.Helper() ++ ++ oldStdout := os.Stdout ++ oldStderr := os.Stderr ++ stdoutR, stdoutW, err := os.Pipe() ++ require.NoError(t, err) ++ stderrR, stderrW, err := os.Pipe() ++ require.NoError(t, err) ++ ++ os.Stdout = stdoutW ++ os.Stderr = stderrW ++ defer func() { ++ os.Stdout = oldStdout ++ os.Stderr = oldStderr ++ }() ++ ++ var stdout bytes.Buffer ++ var stderr bytes.Buffer ++ var wg sync.WaitGroup ++ wg.Add(2) ++ go func() { ++ defer wg.Done() ++ _, _ = io.Copy(&stdout, stdoutR) ++ }() ++ go func() { ++ defer wg.Done() ++ _, _ = io.Copy(&stderr, stderrR) ++ }() ++ ++ runErr := run() ++ require.NoError(t, stdoutW.Close()) ++ require.NoError(t, stderrW.Close()) ++ wg.Wait() ++ require.NoError(t, stdoutR.Close()) ++ require.NoError(t, stderrR.Close()) ++ ++ return stdout.String() + stderr.String(), runErr ++} ++ ++func invalidDockerConfig() []byte { ++ return []byte(`{"version":2,"docker":true}`) ++} ++ ++func requireDockerWarning(t *testing.T, output string) { ++ t.Helper() ++ require.Contains(t, output, dockerWarningText) ++} ++ ++func requireNoDockerWarning(t *testing.T, output string) { ++ t.Helper() ++ require.NotContains(t, output, dockerWarningText) ++} ++ ++func TestPlanWarnsForDockerEnabledConfig(t *testing.T) { ++ output, err := runFoggCommandWithConfig(t, "plan", minimalConfigWithDocker(t, true)) ++ ++ require.NoError(t, err) ++ requireDockerWarning(t, output) ++} ++ ++func TestApplyWarnsForDockerEnabledConfig(t *testing.T) { ++ output, err := runFoggCommandWithConfig(t, "apply", minimalConfigWithDocker(t, true)) ++ ++ require.NoError(t, err) ++ requireDockerWarning(t, output) ++} ++ ++func TestPlanAndApplyDoNotWarnWhenDockerDisabled(t *testing.T) { ++ for _, command := range []string{"plan", "apply"} { ++ t.Run(command, func(t *testing.T) { ++ output, err := runFoggCommandWithConfig(t, command, minimalConfigWithDocker(t, false)) ++ ++ require.NoError(t, err) ++ requireNoDockerWarning(t, output) ++ }) ++ } ++} ++ ++func TestPlanWarnsBeforeFailingInvalidDockerConfig(t *testing.T) { ++ output, err := runFoggCommandWithConfig(t, "plan", invalidDockerConfig()) ++ ++ require.Error(t, err) ++ requireDockerWarning(t, output) ++} ++ ++func TestApplyWarnsBeforeFailingInvalidDockerConfig(t *testing.T) { ++ output, err := runFoggCommandWithConfig(t, "apply", invalidDockerConfig()) ++ ++ require.Error(t, err) ++ requireDockerWarning(t, output) ++} +diff --git a/config/v2/config_test.go b/config/v2/config_test.go +index d2b7e6e2..e6b01626 100644 +--- a/config/v2/config_test.go ++++ b/config/v2/config_test.go +@@ -16,8 +16,9 @@ func TestReadConfig(t *testing.T) { + c, e := ReadConfig(b) + a.NoError(e) + +- e = c.Validate() ++ w, e := c.Validate() + a.Error(e) ++ a.False(containsDockerDeprecationLikeWarning(w), "did not expect Docker deprecation warning in %#v", w) + + b2, e := util.TestFile("v2_minimal_valid") + a.NoError(e) +@@ -25,8 +26,9 @@ func TestReadConfig(t *testing.T) { + c, e = ReadConfig(b2) + a.NoError(e) + +- e = c.Validate() ++ w, e = c.Validate() + a.NoError(e) ++ a.False(containsDockerDeprecationLikeWarning(w), "did not expect Docker deprecation warning in %#v", w) + + } + +@@ -41,8 +43,9 @@ func TestReadSnowflakeProvider(t *testing.T) { + r.NoError(e) + r.NotNil(c) + +- e = c.Validate() ++ w, e := c.Validate() + r.NoError(e) ++ r.False(containsDockerDeprecationLikeWarning(w), "did not expect Docker deprecation warning in %#v", w) + + r.NotNil(c.Defaults.Providers) + r.NotNil(c.Defaults.Providers.Snowflake) +diff --git a/config/v2/validation_warning_test.go b/config/v2/validation_warning_test.go +new file mode 100644 +index 00000000..fd2148a8 +--- /dev/null ++++ b/config/v2/validation_warning_test.go +@@ -0,0 +1,68 @@ ++package v2 ++ ++import ( ++ "strings" ++ "testing" ++ ++ "github.com/chanzuckerberg/fogg/util" ++ "github.com/stretchr/testify/require" ++) ++ ++ ++const dockerDeprecationWarning = "Docker support is deprecated and will be removed in a future version of fogg." ++ ++func containsDockerDeprecationWarning(warnings []string) bool { ++ for _, warning := range warnings { ++ if strings.Contains(warning, dockerDeprecationWarning) { ++ return true ++ } ++ } ++ return false ++} ++ ++func containsDockerDeprecationLikeWarning(warnings []string) bool { ++ for _, warning := range warnings { ++ lower := strings.ToLower(warning) ++ if strings.Contains(lower, "docker") && strings.Contains(lower, "deprecat") { ++ return true ++ } ++ } ++ return false ++} ++ ++func readMinimalValidConfig(t *testing.T) *Config { ++ t.Helper() ++ ++ b, err := util.TestFile("v2_minimal_valid") ++ require.NoError(t, err) ++ ++ conf, err := ReadConfig(b) ++ require.NoError(t, err) ++ return conf ++} ++ ++func TestValidateReturnsDockerDeprecationWarning(t *testing.T) { ++ conf := readMinimalValidConfig(t) ++ conf.Docker = true ++ ++ warnings, err := conf.Validate() ++ require.NoError(t, err) ++ require.True(t, containsDockerDeprecationWarning(warnings), "expected Docker deprecation warning in %#v", warnings) ++} ++ ++func TestValidateReturnsWarningsAlongsideFatalErrors(t *testing.T) { ++ conf := &Config{Docker: true} ++ ++ warnings, err := conf.Validate() ++ require.Error(t, err) ++ require.True(t, containsDockerDeprecationWarning(warnings), "expected Docker deprecation warning in %#v", warnings) ++} ++ ++func TestValidateDoesNotReturnDockerWarningWhenDockerDisabled(t *testing.T) { ++ conf := readMinimalValidConfig(t) ++ conf.Docker = false ++ ++ warnings, err := conf.Validate() ++ require.NoError(t, err) ++ require.False(t, containsDockerDeprecationWarning(warnings), "did not expect Docker deprecation warning in %#v", warnings) ++} +diff --git a/plan/plan_quick_test.go b/plan/plan_quick_test.go +index ad5d65f3..4437c450 100644 +--- a/plan/plan_quick_test.go ++++ b/plan/plan_quick_test.go +@@ -16,7 +16,7 @@ func TestValidConfigNoPanic(t *testing.T) { + assertion := func(conf *v2.Config) bool { + // fmt.Printf("GOT %#v\n\n", pretty.Sprint(conf)) + // validate our configuration +- err := conf.Validate() ++ _, err := conf.Validate() + + // if config is valid, there should be no panic + if err == nil { +diff --git a/plan/plan_test.go b/plan/plan_test.go +index 0616dbf8..269db677 100644 +--- a/plan/plan_test.go ++++ b/plan/plan_test.go +@@ -1,6 +1,7 @@ + package plan + + import ( ++ "strings" + "testing" + + "github.com/chanzuckerberg/fogg/config" +@@ -19,6 +20,16 @@ func init() { + logrus.SetFormatter(formatter) + } + ++func warningsMentionDockerDeprecation(warnings []string) bool { ++ for _, warning := range warnings { ++ lower := strings.ToLower(warning) ++ if strings.Contains(lower, "docker") && strings.Contains(lower, "deprecat") { ++ return true ++ } ++ } ++ return false ++} ++ + // func TestResolveRequired(t *testing.T) { + // resolved := resolveRequired("def", nil) + // assert.Equal(t, "def", resolved) +@@ -108,8 +119,9 @@ func TestPlanBasicV2(t *testing.T) { + c2, err := v2.ReadConfig(b) + assert.Nil(t, err) + +- err = c2.Validate() ++ w, err := c2.Validate() + a.NoError(err) ++ a.False(warningsMentionDockerDeprecation(w), "did not expect Docker deprecation warning in %#v", w) + + plan, e := Eval(c2) + assert.Nil(t, e) +diff --git a/plan/travisci_test.go b/plan/travisci_test.go +index a57ff5fa..2070173e 100644 +--- a/plan/travisci_test.go ++++ b/plan/travisci_test.go +@@ -70,8 +70,9 @@ func Test_buildTravisCI_Profiles(t *testing.T) { + }}, + } + +- err := c.Validate() ++ w, err := c.Validate() + a.NoError(err) ++ a.False(warningsMentionDockerDeprecation(w), "did not expect Docker deprecation warning in %#v", w) + + p := &Plan{} + p.Accounts = p.buildAccounts(c) +@@ -121,8 +122,9 @@ func Test_buildTravisCI_TestBuckets(t *testing.T) { + }}, + } + +- err := c.Validate() ++ w, err := c.Validate() + a.NoError(err) ++ a.False(warningsMentionDockerDeprecation(w), "did not expect Docker deprecation warning in %#v", w) + + p := &Plan{} + p.Accounts = p.buildAccounts(c) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,31 @@ ++#!/bin/bash ++set -euo pipefail ++ ++cd /testbed ++ ++ ++mkdir -p /root/go/src/github.com/chanzuckerberg ++ln -sfn /testbed /root/go/src/github.com/chanzuckerberg/fogg ++dev-switch go 1.23 ++cd /root/go/src/github.com/chanzuckerberg/fogg ++ ++ ++export GO111MODULE=off ++ ++case "${1:-}" in ++ base) ++ go test -count=1 ./apply/ ++ go test -count=1 ./config/v2/ -run '^(Test_nonEmptyString|TestValidateOwnersAccount|TestValidateOwnersComponent|TestResolveStringArray|TestConfig_ValidateAWSProviders|TestReadConfig|TestReadSnowflakeProvider)$' ++ go test -count=1 ./plan/ ++ ;; ++ new) ++ go test -count=1 ./config/v2/ -run '^(TestValidateReturnsDockerDeprecationWarning|TestValidateReturnsWarningsAlongsideFatalErrors|TestValidateDoesNotReturnDockerWarningWhenDockerDisabled)$' ++ go test -count=1 ./cmd/ -run '^(TestPlanWarnsForDockerEnabledConfig|TestApplyWarnsForDockerEnabledConfig|TestPlanAndApplyDoNotWarnWhenDockerDisabled|TestPlanWarnsBeforeFailingInvalidDockerConfig|TestApplyWarnsBeforeFailingInvalidDockerConfig)$' ++ go test -count=1 ./apply/ -run '^(TestApplySmokeTest|TestIntegration)$' ++ go test -count=1 ./plan/ -run '^(TestValidConfigNoPanic|TestPlanBasicV2|Test_buildTravisCI_Profiles|Test_buildTravisCI_TestBuckets)$' ++ ;; ++ *) ++ echo "usage: $0 base|new" >&2 ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000658/tests/test.sh b/tasks/format-code-task-000658/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4bdea511fbff315862fc03128cfeacaf50881670 --- /dev/null +++ b/tasks/format-code-task-000658/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' +apply/apply_test.go +apply/golden_file_test.go +cmd/docker_warning_cli_test.go +config/v2/config_test.go +config/v2/validation_warning_test.go +plan/plan_quick_test.go +plan/plan_test.go +plan/travisci_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-000658/tests/test_command.sh b/tasks/format-code-task-000658/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000658/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-000667/environment/Dockerfile b/tasks/format-code-task-000667/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..65b8b90fc7d805c4f87be1c89e945693aec9ca49 --- /dev/null +++ b/tasks/format-code-task-000667/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:0b2bbd30f406bc237ac619b1d4d7fae3348a10b56fabd7d4f34e9873e2b8932f diff --git a/tasks/format-code-task-000667/environment/setup/files/blocklist b/tasks/format-code-task-000667/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000667/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-000667/environment/setup/setup.sh b/tasks/format-code-task-000667/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000667/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-000667/tests/test.patch b/tasks/format-code-task-000667/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..03b07828969f1f213805b1b6b4f34023521943b2 --- /dev/null +++ b/tasks/format-code-task-000667/tests/test.patch @@ -0,0 +1,452 @@ +diff --git a/usercase-test-coderl/market_manager_execute_order_test.cpp b/usercase-test-coderl/market_manager_execute_order_test.cpp +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/market_manager_execute_order_test.cpp +@@ -0,0 +1,408 @@ ++ ++ ++#include "trader/matching/market_manager.h" ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++using namespace CppTrader::Matching; ++ ++namespace { ++ ++struct EventRecorder : MarketHandler ++{ ++ struct ExecuteEvent ++ { ++ uint64_t id; ++ uint64_t event_price; ++ uint64_t event_qty; ++ uint64_t order_price; ++ uint64_t executed_quantity; ++ uint64_t leaves_quantity; ++ }; ++ ++ struct OrderEvent ++ { ++ uint64_t id; ++ uint64_t price; ++ uint64_t quantity; ++ uint64_t executed_quantity; ++ uint64_t leaves_quantity; ++ }; ++ ++ struct LevelEvent ++ { ++ uint64_t price; ++ uint64_t total_volume; ++ uint64_t visible_volume; ++ uint64_t hidden_volume; ++ uint64_t orders; ++ }; ++ ++ std::vector events; ++ std::vector execute_events; ++ std::vector update_events; ++ std::vector delete_events; ++ std::vector update_level_events; ++ std::vector delete_level_events; ++ ++ size_t execute_count = 0; ++ size_t update_count = 0; ++ size_t delete_count = 0; ++ size_t add_level_count = 0; ++ size_t update_level_count = 0; ++ size_t delete_level_count = 0; ++ ++ void record(const std::string& event) { events.push_back(event); } ++ ++ void onAddSymbol(const Symbol& symbol) override ++ { ++ std::ostringstream stream; ++ stream << "add_symbol id=" << symbol.Id; ++ record(stream.str()); ++ } ++ ++ void onAddOrderBook(const OrderBook& order_book) override ++ { ++ std::ostringstream stream; ++ stream << "add_book symbol=" << order_book.symbol().Id; ++ record(stream.str()); ++ } ++ ++ void onDeleteOrderBook(const OrderBook& order_book) override ++ { ++ std::ostringstream stream; ++ stream << "delete_book symbol=" << order_book.symbol().Id; ++ record(stream.str()); ++ } ++ ++ void onAddLevel(const OrderBook&, const Level& level, bool top) override ++ { ++ ++add_level_count; ++ std::ostringstream stream; ++ stream << "add_level price=" << level.Price << " total=" << level.TotalVolume ++ << " visible=" << level.VisibleVolume << " hidden=" << level.HiddenVolume ++ << " orders=" << level.Orders << " top=" << top; ++ record(stream.str()); ++ } ++ ++ void onUpdateLevel(const OrderBook&, const Level& level, bool top) override ++ { ++ ++update_level_count; ++ update_level_events.push_back({ level.Price, level.TotalVolume, level.VisibleVolume, level.HiddenVolume, level.Orders }); ++ std::ostringstream stream; ++ stream << "update_level price=" << level.Price << " total=" << level.TotalVolume ++ << " visible=" << level.VisibleVolume << " hidden=" << level.HiddenVolume ++ << " orders=" << level.Orders << " top=" << top; ++ record(stream.str()); ++ } ++ ++ void onDeleteLevel(const OrderBook&, const Level& level, bool top) override ++ { ++ ++delete_level_count; ++ delete_level_events.push_back({ level.Price, level.TotalVolume, level.VisibleVolume, level.HiddenVolume, level.Orders }); ++ std::ostringstream stream; ++ stream << "delete_level price=" << level.Price << " total=" << level.TotalVolume ++ << " visible=" << level.VisibleVolume << " hidden=" << level.HiddenVolume ++ << " orders=" << level.Orders << " top=" << top; ++ record(stream.str()); ++ } ++ ++ void onAddOrder(const Order& order) override ++ { ++ std::ostringstream stream; ++ stream << "add_order id=" << order.Id << " price=" << order.Price ++ << " qty=" << order.Quantity << " exec=" << order.ExecutedQuantity ++ << " leaves=" << order.LeavesQuantity; ++ record(stream.str()); ++ } ++ ++ void onUpdateOrder(const Order& order) override ++ { ++ ++update_count; ++ update_events.push_back({ order.Id, order.Price, order.Quantity, order.ExecutedQuantity, order.LeavesQuantity }); ++ std::ostringstream stream; ++ stream << "update_order id=" << order.Id << " price=" << order.Price ++ << " qty=" << order.Quantity << " exec=" << order.ExecutedQuantity ++ << " leaves=" << order.LeavesQuantity; ++ record(stream.str()); ++ } ++ ++ void onDeleteOrder(const Order& order) override ++ { ++ ++delete_count; ++ delete_events.push_back({ order.Id, order.Price, order.Quantity, order.ExecutedQuantity, order.LeavesQuantity }); ++ std::ostringstream stream; ++ stream << "delete_order id=" << order.Id << " price=" << order.Price ++ << " qty=" << order.Quantity << " exec=" << order.ExecutedQuantity ++ << " leaves=" << order.LeavesQuantity; ++ record(stream.str()); ++ } ++ ++ void onExecuteOrder(const Order& order, uint64_t price, uint64_t quantity) override ++ { ++ ++execute_count; ++ execute_events.push_back({ order.Id, price, quantity, order.Price, order.ExecutedQuantity, order.LeavesQuantity }); ++ std::ostringstream stream; ++ stream << "execute_order id=" << order.Id << " event_price=" << price ++ << " event_qty=" << quantity << " order_price=" << order.Price ++ << " exec_before=" << order.ExecutedQuantity ++ << " leaves_before=" << order.LeavesQuantity; ++ record(stream.str()); ++ } ++}; ++ ++struct Session ++{ ++ EventRecorder handler; ++ MarketManager market; ++ ++ Session() : handler(), market(handler) {} ++}; ++ ++void fail(const char* file, int line, const std::string& expr) ++{ ++ std::cerr << file << ":" << line << ": assertion failed: " << expr << std::endl; ++ std::exit(1); ++} ++ ++#define CHECK(expr) do { if (!(expr)) fail(__FILE__, __LINE__, #expr); } while (false) ++ ++Symbol sample_symbol() ++{ ++ return Symbol(0, "ABCDEF "); ++} ++ ++void add_symbol_book_and_order(Session& session) ++{ ++ const Symbol symbol = sample_symbol(); ++ CHECK(session.market.AddSymbol(symbol) == ErrorCode::OK); ++ CHECK(session.market.AddOrderBook(symbol) == ErrorCode::OK); ++ CHECK(session.market.AddOrder(Order::BuyLimit(10, 0, 101, 100)) == ErrorCode::OK); ++} ++ ++const LevelNode* bid101(const MarketManager& market) ++{ ++ const OrderBook* book = market.GetOrderBook(0); ++ CHECK(book != nullptr); ++ return book->GetBid(101); ++} ++ ++bool has_execute_event(const EventRecorder& handler, uint64_t id, uint64_t price, uint64_t quantity) ++{ ++ for (const auto& event : handler.execute_events) ++ { ++ if ((event.id == id) && (event.event_price == price) && (event.event_qty == quantity)) ++ return true; ++ } ++ return false; ++} ++ ++bool has_order_event(const std::vector& events, uint64_t id, uint64_t executed, uint64_t leaves) ++{ ++ for (const auto& event : events) ++ { ++ if ((event.id == id) && (event.executed_quantity == executed) && (event.leaves_quantity == leaves)) ++ return true; ++ } ++ return false; ++} ++ ++bool has_level_event(const std::vector& events, uint64_t price, uint64_t total, uint64_t visible, uint64_t hidden, uint64_t orders) ++{ ++ for (const auto& event : events) ++ { ++ if ((event.price == price) && (event.total_volume == total) && (event.visible_volume == visible) && ++ (event.hidden_volume == hidden) && (event.orders == orders)) ++ return true; ++ } ++ return false; ++} ++ ++void test_partial_and_capped_execution_session() ++{ ++ ++ ++ Session session; ++ add_symbol_book_and_order(session); ++ ++ CHECK(session.market.orders().size() == 1); ++ CHECK(session.market.GetOrder(10) != nullptr); ++ CHECK(session.market.GetOrder(10)->Id == 10); ++ CHECK(session.market.GetOrder(10)->Price == 101); ++ CHECK(session.market.GetOrder(10)->Quantity == 100); ++ CHECK(session.market.GetOrder(10)->ExecutedQuantity == 0); ++ CHECK(session.market.GetOrder(10)->LeavesQuantity == 100); ++ CHECK(bid101(session.market) != nullptr); ++ CHECK(bid101(session.market)->TotalVolume == 100); ++ CHECK(bid101(session.market)->VisibleVolume == 100); ++ CHECK(bid101(session.market)->HiddenVolume == 0); ++ CHECK(bid101(session.market)->Orders == 1); ++ ++ CHECK(session.market.ExecuteOrder(10, 25) == ErrorCode::OK); ++ ++ CHECK(session.market.orders().size() == 1); ++ CHECK(session.market.GetOrder(10) != nullptr); ++ CHECK(session.market.GetOrder(10)->ExecutedQuantity == 25); ++ CHECK(session.market.GetOrder(10)->LeavesQuantity == 75); ++ CHECK(bid101(session.market) != nullptr); ++ CHECK(bid101(session.market)->TotalVolume == 75); ++ CHECK(bid101(session.market)->VisibleVolume == 75); ++ CHECK(bid101(session.market)->HiddenVolume == 0); ++ CHECK(bid101(session.market)->Orders == 1); ++ ++ CHECK(session.handler.execute_count == 1); ++ CHECK(session.handler.update_count == 1); ++ CHECK(has_execute_event(session.handler, 10, 101, 25)); ++ CHECK(has_order_event(session.handler.update_events, 10, 25, 75)); ++ ++ CHECK(session.market.ExecuteOrder(10, 99, 80) == ErrorCode::OK); ++ ++ CHECK(session.market.orders().size() == 0); ++ CHECK(session.market.GetOrder(10) == nullptr); ++ CHECK(session.market.GetOrderBook(0) != nullptr); ++ CHECK(session.market.GetOrderBook(0)->size() == 0); ++ CHECK(session.market.GetOrderBook(0)->GetBid(101) == nullptr); ++ CHECK(session.market.GetOrderBook(0)->best_bid() == nullptr); ++ ++ CHECK(has_execute_event(session.handler, 10, 99, 75)); ++ CHECK(has_order_event(session.handler.delete_events, 10, 100, 0)); ++ CHECK(session.handler.execute_count == 2); ++ CHECK(session.handler.update_count == 1); ++ CHECK(session.handler.delete_count == 1); ++} ++ ++void test_rejects_invalid_ids_quantities_and_unknown_orders() ++{ ++ ++ ++ Session session; ++ add_symbol_book_and_order(session); ++ ++ CHECK(session.market.ExecuteOrder(0, 25) == ErrorCode::ORDER_ID_INVALID); ++ CHECK(session.market.ExecuteOrder(0, 99, 25) == ErrorCode::ORDER_ID_INVALID); ++ CHECK(session.market.ExecuteOrder(10, 0) == ErrorCode::ORDER_QUANTITY_INVALID); ++ CHECK(session.market.ExecuteOrder(10, 99, 0) == ErrorCode::ORDER_QUANTITY_INVALID); ++ CHECK(session.market.ExecuteOrder(999, 1) == ErrorCode::ORDER_NOT_FOUND); ++ CHECK(session.market.ExecuteOrder(999, 99, 1) == ErrorCode::ORDER_NOT_FOUND); ++ CHECK(session.market.orders().size() == 1); ++ CHECK(session.market.GetOrder(10)->ExecutedQuantity == 0); ++ CHECK(session.market.GetOrder(10)->LeavesQuantity == 100); ++} ++ ++void test_returns_order_book_not_found_for_stored_order_without_book() ++{ ++ ++ ++ Session session; ++ add_symbol_book_and_order(session); ++ ++ CHECK(session.market.DeleteOrderBook(0) == ErrorCode::OK); ++ CHECK(session.market.GetOrderBook(0) == nullptr); ++ CHECK(session.market.GetOrder(10) != nullptr); ++ CHECK(session.market.GetOrder(10)->ExecutedQuantity == 0); ++ CHECK(session.market.GetOrder(10)->LeavesQuantity == 100); ++ CHECK(session.market.ExecuteOrder(10, 1) == ErrorCode::ORDER_BOOK_NOT_FOUND); ++ CHECK(session.market.ExecuteOrder(10, 99, 1) == ErrorCode::ORDER_BOOK_NOT_FOUND); ++ CHECK(session.market.GetOrder(10) != nullptr); ++ CHECK(session.market.GetOrder(10)->ExecutedQuantity == 0); ++ CHECK(session.market.GetOrder(10)->LeavesQuantity == 100); ++} ++ ++void test_automatic_matching_runs_after_successful_manual_execution() ++{ ++ ++ ++ Session session; ++ const Symbol symbol = sample_symbol(); ++ CHECK(session.market.AddSymbol(symbol) == ErrorCode::OK); ++ CHECK(session.market.AddOrderBook(symbol) == ErrorCode::OK); ++ CHECK(session.market.AddOrder(Order::BuyLimit(10, 0, 101, 100)) == ErrorCode::OK); ++ CHECK(session.market.AddOrder(Order::SellStop(20, 0, 99, 40)) == ErrorCode::OK); ++ CHECK(session.market.IsMatchingEnabled() == false); ++ session.market.EnableMatching(); ++ CHECK(session.market.IsMatchingEnabled() == true); ++ ++ CHECK(session.market.GetOrder(10) != nullptr); ++ CHECK(session.market.GetOrder(10)->ExecutedQuantity == 0); ++ CHECK(session.market.GetOrder(10)->LeavesQuantity == 100); ++ CHECK(session.market.GetOrder(20) != nullptr); ++ CHECK(session.market.GetOrder(20)->ExecutedQuantity == 0); ++ CHECK(session.market.GetOrder(20)->LeavesQuantity == 40); ++ ++ CHECK(session.market.ExecuteOrder(10, 99, 100) == ErrorCode::OK); ++ ++ CHECK(session.market.orders().size() == 0); ++ CHECK(session.market.GetOrder(10) == nullptr); ++ CHECK(session.market.GetOrder(20) == nullptr); ++ CHECK(session.market.GetOrderBook(0)->size() == 0); ++ ++ CHECK(has_execute_event(session.handler, 10, 99, 100)); ++ CHECK(has_order_event(session.handler.delete_events, 10, 100, 0)); ++ CHECK(session.handler.execute_count == 1); ++ CHECK(session.handler.delete_count >= 1); ++} ++ ++void test_two_market_managers_keep_independent_order_state() ++{ ++ ++ ++ Session a; ++ Session b; ++ add_symbol_book_and_order(a); ++ add_symbol_book_and_order(b); ++ ++ CHECK(a.market.ExecuteOrder(10, 25) == ErrorCode::OK); ++ CHECK(b.market.ExecuteOrder(10, 25) == ErrorCode::OK); ++ ++ CHECK(a.market.orders().size() == 1); ++ CHECK(a.market.GetOrder(10)->ExecutedQuantity == 25); ++ CHECK(a.market.GetOrder(10)->LeavesQuantity == 75); ++ CHECK(bid101(a.market)->TotalVolume == 75); ++ CHECK(b.market.orders().size() == 1); ++ CHECK(b.market.GetOrder(10)->ExecutedQuantity == 25); ++ CHECK(b.market.GetOrder(10)->LeavesQuantity == 75); ++ CHECK(bid101(b.market)->TotalVolume == 75); ++} ++ ++void test_manual_execution_contract_repeats_in_fresh_sessions() ++{ ++ ++ for (int i = 0; i < 3; ++i) ++ { ++ Session session; ++ add_symbol_book_and_order(session); ++ ++ CHECK(session.market.ExecuteOrder(10, 25) == ErrorCode::OK); ++ CHECK(session.market.GetOrder(10) != nullptr); ++ CHECK(session.market.GetOrder(10)->ExecutedQuantity == 25); ++ CHECK(session.market.GetOrder(10)->LeavesQuantity == 75); ++ CHECK(bid101(session.market)->TotalVolume == 75); ++ CHECK(has_execute_event(session.handler, 10, 101, 25)); ++ CHECK(has_order_event(session.handler.update_events, 10, 25, 75)); ++ ++ CHECK(session.market.ExecuteOrder(10, 99, 80) == ErrorCode::OK); ++ CHECK(session.market.GetOrder(10) == nullptr); ++ CHECK(session.market.GetOrderBook(0)->GetBid(101) == nullptr); ++ CHECK(has_execute_event(session.handler, 10, 99, 75)); ++ CHECK(has_order_event(session.handler.delete_events, 10, 100, 0)); ++ } ++} ++ ++} ++ ++int main() ++{ ++ test_partial_and_capped_execution_session(); ++ test_rejects_invalid_ids_quantities_and_unknown_orders(); ++ test_returns_order_book_not_found_for_stored_order_without_book(); ++ test_automatic_matching_runs_after_successful_manual_execution(); ++ test_two_market_managers_keep_independent_order_state(); ++ test_manual_execution_contract_repeats_in_fresh_sessions(); ++ std::cout << "market_manager_execute_order acceptance tests passed" << std::endl; ++ return 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,34 @@ ++#!/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 ++ ++CXX="${CXX:-g++}" ++OUT="/tmp/market_manager_execute_order_test" ++ ++ ++mapfile -t MATCHING_SOURCES < <(find /workspace/repo/source/trader/matching -maxdepth 1 -type f -name '*.cpp' | sort) ++ ++"${CXX}" -std=c++17 -O0 -g -DNDEBUG \ ++ -I/workspace/repo/include \ ++ -I/workspace/repo/modules/CppCommon/include \ ++ -I/workspace/repo/modules/CppCommon/modules/fmt/include \ ++ /workspace/repo/usercase-test-coderl/market_manager_execute_order_test.cpp \ ++ "${MATCHING_SOURCES[@]}" \ ++ /workspace/repo/modules/CppCommon/source/memory/memory.cpp \ ++ /workspace/repo/modules/CppCommon/source/errors/exceptions.cpp \ ++ /workspace/repo/modules/CppCommon/source/errors/system_error.cpp \ ++ /workspace/repo/modules/CppCommon/modules/fmt/src/format.cc \ ++ -o "${OUT}" ++ ++exec "${OUT}" diff --git a/tasks/format-code-task-000667/tests/test.sh b/tasks/format-code-task-000667/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b46fd512db87171539a8917a17fb354138b6b4af --- /dev/null +++ b/tasks/format-code-task-000667/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/market_manager_execute_order_test.cpp +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000667/tests/test_command.sh b/tasks/format-code-task-000667/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000667/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-000669/environment/Dockerfile b/tasks/format-code-task-000669/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8790e886379334222d543d9a1ad498789fd554a9 --- /dev/null +++ b/tasks/format-code-task-000669/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:f12878572466ca1291e88678d3872a9511ff35846840b401a503afa5fcc6cb2a diff --git a/tasks/format-code-task-000669/environment/setup/files/blocklist b/tasks/format-code-task-000669/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000669/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-000669/environment/setup/setup.sh b/tasks/format-code-task-000669/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000669/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-000669/tests/test.patch b/tasks/format-code-task-000669/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..01b1d9726d022a42d065cb6fb5da13ea5ab2f62a --- /dev/null +++ b/tasks/format-code-task-000669/tests/test.patch @@ -0,0 +1,207 @@ +diff --git a/pkg/ipmasq/ipmasq_ipv6_test.go b/pkg/ipmasq/ipmasq_ipv6_test.go +new file mode 100644 +index 0000000000..ce720ec435 +--- /dev/null ++++ b/pkg/ipmasq/ipmasq_ipv6_test.go +@@ -0,0 +1,170 @@ ++ ++ ++ ++package ipmasq ++ ++import ( ++ "net" ++ "os" ++ "path/filepath" ++ "sort" ++ "testing" ++) ++ ++ ++ ++type ipMasqMapMockIPv6 struct { ++ cidrs map[string]net.IPNet ++} ++ ++func newIPMasqMapMockIPv6() *ipMasqMapMockIPv6 { ++ return &ipMasqMapMockIPv6{cidrs: map[string]net.IPNet{}} ++} ++ ++func (m *ipMasqMapMockIPv6) Update(cidr net.IPNet) error { ++ m.cidrs[cidr.String()] = cidr ++ return nil ++} ++ ++func (m *ipMasqMapMockIPv6) Delete(cidr net.IPNet) error { ++ delete(m.cidrs, cidr.String()) ++ return nil ++} ++ ++func (m *ipMasqMapMockIPv6) Dump() ([]net.IPNet, error) { ++ cidrs := make([]net.IPNet, 0, len(m.cidrs)) ++ for _, cidr := range m.cidrs { ++ cidrs = append(cidrs, cidr) ++ } ++ return cidrs, nil ++} ++ ++func (m *ipMasqMapMockIPv6) keys() []string { ++ keys := make([]string, 0, len(m.cidrs)) ++ for k := range m.cidrs { ++ keys = append(keys, k) ++ } ++ sort.Strings(keys) ++ return keys ++} ++ ++func (m *ipMasqMapMockIPv6) has(cidr string) bool { ++ _, ok := m.cidrs[cidr] ++ return ok ++} ++ ++ ++ ++func runWithConfig(t *testing.T, cfg string) *ipMasqMapMockIPv6 { ++ t.Helper() ++ ++ dir := t.TempDir() ++ path := filepath.Join(dir, "ip-masq-agent") ++ if err := os.WriteFile(path, []byte(cfg), 0644); err != nil { ++ t.Fatalf("failed to write config: %v", err) ++ } ++ ++ m := newIPMasqMapMockIPv6() ++ agent, err := newIPMasqAgent(path, m) ++ if err != nil { ++ t.Fatalf("failed to create agent: %v", err) ++ } ++ if err := agent.Update(); err != nil { ++ t.Fatalf("agent Update returned error: %v", err) ++ } ++ return m ++} ++ ++const ipv6LinkLocal = "fe80::/10" ++const ipv4LinkLocal = "169.254.0.0/16" ++ ++ ++ ++func TestIPv6CIDRsAccepted(t *testing.T) { ++ m := runWithConfig(t, "nonMasqueradeCIDRs:\n- fd00::/64\n- 2001:db8::1/32\nmasqLinkLocal: true\n") ++ ++ if !m.has("fd00::/64") { ++ t.Errorf("expected fd00::/64 to be provisioned, got %v", m.keys()) ++ } ++ ++ if !m.has("2001:db8::/32") { ++ t.Errorf("expected 2001:db8::/32 (normalized) to be provisioned, got %v", m.keys()) ++ } ++ if m.has("fe80::/10") { ++ t.Errorf("did not expect IPv6 link-local to be added, got %v", m.keys()) ++ } ++} ++ ++ ++func TestMixedCIDRs(t *testing.T) { ++ m := runWithConfig(t, "nonMasqueradeCIDRs:\n- 10.0.0.0/8\n- fd00::/64\nmasqLinkLocal: true\n") ++ ++ want := []string{"10.0.0.0/8", "fd00::/64"} ++ for _, w := range want { ++ if !m.has(w) { ++ t.Errorf("expected %s to be provisioned, got %v", w, m.keys()) ++ } ++ } ++ if len(m.cidrs) != len(want) { ++ t.Errorf("expected exactly %v, got %v", want, m.keys()) ++ } ++} ++ ++ ++func TestIPv6LinkLocalAddedWhenFalse(t *testing.T) { ++ m := runWithConfig(t, "nonMasqueradeCIDRs:\n- fd00::/64\nmasqLinkLocal: true\nmasqLinkLocalIPv6: false\n") ++ ++ if !m.has(ipv6LinkLocal) { ++ t.Errorf("expected %s to be appended when masqLinkLocalIPv6 is false, got %v", ipv6LinkLocal, m.keys()) ++ } ++ if !m.has("fd00::/64") { ++ t.Errorf("expected fd00::/64 to be provisioned, got %v", m.keys()) ++ } ++ if m.has(ipv4LinkLocal) { ++ t.Errorf("did not expect IPv4 link-local since masqLinkLocal is true, got %v", m.keys()) ++ } ++ if len(m.cidrs) != 2 { ++ t.Errorf("expected exactly [fd00::/64 fe80::/10], got %v", m.keys()) ++ } ++} ++ ++ ++func TestIPv6LinkLocalNotAddedWhenTrue(t *testing.T) { ++ m := runWithConfig(t, "nonMasqueradeCIDRs:\n- fd00::/64\nmasqLinkLocal: true\nmasqLinkLocalIPv6: true\n") ++ ++ if m.has(ipv6LinkLocal) { ++ t.Errorf("did not expect %s when masqLinkLocalIPv6 is true, got %v", ipv6LinkLocal, m.keys()) ++ } ++ if len(m.cidrs) != 1 || !m.has("fd00::/64") { ++ t.Errorf("expected exactly [fd00::/64], got %v", m.keys()) ++ } ++} ++ ++ ++ ++func TestIPv6LinkLocalNotAddedWhenAbsent(t *testing.T) { ++ m := runWithConfig(t, "nonMasqueradeCIDRs:\n- fd00::/64\nmasqLinkLocal: true\n") ++ ++ if m.has(ipv6LinkLocal) { ++ t.Errorf("did not expect %s when masqLinkLocalIPv6 is absent, got %v", ipv6LinkLocal, m.keys()) ++ } ++ if len(m.cidrs) != 1 || !m.has("fd00::/64") { ++ t.Errorf("expected exactly [fd00::/64], got %v", m.keys()) ++ } ++} ++ ++ ++ ++ ++func TestLinkLocalsIndependent(t *testing.T) { ++ m := runWithConfig(t, "nonMasqueradeCIDRs:\n- 10.0.0.0/8\n- fd00::/64\nmasqLinkLocalIPv6: false\n") ++ ++ for _, w := range []string{"10.0.0.0/8", "fd00::/64", ipv4LinkLocal, ipv6LinkLocal} { ++ if !m.has(w) { ++ t.Errorf("expected %s to be provisioned, got %v", w, m.keys()) ++ } ++ } ++ if len(m.cidrs) != 4 { ++ t.Errorf("expected exactly 4 CIDRs, got %v", m.keys()) ++ } ++} +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,26 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++GO=/opt/go-1.23/bin/go ++export GOTOOLCHAIN=local ++export GOCACHE=/tmp/gocache-ipmasq ++unset GOROOT ++ ++ ++env -u GOROOT GOTOOLCHAIN=local GOCACHE="$GOCACHE" "$GO" test ./pkg/ipmasq/ -run 'Test$' ++ ++ ++env -u GOROOT GOTOOLCHAIN=local GOCACHE="$GOCACHE" "$GO" test ./pkg/ipmasq/ -run 'TestIPv6CIDRsAccepted|TestMixedCIDRs|TestIPv6LinkLocal|TestLinkLocalsIndependent' diff --git a/tasks/format-code-task-000669/tests/test.sh b/tasks/format-code-task-000669/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..185393e587283170baea8b36d4164ad06fecf6e8 --- /dev/null +++ b/tasks/format-code-task-000669/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/ipmasq/ipmasq_ipv6_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-000669/tests/test_command.sh b/tasks/format-code-task-000669/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000669/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-000693/environment/Dockerfile b/tasks/format-code-task-000693/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..16c3f671f6bd07de712f038096f66f3292c243f9 --- /dev/null +++ b/tasks/format-code-task-000693/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:0e83dc0e800451fd62ba1974bcb39281db991aaedc4e27a8b533b79a284327f7 diff --git a/tasks/format-code-task-000693/environment/setup/files/blocklist b/tasks/format-code-task-000693/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000693/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-000693/environment/setup/setup.sh b/tasks/format-code-task-000693/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000693/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-000693/tests/test.patch b/tasks/format-code-task-000693/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a634aff415e8853e0711db1a647a2ffb326625dd --- /dev/null +++ b/tasks/format-code-task-000693/tests/test.patch @@ -0,0 +1,336 @@ +diff --git a/test/convo/convos/partialinclude/circular/a.pconvo.txt b/test/convo/convos/partialinclude/circular/a.pconvo.txt +new file mode 100644 +index 0000000..1ca2f15 +--- /dev/null ++++ b/test/convo/convos/partialinclude/circular/a.pconvo.txt +@@ -0,0 +1,6 @@ ++a ++ ++#bot ++amsg ++ ++INCLUDE b +diff --git a/test/convo/convos/partialinclude/circular/b.pconvo.txt b/test/convo/convos/partialinclude/circular/b.pconvo.txt +new file mode 100644 +index 0000000..7068f6a +--- /dev/null ++++ b/test/convo/convos/partialinclude/circular/b.pconvo.txt +@@ -0,0 +1,6 @@ ++b ++ ++#bot ++bmsg ++ ++INCLUDE a +diff --git a/test/convo/convos/partialinclude/circular/main.convo.txt b/test/convo/convos/partialinclude/circular/main.convo.txt +new file mode 100644 +index 0000000..3b01039 +--- /dev/null ++++ b/test/convo/convos/partialinclude/circular/main.convo.txt +@@ -0,0 +1,12 @@ ++main ++ ++#me ++hi ++ ++#bot ++hi ++ ++#me ++trigger ++ ++INCLUDE a +diff --git a/test/convo/convos/partialinclude/duplicate/first.pconvo.txt b/test/convo/convos/partialinclude/duplicate/first.pconvo.txt +new file mode 100644 +index 0000000..da829d7 +--- /dev/null ++++ b/test/convo/convos/partialinclude/duplicate/first.pconvo.txt +@@ -0,0 +1,4 @@ ++dup ++ ++#bot ++x +diff --git a/test/convo/convos/partialinclude/duplicate/second.pconvo.txt b/test/convo/convos/partialinclude/duplicate/second.pconvo.txt +new file mode 100644 +index 0000000..60bb4c8 +--- /dev/null ++++ b/test/convo/convos/partialinclude/duplicate/second.pconvo.txt +@@ -0,0 +1,4 @@ ++dup ++ ++#bot ++y +diff --git a/test/convo/convos/partialinclude/illegalname/bad.pconvo.txt b/test/convo/convos/partialinclude/illegalname/bad.pconvo.txt +new file mode 100644 +index 0000000..646915b +--- /dev/null ++++ b/test/convo/convos/partialinclude/illegalname/bad.pconvo.txt +@@ -0,0 +1,4 @@ ++bad|name ++ ++#bot ++x +diff --git a/test/convo/convos/partialinclude/nested/deep.pconvo.txt b/test/convo/convos/partialinclude/nested/deep.pconvo.txt +new file mode 100644 +index 0000000..11462e4 +--- /dev/null ++++ b/test/convo/convos/partialinclude/nested/deep.pconvo.txt +@@ -0,0 +1,7 @@ ++deep ++ ++#me ++fromdeep ++ ++#bot ++fromdeep +diff --git a/test/convo/convos/partialinclude/nested/main.convo.txt b/test/convo/convos/partialinclude/nested/main.convo.txt +new file mode 100644 +index 0000000..7d21cc4 +--- /dev/null ++++ b/test/convo/convos/partialinclude/nested/main.convo.txt +@@ -0,0 +1,9 @@ ++main ++ ++#me ++start ++ ++#bot ++start ++ ++INCLUDE mid +diff --git a/test/convo/convos/partialinclude/nested/mid.pconvo.txt b/test/convo/convos/partialinclude/nested/mid.pconvo.txt +new file mode 100644 +index 0000000..eebd7fb +--- /dev/null ++++ b/test/convo/convos/partialinclude/nested/mid.pconvo.txt +@@ -0,0 +1,9 @@ ++mid ++ ++#me ++frommid ++ ++#bot ++frommid ++ ++INCLUDE deep +diff --git a/test/convo/convos/partialinclude/notfound/main.convo.txt b/test/convo/convos/partialinclude/notfound/main.convo.txt +new file mode 100644 +index 0000000..911bb1f +--- /dev/null ++++ b/test/convo/convos/partialinclude/notfound/main.convo.txt +@@ -0,0 +1,12 @@ ++mainnotfound ++ ++#me ++hi ++ ++#bot ++hi ++ ++#me ++trigger ++ ++INCLUDE doesnotexist +diff --git a/test/convo/convos/partialinclude/single/main.convo.txt b/test/convo/convos/partialinclude/single/main.convo.txt +new file mode 100644 +index 0000000..7e124ff +--- /dev/null ++++ b/test/convo/convos/partialinclude/single/main.convo.txt +@@ -0,0 +1,9 @@ ++main ++ ++#me ++start ++ ++#bot ++start ++ ++INCLUDE sub +diff --git a/test/convo/convos/partialinclude/single/sub.pconvo.txt b/test/convo/convos/partialinclude/single/sub.pconvo.txt +new file mode 100644 +index 0000000..f7fd373 +--- /dev/null ++++ b/test/convo/convos/partialinclude/single/sub.pconvo.txt +@@ -0,0 +1,7 @@ ++sub ++ ++#me ++fromsub ++ ++#bot ++fromsub +diff --git a/test/convo/convos/partialinclude/wrongarg/main.convo.txt b/test/convo/convos/partialinclude/wrongarg/main.convo.txt +new file mode 100644 +index 0000000..6229030 +--- /dev/null ++++ b/test/convo/convos/partialinclude/wrongarg/main.convo.txt +@@ -0,0 +1,12 @@ ++mainwrongarg ++ ++#me ++hi ++ ++#bot ++hi ++ ++#me ++trigger ++ ++INCLUDE a|b +diff --git a/test/convo/partialinclude.spec.js b/test/convo/partialinclude.spec.js +new file mode 100644 +index 0000000..ad5c46d +--- /dev/null ++++ b/test/convo/partialinclude.spec.js +@@ -0,0 +1,122 @@ ++const path = require('path') ++const assert = require('chai').assert ++const BotDriver = require('../../').BotDriver ++const Capabilities = require('../../').Capabilities ++ ++const echoConnector = ({ queueBotSays }) => { ++ return { ++ UserSays (msg) { ++ const botMsg = { sender: 'bot', sourceData: msg.sourceData, messageText: msg.messageText } ++ queueBotSays(botMsg) ++ } ++ } ++} ++ ++const CONVODIR = path.resolve(__dirname, 'convos', 'partialinclude') ++ ++describe('convo.partialinclude', function () { ++ beforeEach(async function () { ++ const myCaps = { ++ [Capabilities.PROJECTNAME]: 'convo.partialinclude', ++ [Capabilities.CONTAINERMODE]: echoConnector ++ } ++ this.driver = new BotDriver(myCaps) ++ this.compiler = this.driver.BuildCompiler() ++ this.container = await this.driver.Build() ++ await this.container.Start() ++ }) ++ afterEach(async function () { ++ this.container && await this.container.Stop() ++ this.container && await this.container.Clean() ++ }) ++ ++ it('should expand an included partial convo inline', async function () { ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'single'), 'sub.pconvo.txt') ++ assert.equal(this.compiler.convos.length, 0) ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'single'), 'main.convo.txt') ++ assert.equal(this.compiler.convos.length, 1) ++ ++ const transcript = await this.compiler.convos[0].Run(this.container) ++ assert.equal(transcript.steps.length, 4) ++ const messages = transcript.steps.map(s => s.actual.messageText) ++ assert.include(messages, 'start') ++ assert.include(messages, 'fromsub') ++ }) ++ ++ it('should expand nested partial convos', async function () { ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'nested'), 'deep.pconvo.txt') ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'nested'), 'mid.pconvo.txt') ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'nested'), 'main.convo.txt') ++ assert.equal(this.compiler.convos.length, 1) ++ ++ const transcript = await this.compiler.convos[0].Run(this.container) ++ assert.equal(transcript.steps.length, 6) ++ const messages = transcript.steps.map(s => s.actual.messageText) ++ assert.include(messages, 'start') ++ assert.include(messages, 'frommid') ++ assert.include(messages, 'fromdeep') ++ }) ++ ++ it('should fail running a convo with a circular include', async function () { ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'circular'), 'a.pconvo.txt') ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'circular'), 'b.pconvo.txt') ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'circular'), 'main.convo.txt') ++ assert.equal(this.compiler.convos.length, 1) ++ ++ let failed = false ++ try { ++ await this.compiler.convos[0].Run(this.container) ++ } catch (err) { ++ failed = true ++ } ++ assert.isTrue(failed, 'expected the convo run to fail with a circular include') ++ }) ++ ++ it('should fail running a convo that includes a missing partial convo', async function () { ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'notfound'), 'main.convo.txt') ++ assert.equal(this.compiler.convos.length, 1) ++ ++ let failed = false ++ try { ++ await this.compiler.convos[0].Run(this.container) ++ } catch (err) { ++ failed = true ++ } ++ assert.isTrue(failed, 'expected the convo run to fail with a missing partial convo') ++ }) ++ ++ it('should fail running a convo with an include that has not exactly one argument', async function () { ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'wrongarg'), 'main.convo.txt') ++ assert.equal(this.compiler.convos.length, 1) ++ ++ let failed = false ++ try { ++ await this.compiler.convos[0].Run(this.container) ++ } catch (err) { ++ failed = true ++ } ++ assert.isTrue(failed, 'expected the convo run to fail with a wrong include argument') ++ }) ++ ++ it('should reject duplicate partial convo names', function () { ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'duplicate'), 'first.pconvo.txt') ++ ++ let failed = false ++ try { ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'duplicate'), 'second.pconvo.txt') ++ } catch (err) { ++ failed = true ++ } ++ assert.isTrue(failed, 'expected loading a duplicate partial convo name to fail') ++ }) ++ ++ it('should reject a partial convo with an invalid name', function () { ++ let failed = false ++ try { ++ this.compiler.ReadScript(path.resolve(CONVODIR, 'illegalname'), 'bad.pconvo.txt') ++ } catch (err) { ++ failed = true ++ } ++ assert.isTrue(failed, 'expected loading a partial convo with an invalid name to fail') ++ }) ++}) +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 ++ ++ ++ ++ ++./node_modules/.bin/mocha \ ++ test/scripting/scriptingProvider.spec.js \ ++ test/scripting/txt/decompile.spec.js \ ++ test/convo/scriptingmemory.spec.js \ ++ test/convo/transcript.spec.js \ ++ test/compiler/compilerxlsx.spec.js \ ++ test/scripting/userinputs/buttonInputConvos.spec.js \ ++ test/scripting/userinputs/defaultUserInputs.spec.js \ ++ test/scripting/userinputs/mediaInputConvos.spec.js \ ++ test/scripting/asserters/mediaAsserter.spec.js ++ ++ ++./node_modules/.bin/mocha test/convo/partialinclude.spec.js diff --git a/tasks/format-code-task-000693/tests/test.sh b/tasks/format-code-task-000693/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d64d77127aa50aaeb5b93999ba58c5d0e929a4e5 --- /dev/null +++ b/tasks/format-code-task-000693/tests/test.sh @@ -0,0 +1,51 @@ +#!/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/convo/convos/partialinclude/circular/a.pconvo.txt +test/convo/convos/partialinclude/circular/b.pconvo.txt +test/convo/convos/partialinclude/circular/main.convo.txt +test/convo/convos/partialinclude/duplicate/first.pconvo.txt +test/convo/convos/partialinclude/duplicate/second.pconvo.txt +test/convo/convos/partialinclude/illegalname/bad.pconvo.txt +test/convo/convos/partialinclude/nested/deep.pconvo.txt +test/convo/convos/partialinclude/nested/main.convo.txt +test/convo/convos/partialinclude/nested/mid.pconvo.txt +test/convo/convos/partialinclude/notfound/main.convo.txt +test/convo/convos/partialinclude/single/main.convo.txt +test/convo/convos/partialinclude/single/sub.pconvo.txt +test/convo/convos/partialinclude/wrongarg/main.convo.txt +test/convo/partialinclude.spec.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-000693/tests/test_command.sh b/tasks/format-code-task-000693/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000693/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-000694/environment/Dockerfile b/tasks/format-code-task-000694/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5534766226b7c84c90e11150917735b67ab3aacd --- /dev/null +++ b/tasks/format-code-task-000694/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:53f0f4383d81f6753f08bd0427abe6b51320360c9136be25c8272c0a5d9a1357 diff --git a/tasks/format-code-task-000694/environment/setup/files/blocklist b/tasks/format-code-task-000694/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000694/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-000694/environment/setup/setup.sh b/tasks/format-code-task-000694/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000694/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-000694/tests/test.patch b/tasks/format-code-task-000694/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fcf8e0dae57671c95958affdb0342042eb178f1f --- /dev/null +++ b/tasks/format-code-task-000694/tests/test.patch @@ -0,0 +1,77 @@ +diff --git a/coderd/workspaceagents_test.go b/coderd/workspaceagents_test.go +index e0c4c7f45ee4c..e590922e9018b 100644 +--- a/coderd/workspaceagents_test.go ++++ b/coderd/workspaceagents_test.go +@@ -856,6 +856,32 @@ func TestWorkspaceAgentReportStats(t *testing.T) { + agentClient.SetSessionToken(authToken) + + _, err := agentClient.PostStats(context.Background(), &agentsdk.Stats{ ++ ConnectionsByProto: map[string]int64{"TCP": 1}, ++ ++ ++ ++ ConnectionCount: 1, ++ RxPackets: 1, ++ RxBytes: 1, ++ TxPackets: 1, ++ TxBytes: 1, ++ SessionCountVSCode: 0, ++ SessionCountJetBrains: 0, ++ SessionCountReconnectingPTY: 0, ++ SessionCountSSH: 0, ++ ConnectionMedianLatencyMS: 10, ++ }) ++ require.NoError(t, err) ++ ++ newWorkspace, err := client.Workspace(context.Background(), ws.ID) ++ require.NoError(t, err) ++ ++ assert.True(t, ++ newWorkspace.LastUsedAt.Equal(ws.LastUsedAt), ++ "%s and %s should not differ", newWorkspace.LastUsedAt, ws.LastUsedAt, ++ ) ++ ++ _, err = agentClient.PostStats(context.Background(), &agentsdk.Stats{ + ConnectionsByProto: map[string]int64{"TCP": 1}, + ConnectionCount: 1, + RxPackets: 1, +@@ -863,14 +889,14 @@ func TestWorkspaceAgentReportStats(t *testing.T) { + TxPackets: 1, + TxBytes: 1, + SessionCountVSCode: 1, +- SessionCountJetBrains: 1, +- SessionCountReconnectingPTY: 1, +- SessionCountSSH: 1, ++ SessionCountJetBrains: 0, ++ SessionCountReconnectingPTY: 0, ++ SessionCountSSH: 0, + ConnectionMedianLatencyMS: 10, + }) + require.NoError(t, err) + +- newWorkspace, err := client.Workspace(context.Background(), ws.ID) ++ newWorkspace, err = client.Workspace(context.Background(), ws.ID) + require.NoError(t, err) + + assert.True(t, +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3RvWrDMBQFYM9+ikvoaknXtRwoZMjWMaSBjsG2hBPaSEGWQx+/tpeUQpslobQ9 ++36J/6Yoj6n7/arbWnWRyK2ow13pqB5/bqc8655yVLuZFophLlSekb1bRB30Xq0CUBO/jd/surf9S ++4px/tF3cNv5wqJwR3e56b1zKn0t9zr/Ih/yLku8TUtcr4Wv/PP/G0BR8bU1q344+RFotN4+LmRw/ ++LFsv6717uBvnZmnrWeRKMNN4hLITZaF3tBkGzz68dMeqscvWuri2401PsYodCdl4Y4ORlDW+d3HB ++6U9/GgAAAAAAAAAAAAAAAAAAAADgj3gH1SXkDQAoAAA= +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-000694/tests/test.sh b/tasks/format-code-task-000694/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ca2b845fe736e7563aed7304fc99aed4e2ca3b75 --- /dev/null +++ b/tasks/format-code-task-000694/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' +coderd/workspaceagents_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-000694/tests/test_command.sh b/tasks/format-code-task-000694/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000694/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-000712/environment/Dockerfile b/tasks/format-code-task-000712/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b9ec55ae910e6637b5860434d9de0623514c0e8d --- /dev/null +++ b/tasks/format-code-task-000712/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:47b3532699382de8ea4583a2f5fe1856a03ed60a13c8a63c4e61ef1a27004d87 diff --git a/tasks/format-code-task-000712/environment/setup/files/blocklist b/tasks/format-code-task-000712/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000712/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-000712/environment/setup/setup.sh b/tasks/format-code-task-000712/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000712/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-000712/tests/test.patch b/tasks/format-code-task-000712/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3deab8900eb770d6a0244c1e24007da2f351db8b --- /dev/null +++ b/tasks/format-code-task-000712/tests/test.patch @@ -0,0 +1,775 @@ +diff --git a/usercase-test-coderl/fixtures/fake_apiserver.go b/usercase-test-coderl/fixtures/fake_apiserver.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/fake_apiserver.go +@@ -0,0 +1,387 @@ ++package main ++ ++import ( ++ "encoding/json" ++ "flag" ++ "fmt" ++ "io" ++ "log" ++ "net" ++ "net/http" ++ "net/url" ++ "os" ++ "path/filepath" ++ "strings" ++ "sync" ++) ++ ++type serverState struct { ++ scenario string ++ dir string ++ mu sync.Mutex ++ patches map[string]string ++} ++ ++func main() { ++ var scenario, dir string ++ flag.StringVar(&scenario, "scenario", "", "fixture scenario") ++ flag.StringVar(&dir, "dir", "", "directory for kubeconfig and records") ++ flag.Parse() ++ if scenario == "" || dir == "" { ++ log.Fatal("scenario and dir are required") ++ } ++ ++ ln, err := net.Listen("tcp", "127.0.0.1:0") ++ if err != nil { ++ log.Fatal(err) ++ } ++ st := &serverState{scenario: scenario, dir: dir, patches: map[string]string{}} ++ mux := http.NewServeMux() ++ mux.HandleFunc("/", st.handle) ++ ++ if err := os.WriteFile(filepath.Join(dir, "kubeconfig"), []byte(kubeconfig("http://"+ln.Addr().String())), 0644); err != nil { ++ log.Fatal(err) ++ } ++ log.Printf("ready %s", ln.Addr().String()) ++ log.Fatal(http.Serve(ln, mux)) ++} ++ ++func kubeconfig(server string) string { ++ return fmt.Sprintf(`apiVersion: v1 ++kind: Config ++clusters: ++- name: fake ++ cluster: ++ server: %s ++users: ++- name: fake ++ user: {} ++contexts: ++- name: fake ++ context: ++ cluster: fake ++ user: fake ++current-context: fake ++`, server) ++} ++ ++func (st *serverState) handle(w http.ResponseWriter, r *http.Request) { ++ if r.URL.Path == "/healthz" { ++ io.WriteString(w, "ok") ++ return ++ } ++ if r.URL.Path == "/api/v1" { ++ writeJSON(w, map[string]any{ ++ "kind": "APIResourceList", ++ "apiVersion": "v1", ++ "groupVersion": "v1", ++ "resources": []map[string]any{ ++ {"name": "pods", "kind": "Pod", "namespaced": true, "verbs": []string{"get", "list", "watch", "patch"}}, ++ {"name": "pods/ephemeralcontainers", "kind": "Pod", "namespaced": true, "verbs": []string{"get", "patch"}}, ++ }, ++ }) ++ return ++ } ++ if r.Method == http.MethodPatch && strings.HasSuffix(r.URL.Path, "/ephemeralcontainers") { ++ st.patchPod(w, r) ++ return ++ } ++ if r.Method == http.MethodGet && strings.HasPrefix(r.URL.Path, "/api/v1/namespaces/") && strings.Contains(r.URL.RawQuery, "watch=true") { ++ st.watchPod(w, r) ++ return ++ } ++ if r.Method != http.MethodGet { ++ http.NotFound(w, r) ++ return ++ } ++ ++ parts := strings.Split(strings.Trim(r.URL.Path, "/"), "/") ++ switch { ++ case len(parts) == 5 && parts[0] == "api" && parts[1] == "v1" && parts[2] == "namespaces" && parts[4] == "pods": ++ st.listPods(w, parts[3], r.URL.Query()) ++ case len(parts) == 6 && parts[0] == "api" && parts[1] == "v1" && parts[2] == "namespaces" && parts[4] == "pods": ++ st.getPod(w, parts[3], parts[5]) ++ case len(parts) == 7 && parts[0] == "apis" && parts[1] == "apps" && parts[2] == "v1" && parts[3] == "namespaces" && parts[5] == "deployments": ++ st.getDeployment(w, parts[4], parts[6]) ++ case len(parts) == 6 && parts[0] == "apis" && parts[1] == "apps" && parts[2] == "v1" && parts[3] == "namespaces" && parts[5] == "replicasets": ++ st.listReplicaSets(w, parts[4]) ++ case len(parts) == 7 && parts[0] == "apis" && parts[1] == "apps" && parts[2] == "v1" && parts[3] == "namespaces" && parts[5] == "statefulsets": ++ st.getStatefulSet(w, parts[4], parts[6]) ++ case len(parts) == 7 && parts[0] == "apis" && parts[1] == "apps" && parts[2] == "v1" && parts[3] == "namespaces" && parts[5] == "daemonsets": ++ st.getDaemonSet(w, parts[4], parts[6]) ++ default: ++ http.NotFound(w, r) ++ } ++} ++ ++func (st *serverState) getPod(w http.ResponseWriter, ns, name string) { ++ pod, ok := st.pod(ns, name) ++ if !ok { ++ writeStatus(w, http.StatusNotFound, "pods", name) ++ return ++ } ++ writeJSON(w, pod) ++} ++ ++func (st *serverState) listPods(w http.ResponseWriter, ns string, q url.Values) { ++ var pods []any ++ for _, p := range st.allPods(ns) { ++ pods = append(pods, p) ++ } ++ writeJSON(w, map[string]any{"kind": "PodList", "apiVersion": "v1", "items": pods}) ++} ++ ++func (st *serverState) getDeployment(w http.ResponseWriter, ns, name string) { ++ deploymentScenario := strings.HasPrefix(st.scenario, "tcp_") || ++ st.scenario == "deployment_no_rs" || ++ st.scenario == "deployment_no_pod" ++ if name != "api" || ns != "alpha" || !deploymentScenario { ++ writeStatus(w, http.StatusNotFound, "deployments", name) ++ return ++ } ++ writeJSON(w, deployment(ns, name, "dep-api", map[string]string{"app": "api"})) ++} ++ ++func (st *serverState) listReplicaSets(w http.ResponseWriter, ns string) { ++ items := []any{} ++ if ns == "alpha" { ++ switch st.scenario { ++ case "tcp_success": ++ items = append(items, replicaSet(ns, "api-rs", "rs-api", "api", "dep-api", 2, map[string]string{"app": "api"})) ++ case "deployment_no_rs": ++ items = append(items, replicaSet(ns, "api-rs-zero", "rs-api-zero", "api", "dep-api", 0, map[string]string{"app": "api"})) ++ case "deployment_no_pod": ++ items = append(items, replicaSet(ns, "api-rs", "rs-api", "api", "dep-api", 1, map[string]string{"app": "api"})) ++ } ++ } ++ writeJSON(w, map[string]any{"kind": "ReplicaSetList", "apiVersion": "apps/v1", "items": items}) ++} ++ ++func (st *serverState) getStatefulSet(w http.ResponseWriter, ns, name string) { ++ if ns != "alpha" || name != "web" { ++ writeStatus(w, http.StatusNotFound, "statefulsets", name) ++ return ++ } ++ replicas := 1 ++ if st.scenario == "statefulset_zero" { ++ replicas = 0 ++ } ++ writeJSON(w, statefulSet(ns, name, "ss-web", replicas, map[string]string{"app": "web"})) ++} ++ ++func (st *serverState) getDaemonSet(w http.ResponseWriter, ns, name string) { ++ if ns != "beta" || name != "dns" { ++ writeStatus(w, http.StatusNotFound, "daemonsets", name) ++ return ++ } ++ available := 1 ++ if st.scenario == "daemonset_zero" { ++ available = 0 ++ } ++ writeJSON(w, daemonSet(ns, name, "ds-dns", available, map[string]string{"app": "dns"})) ++} ++ ++func (st *serverState) allPods(ns string) []map[string]any { ++ var pods []map[string]any ++ for _, name := range []string{"api-pod", "api-pending", "api-no-ip", "web-0", "dns-node-a", "db", "ghost"} { ++ if pod, ok := st.pod(ns, name); ok { ++ pods = append(pods, pod) ++ } ++ } ++ return pods ++} ++ ++func (st *serverState) pod(ns, name string) (map[string]any, bool) { ++ switch st.scenario { ++ case "pod_missing": ++ if ns == "beta" && name == "db" { ++ return pod(ns, name, "pod-db", "Running", "10.2.0.31", map[string]string{"app": "db"}, nil), true ++ } ++ return nil, false ++ case "pod_not_running": ++ if ns == "alpha" && name == "api-pending" { ++ return pod(ns, name, "pod-pending", "Pending", "", map[string]string{"app": "api"}, nil), true ++ } ++ case "pod_no_ip": ++ if ns == "alpha" && name == "api-no-ip" { ++ return pod(ns, name, "pod-no-ip", "Running", "", map[string]string{"app": "api"}, nil), true ++ } ++ case "tcp_success": ++ if ns == "alpha" && name == "api-pod" { ++ return pod(ns, name, "pod-api", "Running", "10.1.0.21", map[string]string{"app": "api"}, owner("ReplicaSet", "api-rs", "rs-api")), true ++ } ++ if ns == "alpha" && name == "api-pending" { ++ return pod(ns, name, "pod-api-pending", "Running", "", map[string]string{"app": "api"}, owner("ReplicaSet", "api-rs", "rs-api")), true ++ } ++ if ns == "beta" && name == "db" { ++ return pod(ns, name, "pod-db", "Running", "10.2.0.31", map[string]string{"app": "db"}, nil), true ++ } ++ case "udp_success": ++ if ns == "alpha" && name == "web-0" { ++ return pod(ns, name, "pod-web-0", "Running", "10.1.0.41", map[string]string{"app": "web"}, owner("StatefulSet", "web", "ss-web")), true ++ } ++ if ns == "beta" && name == "dns-node-a" { ++ return pod(ns, name, "pod-dns-a", "Running", "10.2.0.50", map[string]string{"app": "dns"}, owner("DaemonSet", "dns", "ds-dns")), true ++ } ++ } ++ return nil, false ++} ++ ++func (st *serverState) patchPod(w http.ResponseWriter, r *http.Request) { ++ parts := strings.Split(strings.Trim(r.URL.Path, "/"), "/") ++ ns, name := parts[3], parts[5] ++ body, _ := io.ReadAll(r.Body) ++ var patch map[string]any ++ _ = json.Unmarshal(body, &patch) ++ ec := lastEphemeralContainer(patch) ++ ecName, _ := ec["name"].(string) ++ kind := "unknown" ++ fields := []string{fmt.Sprintf("%s/%s", ns, name)} ++ env := envMap(ec) ++ if _, ok := env["TARGET_HOST"]; ok { ++ kind = "scanner" ++ fields = append(fields, "scanner", "target="+env["TARGET_HOST"], "port="+env["TARGET_PORT"], "protocol="+env["PROTOCOL"], "attempts="+env["ATTEMPTS"]) ++ } else { ++ kind = "sniffer" ++ fields = append(fields, "sniffer", "protocol="+env["PROTOCOL"], "matches="+env["MATCHES"], "iface="+env["IFACE"], "timeout="+env["TIMEOUT_SECONDS"]) ++ } ++ ++ st.mu.Lock() ++ st.patches[ns+"/"+name] = ecName ++ f, err := os.OpenFile(filepath.Join(st.dir, "patches.log"), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644) ++ if err == nil { ++ fmt.Fprintln(f, strings.Join(fields, " ")) ++ _ = f.Close() ++ } ++ st.mu.Unlock() ++ ++ p, ok := st.pod(ns, name) ++ if !ok { ++ writeStatus(w, http.StatusNotFound, "pods", name) ++ return ++ } ++ spec := p["spec"].(map[string]any) ++ spec["ephemeralContainers"] = []any{map[string]any{"name": ecName, "env": ec["env"]}} ++ _ = kind ++ writeJSON(w, p) ++} ++ ++func (st *serverState) watchPod(w http.ResponseWriter, r *http.Request) { ++ parts := strings.Split(strings.Trim(r.URL.Path, "/"), "/") ++ ns := parts[3] ++ name := fieldSelectorValue(r.URL.Query().Get("fieldSelector"), "metadata.name") ++ st.mu.Lock() ++ ecName := st.patches[ns+"/"+name] ++ st.mu.Unlock() ++ p, ok := st.pod(ns, name) ++ if !ok { ++ writeStatus(w, http.StatusNotFound, "pods", name) ++ return ++ } ++ p["status"].(map[string]any)["ephemeralContainerStatuses"] = []any{map[string]any{ ++ "name": ecName, ++ "state": map[string]any{"terminated": map[string]any{ ++ "exitCode": 0, ++ "reason": "Completed", ++ }}, ++ }} ++ w.Header().Set("Content-Type", "application/json") ++ _ = json.NewEncoder(w).Encode(map[string]any{"type": "MODIFIED", "object": p}) ++} ++ ++func fieldSelectorValue(selector, key string) string { ++ for _, part := range strings.Split(selector, ",") { ++ pair := strings.SplitN(part, "=", 2) ++ if len(pair) == 2 && pair[0] == key { ++ return pair[1] ++ } ++ } ++ return "" ++} ++ ++func lastEphemeralContainer(patch map[string]any) map[string]any { ++ spec, _ := patch["spec"].(map[string]any) ++ ecs, _ := spec["ephemeralContainers"].([]any) ++ if len(ecs) == 0 { ++ return map[string]any{} ++ } ++ ec, _ := ecs[len(ecs)-1].(map[string]any) ++ return ec ++} ++ ++func envMap(ec map[string]any) map[string]string { ++ out := map[string]string{} ++ envs, _ := ec["env"].([]any) ++ for _, item := range envs { ++ m, _ := item.(map[string]any) ++ name, _ := m["name"].(string) ++ value, _ := m["value"].(string) ++ out[name] = value ++ } ++ return out ++} ++ ++func deployment(ns, name, uid string, labels map[string]string) map[string]any { ++ return map[string]any{ ++ "kind": "Deployment", "apiVersion": "apps/v1", ++ "metadata": map[string]any{"name": name, "namespace": ns, "uid": uid}, ++ "spec": map[string]any{"selector": map[string]any{"matchLabels": labels}}, ++ } ++} ++ ++func replicaSet(ns, name, uid, depName, depUID string, replicas int, labels map[string]string) map[string]any { ++ return map[string]any{ ++ "kind": "ReplicaSet", "apiVersion": "apps/v1", ++ "metadata": map[string]any{"name": name, "namespace": ns, "uid": uid, "labels": labels, "ownerReferences": []any{owner("Deployment", depName, depUID)}}, ++ "spec": map[string]any{"replicas": replicas, "selector": map[string]any{"matchLabels": labels}}, ++ } ++} ++ ++func statefulSet(ns, name, uid string, replicas int, labels map[string]string) map[string]any { ++ return map[string]any{ ++ "kind": "StatefulSet", "apiVersion": "apps/v1", ++ "metadata": map[string]any{"name": name, "namespace": ns, "uid": uid}, ++ "spec": map[string]any{"replicas": replicas, "selector": map[string]any{"matchLabels": labels}}, ++ } ++} ++ ++func daemonSet(ns, name, uid string, available int, labels map[string]string) map[string]any { ++ return map[string]any{ ++ "kind": "DaemonSet", "apiVersion": "apps/v1", ++ "metadata": map[string]any{"name": name, "namespace": ns, "uid": uid}, ++ "spec": map[string]any{"selector": map[string]any{"matchLabels": labels}}, ++ "status": map[string]any{"numberAvailable": available}, ++ } ++} ++ ++func pod(ns, name, uid, phase, ip string, labels map[string]string, ownerRef map[string]any) map[string]any { ++ owners := []any{} ++ if ownerRef != nil { ++ owners = append(owners, ownerRef) ++ } ++ return map[string]any{ ++ "kind": "Pod", "apiVersion": "v1", ++ "metadata": map[string]any{"name": name, "namespace": ns, "uid": uid, "labels": labels, "ownerReferences": owners}, ++ "spec": map[string]any{"containers": []any{map[string]any{"name": "app", "image": "example/app:1"}}}, ++ "status": map[string]any{"phase": phase, "podIP": ip}, ++ } ++} ++ ++func owner(kind, name, uid string) map[string]any { ++ return map[string]any{"apiVersion": "apps/v1", "kind": kind, "name": name, "uid": uid, "controller": true} ++} ++ ++func writeStatus(w http.ResponseWriter, code int, resource, name string) { ++ w.WriteHeader(code) ++ writeJSON(w, map[string]any{ ++ "kind": "Status", "apiVersion": "v1", "status": "Failure", "reason": "NotFound", ++ "message": fmt.Sprintf("%s %q not found", resource, name), ++ "code": code, ++ "details": map[string]any{"name": name, "kind": resource}, ++ }) ++} ++ ++func writeJSON(w http.ResponseWriter, v any) { ++ w.Header().Set("Content-Type", "application/json") ++ _ = json.NewEncoder(w).Encode(v) ++} +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,356 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++export GOMAXPROCS=2 ++ ++( cd /workspace/repo && go build -o /tmp/netassert-coderl ./cmd/netassert/cli ) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN=/tmp/netassert-coderl ++ ++TMP=$(mktemp -d); trap 'cleanup' EXIT ++SERVER_PIDS="" ++cd "$TMP" || exit 1 ++fail() { echo "FAIL: $*" >&2; exit 1; } ++cleanup() { ++ for pid in $SERVER_PIDS; do ++ kill "$pid" 2>/dev/null || true ++ done ++ rm -rf "$TMP" ++} ++ ++start_server() { ++ scenario=$1 ++ dir=$TMP/$scenario ++ mkdir -p "$dir" ++ ( cd /workspace/repo && go run ./usercase-test-coderl/fixtures/fake_apiserver.go -scenario "$scenario" -dir "$dir" >"$dir/server.out" 2>"$dir/server.err" ) & ++ pid=$! ++ SERVER_PIDS="$SERVER_PIDS $pid" ++ for _ in $(seq 1 100); do ++ [ -s "$dir/kubeconfig" ] && break ++ kill -0 "$pid" 2>/dev/null || { cat "$dir/server.err" >&2; fail "$scenario server exited"; } ++ sleep 0.1 ++ done ++ [ -s "$dir/kubeconfig" ] || { cat "$dir/server.err" >&2; fail "$scenario server did not write kubeconfig"; } ++} ++ ++run_case() { ++ scenario=$1 ++ test_yaml=$2 ++ start_server "$scenario" ++ dir=$TMP/$scenario ++ printf '%s\n' "$test_yaml" > "$dir/tests.yaml" ++ "$BIN" run --input-file "$dir/tests.yaml" --kubeconfig "$dir/kubeconfig" --tap "$dir/results.tap" --pause-sec 0 --suffix-length 1 --log-level error >"$dir/out" 2>"$dir/err" ++ ec=$? ++} ++ ++assert_file_exact() { ++ file=$1 ++ expected=$2 ++ actual=$(cat "$file") ++ [ "$actual" = "$expected" ] || fail "$file content: ++$actual" ++} ++ ++assert_no_patches() { ++ dir=$1 ++ [ ! -s "$dir/patches.log" ] || fail "$dir unexpected container launches: $(cat "$dir/patches.log")" ++} ++ ++assert_file_line_count() { ++ file=$1 ++ expected=$2 ++ actual=$(wc -l < "$file" | tr -d ' ') ++ [ "$actual" = "$expected" ] || fail "$file line count $actual; want $expected: $(cat "$file")" ++} ++ ++assert_text_contains_all_ci() { ++ label=$1 ++ text=$2 ++ shift 2 ++ lower=$(printf '%s' "$text" | tr '[:upper:]' '[:lower:]') ++ for needle in "$@"; do ++ needle_lower=$(printf '%s' "$needle" | tr '[:upper:]' '[:lower:]') ++ case "$lower" in ++ *"$needle_lower"*) ;; ++ *) fail "$label missing required text '$needle': $text" ;; ++ esac ++ done ++} ++ ++assert_file_contains_all_ci() { ++ file=$1 ++ shift ++ assert_text_contains_all_ci "$file" "$(cat "$file")" "$@" ++} ++ ++assert_file_contains_any_ci() { ++ file=$1 ++ shift ++ lower=$(tr '[:upper:]' '[:lower:]' < "$file") ++ for needle in "$@"; do ++ needle_lower=$(printf '%s' "$needle" | tr '[:upper:]' '[:lower:]') ++ case "$lower" in ++ *"$needle_lower"*) return 0 ;; ++ esac ++ done ++ fail "$file missing any required text [$*]: $(cat "$file")" ++} ++ ++assert_stderr_runtime_only() { ++ file=$1 ++ [ ! -s "$file" ] && return 0 ++ grep -Eq '^[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} maxprocs: ' "$file" \ ++ || fail "$file unexpected stderr: $(cat "$file")" ++} ++ ++ ++ ++ ++run_case tcp_success '- name: tcp deployment to pod ++ type: k8s ++ protocol: tcp ++ targetPort: 8080 ++ timeoutSeconds: 1 ++ attempts: 1 ++ exitCode: 0 ++ src: ++ k8sResource: ++ kind: deployment ++ name: api ++ namespace: alpha ++ dst: ++ k8sResource: ++ kind: pod ++ name: db ++ namespace: beta' ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_stderr_runtime_only "$TMP/tcp_success/err" ++assert_file_exact "$TMP/tcp_success/results.tap" 'TAP version 14 ++1..1 ++ok 1 - tcp deployment to pod' ++ ++assert_file_line_count "$TMP/tcp_success/patches.log" 1 ++assert_file_contains_all_ci "$TMP/tcp_success/patches.log" "alpha/api-pod" "scanner" "target=10.2.0.31" ++ ++ ++ ++ ++run_case pod_missing '- name: missing pod source ++ type: k8s ++ protocol: tcp ++ targetPort: 8080 ++ timeoutSeconds: 1 ++ attempts: 1 ++ exitCode: 0 ++ src: ++ k8sResource: ++ kind: pod ++ name: ghost ++ namespace: alpha ++ dst: ++ k8sResource: ++ kind: pod ++ name: db ++ namespace: beta' ++[ "$ec" -ne 0 ] || fail "F2 want non-zero exit" ++assert_stderr_runtime_only "$TMP/pod_missing/err" ++ ++assert_file_contains_all_ci "$TMP/pod_missing/results.tap" "not ok 1 - missing pod source" "reason:" "pod" "ghost" "alpha" ++assert_file_contains_any_ci "$TMP/pod_missing/results.tap" "missing" "not found" "could not find" "unable to find" ++assert_no_patches "$TMP/pod_missing" ++ ++ ++ ++ ++run_case pod_not_running '- name: pending pod source ++ type: k8s ++ protocol: tcp ++ targetPort: 8080 ++ timeoutSeconds: 1 ++ attempts: 1 ++ exitCode: 0 ++ src: ++ k8sResource: ++ kind: pod ++ name: api-pending ++ namespace: alpha ++ dst: ++ k8sResource: ++ kind: pod ++ name: db ++ namespace: beta' ++[ "$ec" -ne 0 ] || fail "F3 want non-zero exit" ++assert_stderr_runtime_only "$TMP/pod_not_running/err" ++ ++assert_file_contains_all_ci "$TMP/pod_not_running/results.tap" "not ok 1 - pending pod source" "reason:" "pod" "api-pending" "alpha" "running" ++assert_file_contains_any_ci "$TMP/pod_not_running/results.tap" "not running" "not in running" "pending" ++assert_no_patches "$TMP/pod_not_running" ++ ++ ++ ++ ++run_case pod_no_ip '- name: no ip pod source ++ type: k8s ++ protocol: tcp ++ targetPort: 8080 ++ timeoutSeconds: 1 ++ attempts: 1 ++ exitCode: 0 ++ src: ++ k8sResource: ++ kind: pod ++ name: api-no-ip ++ namespace: alpha ++ dst: ++ k8sResource: ++ kind: pod ++ name: db ++ namespace: beta' ++[ "$ec" -ne 0 ] || fail "F4 want non-zero exit" ++assert_stderr_runtime_only "$TMP/pod_no_ip/err" ++ ++assert_file_contains_all_ci "$TMP/pod_no_ip/results.tap" "not ok 1 - no ip pod source" "reason:" "pod" "api-no-ip" "alpha" "ip" ++assert_file_contains_any_ci "$TMP/pod_no_ip/results.tap" "no ip" "without ip" "empty pod ip" "does not have an ip" ++assert_no_patches "$TMP/pod_no_ip" ++ ++ ++ ++ ++run_case deployment_no_rs '- name: deployment no eligible replicaset ++ type: k8s ++ protocol: tcp ++ targetPort: 8080 ++ timeoutSeconds: 1 ++ attempts: 1 ++ exitCode: 0 ++ src: ++ k8sResource: ++ kind: deployment ++ name: api ++ namespace: alpha ++ dst: ++ k8sResource: ++ kind: pod ++ name: db ++ namespace: beta' ++[ "$ec" -ne 0 ] || fail "F5 want non-zero exit" ++assert_stderr_runtime_only "$TMP/deployment_no_rs/err" ++ ++assert_file_contains_all_ci "$TMP/deployment_no_rs/results.tap" "not ok 1 - deployment no eligible replicaset" "reason:" "deployment" "api" "alpha" "replica" ++assert_file_contains_any_ci "$TMP/deployment_no_rs/results.tap" "no" "not found" "could not find" "unable to find" "zero" ++assert_no_patches "$TMP/deployment_no_rs" ++ ++ ++ ++ ++run_case deployment_no_pod '- name: deployment no eligible pod ++ type: k8s ++ protocol: tcp ++ targetPort: 8080 ++ timeoutSeconds: 1 ++ attempts: 1 ++ exitCode: 0 ++ src: ++ k8sResource: ++ kind: deployment ++ name: api ++ namespace: alpha ++ dst: ++ k8sResource: ++ kind: pod ++ name: db ++ namespace: beta' ++[ "$ec" -ne 0 ] || fail "F6 want non-zero exit" ++assert_stderr_runtime_only "$TMP/deployment_no_pod/err" ++ ++assert_file_contains_all_ci "$TMP/deployment_no_pod/results.tap" "not ok 1 - deployment no eligible pod" "reason:" "deployment" "api" "alpha" "pod" ++assert_file_contains_any_ci "$TMP/deployment_no_pod/results.tap" "no" "not found" "could not find" "unable to find" "zero" ++assert_no_patches "$TMP/deployment_no_pod" ++ ++ ++ ++ ++run_case statefulset_zero '- name: statefulset zero replicas ++ type: k8s ++ protocol: tcp ++ targetPort: 8080 ++ timeoutSeconds: 1 ++ attempts: 1 ++ exitCode: 0 ++ src: ++ k8sResource: ++ kind: statefulset ++ name: web ++ namespace: alpha ++ dst: ++ k8sResource: ++ kind: pod ++ name: db ++ namespace: beta' ++[ "$ec" -ne 0 ] || fail "F7 want non-zero exit" ++assert_stderr_runtime_only "$TMP/statefulset_zero/err" ++ ++assert_file_contains_all_ci "$TMP/statefulset_zero/results.tap" "not ok 1 - statefulset zero replicas" "reason:" "statefulset" "web" "alpha" "replica" ++assert_file_contains_any_ci "$TMP/statefulset_zero/results.tap" "zero" "no replica" "scaled to zero" ++assert_no_patches "$TMP/statefulset_zero" ++ ++ ++ ++ ++run_case daemonset_zero '- name: daemonset zero available ++ type: k8s ++ protocol: tcp ++ targetPort: 8080 ++ timeoutSeconds: 1 ++ attempts: 1 ++ exitCode: 0 ++ src: ++ k8sResource: ++ kind: daemonset ++ name: dns ++ namespace: beta ++ dst: ++ k8sResource: ++ kind: pod ++ name: db ++ namespace: beta' ++[ "$ec" -ne 0 ] || fail "F8 want non-zero exit" ++assert_stderr_runtime_only "$TMP/daemonset_zero/err" ++ ++assert_file_contains_all_ci "$TMP/daemonset_zero/results.tap" "not ok 1 - daemonset zero available" "reason:" "daemonset" "dns" "available" ++assert_file_contains_any_ci "$TMP/daemonset_zero/results.tap" "zero" "no available" "0 available" ++assert_no_patches "$TMP/daemonset_zero" ++ ++ ++ ++ ++run_case udp_success '- name: udp statefulset to daemonset ++ type: k8s ++ protocol: udp ++ targetPort: 5353 ++ timeoutSeconds: 1 ++ attempts: 2 ++ exitCode: 0 ++ src: ++ k8sResource: ++ kind: statefulset ++ name: web ++ namespace: alpha ++ dst: ++ k8sResource: ++ kind: daemonset ++ name: dns ++ namespace: beta' ++[ "$ec" -eq 0 ] || fail "F9 exit $ec; want 0" ++assert_stderr_runtime_only "$TMP/udp_success/err" ++assert_file_exact "$TMP/udp_success/results.tap" 'TAP version 14 ++1..1 ++ok 1 - udp statefulset to daemonset' ++ ++assert_file_line_count "$TMP/udp_success/patches.log" 2 ++assert_text_contains_all_ci "$TMP/udp_success/patches.log first launch" "$(sed -n '1p' "$TMP/udp_success/patches.log")" "beta/dns-node-a" "sniffer" ++assert_text_contains_all_ci "$TMP/udp_success/patches.log second launch" "$(sed -n '2p' "$TMP/udp_success/patches.log")" "alpha/web-0" "scanner" "target=10.2.0.50" ++ ++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,17 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOVCS='*:off' ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000712/tests/test.sh b/tasks/format-code-task-000712/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d1028431e2e499ff4512d7487ec14f8f8df115e6 --- /dev/null +++ b/tasks/format-code-task-000712/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/fake_apiserver.go +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-000712/tests/test_command.sh b/tasks/format-code-task-000712/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000712/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-000724/environment/Dockerfile b/tasks/format-code-task-000724/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f947527ff4f496c82bc061012ccb177fc62cd957 --- /dev/null +++ b/tasks/format-code-task-000724/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:828bab10aae3f32ddab8644bebcb0ec542b7d8eff3f9c7bf95e9f9d09718acaa diff --git a/tasks/format-code-task-000724/environment/setup/files/blocklist b/tasks/format-code-task-000724/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000724/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-000724/environment/setup/setup.sh b/tasks/format-code-task-000724/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000724/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-000724/tests/test.patch b/tasks/format-code-task-000724/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..12b863ee1059d0b175c2bc78e786b0dff8d0a8ae --- /dev/null +++ b/tasks/format-code-task-000724/tests/test.patch @@ -0,0 +1,220 @@ +diff --git a/rest/adminapitest/admin_api_audit_config_test.go b/rest/adminapitest/admin_api_audit_config_test.go +new file mode 100644 +index 000000000..981ffd0a8 +--- /dev/null ++++ b/rest/adminapitest/admin_api_audit_config_test.go +@@ -0,0 +1,193 @@ ++package adminapitest ++ ++import ( ++ "encoding/json" ++ "fmt" ++ "net/http" ++ "testing" ++ ++ "github.com/couchbase/sync_gateway/base" ++ "github.com/couchbase/sync_gateway/rest" ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++) ++ ++const unknownAuditEventIDForConfigAPITest = "999999999" ++ ++type auditConfigResponse struct { ++ Enabled bool `json:"enabled"` ++ Events map[string]any `json:"events"` ++} ++ ++func requireAuditConfig(t *testing.T, rt *rest.RestTester) (auditConfigResponse, string) { ++ t.Helper() ++ resp := rt.SendAdminRequest(http.MethodGet, "/db/_config/audit", "") ++ rest.RequireStatus(t, resp, http.StatusOK) ++ var body auditConfigResponse ++ require.NoError(t, json.Unmarshal(resp.Body.Bytes(), &body)) ++ require.NotNil(t, body.Events) ++ return body, resp.Header().Get("ETag") ++} ++ ++func requireAuditEventBool(t *testing.T, body auditConfigResponse, id base.AuditID) bool { ++ t.Helper() ++ raw, ok := body.Events[id.String()] ++ require.Truef(t, ok, "expected audit event %s in response", id.String()) ++ val, ok := raw.(bool) ++ require.Truef(t, ok, "expected audit event %s value to be a bool, got %T", id.String(), raw) ++ return val ++} ++ ++func requireDBConfigAuditEvents(t *testing.T, rt *rest.RestTester) map[string]bool { ++ t.Helper() ++ resp := rt.SendAdminRequest(http.MethodGet, "/db/_config", "") ++ rest.RequireStatus(t, resp, http.StatusOK) ++ var cfg map[string]any ++ require.NoError(t, json.Unmarshal(resp.Body.Bytes(), &cfg)) ++ logging, ok := cfg["logging"].(map[string]any) ++ require.True(t, ok, "expected logging object in database config") ++ audit, ok := logging["audit"].(map[string]any) ++ require.True(t, ok, "expected logging.audit object in database config") ++ events := make(map[string]bool) ++ if rawEvents, ok := audit["enabled_events"].([]any); ok { ++ for _, raw := range rawEvents { ++ switch v := raw.(type) { ++ case float64: ++ events[fmt.Sprintf("%.0f", v)] = true ++ case string: ++ events[v] = true ++ } ++ } ++ } ++ return events ++} ++ ++func TestDatabaseConfigAuditAPIGetShapeDefaultsAndETag(t *testing.T) { ++ rt := rest.NewRestTesterPersistentConfig(t) ++ defer rt.Close() ++ ++ body, auditETag := requireAuditConfig(t, rt) ++ assert.IsType(t, false, body.Enabled) ++ require.NotEmpty(t, body.Events) ++ assert.Contains(t, body.Events, base.AuditIDPublicUserAuthenticated.String()) ++ _, ok := body.Events[base.AuditIDPublicUserAuthenticated.String()].(bool) ++ assert.True(t, ok, "non-verbose audit event values should be booleans") ++ require.NotEmpty(t, auditETag) ++ cfgResp := rt.SendAdminRequest(http.MethodGet, "/db/_config", "") ++ rest.RequireStatus(t, cfgResp, http.StatusOK) ++ assert.Equal(t, cfgResp.Header().Get("ETag"), auditETag) ++ ++ putBody := fmt.Sprintf(`{"enabled":true,"events":{"%s":true}}`, base.AuditIDPublicUserAuthenticated) ++ resp := rt.SendAdminRequest(http.MethodPut, "/db/_config/audit", putBody) ++ rest.RequireStatus(t, resp, http.StatusOK) ++ _, updatedETag := requireAuditConfig(t, rt) ++ require.NotEmpty(t, updatedETag) ++ assert.NotEqual(t, auditETag, updatedETag) ++ cfgResp = rt.SendAdminRequest(http.MethodGet, "/db/_config", "") ++ rest.RequireStatus(t, cfgResp, http.StatusOK) ++ assert.Equal(t, cfgResp.Header().Get("ETag"), updatedETag) ++} ++ ++func TestDatabaseConfigAuditAPIPostPatchPersistsAndGetReflects(t *testing.T) { ++ rt := rest.NewRestTesterPersistentConfig(t) ++ defer rt.Close() ++ ++ eventA := base.AuditIDAuditEnabled ++ eventB := base.AuditIDPublicUserAuthenticated ++ resp := rt.SendAdminRequest(http.MethodPut, "/db/_config/audit", fmt.Sprintf(`{"enabled":true,"events":{"%s":true,"%s":true}}`, eventA, eventB)) ++ rest.RequireStatus(t, resp, http.StatusOK) ++ ++ resp = rt.SendAdminRequest(http.MethodPost, "/db/_config/audit", fmt.Sprintf(`{"events":{"%s":false}}`, eventA)) ++ rest.RequireStatus(t, resp, http.StatusOK) ++ body, _ := requireAuditConfig(t, rt) ++ assert.False(t, requireAuditEventBool(t, body, eventA), "POST false should remove the specified enabled event") ++ assert.True(t, requireAuditEventBool(t, body, eventB), "POST should preserve omitted enabled events") ++ ++ persistedEvents := requireDBConfigAuditEvents(t, rt) ++ assert.NotContains(t, persistedEvents, eventA.String()) ++ assert.Contains(t, persistedEvents, eventB.String()) ++ ++ resp = rt.SendAdminRequest(http.MethodPost, "/db/_config/audit", fmt.Sprintf(`{"enabled":false,"events":{"%s":true}}`, eventA)) ++ rest.RequireStatus(t, resp, http.StatusOK) ++ body, _ = requireAuditConfig(t, rt) ++ assert.False(t, body.Enabled) ++ assert.True(t, requireAuditEventBool(t, body, eventA)) ++ assert.True(t, requireAuditEventBool(t, body, eventB), "POST should still preserve omitted events on later patches") ++} ++ ++func TestDatabaseConfigAuditAPIPutReplacesEvents(t *testing.T) { ++ rt := rest.NewRestTesterPersistentConfig(t) ++ defer rt.Close() ++ ++ eventA := base.AuditIDAuditEnabled ++ eventB := base.AuditIDPublicUserAuthenticated ++ resp := rt.SendAdminRequest(http.MethodPut, "/db/_config/audit", fmt.Sprintf(`{"enabled":true,"events":{"%s":true,"%s":true}}`, eventA, eventB)) ++ rest.RequireStatus(t, resp, http.StatusOK) ++ ++ resp = rt.SendAdminRequest(http.MethodPut, "/db/_config/audit", fmt.Sprintf(`{"enabled":false,"events":{"%s":true}}`, eventA)) ++ rest.RequireStatus(t, resp, http.StatusOK) ++ body, _ := requireAuditConfig(t, rt) ++ assert.True(t, requireAuditEventBool(t, body, eventA)) ++ assert.False(t, requireAuditEventBool(t, body, eventB), "PUT should disable previously enabled events omitted from the replacement body") ++ ++ persistedEvents := requireDBConfigAuditEvents(t, rt) ++ assert.Contains(t, persistedEvents, eventA.String()) ++ assert.NotContains(t, persistedEvents, eventB.String()) ++} ++ ++func TestDatabaseConfigAuditAPIVerboseShape(t *testing.T) { ++ rt := rest.NewRestTesterPersistentConfig(t) ++ defer rt.Close() ++ ++ resp := rt.SendAdminRequest(http.MethodGet, "/db/_config/audit?verbose=true", "") ++ rest.RequireStatus(t, resp, http.StatusOK) ++ var body map[string]any ++ require.NoError(t, json.Unmarshal(resp.Body.Bytes(), &body)) ++ assert.IsType(t, false, body["enabled"]) ++ events, ok := body["events"].(map[string]any) ++ require.True(t, ok, "expected verbose response to include an events object") ++ event, ok := events[base.AuditIDPublicUserAuthenticated.String()].(map[string]any) ++ require.True(t, ok, "expected verbose event entry to be an object") ++ assert.IsType(t, false, event["enabled"]) ++ assert.IsType(t, false, event["filterable"]) ++ if name, ok := event["name"]; ok { ++ assert.IsType(t, "", name) ++ } ++ if description, ok := event["description"]; ok { ++ assert.IsType(t, "", description) ++ } ++} ++ ++func TestDatabaseConfigAuditAPINonPersistentUnavailable(t *testing.T) { ++ rt := rest.NewRestTester(t, nil) ++ defer rt.Close() ++ ++ resp := rt.SendAdminRequest(http.MethodGet, "/db/_config/audit", "") ++ rest.RequireStatus(t, resp, http.StatusServiceUnavailable) ++ require.NotEmpty(t, resp.BodyString()) ++} ++ ++func TestDatabaseConfigAuditAPIRejectsInvalidEventIDs(t *testing.T) { ++ rt := rest.NewRestTesterPersistentConfig(t) ++ defer rt.Close() ++ ++ eventA := base.AuditIDPublicUserAuthenticated ++ resp := rt.SendAdminRequest(http.MethodPut, "/db/_config/audit", fmt.Sprintf(`{"enabled":true,"events":{"%s":true}}`, eventA)) ++ rest.RequireStatus(t, resp, http.StatusOK) ++ before, _ := requireAuditConfig(t, rt) ++ ++ resp = rt.SendAdminRequest(http.MethodPut, "/db/_config/audit", `{"events":{"not-a-number":true}}`) ++ rest.RequireStatus(t, resp, http.StatusBadRequest) ++ invalidErrorBody := resp.BodyString() ++ require.NotEmpty(t, invalidErrorBody) ++ ++ resp = rt.SendAdminRequest(http.MethodPost, "/db/_config/audit", fmt.Sprintf(`{"events":{"%s":true}}`, unknownAuditEventIDForConfigAPITest)) ++ rest.RequireStatus(t, resp, http.StatusBadRequest) ++ unknownErrorBody := resp.BodyString() ++ require.NotEmpty(t, unknownErrorBody) ++ assert.NotEqual(t, invalidErrorBody, unknownErrorBody, "malformed and unknown event ID errors should be distinguishable") ++ ++ after, _ := requireAuditConfig(t, rt) ++ assert.Equal(t, before.Enabled, after.Enabled) ++ assert.Equal(t, requireAuditEventBool(t, before, eventA), requireAuditEventBool(t, after, eventA)) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ go test -v -count=1 ./rest/adminapitest/ -run 'TestPersistentConfigConcurrency' ++ ;; ++ new) ++ go test -v -count=1 ./rest/adminapitest/ -run 'TestDatabaseConfigAuditAPI' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000724/tests/test.sh b/tasks/format-code-task-000724/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..884b56747886e788b945ed02f7a06286bb8f6a75 --- /dev/null +++ b/tasks/format-code-task-000724/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' +rest/adminapitest/admin_api_audit_config_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-000724/tests/test_command.sh b/tasks/format-code-task-000724/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000724/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-000803/environment/Dockerfile b/tasks/format-code-task-000803/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fabee8e2d2d7dcc4ef12fdba1330da69fb54bbf8 --- /dev/null +++ b/tasks/format-code-task-000803/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:bd92951c2d74abfca16569dd0971d8847a1ae8bf7753439a11c18f8320ef070f diff --git a/tasks/format-code-task-000803/environment/setup/files/blocklist b/tasks/format-code-task-000803/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000803/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-000803/environment/setup/setup.sh b/tasks/format-code-task-000803/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000803/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-000803/tests/test.patch b/tasks/format-code-task-000803/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1e5a1ae13ec8a419199f26e9a27407059a17a849 --- /dev/null +++ b/tasks/format-code-task-000803/tests/test.patch @@ -0,0 +1,103 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..65d14b7 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m unittest tests.test_tools.test_table_default_align -v"] ++} +diff --git a/tests/test_tools/test_table_default_align.py b/tests/test_tools/test_table_default_align.py +new file mode 100644 +index 0000000..7c2d532 +--- /dev/null ++++ b/tests/test_tools/test_table_default_align.py +@@ -0,0 +1,75 @@ ++ ++ ++ ++ ++ ++ ++from unittest import TestCase ++from mdutils.tools.Table import Table ++ ++ ++class TestTableDefaultAlign(TestCase): ++ ++ def test_create_table_default_uses_plain_dashes(self): ++ ++ table = Table() ++ result = table.create_table(columns=2, rows=2, text=['a', 'b', 'c', 'd']) ++ expected = '\n|a|b|\n| --- | --- |\n|c|d|\n' ++ self.assertEqual(result, expected) ++ ++ def test_create_table_default_does_not_use_center(self): ++ ++ table = Table() ++ result = table.create_table(columns=2, rows=2, text=['a', 'b', 'c', 'd']) ++ self.assertNotIn(':---:', result) ++ self.assertNotIn(':---', result) ++ self.assertNotIn('---:', result) ++ ++ def test_create_table_explicit_none_uses_plain_dashes(self): ++ ++ table = Table() ++ result = table.create_table(columns=2, rows=2, ++ text=['a', 'b', 'c', 'd'], text_align=None) ++ expected = '\n|a|b|\n| --- | --- |\n|c|d|\n' ++ self.assertEqual(result, expected) ++ ++ def test_create_table_center_alignment_preserved(self): ++ ++ table = Table() ++ result = table.create_table(columns=2, rows=2, ++ text=['a', 'b', 'c', 'd'], text_align='center') ++ expected = '\n|a|b|\n| :---: | :---: |\n|c|d|\n' ++ self.assertEqual(result, expected) ++ ++ def test_create_table_left_alignment_preserved(self): ++ ++ table = Table() ++ result = table.create_table(columns=2, rows=2, ++ text=['a', 'b', 'c', 'd'], text_align='left') ++ expected = '\n|a|b|\n| :--- | :--- |\n|c|d|\n' ++ self.assertEqual(result, expected) ++ ++ def test_create_table_right_alignment_preserved(self): ++ ++ table = Table() ++ result = table.create_table(columns=2, rows=2, ++ text=['a', 'b', 'c', 'd'], text_align='right') ++ expected = '\n|a|b|\n| ---: | ---: |\n|c|d|\n' ++ self.assertEqual(result, expected) ++ ++ def test_create_table_invalid_text_align_raises(self): ++ ++ table = Table() ++ with self.assertRaises(ValueError): ++ table.create_table(columns=2, rows=2, ++ text=['a', 'b', 'c', 'd'], ++ text_align='invalid') ++ ++ def test_create_table_default_three_columns(self): ++ ++ table = Table() ++ result = table.create_table(columns=3, rows=2, ++ text=['a', 'b', 'c', 'd', 'e', 'f']) ++ self.assertIn('| --- | --- | --- |', result) ++ self.assertNotIn(':---:', result) ++ +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m unittest tests.test_tools.test_table_default_align -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000803/tests/test.sh b/tasks/format-code-task-000803/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..34b2cba7c6a086b965f79223bfa9f1396a9b1339 --- /dev/null +++ b/tasks/format-code-task-000803/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_tools/test_table_default_align.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-000803/tests/test_command.sh b/tasks/format-code-task-000803/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000803/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-000804/environment/Dockerfile b/tasks/format-code-task-000804/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f017b0efb41a37ca884e770844cec768f6a0566a --- /dev/null +++ b/tasks/format-code-task-000804/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:4fd99819fe72b33a0e0247c2963ad22216baaa5da6ace2d51a31c3fe780a7281 diff --git a/tasks/format-code-task-000804/environment/setup/files/blocklist b/tasks/format-code-task-000804/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000804/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-000804/environment/setup/setup.sh b/tasks/format-code-task-000804/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000804/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-000804/tests/test.patch b/tasks/format-code-task-000804/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b472a46b75bac752f44075bb61c200b21fbe23bd --- /dev/null +++ b/tasks/format-code-task-000804/tests/test.patch @@ -0,0 +1,51 @@ +diff --git a/collectors/pool_usage_test.go b/collectors/pool_usage_test.go +index a370def..4866401 100644 +--- a/collectors/pool_usage_test.go ++++ b/collectors/pool_usage_test.go +@@ -128,6 +128,15 @@ func TestPoolUsageCollector(t *testing.T) { + }, + reUnmatch: []*regexp.Regexp{}, + }, ++ { ++ input: ` ++{"pools": [ ++ {"name": "ssd", "id": 11, "stats": {"max_avail": 4618201748262, "objects": 5, "rd": 4, "wr": 6}} ++]}`, ++ reMatch: []*regexp.Regexp{ ++ regexp.MustCompile(`pool_available_bytes{pool="ssd"} 4.618201748262e\+12`), ++ }, ++ }, + } { + func() { + collector := NewPoolUsageCollector(NewNoopConn(tt.input)) +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,15 @@ ++H4sIAAAAAAAAA+2VS2/jNhCAfa1+xSwCdOODSEmO7abdzSVtt5diF9v2VBQGJY1kNhKp8GEkwP74 ++DmUbkQOkyWEXRVt+BkyanBdnhjQrvezqDaodn30pMmK9XI4j8Xgc5/myyItitcjX61mW56tsPYPl ++F4togrdOGICZ0dr9ndxz+/9S2EP9HVq3qXTfC1Uzu/18Pp6pf7HKiof6rwqq/8UqX84g+3whPM3/ ++vP5nr3gpFS+F3SZVDWMTlFgnyRn8oKw3CJ0sjai1TWvcgbQgFWWs67CGc4VY09hoA61OKxy2cP1O ++A/XQIDvhpFbzRDbwCurhpoXUntq64vTNle86KK6+zr8Dt0WVAHEGP8o7EIMDq72pkJw2YRd86ZXz ++7LjayA4B76R1FqhpQ3Sl0TcHK6TzO6QNcHQVJ2P8oMY6UmA1f2Tsj0kAgX73Us2XibFaWlGGvBWT ++k3/6BM54HL02chzIUtqiAz/UwiGkt7cny4f8Q3oftk5SmpAFKtx1h0KROuXkHoIwUnlYr2tOg/U9 ++NEb3IGAwuJPaWzBeJaYPudrLwV5utGUwBHFYD5V2W0ozqaa04DsMc/0nVo6RNE17pCx6y6tOonKb ++VndCtbDL2DcsCwUyeOuloSyUWAlv8VtSS0E62Ao70Wc/UUE7NOdzODfY6x1pSAW7nGXzqca1phyj ++Yb+gm4qKhhZHr/OkEg6ujid48wZev3v/8/vvXyf7+KGVbutLRk3La0k/RKcryh8P7bzBu0EbMpUk ++rYacFUuWJcnhCHCefDVRDvL8eA3I8+KSZKcCzyTnRLZEbdSaD2hu7HjoR/t7zWDS6dI3QWTB8mfc ++0YGxC97okxZZfpnlxWWxWOTFOm3qxaq5KIpMXD4dNf03aBUMXDzti6ZVY/deChIaA2XatPyO2/tx ++46Kg08wf8jgx1AvnHJnw9eGIm+MRqRQOlaU35ZCQHDinlqjJQuWCsaET1YmxJxP+9upFYoe6jO0S ++7sJHr8ZXaNC6A29FixCey9AaYYRwI96GJmOUKnohK6eN5ZDS9YJfSeAD6f0W1K6Pu5Dukn/6HyAS ++iUQikUgkEolEIpFIJBKJRCKRSCQSiUQi/wX+AtxKkycAKAAA +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-000804/tests/test.sh b/tasks/format-code-task-000804/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0c86477b25e671e5e162c630d9204794fbc4fb9 --- /dev/null +++ b/tasks/format-code-task-000804/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' +collectors/pool_usage_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-000804/tests/test_command.sh b/tasks/format-code-task-000804/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000804/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-000832/environment/Dockerfile b/tasks/format-code-task-000832/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9d672140489248c5e7d54a9ba6d2fe41f803b6f0 --- /dev/null +++ b/tasks/format-code-task-000832/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:f16cc91db99dab6e914f98e7ba847de0ffc8385753f93ed8b140c08152b33f03 diff --git a/tasks/format-code-task-000832/environment/setup/files/blocklist b/tasks/format-code-task-000832/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000832/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-000832/environment/setup/setup.sh b/tasks/format-code-task-000832/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000832/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-000832/tests/test.patch b/tasks/format-code-task-000832/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2f7a9d8aeb57546d458f2ef9f968ad38b1f393e7 --- /dev/null +++ b/tasks/format-code-task-000832/tests/test.patch @@ -0,0 +1,105 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..065313e +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/asyncio/test_asyncio_appstore.py -v"] ++} +diff --git a/tests/asyncio/test_asyncio_appstore.py b/tests/asyncio/test_asyncio_appstore.py +index 4b92d24..e6e1f11 100644 +--- a/tests/asyncio/test_asyncio_appstore.py ++++ b/tests/asyncio/test_asyncio_appstore.py +@@ -1,9 +1,10 @@ +-from unittest.mock import patch ++from unittest.mock import AsyncMock, MagicMock, patch + + import pytest + + from inapppy import InAppPyValidationError + from inapppy.asyncio import AppStoreValidator ++from inapppy.asyncio import appstore as appstore_module + + + def test_appstore_validator_initiation_simple(appstore_validator: AppStoreValidator): +@@ -99,3 +100,66 @@ async def test_appstore_auto_retry_wrong_env_request(appstore_validator_auto_ret + await validator.validate(receipt="test-receipt", shared_secret="shared-secret") + assert validator.sandbox is False + assert validator.url == "https://buy.itunes.apple.com/verifyReceipt" ++ ++ ++@pytest.mark.asyncio ++async def test_appstore_aenter_returns_self_for_async_with_as(appstore_validator: AppStoreValidator): ++ """Verifies the issue's reported working example: `async with validator as v` ++ must yield the validator instance (i.e. `__aenter__` must return self), ++ so that the user can call methods on the bound name `v`. ++ """ ++ fake_session = MagicMock() ++ fake_session.close = AsyncMock() ++ with patch.object(appstore_module, "ClientSession", return_value=fake_session): ++ async with appstore_validator as v: ++ assert v is appstore_validator ++ assert v is not None ++ ++ assert v.url == "https://buy.itunes.apple.com/verifyReceipt" ++ ++ ++@pytest.mark.asyncio ++async def test_appstore_aenter_initializes_session(appstore_validator: AppStoreValidator): ++ """Preservation: __aenter__ still initializes _session so that post_json ++ (which uses self._session.post) does not see None. ++ """ ++ fake_session = MagicMock() ++ fake_session.close = AsyncMock() ++ assert appstore_validator._session is None ++ with patch.object(appstore_module, "ClientSession", return_value=fake_session): ++ async with appstore_validator: ++ assert appstore_validator._session is fake_session ++ assert appstore_validator._session is not None ++ ++ ++@pytest.mark.asyncio ++async def test_appstore_aexit_closes_and_clears_session(appstore_validator: AppStoreValidator): ++ """Preservation: __aexit__ still closes and clears the session.""" ++ fake_session = MagicMock() ++ fake_session.close = AsyncMock() ++ with patch.object(appstore_module, "ClientSession", return_value=fake_session): ++ async with appstore_validator: ++ pass ++ fake_session.close.assert_awaited_once() ++ assert appstore_validator._session is None ++ ++ ++@pytest.mark.asyncio ++async def test_appstore_async_with_as_then_validate(appstore_validator: AppStoreValidator): ++ """End-to-end repro of the issue's working example pattern: ++ async with validator as v: ++ result = await v.validate(...) ++ The bound `v` must be the validator instance so the validate call lands on it. ++ """ ++ fake_session = MagicMock() ++ fake_session.close = AsyncMock() ++ ++ async def post_json(self, request_json): ++ return {"status": 0, "ok": True} ++ ++ with patch.object(appstore_module, "ClientSession", return_value=fake_session): ++ with patch.object(AppStoreValidator, "post_json", new=post_json): ++ async with appstore_validator as v: ++ ++ result = await v.validate(receipt="test-receipt", shared_secret="s") ++ assert result == {"status": 0, "ok": True} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/asyncio/test_asyncio_appstore.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000832/tests/test.sh b/tasks/format-code-task-000832/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0f215e03b287c8df3b5c209a3a66b9863c489a2d --- /dev/null +++ b/tasks/format-code-task-000832/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/asyncio/test_asyncio_appstore.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-000832/tests/test_command.sh b/tasks/format-code-task-000832/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000832/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-000835/environment/Dockerfile b/tasks/format-code-task-000835/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8de52353db166d067013640f41da2cd50e065ae5 --- /dev/null +++ b/tasks/format-code-task-000835/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:cf32a2de38df16dc7f95c3e2f0947683b5340d3a2ecfd883be624e7dfd39ccbf diff --git a/tasks/format-code-task-000835/environment/setup/files/blocklist b/tasks/format-code-task-000835/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000835/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-000835/environment/setup/setup.sh b/tasks/format-code-task-000835/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000835/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-000835/tests/test.patch b/tasks/format-code-task-000835/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ac74bc96ce4c4c4f4cebffc0677ff1399e266fb8 --- /dev/null +++ b/tasks/format-code-task-000835/tests/test.patch @@ -0,0 +1,540 @@ +diff --git a/usercase-test-coderl/openai_provider.test.ts b/usercase-test-coderl/openai_provider.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/openai_provider.test.ts +@@ -0,0 +1,507 @@ ++import http, { type IncomingMessage, type ServerResponse } from 'node:http'; ++ ++import { afterEach, describe, expect, it } from 'vitest'; ++ ++import { ++ createProvider, ++ providerConfig, ++} from '../packages/agent/src/core/llm/provider.js'; ++import { OpenAIProvider } from '../packages/agent/src/core/llm/providers/openai.js'; ++ ++type CapturedRequest = { ++ method: string; ++ url: string; ++ authorization: string; ++ body: unknown; ++}; ++ ++type CompletionResponse = { ++ choices: Array<{ ++ message: { ++ content: string | null; ++ tool_calls?: Array<{ ++ id: string; ++ type: 'function'; ++ function: { ++ name: string; ++ arguments: string; ++ }; ++ }>; ++ }; ++ }>; ++ usage?: { ++ prompt_tokens?: number; ++ completion_tokens?: number; ++ }; ++}; ++ ++const openServers: http.Server[] = []; ++ ++const successResponse: CompletionResponse = { ++ choices: [ ++ { ++ message: { ++ content: 'This is a test response', ++ tool_calls: [ ++ { ++ id: 'tool-call-1', ++ type: 'function', ++ function: { ++ name: 'testFunction', ++ arguments: '{"arg1":"value1"}', ++ }, ++ }, ++ ], ++ }, ++ }, ++ ], ++ usage: { ++ prompt_tokens: 10, ++ completion_tokens: 20, ++ }, ++}; ++ ++async function readBody(request: IncomingMessage): Promise { ++ const chunks: Buffer[] = []; ++ for await (const chunk of request) { ++ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)); ++ } ++ return Buffer.concat(chunks).toString('utf8'); ++} ++ ++async function startOpenAICompatibleServer(options?: { ++ response?: CompletionResponse; ++ status?: number; ++ errorBody?: unknown; ++}) { ++ const requests: CapturedRequest[] = []; ++ const response = options?.response ?? successResponse; ++ const status = options?.status ?? 200; ++ ++ const server = http.createServer( ++ async (request: IncomingMessage, reply: ServerResponse) => { ++ const rawBody = await readBody(request); ++ requests.push({ ++ method: request.method ?? '', ++ url: request.url ?? '', ++ authorization: request.headers.authorization ?? '', ++ body: rawBody.length > 0 ? JSON.parse(rawBody) : null, ++ }); ++ ++ reply.statusCode = status; ++ reply.setHeader('content-type', 'application/json'); ++ reply.end( ++ JSON.stringify( ++ status >= 400 ++ ? (options?.errorBody ?? { ++ error: { message: 'local failure' }, ++ }) ++ : response, ++ ), ++ ); ++ }, ++ ); ++ ++ await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve)); ++ openServers.push(server); ++ ++ const address = server.address(); ++ if (!address || typeof address === 'string') { ++ throw new Error('Expected TCP server address'); ++ } ++ ++ return { ++ baseUrl: `http://127.0.0.1:${address.port}/v1`, ++ requests, ++ close: async () => { ++ const index = openServers.indexOf(server); ++ if (index < 0) { ++ return; ++ } ++ await new Promise((resolve, reject) => ++ server.close((error) => (error ? reject(error) : resolve())), ++ ); ++ openServers.splice(index, 1); ++ }, ++ }; ++} ++ ++function activeResourceCount(): number { ++ return process ++ .getActiveResourcesInfo() ++ .filter((resource) => resource === 'TCPServerWrap').length; ++} ++ ++afterEach(async () => { ++ await Promise.all( ++ openServers.splice(0).map( ++ (server) => ++ new Promise((resolve) => { ++ server.close(() => resolve()); ++ }), ++ ), ++ ); ++}); ++ ++describe('OpenAI-compatible LLM provider acceptance', () => { ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ it('sends normalized messages, tools, generation options, and returns normalized response values across repeated calls', async () => { ++ ++ ++ ++ ++ const server = await startOpenAICompatibleServer(); ++ const provider = new OpenAIProvider('gpt-4', { ++ apiKey: 'key-a', ++ baseUrl: server.baseUrl, ++ }); ++ ++ expect(provider.name).toBe('openai'); ++ expect(provider.provider).toBe('openai.chat'); ++ expect(provider.model).toBe('gpt-4'); ++ ++ const firstResponse = await provider.generateText({ ++ messages: [ ++ { role: 'system', content: 'System prompt' }, ++ { role: 'user', content: 'User prompt' }, ++ { role: 'assistant', content: 'Assistant memory' }, ++ { ++ role: 'tool_use', ++ id: 'tool-1', ++ name: 'lookup', ++ content: '{"query":"abc"}', ++ }, ++ { ++ role: 'tool_result', ++ tool_use_id: 'tool-1', ++ content: '{"ok":true}', ++ is_error: false, ++ }, ++ ], ++ functions: [ ++ { ++ name: 'lookup', ++ description: 'Look up a value', ++ parameters: { ++ type: 'object', ++ properties: { query: { type: 'string' } }, ++ required: ['query'], ++ }, ++ }, ++ ], ++ temperature: 0.25, ++ maxTokens: 77, ++ stopSequences: ['END'], ++ topP: 0.9, ++ presencePenalty: 0.1, ++ frequencyPenalty: 0.2, ++ responseFormat: 'json_object', ++ }); ++ ++ ++ expect(server.requests[0]).toEqual(expect.objectContaining({ ++ method: 'POST', ++ url: '/v1/chat/completions', ++ authorization: 'Bearer key-a', ++ body: expect.objectContaining({ ++ model: 'gpt-4', ++ messages: [ ++ { role: 'system', content: 'System prompt' }, ++ { role: 'user', content: 'User prompt' }, ++ { role: 'assistant', content: 'Assistant memory' }, ++ { ++ role: 'assistant', ++ content: '', ++ tool_calls: [ ++ { ++ id: 'tool-1', ++ type: 'function', ++ function: { ++ name: 'lookup', ++ arguments: '{"query":"abc"}', ++ }, ++ }, ++ ], ++ }, ++ { ++ role: 'tool', ++ content: '{"ok":true}', ++ tool_call_id: 'tool-1', ++ }, ++ ], ++ temperature: 0.25, ++ max_tokens: 77, ++ stop: ['END'], ++ top_p: 0.9, ++ presence_penalty: 0.1, ++ frequency_penalty: 0.2, ++ tools: [ ++ { ++ type: 'function', ++ function: { ++ name: 'lookup', ++ description: 'Look up a value', ++ parameters: { ++ type: 'object', ++ properties: { query: { type: 'string' } }, ++ required: ['query'], ++ }, ++ }, ++ }, ++ ], ++ response_format: { type: 'json_object' }, ++ }), ++ })); ++ expect(firstResponse.text).toBe('This is a test response'); ++ expect(firstResponse.toolCalls).toEqual([ ++ { ++ id: 'tool-call-1', ++ name: 'testFunction', ++ content: '{"arg1":"value1"}', ++ }, ++ ]); ++ expect(firstResponse.tokenUsage.input).toBe(10); ++ expect(firstResponse.tokenUsage.output).toBe(20); ++ expect(firstResponse.totalTokens).toBe(30); ++ expect(firstResponse.contextWindow).toBe(8192); ++ ++ const secondResponse = await provider.generateText({ ++ messages: [{ role: 'user', content: 'Second prompt' }], ++ }); ++ ++ ++ expect(server.requests[1]).toEqual(expect.objectContaining({ ++ method: 'POST', ++ url: '/v1/chat/completions', ++ authorization: 'Bearer key-a', ++ body: expect.objectContaining({ ++ model: 'gpt-4', ++ messages: [{ role: 'user', content: 'Second prompt' }], ++ }), ++ })); ++ expect(secondResponse.text).toBe('This is a test response'); ++ expect(secondResponse.toolCalls).toEqual([ ++ { ++ id: 'tool-call-1', ++ name: 'testFunction', ++ content: '{"arg1":"value1"}', ++ }, ++ ]); ++ expect(secondResponse.tokenUsage.input).toBe(10); ++ expect(secondResponse.tokenUsage.output).toBe(20); ++ expect(secondResponse.totalTokens).toBe(30); ++ expect(secondResponse.contextWindow).toBe(8192); ++ ++ await server.close(); ++ }); ++ ++ it('selects OpenAI and xAI through createProvider with documented defaults', () => { ++ ++ ++ ++ ++ const openai = createProvider('openai'); ++ const xai = createProvider('xai'); ++ ++ expect(providerConfig.openai.keyName).toBe('OPENAI_API_KEY'); ++ expect(providerConfig.openai.model).toBe('gpt-4o-2024-05-13'); ++ ++ expect(openai).toBeInstanceOf(OpenAIProvider); ++ expect(openai.name).toBe('openai'); ++ expect(openai.provider).toBe('openai.chat'); ++ expect(openai.model).toBe('gpt-4o-2024-05-13'); ++ ++ expect(providerConfig.xai.keyName).toBe('XAI_API_KEY'); ++ expect(providerConfig.xai.model).toBe('grok-2-latest'); ++ expect(providerConfig.xai.baseUrl).toBe('https://api.x.ai/v1'); ++ ++ expect(xai).toBeInstanceOf(OpenAIProvider); ++ expect(xai.model).toBe('grok-2-latest'); ++ }); ++ ++ it('uses a provided context window for unknown model names', async () => { ++ ++ ++ ++ ++ const server = await startOpenAICompatibleServer(); ++ const provider = new OpenAIProvider('custom-model', { ++ apiKey: 'key-context', ++ baseUrl: server.baseUrl, ++ contextWindow: 4096, ++ }); ++ ++ const response = await provider.generateText({ ++ messages: [{ role: 'user', content: 'Context?' }], ++ }); ++ ++ ++ expect(server.requests[0]).toEqual(expect.objectContaining({ ++ method: 'POST', ++ url: '/v1/chat/completions', ++ authorization: 'Bearer key-context', ++ body: expect.objectContaining({ ++ model: 'custom-model', ++ messages: [{ role: 'user', content: 'Context?' }], ++ }), ++ })); ++ expect(response.contextWindow).toBe(4096); ++ expect(response.totalTokens).toBe(30); ++ ++ await server.close(); ++ }); ++ ++ it('rejects with the specific OpenAI API wrapper error when the compatible API call fails', async () => { ++ ++ ++ ++ ++ const server = await startOpenAICompatibleServer({ ++ status: 500, ++ errorBody: { error: { message: 'local failure' } }, ++ }); ++ const provider = new OpenAIProvider('gpt-4o', { ++ apiKey: 'key-error', ++ baseUrl: server.baseUrl, ++ }); ++ ++ await expect( ++ provider.generateText({ ++ messages: [{ role: 'user', content: 'Please fail' }], ++ }), ++ ).rejects.toThrow(Error); ++ ++ await expect( ++ provider.generateText({ ++ messages: [{ role: 'user', content: 'Please fail again' }], ++ }), ++ ).rejects.toThrow(/^Error calling OpenAI API: .*local failure/); ++ ++ await server.close(); ++ }); ++ ++ it('keeps model and base URL configuration independent across provider instances', async () => { ++ ++ ++ ++ ++ const serverA = await startOpenAICompatibleServer(); ++ const serverB = await startOpenAICompatibleServer(); ++ const providerA = new OpenAIProvider('gpt-4', { ++ apiKey: 'key-a', ++ baseUrl: serverA.baseUrl, ++ }); ++ const providerB = new OpenAIProvider('gpt-4o', { ++ apiKey: 'key-b', ++ baseUrl: serverB.baseUrl, ++ }); ++ ++ await providerA.generateText({ ++ messages: [{ role: 'user', content: 'A first' }], ++ }); ++ await providerB.generateText({ ++ messages: [{ role: 'user', content: 'B first' }], ++ }); ++ await providerA.generateText({ ++ messages: [{ role: 'user', content: 'A second' }], ++ }); ++ ++ expect(providerA.model).toBe('gpt-4'); ++ expect(providerB.model).toBe('gpt-4o'); ++ ++ expect(serverA.requests).toEqual([ ++ expect.objectContaining({ ++ method: 'POST', ++ url: '/v1/chat/completions', ++ authorization: 'Bearer key-a', ++ body: expect.objectContaining({ ++ model: 'gpt-4', ++ messages: [{ role: 'user', content: 'A first' }], ++ }), ++ }), ++ expect.objectContaining({ ++ method: 'POST', ++ url: '/v1/chat/completions', ++ authorization: 'Bearer key-a', ++ body: expect.objectContaining({ ++ model: 'gpt-4', ++ messages: [{ role: 'user', content: 'A second' }], ++ }), ++ }), ++ ]); ++ expect(serverB.requests).toEqual([ ++ expect.objectContaining({ ++ method: 'POST', ++ url: '/v1/chat/completions', ++ authorization: 'Bearer key-b', ++ body: expect.objectContaining({ ++ model: 'gpt-4o', ++ messages: [{ role: 'user', content: 'B first' }], ++ }), ++ }), ++ ]); ++ ++ await serverA.close(); ++ await serverB.close(); ++ }); ++ ++ it('allows repeated cleanup of the local OpenAI-compatible endpoint used by the session', async () => { ++ ++ ++ ++ ++ const server = await startOpenAICompatibleServer(); ++ const provider = new OpenAIProvider('gpt-4', { ++ apiKey: 'key-cleanup', ++ baseUrl: server.baseUrl, ++ }); ++ ++ const response = await provider.generateText({ ++ messages: [{ role: 'user', content: 'Cleanup' }], ++ }); ++ expect(response.text).toBe('This is a test response'); ++ ++ expect(server.requests).toHaveLength(1); ++ ++ await server.close(); ++ }); ++ ++ it('keeps the local endpoint resource count bounded across repeated construct-use-cleanup cycles', async () => { ++ ++ ++ ++ ++ const server = await startOpenAICompatibleServer(); ++ const provider = new OpenAIProvider('gpt-4', { ++ apiKey: 'key-repeated', ++ baseUrl: server.baseUrl, ++ }); ++ ++ for (let index = 0; index < 3; index += 1) { ++ const response = await provider.generateText({ ++ messages: [{ role: 'user', content: `Cycle ${index}` }], ++ }); ++ expect(response.totalTokens).toBe(30); ++ } ++ ++ ++ expect(server.requests).toHaveLength(3); ++ for (const request of server.requests) { ++ expect(request).toEqual(expect.objectContaining({ ++ authorization: 'Bearer key-repeated', ++ body: expect.objectContaining({ model: 'gpt-4' }), ++ })); ++ } ++ ++ await server.close(); ++ }); ++}); +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 ++ ++if [ ! -x ./packages/agent/node_modules/.bin/vitest ]; then ++ echo "Missing local Vitest binary at ./packages/agent/node_modules/.bin/vitest; refusing offline install." >&2 ++ exit 127 ++fi ++ ++exec ./packages/agent/node_modules/.bin/vitest run \ ++ /workspace/repo/usercase-test-coderl/openai_provider.test.ts \ ++ --root /workspace/repo diff --git a/tasks/format-code-task-000835/tests/test.sh b/tasks/format-code-task-000835/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2d1e349f8f6111b01f7fefc9f3a7173b71414a18 --- /dev/null +++ b/tasks/format-code-task-000835/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/openai_provider.test.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-000835/tests/test_command.sh b/tasks/format-code-task-000835/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000835/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-000866/environment/Dockerfile b/tasks/format-code-task-000866/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6839857c2c8b2eb9d1acfa3a1b4acfe37c413b29 --- /dev/null +++ b/tasks/format-code-task-000866/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:eed3263e00a894dc67e3b4579f805ddbb05426d4ef45b17f64f495161cddf48b diff --git a/tasks/format-code-task-000866/environment/setup/files/blocklist b/tasks/format-code-task-000866/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000866/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-000866/environment/setup/setup.sh b/tasks/format-code-task-000866/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000866/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-000866/tests/test.patch b/tasks/format-code-task-000866/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..14c27b7d461026717badb36e93138d24c047e9c4 --- /dev/null +++ b/tasks/format-code-task-000866/tests/test.patch @@ -0,0 +1,209 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..811df295 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/driver/runner_test.py::BulkIndexRunnerTests -v"] ++} +diff --git a/tests/driver/runner_test.py b/tests/driver/runner_test.py +index 044bff50..14026e7e 100644 +--- a/tests/driver/runner_test.py ++++ b/tests/driver/runner_test.py +@@ -665,6 +665,182 @@ class BulkIndexRunnerTests(TestCase): + + es.bulk.assert_called_with(body=bulk_params["body"], params={}) + ++ @mock.patch("elasticsearch.Elasticsearch") ++ def test_simple_bulk_with_ingest_pipeline_stats(self, es): ++ es.bulk.return_value = { ++ "took": 30, ++ "ingest_took": 20, ++ "errors": False, ++ "items": [ ++ { ++ "index": { ++ "_index": "test", ++ "_type": "type1", ++ "_id": "1", ++ "_version": 1, ++ "result": "created", ++ "_shards": { ++ "total": 2, ++ "successful": 1, ++ "failed": 0 ++ }, ++ "created": True, ++ "status": 201, ++ "_seq_no": 0 ++ } ++ } ++ ] ++ } ++ bulk = runner.BulkIndex() ++ ++ bulk_params = { ++ "body": [ ++ "action_meta_data", ++ "index_line" ++ ], ++ "action-metadata-present": True, ++ "detailed-results": False, ++ "bulk-size": 1, ++ "index": "test" ++ } ++ ++ result = bulk(es, bulk_params) ++ ++ self.assertEqual(30, result["took"]) ++ self.assertIn("ingest_took", result) ++ self.assertEqual(20, result["ingest_took"]) ++ ++ @mock.patch("elasticsearch.Elasticsearch") ++ def test_simple_bulk_without_ingest_pipeline_stats(self, es): ++ es.bulk.return_value = { ++ "took": 30, ++ "errors": False, ++ "items": [ ++ { ++ "index": { ++ "_index": "test", ++ "_type": "type1", ++ "_id": "1", ++ "_version": 1, ++ "result": "created", ++ "_shards": { ++ "total": 2, ++ "successful": 1, ++ "failed": 0 ++ }, ++ "created": True, ++ "status": 201, ++ "_seq_no": 0 ++ } ++ } ++ ] ++ } ++ bulk = runner.BulkIndex() ++ ++ bulk_params = { ++ "body": [ ++ "action_meta_data", ++ "index_line" ++ ], ++ "action-metadata-present": True, ++ "detailed-results": False, ++ "bulk-size": 1, ++ "index": "test" ++ } ++ ++ result = bulk(es, bulk_params) ++ ++ self.assertEqual(30, result["took"]) ++ self.assertNotIn("ingest_took", result) ++ ++ @mock.patch("elasticsearch.Elasticsearch") ++ def test_detailed_bulk_with_ingest_pipeline_stats(self, es): ++ es.bulk.return_value = { ++ "took": 30, ++ "ingest_took": 20, ++ "errors": False, ++ "items": [ ++ { ++ "index": { ++ "_index": "test", ++ "_type": "type1", ++ "_id": "1", ++ "_version": 1, ++ "result": "created", ++ "_shards": { ++ "total": 2, ++ "successful": 1, ++ "failed": 0 ++ }, ++ "created": True, ++ "status": 201, ++ "_seq_no": 0 ++ } ++ } ++ ] ++ } ++ bulk = runner.BulkIndex() ++ ++ bulk_params = { ++ "body": [ ++ '{ "index" : { "_index" : "test", "_type" : "type1" } }', ++ '{"location" : [-0.1485188, 51.5250666]}' ++ ], ++ "action-metadata-present": True, ++ "bulk-size": 1, ++ "detailed-results": True, ++ "index": "test" ++ } ++ ++ result = bulk(es, bulk_params) ++ ++ self.assertEqual(30, result["took"]) ++ self.assertIn("ingest_took", result) ++ self.assertEqual(20, result["ingest_took"]) ++ ++ @mock.patch("elasticsearch.Elasticsearch") ++ def test_detailed_bulk_without_ingest_pipeline_stats(self, es): ++ es.bulk.return_value = { ++ "took": 30, ++ "errors": False, ++ "items": [ ++ { ++ "index": { ++ "_index": "test", ++ "_type": "type1", ++ "_id": "1", ++ "_version": 1, ++ "result": "created", ++ "_shards": { ++ "total": 2, ++ "successful": 1, ++ "failed": 0 ++ }, ++ "created": True, ++ "status": 201, ++ "_seq_no": 0 ++ } ++ } ++ ] ++ } ++ bulk = runner.BulkIndex() ++ ++ bulk_params = { ++ "body": [ ++ '{ "index" : { "_index" : "test", "_type" : "type1" } }', ++ '{"location" : [-0.1485188, 51.5250666]}' ++ ], ++ "action-metadata-present": True, ++ "bulk-size": 1, ++ "detailed-results": True, ++ "index": "test" ++ } ++ ++ result = bulk(es, bulk_params) ++ ++ self.assertEqual(30, result["took"]) ++ self.assertNotIn("ingest_took", result) ++ + + class ForceMergeRunnerTests(TestCase): + @mock.patch("elasticsearch.Elasticsearch") +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/driver/runner_test.py::BulkIndexRunnerTests::test_simple_bulk_with_ingest_pipeline_stats tests/driver/runner_test.py::BulkIndexRunnerTests::test_simple_bulk_without_ingest_pipeline_stats tests/driver/runner_test.py::BulkIndexRunnerTests::test_detailed_bulk_with_ingest_pipeline_stats tests/driver/runner_test.py::BulkIndexRunnerTests::test_detailed_bulk_without_ingest_pipeline_stats ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000866/tests/test.sh b/tasks/format-code-task-000866/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4d1bb51c182c84b4bc0c5622ed91daef654f31ee --- /dev/null +++ b/tasks/format-code-task-000866/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/driver/runner_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-000866/tests/test_command.sh b/tasks/format-code-task-000866/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000866/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-000868/environment/Dockerfile b/tasks/format-code-task-000868/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..42fad8207254106e34a1c2e53a48e36225fca5d3 --- /dev/null +++ b/tasks/format-code-task-000868/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:8fa366fb13ac54fd80f482e121feef5a81fe91b99f3719ad3760a4a5178a2643 diff --git a/tasks/format-code-task-000868/environment/setup/files/blocklist b/tasks/format-code-task-000868/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000868/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-000868/environment/setup/setup.sh b/tasks/format-code-task-000868/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000868/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-000868/tests/test.patch b/tasks/format-code-task-000868/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b4cd7a8fbd7a9b760f8e1cec7672ed18953d7f23 --- /dev/null +++ b/tasks/format-code-task-000868/tests/test.patch @@ -0,0 +1,605 @@ +diff --git a/usercase-test-coderl/limit_show_num.test.js b/usercase-test-coderl/limit_show_num.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/limit_show_num.test.js +@@ -0,0 +1,577 @@ ++/* eslint-disable no-console */ ++ ++ ++ ++ ++ ++const assert = require('assert') ++const childProcess = require('child_process') ++const fs = require('fs') ++const http = require('http') ++const https = require('https') ++const net = require('net') ++const os = require('os') ++const path = require('path') ++ ++require('babel-register')({ ++ babelrc: false, ++ presets: [['env', { modules: 'commonjs', targets: { node: 'current' } }], 'stage-2'], ++ plugins: ['transform-object-assign'] ++}) ++ ++const { pie, ring } = require('/workspace/repo/src/packages/pie/main.js') ++ ++function summary (options) { ++ return { ++ data: options.series[0].data, ++ legend: options.legend && options.legend.data, ++ legendShow: options.legend && options.legend.show ++ } ++} ++ ++function assertSummary (options, expected) { ++ ++ assert.deepStrictEqual(summary(options), expected) ++} ++ ++function cloneJson (value) { ++ return JSON.parse(JSON.stringify(value)) ++} ++ ++function escapeRegExp (value) { ++ return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&') ++} ++ ++function numericText (value) { ++ return Number(String(value).replace(/,/g, '')) ++} ++ ++function assertOtherTooltip (formatter, item, expectedEntries) { ++ const actual = formatter(item) ++ ++ ++ assert.match(actual, /其他\s*:/) ++ expectedEntries.forEach(({ name, value, percent }) => { ++ const entry = new RegExp(`${escapeRegExp(name)}:\\s*([^()<>]+?)\\s*\\(([-+]?\\d+(?:\\.\\d+)?)%\\)`) ++ const match = actual.match(entry) ++ assert.ok(match, `expected tooltip entry for ${name} in ${actual}`) ++ assert.strictEqual(numericText(match[1]), value) ++ assert.ok( ++ Math.abs(Number(match[2]) - percent) < 0.01, ++ `expected ${name} percent ${percent}, got ${match[2]}` ++ ) ++ }) ++} ++ ++function assertDeepFrozenCallInputs (fn, columns, rows, settings, extra) { ++ const before = { ++ columns: cloneJson(columns), ++ rows: cloneJson(rows), ++ settings: cloneJson(settings), ++ extra: cloneJson(extra) ++ } ++ fn(columns, rows, settings, extra) ++ assert.deepStrictEqual(columns, before.columns) ++ assert.deepStrictEqual(rows, before.rows) ++ assert.deepStrictEqual(settings, before.settings) ++ assert.deepStrictEqual(extra, before.extra) ++} ++ ++function test (name, fn) { ++ try { ++ fn() ++ console.log('ok - ' + name) ++ } catch (err) { ++ console.error('not ok - ' + name) ++ console.error(err && err.stack ? err.stack : err) ++ process.exitCode = 1 ++ } ++} ++ ++test('pie collapses sorted over-limit slices and expands other tooltip', () => { ++ ++ ++ ++ ++ const actual = pie( ++ ['name', 'value'], ++ [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: 'D', value: 5 }, ++ { name: 'E', value: 15 } ++ ], ++ { limitShowNum: 3 }, ++ { tooltipVisible: true, legendVisible: true } ++ ) ++ ++ assertSummary(actual, { ++ data: [ ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: 'E', value: 15 }, ++ { name: '其他', value: 15 } ++ ], ++ legend: ['B', 'C', 'E', '其他'], ++ legendShow: true ++ }) ++ assertOtherTooltip( ++ actual.tooltip.formatter, ++ { color: '#abc', name: '其他', value: 15, percent: 15 }, ++ [ ++ { name: 'A', value: 10, percent: 10.00 }, ++ { name: 'D', value: 5, percent: 5.00 } ++ ] ++ ) ++}) ++ ++test('ring applies the same collapsed-slice behavior with ring radius', () => { ++ ++ ++ ++ ++ const actual = ring( ++ ['name', 'value'], ++ [ ++ { name: 'X', value: 5 }, ++ { name: 'Y', value: 7 }, ++ { name: 'Z', value: 11 }, ++ { name: 'W', value: 13 } ++ ], ++ { limitShowNum: 2 }, ++ { tooltipVisible: true, legendVisible: true } ++ ) ++ ++ assertSummary(actual, { ++ data: [ ++ { name: 'W', value: 13 }, ++ { name: 'Z', value: 11 }, ++ { name: '其他', value: 12 } ++ ], ++ legend: ['W', 'Z', '其他'], ++ legendShow: true ++ }) ++ assertOtherTooltip( ++ actual.tooltip.formatter, ++ { color: '#abc', name: '其他', value: 12, percent: 33.33 }, ++ [ ++ { name: 'Y', value: 7, percent: 19.44 }, ++ { name: 'X', value: 5, percent: 13.89 } ++ ] ++ ) ++}) ++ ++test('pie with isRing true has collapsed ring data through the public pie call', () => { ++ ++ ++ ++ ++ const actual = pie( ++ ['name', 'value'], ++ [ ++ { name: 'X', value: 5 }, ++ { name: 'Y', value: 7 }, ++ { name: 'Z', value: 11 }, ++ { name: 'W', value: 13 } ++ ], ++ { limitShowNum: 2 }, ++ { tooltipVisible: false, legendVisible: true }, ++ true ++ ) ++ ++ assertSummary(actual, { ++ data: [ ++ { name: 'W', value: 13 }, ++ { name: 'Z', value: 11 }, ++ { name: '其他', value: 12 } ++ ], ++ legend: ['W', 'Z', '其他'], ++ legendShow: true ++ }) ++}) ++ ++test('positive boundary one keeps only the top slice and groups all others', () => { ++ ++ ++ ++ ++ const actual = pie( ++ ['name', 'value'], ++ [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: 'D', value: 5 } ++ ], ++ { limitShowNum: 1 }, ++ { tooltipVisible: true, legendVisible: true } ++ ) ++ ++ assertSummary(actual, { ++ data: [ ++ { name: 'B', value: 50 }, ++ { name: '其他', value: 35 } ++ ], ++ legend: ['B', '其他'], ++ legendShow: true ++ }) ++ assertOtherTooltip( ++ actual.tooltip.formatter, ++ { color: '#abc', name: '其他', value: 35, percent: 41.18 }, ++ [ ++ { name: 'C', value: 20, percent: 23.53 }, ++ { name: 'A', value: 10, percent: 11.76 }, ++ { name: 'D', value: 5, percent: 5.88 } ++ ] ++ ) ++}) ++ ++test('custom dimension and selected metric drive sorting and remainder values', () => { ++ ++ ++ ++ ++ const actual = pie( ++ ['category', 'amount'], ++ [ ++ { category: 'low', amount: 3 }, ++ { category: 'peak', amount: 9 }, ++ { category: 'mid', amount: 6 }, ++ { category: 'tail', amount: 2 } ++ ], ++ { limitShowNum: 2, dimension: 'category', metrics: 'amount' }, ++ { tooltipVisible: true, legendVisible: true } ++ ) ++ ++ assertSummary(actual, { ++ data: [ ++ { name: 'peak', value: 9 }, ++ { name: 'mid', value: 6 }, ++ { name: '其他', value: 5 } ++ ], ++ legend: ['peak', 'mid', '其他'], ++ legendShow: true ++ }) ++ assertOtherTooltip( ++ actual.tooltip.formatter, ++ { color: '#abc', name: '其他', value: 5, percent: 25 }, ++ [ ++ { name: 'low', value: 3, percent: 15.00 }, ++ { name: 'tail', value: 2, percent: 10.00 } ++ ] ++ ) ++}) ++ ++test('omitted limitShowNum preserves all rows without an other slice', () => { ++ ++ ++ ++ ++ const actual = pie( ++ ['name', 'value'], ++ [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 } ++ ], ++ {}, ++ { tooltipVisible: true, legendVisible: true } ++ ) ++ ++ assertSummary(actual, { ++ data: [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 } ++ ], ++ legend: ['A', 'B', 'C'], ++ legendShow: true ++ }) ++}) ++ ++test('zero limitShowNum preserves all rows without sorting or other slice', () => { ++ ++ ++ ++ ++ const actual = pie( ++ ['name', 'value'], ++ [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 } ++ ], ++ { limitShowNum: 0 }, ++ { tooltipVisible: false, legendVisible: true } ++ ) ++ ++ assertSummary(actual, { ++ data: [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 } ++ ], ++ legend: ['A', 'B', 'C'], ++ legendShow: true ++ }) ++}) ++ ++test('limitShowNum equal to row count sorts but does not add other slice', () => { ++ ++ ++ ++ ++ const actual = pie( ++ ['name', 'value'], ++ [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 } ++ ], ++ { limitShowNum: 3 }, ++ { tooltipVisible: false, legendVisible: true } ++ ) ++ ++ assertSummary(actual, { ++ data: [ ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: 'A', value: 10 } ++ ], ++ legend: ['B', 'C', 'A'], ++ legendShow: true ++ }) ++}) ++ ++test('limitShowNum greater than row count sorts but does not add other slice', () => { ++ ++ ++ ++ ++ const actual = pie( ++ ['name', 'value'], ++ [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 } ++ ], ++ { limitShowNum: 5 }, ++ { tooltipVisible: false, legendVisible: true } ++ ) ++ ++ assertSummary(actual, { ++ data: [ ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: 'A', value: 10 } ++ ], ++ legend: ['B', 'C', 'A'], ++ legendShow: true ++ }) ++}) ++ ++test('ring with omitted limitShowNum preserves all rows without an other slice', () => { ++ ++ const actual = ring( ++ ['name', 'value'], ++ [ ++ { name: 'X', value: 5 }, ++ { name: 'Y', value: 7 }, ++ { name: 'Z', value: 11 } ++ ], ++ {}, ++ { tooltipVisible: true, legendVisible: true } ++ ) ++ ++ assertSummary(actual, { ++ data: [ ++ { name: 'X', value: 5 }, ++ { name: 'Y', value: 7 }, ++ { name: 'Z', value: 11 } ++ ], ++ legend: ['X', 'Y', 'Z'], ++ legendShow: true ++ }) ++}) ++ ++test('referential transparency returns the same literal option fragments for repeated calls', () => { ++ const args = [ ++ ['name', 'value'], ++ [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: 'D', value: 5 } ++ ], ++ { limitShowNum: 2 }, ++ { tooltipVisible: true, legendVisible: true } ++ ] ++ assertSummary(pie.apply(null, cloneJson(args)), { ++ data: [ ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: '其他', value: 15 } ++ ], ++ legend: ['B', 'C', '其他'], ++ legendShow: true ++ }) ++ assertSummary(pie.apply(null, cloneJson(args)), { ++ data: [ ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: '其他', value: 15 } ++ ], ++ legend: ['B', 'C', '其他'], ++ legendShow: true ++ }) ++}) ++ ++test('does not mutate caller-owned inputs', () => { ++ assertDeepFrozenCallInputs( ++ pie, ++ ['name', 'value'], ++ [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: 'D', value: 5 } ++ ], ++ { limitShowNum: 2, legendName: { B: 'Bee' } }, ++ { tooltipVisible: true, legendVisible: true } ++ ) ++}) ++ ++test('fresh process result matches in-process result to reject module-global state', () => { ++ const inProcess = summary(pie( ++ ['name', 'value'], ++ [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: 'D', value: 5 } ++ ], ++ { limitShowNum: 2 }, ++ { tooltipVisible: true, legendVisible: true } ++ )) ++ const script = ` ++ require('babel-register')({ ++ babelrc: false, ++ presets: [['env', { modules: 'commonjs', targets: { node: 'current' } }], 'stage-2'], ++ plugins: ['transform-object-assign'] ++ }); ++ const { pie } = require('/workspace/repo/src/packages/pie/main.js'); ++ const options = pie( ++ ['name', 'value'], ++ [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: 'D', value: 5 } ++ ], ++ { limitShowNum: 2 }, ++ { tooltipVisible: true, legendVisible: true } ++ ); ++ process.stdout.write(JSON.stringify({ ++ data: options.series[0].data, ++ legend: options.legend && options.legend.data, ++ legendShow: options.legend && options.legend.show ++ })); ++ ` ++ const fresh = JSON.parse(childProcess.execFileSync(process.execPath, ['-e', script], { ++ cwd: '/workspace/repo', ++ encoding: 'utf8' ++ })) ++ ++ assert.deepStrictEqual(inProcess, { ++ data: [ ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: '其他', value: 15 } ++ ], ++ legend: ['B', 'C', '其他'], ++ legendShow: true ++ }) ++ assert.deepStrictEqual(fresh, inProcess) ++}) ++ ++test('does not perform undeclared filesystem or network side effects', () => { ++ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'pie-limit-side-effects-')) ++ const originalCwd = process.cwd() ++ const original = { ++ writeFileSync: fs.writeFileSync, ++ appendFileSync: fs.appendFileSync, ++ writeFile: fs.writeFile, ++ appendFile: fs.appendFile, ++ createWriteStream: fs.createWriteStream, ++ mkdirSync: fs.mkdirSync, ++ netConnect: net.connect, ++ netCreateConnection: net.createConnection, ++ httpRequest: http.request, ++ httpGet: http.get, ++ httpsRequest: https.request, ++ httpsGet: https.get ++ } ++ const rejectSideEffect = () => { ++ throw new Error('undeclared side effect attempted') ++ } ++ ++ try { ++ process.chdir(tmp) ++ const before = fs.readdirSync('.').sort() ++ fs.writeFileSync = rejectSideEffect ++ fs.appendFileSync = rejectSideEffect ++ fs.writeFile = rejectSideEffect ++ fs.appendFile = rejectSideEffect ++ fs.createWriteStream = rejectSideEffect ++ fs.mkdirSync = rejectSideEffect ++ net.connect = rejectSideEffect ++ net.createConnection = rejectSideEffect ++ http.request = rejectSideEffect ++ http.get = rejectSideEffect ++ https.request = rejectSideEffect ++ https.get = rejectSideEffect ++ ++ const actual = pie( ++ ['name', 'value'], ++ [ ++ { name: 'A', value: 10 }, ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: 'D', value: 5 } ++ ], ++ { limitShowNum: 2 }, ++ { tooltipVisible: true, legendVisible: true } ++ ) ++ ++ assertSummary(actual, { ++ data: [ ++ { name: 'B', value: 50 }, ++ { name: 'C', value: 20 }, ++ { name: '其他', value: 15 } ++ ], ++ legend: ['B', 'C', '其他'], ++ legendShow: true ++ }) ++ assert.deepStrictEqual(fs.readdirSync('.').sort(), before) ++ } finally { ++ fs.writeFileSync = original.writeFileSync ++ fs.appendFileSync = original.appendFileSync ++ fs.writeFile = original.writeFile ++ fs.appendFile = original.appendFile ++ fs.createWriteStream = original.createWriteStream ++ fs.mkdirSync = original.mkdirSync ++ net.connect = original.netConnect ++ net.createConnection = original.netCreateConnection ++ http.request = original.httpRequest ++ http.get = original.httpGet ++ https.request = original.httpsRequest ++ https.get = original.httpsGet ++ process.chdir(originalCwd) ++ fs.rmdirSync(tmp) ++ } ++}) ++ ++process.on('exit', () => { ++ if (process.exitCode) process.exit(process.exitCode) ++}) +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 ++if [ ! -d /workspace/repo/node_modules ]; then ++ echo "node_modules is required for offline test execution" >&2 ++ exit 1 ++fi ++exec node /workspace/repo/usercase-test-coderl/limit_show_num.test.js diff --git a/tasks/format-code-task-000868/tests/test.sh b/tasks/format-code-task-000868/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b55d7687f0586a63a136bf5d5591d181521ca5b7 --- /dev/null +++ b/tasks/format-code-task-000868/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/limit_show_num.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-000868/tests/test_command.sh b/tasks/format-code-task-000868/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000868/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-000892/environment/Dockerfile b/tasks/format-code-task-000892/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1134b7bfae7d5dd7bfcc7e5408dca6b6910da79c --- /dev/null +++ b/tasks/format-code-task-000892/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:d2a34614e3ea18ee967c7fa03cb06bcdcd71d205217a7aedeba87aca11e38e41 diff --git a/tasks/format-code-task-000892/environment/setup/files/blocklist b/tasks/format-code-task-000892/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000892/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-000892/environment/setup/setup.sh b/tasks/format-code-task-000892/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000892/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-000892/tests/test.patch b/tasks/format-code-task-000892/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7b3f6255557dba75fd735fd7f2b7e49fcab31e0d --- /dev/null +++ b/tasks/format-code-task-000892/tests/test.patch @@ -0,0 +1,134 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..6cdc947 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx mocha tests/rules/no-html.test.js --timeout 30000"] ++} +diff --git a/tests/rules/no-html.test.js b/tests/rules/no-html.test.js +index 99a7099..dca4b36 100644 +--- a/tests/rules/no-html.test.js ++++ b/tests/rules/no-html.test.js +@@ -222,5 +222,107 @@ ruleTester.run("no-html", rule, { + }, + ], + }, ++ ++ ++ { ++ code: '
Some content
', ++ errors: [ ++ { ++ messageId: "disallowedElement", ++ line: 1, ++ column: 1, ++ endLine: 1, ++ endColumn: 15, ++ data: { ++ name: "div", ++ }, ++ }, ++ ], ++ }, ++ ++ ++ { ++ code: 'link', ++ errors: [ ++ { ++ messageId: "disallowedElement", ++ line: 1, ++ column: 1, ++ endLine: 1, ++ endColumn: 47, ++ data: { ++ name: "a", ++ }, ++ }, ++ ], ++ }, ++ ++ ++ { ++ code: "
x
", ++ errors: [ ++ { ++ messageId: "disallowedElement", ++ line: 1, ++ column: 1, ++ endLine: 1, ++ endColumn: 18, ++ data: { ++ name: "div", ++ }, ++ }, ++ ], ++ }, ++ ++ ++ { ++ code: 'link', ++ errors: [ ++ { ++ messageId: "disallowedElement", ++ line: 1, ++ column: 1, ++ endLine: 1, ++ endColumn: 18, ++ data: { ++ name: "a", ++ }, ++ }, ++ ], ++ }, ++ ++ ++ { ++ code: "
x
", ++ errors: [ ++ { ++ messageId: "disallowedElement", ++ line: 1, ++ column: 1, ++ endLine: 1, ++ endColumn: 9, ++ data: { ++ name: "div", ++ }, ++ }, ++ ], ++ }, ++ ++ ++ { ++ code: '\n\nx', ++ errors: [ ++ { ++ messageId: "disallowedElement", ++ line: 1, ++ column: 1, ++ endLine: 1, ++ endColumn: 3, ++ data: { ++ name: "p", ++ }, ++ }, ++ ], ++ }, + ], + }); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx mocha tests/rules/no-html.test.js --timeout 30000 ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000892/tests/test.sh b/tasks/format-code-task-000892/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..114e5b1583fb672e80a884f0c75d973c31e4044a --- /dev/null +++ b/tasks/format-code-task-000892/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/rules/no-html.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-000892/tests/test_command.sh b/tasks/format-code-task-000892/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000892/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-000947/environment/Dockerfile b/tasks/format-code-task-000947/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..68f21c2c14850988af4addcb008c71567956c13c --- /dev/null +++ b/tasks/format-code-task-000947/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:f460883479ea13ad8d6871d71b35daf03889df5372d766412b520cc996275b7e diff --git a/tasks/format-code-task-000947/environment/setup/files/blocklist b/tasks/format-code-task-000947/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000947/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-000947/environment/setup/setup.sh b/tasks/format-code-task-000947/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000947/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-000947/tests/test.patch b/tasks/format-code-task-000947/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..772c9b629611c1d043911f63e25a8504092d8b6f --- /dev/null +++ b/tasks/format-code-task-000947/tests/test.patch @@ -0,0 +1,51 @@ +diff --git a/spec/ffi/pointer_spec.rb b/spec/ffi/pointer_spec.rb +index f75d28d..f49a69c 100644 +--- a/spec/ffi/pointer_spec.rb ++++ b/spec/ffi/pointer_spec.rb +@@ -233,10 +233,24 @@ describe "Pointer" do + expect(FFI::Pointer.new(0).size_limit?).to be false + end + ++ it "is available on memory pointers" do ++ memory_pointer = FFI::MemoryPointer.new(:int, 10) ++ ++ expect(memory_pointer).to respond_to(:size_limit?) ++ expect { memory_pointer.size_limit? }.not_to raise_error ++ expect([true, false]).to include(memory_pointer.size_limit?) ++ end ++ ++ it "returns true for bounded memory pointers" do ++ expect(FFI::MemoryPointer.new(:int, 10).size_limit?).to be true ++ expect(FFI::MemoryPointer.new(:char, 4).size_limit?).to be true ++ expect(FFI::Buffer.new(:int, 2).size_limit?).to be true ++ end ++ + it "should have size limit" do + expect(FFI::Pointer.new(0).slice(0, 10).size_limit?).to be true + end +- end if RUBY_ENGINE != "truffleruby" ++ end + end + + describe "AutoPointer" do +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ bundle exec rspec spec/ffi/pointer_spec.rb:232 spec/ffi/pointer_spec.rb:250 ++ ;; ++ new) ++ bundle exec rspec spec/ffi/pointer_spec.rb:232 spec/ffi/pointer_spec.rb:236 spec/ffi/pointer_spec.rb:244 spec/ffi/pointer_spec.rb:250 ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000947/tests/test.sh b/tasks/format-code-task-000947/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a6acb9a759e6be30be281a38c3b997476b96f1ea --- /dev/null +++ b/tasks/format-code-task-000947/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +spec/ffi/pointer_spec.rb +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000947/tests/test_command.sh b/tasks/format-code-task-000947/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000947/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-000971/environment/Dockerfile b/tasks/format-code-task-000971/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3c30349500fd3998d1597da57552210b5e48c4ed --- /dev/null +++ b/tasks/format-code-task-000971/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:e72d3ae43f52290f637713986ba2efdafdfdf6950bb617b540770aa75475510a diff --git a/tasks/format-code-task-000971/environment/setup/files/blocklist b/tasks/format-code-task-000971/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000971/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-000971/environment/setup/setup.sh b/tasks/format-code-task-000971/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000971/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-000971/tests/test.patch b/tasks/format-code-task-000971/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..afc174cecc487af0916fc59ad6ba719e994105ae --- /dev/null +++ b/tasks/format-code-task-000971/tests/test.patch @@ -0,0 +1,135 @@ +diff --git a/synthesis_tests/test_versioneer_resilience.py b/synthesis_tests/test_versioneer_resilience.py +new file mode 100644 +index 00000000..e1c00941 +--- /dev/null ++++ b/synthesis_tests/test_versioneer_resilience.py +@@ -0,0 +1,120 @@ ++import importlib.util ++import os ++import tempfile ++import unittest ++ ++import versioneer ++ ++ ++def load_runtime_version_module(): ++ path = os.path.join(os.path.dirname(os.path.dirname(__file__)), ++ "pyemma", "_version.py") ++ spec = importlib.util.spec_from_file_location("pyemma_runtime_version", path) ++ module = importlib.util.module_from_spec(spec) ++ spec.loader.exec_module(module) ++ return module ++ ++ ++class VersioneerResilienceTests(unittest.TestCase): ++ def setUp(self): ++ self.runtime = load_runtime_version_module() ++ self.root = tempfile.mkdtemp(prefix="versioneer-test-") ++ open(os.path.join(self.root, ".git"), "w").close() ++ ++ def tearDown(self): ++ os.unlink(os.path.join(self.root, ".git")) ++ os.rmdir(self.root) ++ ++ @staticmethod ++ def runner(describe, full="0123456789abcdef", count="7"): ++ def run(commands, args, cwd=None, **kwargs): ++ if args[0] == "describe": ++ return describe ++ if args[0] == "rev-parse": ++ return full ++ if args[0] == "rev-list": ++ return count ++ raise AssertionError("unexpected command: %r" % (args,)) ++ return run ++ ++ def test_tagged_history_keeps_existing_shape_in_both_copies(self): ++ run = self.runner("v2.4-3-gabcdef0-dirty") ++ expected = { ++ "closest-tag": "2.4", ++ "distance": 3, ++ "short": "abcdef0", ++ "dirty": True, ++ "long": "0123456789abcdef", ++ "error": None, ++ } ++ self.assertEqual(versioneer.git_pieces_from_vcs("v", self.root, False, run), expected) ++ self.assertEqual(self.runtime.git_pieces_from_vcs("v", self.root, False, run), expected) ++ ++ def test_untagged_history_uses_numeric_count_in_both_copies(self): ++ run = self.runner("abcdef0", count="12\n") ++ for module in (versioneer, self.runtime): ++ pieces = module.git_pieces_from_vcs("v", self.root, False, run) ++ self.assertIsNone(pieces["closest-tag"]) ++ self.assertEqual(pieces["distance"], 12) ++ self.assertEqual(pieces["short"], "0123456") ++ self.assertIsNone(pieces["error"]) ++ ++ def test_missing_count_is_a_structured_error_not_an_exception(self): ++ run = self.runner("abcdef0", count=None) ++ for module in (versioneer, self.runtime): ++ try: ++ pieces = module.git_pieces_from_vcs("v", self.root, False, run) ++ except Exception as exc: ++ self.fail("git metadata failure should be returned as error data: %s" % exc) ++ self.assertIsNone(pieces["closest-tag"]) ++ self.assertIsNone(pieces.get("distance")) ++ self.assertIsInstance(pieces["error"], str) ++ rendered = module.render(pieces, "pep440") ++ self.assertEqual(rendered["version"], "unknown") ++ self.assertEqual(rendered["error"], pieces["error"]) ++ ++ def test_non_numeric_count_is_a_structured_error_not_an_exception(self): ++ run = self.runner("abcdef0", count="not-a-count") ++ for module in (versioneer, self.runtime): ++ try: ++ pieces = module.git_pieces_from_vcs("v", self.root, False, run) ++ except Exception as exc: ++ self.fail("git metadata failure should be returned as error data: %s" % exc) ++ self.assertIsInstance(pieces["error"], str) ++ self.assertTrue(pieces["error"].strip()) ++ ++ def test_public_build_lookup_falls_back_when_provider_raises(self): ++ original_keywords = versioneer.HANDLERS["git"]["keywords"] ++ original_vcs = versioneer.HANDLERS["git"]["pieces_from_vcs"] ++ try: ++ versioneer.HANDLERS["git"]["keywords"] = lambda *a: (_ for _ in ()).throw(versioneer.NotThisMethod()) ++ versioneer.HANDLERS["git"]["pieces_from_vcs"] = lambda *a: (_ for _ in ()).throw(ValueError("bad count")) ++ try: ++ result = versioneer.get_versions() ++ except Exception as exc: ++ self.fail("public lookup should degrade to unknown version: %s" % exc) ++ finally: ++ versioneer.HANDLERS["git"]["keywords"] = original_keywords ++ versioneer.HANDLERS["git"]["pieces_from_vcs"] = original_vcs ++ self.assertEqual(result["version"], "0+unknown") ++ self.assertIsNotNone(result["error"]) ++ ++ def test_public_runtime_lookup_falls_back_when_provider_raises(self): ++ original_keywords = self.runtime.git_versions_from_keywords ++ original_vcs = self.runtime.git_pieces_from_vcs ++ try: ++ self.runtime.git_versions_from_keywords = lambda *a: (_ for _ in ()).throw(self.runtime.NotThisMethod()) ++ self.runtime.git_pieces_from_vcs = lambda *a: (_ for _ in ()).throw(ValueError("bad count")) ++ try: ++ result = self.runtime.get_versions() ++ except Exception as exc: ++ self.fail("public lookup should degrade to unknown version: %s" % exc) ++ finally: ++ self.runtime.git_versions_from_keywords = original_keywords ++ self.runtime.git_pieces_from_vcs = original_vcs ++ self.assertEqual(result["version"], "0+unknown") ++ self.assertIsNotNone(result["error"]) ++ ++ ++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,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++python -m unittest synthesis_tests.test_versioneer_resilience -v diff --git a/tasks/format-code-task-000971/tests/test.sh b/tasks/format-code-task-000971/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..85311a614b676f53cb34912d478c1ca3e39a46ad --- /dev/null +++ b/tasks/format-code-task-000971/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' +synthesis_tests/test_versioneer_resilience.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-000971/tests/test_command.sh b/tasks/format-code-task-000971/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000971/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-000976/environment/Dockerfile b/tasks/format-code-task-000976/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c791c3c7f802204a994ab1afec968ed8fe9d98f6 --- /dev/null +++ b/tasks/format-code-task-000976/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:dbce2ec4ec5075a466547d5e6e633a2da4b1ac0883f18635a7ec30d4903cea63 diff --git a/tasks/format-code-task-000976/environment/setup/files/blocklist b/tasks/format-code-task-000976/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000976/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-000976/environment/setup/setup.sh b/tasks/format-code-task-000976/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000976/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-000976/tests/test.patch b/tasks/format-code-task-000976/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e4d069334063609cb7266958a5168f3de9bc99d2 --- /dev/null +++ b/tasks/format-code-task-000976/tests/test.patch @@ -0,0 +1,35 @@ +diff --git a/tests/unit/neptune/new/internal/backends/test_nql_contract.py b/tests/unit/neptune/new/internal/backends/test_nql_contract.py +new file mode 100644 +index 00000000..77337127 +--- /dev/null ++++ b/tests/unit/neptune/new/internal/backends/test_nql_contract.py +@@ -0,0 +1,20 @@ ++import json ++ ++from neptune.internal.backends.nql import NQLAggregator, NQLAttributeOperator, NQLAttributeType, NQLEmptyQuery, NQLQueryAggregate, NQLQueryAttribute, RawNQLQuery ++ ++def test_literals(): ++ text = 'owner "quoted"\\line\nnext' ++ assert str(NQLQueryAttribute("sys/owner", NQLAttributeType.STRING, NQLAttributeOperator.EQUALS, text)) == f"(`sys/owner`:string = {json.dumps(text)})" ++ assert str(NQLQueryAttribute("count", NQLAttributeType.INTEGER, NQLAttributeOperator.GREATER_THAN, 7)) == "(`count`:integer > 7)" ++ assert str(NQLQueryAttribute("ratio", NQLAttributeType.FLOAT, NQLAttributeOperator.EQUALS, 1.25)) == "(`ratio`:float = 1.25)" ++ assert str(NQLQueryAttribute("sys/trashed", NQLAttributeType.BOOLEAN, NQLAttributeOperator.EQUALS, False)) == "(`sys/trashed`:bool = false)" ++ ++def test_aggregate_preserves_items(): ++ keep = NQLQueryAttribute("name", NQLAttributeType.STRING, NQLAttributeOperator.EQUALS, "alice") ++ original = [NQLEmptyQuery(), keep] ++ aggregate = NQLQueryAggregate(items=original, aggregator=NQLAggregator.AND) ++ assert aggregate.eval() == keep ++ assert aggregate.items == original ++ ++def test_raw_whitespace_empty(): ++ assert RawNQLQuery(" \t\n").eval() == NQLEmptyQuery() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++.venv/bin/pytest -q tests/unit/neptune/new/internal/backends/test_nql_contract.py diff --git a/tasks/format-code-task-000976/tests/test.sh b/tasks/format-code-task-000976/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4ca057babf0267817758a2ce531bd0cbf8762036 --- /dev/null +++ b/tasks/format-code-task-000976/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/neptune/new/internal/backends/test_nql_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000976/tests/test_command.sh b/tasks/format-code-task-000976/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000976/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-000978/environment/Dockerfile b/tasks/format-code-task-000978/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9a8acd360a9970a5e657ef6d1da2f0eb34cf50c8 --- /dev/null +++ b/tasks/format-code-task-000978/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:0214781161f04e77611bb1d72e4017a15fdc636a927ab7ad8b47f4343135e6cd diff --git a/tasks/format-code-task-000978/environment/setup/files/blocklist b/tasks/format-code-task-000978/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000978/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-000978/environment/setup/setup.sh b/tasks/format-code-task-000978/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000978/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-000978/tests/test.patch b/tasks/format-code-task-000978/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7da9b3266a536bcd79ae3d98f581fb6e0c109de9 --- /dev/null +++ b/tasks/format-code-task-000978/tests/test.patch @@ -0,0 +1,158 @@ +diff --git a/rest/model/subscriber_compatibility_test.go b/rest/model/subscriber_compatibility_test.go +new file mode 100644 +index 000000000..c8aa6543d +--- /dev/null ++++ b/rest/model/subscriber_compatibility_test.go +@@ -0,0 +1,142 @@ ++package model ++ ++import ( ++ "encoding/json" ++ "net/http" ++ "testing" ++ ++ "github.com/evergreen-ci/evergreen/model/event" ++ "github.com/evergreen-ci/utility" ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++) ++ ++func TestRunChildPatchSubscriberRoundTrip(t *testing.T) { ++ original := event.Subscriber{ ++ Type: event.RunChildPatchSubscriberType, ++ Target: event.ChildPatchSubscriber{ ++ ParentStatus: "failed", ++ ChildPatchId: "patch-123", ++ Requester: "github_pr", ++ }, ++ } ++ ++ api := APISubscriber{} ++ require.NoError(t, api.BuildFromService(original)) ++ require.Equal(t, event.RunChildPatchSubscriberType, utility.FromStringPtr(api.Type)) ++ targetBytes, err := json.Marshal(api.Target) ++ require.NoError(t, err) ++ var target map[string]any ++ require.NoError(t, json.Unmarshal(targetBytes, &target)) ++ assert.Equal(t, "failed", target["parent_status"]) ++ assert.Equal(t, "patch-123", target["child_patch_id"]) ++ assert.Equal(t, "github_pr", target["requester"]) ++ ++ converted, err := api.ToService() ++ require.NoError(t, err) ++ assert.Equal(t, original.Type, converted.Type) ++ assertChildPatchTargetEqual(t, original.Target, converted.Target) ++} ++ ++func TestRunChildPatchSubscriberAcceptsJSONTarget(t *testing.T) { ++ api := APISubscriber{ ++ Type: utility.ToStringPtr(event.RunChildPatchSubscriberType), ++ Target: map[string]any{ ++ "parent_status": "success", ++ "child_patch_id": "patch-456", ++ "requester": "api", ++ }, ++ } ++ ++ converted, err := api.ToService() ++ require.NoError(t, err) ++ assert.Equal(t, event.RunChildPatchSubscriberType, converted.Type) ++ assertChildPatchTargetEqual(t, event.ChildPatchSubscriber{ ++ ParentStatus: "success", ++ ChildPatchId: "patch-456", ++ Requester: "api", ++ }, converted.Target) ++} ++ ++func TestGithubPRSubscriberPreservesChildMetadata(t *testing.T) { ++ original := event.Subscriber{ ++ Type: event.GithubPullRequestSubscriberType, ++ Target: event.GithubPullRequestSubscriber{ ++ Owner: "octo", ++ Repo: "evergreen", ++ PRNumber: 42, ++ Ref: "feature", ++ ChildId: "child-1", ++ Type: "merge", ++ }, ++ } ++ ++ api := APISubscriber{} ++ require.NoError(t, api.BuildFromService(original)) ++ targetBytes, err := json.Marshal(api.Target) ++ require.NoError(t, err) ++ var target map[string]any ++ require.NoError(t, json.Unmarshal(targetBytes, &target)) ++ assert.Equal(t, "child-1", target["child"]) ++ assert.Equal(t, "merge", target["type"]) ++ ++ converted, err := api.ToService() ++ require.NoError(t, err) ++ assert.Equal(t, original.Type, converted.Type) ++ var convertedTarget event.GithubPullRequestSubscriber ++ switch target := converted.Target.(type) { ++ case event.GithubPullRequestSubscriber: ++ convertedTarget = target ++ case *event.GithubPullRequestSubscriber: ++ require.NotNil(t, target) ++ convertedTarget = *target ++ default: ++ require.Failf(t, "unexpected target type", "%T", converted.Target) ++ } ++ assert.Equal(t, original.Target.(event.GithubPullRequestSubscriber), convertedTarget) ++} ++ ++func assertChildPatchTargetEqual(t *testing.T, expected, actual any) { ++ t.Helper() ++ expectedTarget := expected.(event.ChildPatchSubscriber) ++ var actualTarget event.ChildPatchSubscriber ++ switch target := actual.(type) { ++ case event.ChildPatchSubscriber: ++ actualTarget = target ++ case *event.ChildPatchSubscriber: ++ require.NotNil(t, target) ++ actualTarget = *target ++ default: ++ require.Failf(t, "unexpected target type", "%T", actual) ++ } ++ assert.Equal(t, expectedTarget, actualTarget) ++} ++ ++func TestStructuredSubscriberBuildAcceptsValueAndPointerTargets(t *testing.T) { ++ cases := []event.Subscriber{ ++ {Type: event.GithubCheckSubscriberType, Target: event.GithubCheckSubscriber{Owner: "o", Repo: "r", Ref: "main"}}, ++ {Type: event.GithubMergeSubscriberType, Target: &event.GithubMergeSubscriber{Owner: "o", Repo: "r", Ref: "main"}}, ++ {Type: event.EvergreenWebhookSubscriberType, Target: event.WebhookSubscriber{URL: "https://example.test", Secret: []byte("secret")}}, ++ {Type: event.JIRAIssueSubscriberType, Target: &event.JIRAIssueSubscriber{Project: "EVG", IssueType: "Bug"}}, ++ } ++ for _, original := range cases { ++ t.Run(original.Type, func(t *testing.T) { ++ api := APISubscriber{} ++ require.NoError(t, api.BuildFromService(original)) ++ require.NotNil(t, api.Target) ++ }) ++ } ++} ++ ++func TestRunChildPatchMalformedTargetReturnsBadRequest(t *testing.T) { ++ api := APISubscriber{ ++ Type: utility.ToStringPtr(event.RunChildPatchSubscriberType), ++ Target: map[string]any{"parent_status": 17}, ++ } ++ ++ _, err := api.ToService() ++ require.Error(t, err) ++ assert.Contains(t, err.Error(), "400") ++ assert.Contains(t, err.Error(), http.StatusText(http.StatusBadRequest)) ++ assert.Contains(t, err.Error(), "malformed") ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++go test ./rest/model -run 'TestRunChildPatchSubscriberRoundTrip|TestRunChildPatchSubscriberAcceptsJSONTarget|TestGithubPRSubscriberPreservesChildMetadata|TestStructuredSubscriberBuildAcceptsValueAndPointerTargets|TestRunChildPatchMalformedTargetReturnsBadRequest|TestSubscriberModels.*|TestSubscriptionModels' -count=1 diff --git a/tasks/format-code-task-000978/tests/test.sh b/tasks/format-code-task-000978/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..29ab5f1651778ec210667e468b8ce2dfa20a19ab --- /dev/null +++ b/tasks/format-code-task-000978/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' +rest/model/subscriber_compatibility_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-000978/tests/test_command.sh b/tasks/format-code-task-000978/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000978/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-000985/environment/Dockerfile b/tasks/format-code-task-000985/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f05732520aadff6b18c0278c5d91b71313592cca --- /dev/null +++ b/tasks/format-code-task-000985/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:cd2a7b781c622ced4aa26889d2e5332a61c28309bd7a268e4714c108d61f8320 diff --git a/tasks/format-code-task-000985/environment/setup/files/blocklist b/tasks/format-code-task-000985/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000985/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-000985/environment/setup/setup.sh b/tasks/format-code-task-000985/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000985/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-000985/tests/test.patch b/tasks/format-code-task-000985/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c50748a0a0940c79b52f33503446b390e1d97735 --- /dev/null +++ b/tasks/format-code-task-000985/tests/test.patch @@ -0,0 +1,374 @@ +diff --git a/lib/lru/lru_codespec_test.go b/lib/lru/lru_codespec_test.go +new file mode 100644 +index 0000000..5784f7d +--- /dev/null ++++ b/lib/lru/lru_codespec_test.go +@@ -0,0 +1,358 @@ ++package lru_test ++ ++import ( ++ "fmt" ++ "reflect" ++ "strings" ++ "sync" ++ "testing" ++ ++ "awesome-golang-algorithm/lib/lru" ++) ++ ++type sizedString string ++ ++func (s sizedString) Len() int { return len(s) } ++ ++type byteCache interface { ++ Bytes() int64 ++} ++ ++type peekCache interface { ++ Peek(string) (lru.Value, bool) ++} ++ ++type removeCache interface { ++ Remove(string) bool ++} ++ ++type purgeCache interface { ++ Purge() ++} ++ ++type resizeCache interface { ++ Resize(int64) int ++} ++ ++type extendedCache interface { ++ byteCache ++ peekCache ++ removeCache ++ purgeCache ++ resizeCache ++} ++ ++func requireBytes(t *testing.T, c *lru.Cache) byteCache { ++ t.Helper() ++ api, ok := any(c).(byteCache) ++ if !ok { ++ t.Fatalf("Cache must expose Bytes() int64") ++ } ++ return api ++} ++ ++func requirePeek(t *testing.T, c *lru.Cache) peekCache { ++ t.Helper() ++ api, ok := any(c).(peekCache) ++ if !ok { ++ t.Fatalf("Cache must expose Peek(string) (Value, bool)") ++ } ++ return api ++} ++ ++func requireRemove(t *testing.T, c *lru.Cache) removeCache { ++ t.Helper() ++ api, ok := any(c).(removeCache) ++ if !ok { ++ t.Fatalf("Cache must expose Remove(string) bool") ++ } ++ return api ++} ++ ++func requirePurge(t *testing.T, c *lru.Cache) purgeCache { ++ t.Helper() ++ api, ok := any(c).(purgeCache) ++ if !ok { ++ t.Fatalf("Cache must expose Purge()") ++ } ++ return api ++} ++ ++func requireResize(t *testing.T, c *lru.Cache) resizeCache { ++ t.Helper() ++ api, ok := any(c).(resizeCache) ++ if !ok { ++ t.Fatalf("Cache must expose Resize(int64) int") ++ } ++ return api ++} ++ ++func requireExtended(t *testing.T, c *lru.Cache) extendedCache { ++ t.Helper() ++ api, ok := any(c).(extendedCache) ++ if !ok { ++ t.Fatalf("Cache must expose the complete lifecycle API") ++ } ++ return api ++} ++ ++func assertValue(t *testing.T, value lru.Value, ok bool, want string) { ++ t.Helper() ++ if !ok { ++ t.Fatalf("expected cached value %q, got a miss", want) ++ } ++ got, typeOK := value.(sizedString) ++ if !typeOK || string(got) != want { ++ t.Fatalf("cached value = %#v, want sizedString(%q)", value, want) ++ } ++} ++ ++func TestCodespecExtendedAPISurface(t *testing.T) { ++ c := lru.New(0, nil) ++ requireExtended(t, c) ++} ++ ++func TestCodespecReplacementAccountingAndRecency(t *testing.T) { ++ var evicted []string ++ c := lru.New(10, func(key string, value lru.Value) { ++ evicted = append(evicted, fmt.Sprintf("%s=%s", key, value.(sizedString))) ++ }) ++ bytes := requireBytes(t, c) ++ peek := requirePeek(t, c) ++ ++ c.Add("a", sizedString("1111")) ++ c.Add("b", sizedString("2222")) ++ if got := bytes.Bytes(); got != 10 { ++ t.Fatalf("Bytes after two inserts = %d, want 10", got) ++ } ++ ++ c.Add("a", sizedString("x")) ++ if got := bytes.Bytes(); got != 7 { ++ t.Fatalf("Bytes after shrinking replacement = %d, want 7", got) ++ } ++ if len(evicted) != 0 { ++ t.Fatalf("replacement unexpectedly invoked OnEvicted for %v", evicted) ++ } ++ ++ c.Add("c", sizedString("zz")) ++ if got := bytes.Bytes(); got != 10 || c.Len() != 3 { ++ t.Fatalf("exact-capacity cache has Bytes=%d Len=%d, want 10 and 3", got, c.Len()) ++ } ++ ++ c.Add("a", sizedString("1234567")) ++ if got := bytes.Bytes(); got != 8 || c.Len() != 1 { ++ t.Fatalf("after growing replacement Bytes=%d Len=%d, want 8 and 1", got, c.Len()) ++ } ++ value, ok := peek.Peek("a") ++ assertValue(t, value, ok, "1234567") ++ if !reflect.DeepEqual(evicted, []string{"b=2222", "c=zz"}) { ++ t.Fatalf("replacement eviction records = %v, want [b=2222 c=zz]", evicted) ++ } ++} ++ ++func TestCodespecPeekDoesNotPromote(t *testing.T) { ++ c := lru.New(4, nil) ++ peek := requirePeek(t, c) ++ c.Add("a", sizedString("1")) ++ c.Add("b", sizedString("2")) ++ ++ value, ok := peek.Peek("a") ++ assertValue(t, value, ok, "1") ++ if value, ok := peek.Peek("missing"); ok || value != nil { ++ t.Fatalf("Peek miss = (%#v, %v), want (nil, false)", value, ok) ++ } ++ c.Add("c", sizedString("3")) ++ if _, ok := peek.Peek("a"); ok { ++ t.Fatal("Peek promoted a; it should have been the capacity eviction") ++ } ++ ++ if _, ok := c.Get("b"); !ok { ++ t.Fatal("expected b before checking Get recency") ++ } ++ c.Add("d", sizedString("4")) ++ if _, ok := peek.Peek("c"); ok { ++ t.Fatal("Get did not promote b; c should have been evicted") ++ } ++ value, ok = peek.Peek("b") ++ assertValue(t, value, ok, "2") ++ value, ok = peek.Peek("d") ++ assertValue(t, value, ok, "4") ++} ++ ++func TestCodespecRemoveAndMissingKey(t *testing.T) { ++ var evicted []string ++ c := lru.New(0, func(key string, value lru.Value) { ++ evicted = append(evicted, fmt.Sprintf("%s=%s", key, value.(sizedString))) ++ }) ++ bytes := requireBytes(t, c) ++ peek := requirePeek(t, c) ++ remove := requireRemove(t, c) ++ c.Add("a", sizedString("12")) ++ c.Add("b", sizedString("345")) ++ ++ if !remove.Remove("a") { ++ t.Fatal("Remove returned false for an existing key") ++ } ++ if _, ok := peek.Peek("a"); ok || c.Len() != 1 || bytes.Bytes() != 4 { ++ t.Fatalf("state after Remove: present=%v Len=%d Bytes=%d, want false, 1, 4", ok, c.Len(), bytes.Bytes()) ++ } ++ if remove.Remove("absent") { ++ t.Fatal("Remove returned true for a missing key") ++ } ++ if !reflect.DeepEqual(evicted, []string{"a=12"}) { ++ t.Fatalf("Remove callbacks = %v, want [a=12]", evicted) ++ } ++} ++ ++func TestCodespecRemoveOldestUsesCurrentRecency(t *testing.T) { ++ var evicted []string ++ c := lru.New(0, func(key string, value lru.Value) { ++ evicted = append(evicted, fmt.Sprintf("%s=%s", key, value.(sizedString))) ++ }) ++ bytes := requireBytes(t, c) ++ c.Add("a", sizedString("1")) ++ c.Add("b", sizedString("22")) ++ if _, ok := c.Get("a"); !ok { ++ t.Fatal("expected Get hit for a") ++ } ++ c.RemoveOldest() ++ if _, ok := c.Get("b"); ok || c.Len() != 1 || bytes.Bytes() != 2 { ++ t.Fatalf("RemoveOldest left invalid state: bPresent=%v Len=%d Bytes=%d", ok, c.Len(), bytes.Bytes()) ++ } ++ c.RemoveOldest() ++ c.RemoveOldest() ++ if !reflect.DeepEqual(evicted, []string{"b=22", "a=1"}) { ++ t.Fatalf("RemoveOldest callbacks = %v, want [b=22 a=1]", evicted) ++ } ++} ++ ++func TestCodespecPurgeClearsExactlyOnce(t *testing.T) { ++ counts := map[string]int{} ++ var badPayload []string ++ c := lru.New(0, func(key string, value lru.Value) { ++ counts[key]++ ++ got, ok := value.(sizedString) ++ if !ok || string(got) != key { ++ badPayload = append(badPayload, key) ++ } ++ }) ++ api := requireExtended(t, c) ++ for _, key := range []string{"a", "bb", "ccc"} { ++ c.Add(key, sizedString(key)) ++ } ++ api.Purge() ++ if len(badPayload) != 0 { ++ t.Fatalf("Purge callbacks carried wrong values for keys %v", badPayload) ++ } ++ if c.Len() != 0 || api.Bytes() != 0 { ++ t.Fatalf("Purge left Len=%d Bytes=%d, want zero", c.Len(), api.Bytes()) ++ } ++ for _, key := range []string{"a", "bb", "ccc"} { ++ if _, ok := api.Peek(key); ok { ++ t.Fatalf("key %q remains after Purge", key) ++ } ++ if counts[key] != 1 { ++ t.Fatalf("callback count for %q = %d, want 1", key, counts[key]) ++ } ++ } ++ api.Purge() ++ if !reflect.DeepEqual(counts, map[string]int{"a": 1, "bb": 1, "ccc": 1}) { ++ t.Fatalf("second Purge changed callbacks: %v", counts) ++ } ++} ++ ++func TestCodespecResizeAndUnlimitedMode(t *testing.T) { ++ var evicted []string ++ c := lru.New(0, func(key string, value lru.Value) { ++ evicted = append(evicted, fmt.Sprintf("%s=%s", key, value.(sizedString))) ++ }) ++ api := requireExtended(t, c) ++ c.Add("a", sizedString("12")) ++ c.Add("b", sizedString("345")) ++ c.Add("c", sizedString("6789")) ++ c.Get("a") ++ ++ if got := api.Resize(8); got != 1 || api.Bytes() != 8 { ++ t.Fatalf("Resize(8) evicted %d with %d bytes, want 1 and 8", got, api.Bytes()) ++ } ++ if got := api.Resize(4); got != 1 || api.Bytes() != 3 { ++ t.Fatalf("Resize(4) evicted %d with %d bytes, want 1 and 3", got, api.Bytes()) ++ } ++ if got := api.Resize(20); got != 0 { ++ t.Fatalf("growing Resize evicted %d entries, want 0", got) ++ } ++ if got := api.Resize(0); got != 0 { ++ t.Fatalf("Resize(0) evicted %d entries, want 0", got) ++ } ++ c.Add("large", sizedString(strings.Repeat("x", 100))) ++ if _, ok := api.Peek("large"); !ok || c.Len() != 2 || api.Bytes() != 108 { ++ t.Fatalf("unlimited mode rejected entry: present=%v Len=%d Bytes=%d", ok, c.Len(), api.Bytes()) ++ } ++ if !reflect.DeepEqual(evicted, []string{"b=345", "c=6789"}) { ++ t.Fatalf("Resize callbacks = %v, want [b=345 c=6789]", evicted) ++ } ++} ++ ++func TestCodespecOversizedEntryEvictsItself(t *testing.T) { ++ var evicted []string ++ c := lru.New(3, func(key string, value lru.Value) { ++ evicted = append(evicted, fmt.Sprintf("%s=%s", key, value.(sizedString))) ++ }) ++ bytes := requireBytes(t, c) ++ peek := requirePeek(t, c) ++ c.Add("xx", sizedString("yy")) ++ if _, ok := peek.Peek("xx"); ok || c.Len() != 0 || bytes.Bytes() != 0 { ++ t.Fatalf("oversized entry remains: present=%v Len=%d Bytes=%d", ok, c.Len(), bytes.Bytes()) ++ } ++ if !reflect.DeepEqual(evicted, []string{"xx=yy"}) { ++ t.Fatalf("oversized entry callbacks = %v, want [xx=yy]", evicted) ++ } ++} ++ ++func TestCodespecConcurrentPublicOperations(t *testing.T) { ++ c := lru.New(96, nil) ++ api := requireExtended(t, c) ++ var wg sync.WaitGroup ++ for worker := 0; worker < 7; worker++ { ++ worker := worker ++ wg.Add(1) ++ go func() { ++ defer wg.Done() ++ for i := 0; i < 300; i++ { ++ key := fmt.Sprintf("w%d-%d", worker, i%11) ++ c.Add(key, sizedString(strings.Repeat("v", i%9+1))) ++ c.Get(key) ++ api.Peek(key) ++ if i%4 == 0 { ++ api.Remove(key) ++ } ++ c.Len() ++ api.Bytes() ++ } ++ }() ++ } ++ wg.Add(1) ++ go func() { ++ defer wg.Done() ++ for i := 0; i < 300; i++ { ++ if i%2 == 0 { ++ api.Resize(0) ++ } else { ++ api.Resize(96) ++ } ++ if i%7 == 0 { ++ c.RemoveOldest() ++ } ++ if i%41 == 0 { ++ api.Purge() ++ } ++ } ++ }() ++ wg.Wait() ++ ++ api.Resize(0) ++ api.Purge() ++ if c.Len() != 0 || api.Bytes() != 0 { ++ t.Fatalf("cache invariant after concurrent operations: Len=%d Bytes=%d", c.Len(), api.Bytes()) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++go test -race -count=1 ./lib/lru diff --git a/tasks/format-code-task-000985/tests/test.sh b/tasks/format-code-task-000985/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a786bf2e23503c0bdefe1816dee603da1ad4ec7b --- /dev/null +++ b/tasks/format-code-task-000985/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' +lib/lru/lru_codespec_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000985/tests/test_command.sh b/tasks/format-code-task-000985/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000985/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-001054/environment/Dockerfile b/tasks/format-code-task-001054/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ee8b32f0e8fec872428e10276abdd7e34c719be8 --- /dev/null +++ b/tasks/format-code-task-001054/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:5819cfbd07f9c3b45054c9fd7b2453daa5c8999c4a1f02184b7590859837e236 diff --git a/tasks/format-code-task-001054/environment/setup/files/blocklist b/tasks/format-code-task-001054/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001054/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-001054/environment/setup/setup.sh b/tasks/format-code-task-001054/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001054/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-001054/tests/test.patch b/tasks/format-code-task-001054/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..38dc9885bab15e90109ddbff5036d0c594d933b0 --- /dev/null +++ b/tasks/format-code-task-001054/tests/test.patch @@ -0,0 +1,326 @@ +diff --git a/client/codespec_mutation_api_test.go b/client/codespec_mutation_api_test.go +new file mode 100644 +index 000000000..14cf22da9 +--- /dev/null ++++ b/client/codespec_mutation_api_test.go +@@ -0,0 +1,305 @@ ++package client_test ++ ++import ( ++ "errors" ++ "io/ioutil" ++ "net/http" ++ "net/url" ++ "reflect" ++ "testing" ++ "time" ++ ++ "github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context" ++ "github.com/coreos/etcd/client" ++) ++ ++type codespecRecordingHTTPClient struct { ++ endpoint url.URL ++ requests []*http.Request ++ status int ++ header http.Header ++ body []byte ++ err error ++} ++ ++func newCodespecRecordingHTTPClient() *codespecRecordingHTTPClient { ++ return &codespecRecordingHTTPClient{ ++ endpoint: url.URL{Scheme: "https", Host: "example.test", Path: "/gateway"}, ++ status: http.StatusOK, ++ header: make(http.Header), ++ body: []byte(`{"action":"set","node":{"key":"/alpha beta","value":"stored","modifiedIndex":9,"createdIndex":3}}`), ++ } ++} ++ ++func (c *codespecRecordingHTTPClient) Do(_ context.Context, action client.HTTPAction) (*http.Response, []byte, error) { ++ if c.err != nil { ++ return nil, nil, c.err ++ } ++ req := action.HTTPRequest(c.endpoint) ++ c.requests = append(c.requests, req) ++ return &http.Response{StatusCode: c.status, Header: c.header}, c.body, nil ++} ++ ++type codespecPutAPI interface { ++ Set(context.Context, string, string, time.Duration) (*client.Response, error) ++ Update(context.Context, string, string, time.Duration) (*client.Response, error) ++} ++ ++type codespecDeleteAPI interface { ++ Delete(context.Context, string, bool) (*client.Response, error) ++} ++ ++type codespecCompareAPI interface { ++ CompareAndSwap(context.Context, string, string, time.Duration, string, uint64) (*client.Response, error) ++ CompareAndDelete(context.Context, string, string, uint64) (*client.Response, error) ++} ++ ++func TestCodespecMutationMethodsArePublic(t *testing.T) { ++ apiType := reflect.TypeOf((*client.KeysAPI)(nil)).Elem() ++ for _, name := range []string{"Set", "Update", "Delete", "CompareAndSwap", "CompareAndDelete"} { ++ if _, ok := apiType.MethodByName(name); !ok { ++ t.Errorf("client.KeysAPI is missing public method %s", name) ++ } ++ } ++} ++ ++func TestCodespecSetAndUpdateRequests(t *testing.T) { ++ recorder := newCodespecRecordingHTTPClient() ++ recorder.header.Set("X-Etcd-Index", "41") ++ api, ok := client.NewKeysAPI(recorder).(codespecPutAPI) ++ if !ok { ++ t.Fatal("NewKeysAPI result does not implement Set and Update") ++ } ++ ++ resp, err := api.Set(context.Background(), "/alpha beta", "hello world", -time.Second) ++ if err != nil { ++ t.Fatalf("Set returned error: %v", err) ++ } ++ if resp == nil || resp.Action != "set" || resp.Index != 41 || resp.Node == nil || resp.Node.Value != "stored" { ++ t.Fatalf("Set response = %#v, want decoded HTTP response", resp) ++ } ++ if len(recorder.requests) != 1 { ++ t.Fatalf("Set issued %d requests, want 1", len(recorder.requests)) ++ } ++ assertCodespecRequest(t, recorder.requests[0], "PUT", "/gateway/v2/keys/alpha beta", url.Values{}, url.Values{"value": {"hello world"}}) ++ ++ resp, err = api.Update(context.Background(), "alpha beta", "replacement", 0) ++ if err != nil { ++ t.Fatalf("Update returned error: %v", err) ++ } ++ if resp.Index != 41 { ++ t.Fatalf("Update response index = %d, want 41", resp.Index) ++ } ++ if len(recorder.requests) != 2 { ++ t.Fatalf("Update issued %d total requests, want 2", len(recorder.requests)) ++ } ++ assertCodespecRequest(t, recorder.requests[1], "PUT", "/gateway/v2/keys/alpha beta", url.Values{"prevExist": {"true"}}, url.Values{"value": {"replacement"}, "ttl": {"0"}}) ++} ++ ++func TestCodespecDeleteRecursiveModes(t *testing.T) { ++ recorder := newCodespecRecordingHTTPClient() ++ recorder.header.Set("X-Etcd-Index", "41") ++ api, ok := client.NewKeysAPI(recorder).(codespecDeleteAPI) ++ if !ok { ++ t.Fatal("NewKeysAPI result does not implement Delete") ++ } ++ ++ for _, recursive := range []bool{false, true} { ++ resp, err := api.Delete(context.Background(), "/tree/item", recursive) ++ if err != nil { ++ t.Fatalf("Delete(%t) returned error: %v", recursive, err) ++ } ++ assertCodespecDecodedResponse(t, resp, "Delete") ++ } ++ if len(recorder.requests) != 2 { ++ t.Fatalf("Delete issued %d requests, want 2", len(recorder.requests)) ++ } ++ assertCodespecRequest(t, recorder.requests[0], "DELETE", "/gateway/v2/keys/tree/item", url.Values{"recursive": {"false"}}, nil) ++ assertCodespecRequest(t, recorder.requests[1], "DELETE", "/gateway/v2/keys/tree/item", url.Values{"recursive": {"true"}}, nil) ++} ++ ++func TestCodespecCompareAndSwapConditions(t *testing.T) { ++ recorder := newCodespecRecordingHTTPClient() ++ recorder.header.Set("X-Etcd-Index", "41") ++ api, ok := client.NewKeysAPI(recorder).(codespecCompareAPI) ++ if !ok { ++ t.Fatal("NewKeysAPI result does not implement compare operations") ++ } ++ ++ resp, err := api.CompareAndSwap(context.Background(), "/item", "new", 2500*time.Millisecond, "old value", 0) ++ if err != nil { ++ t.Fatalf("CompareAndSwap with prevValue returned error: %v", err) ++ } ++ assertCodespecDecodedResponse(t, resp, "CompareAndSwap") ++ if len(recorder.requests) != 1 { ++ t.Fatalf("CompareAndSwap issued %d requests after prevValue case, want 1", len(recorder.requests)) ++ } ++ assertCodespecRequest(t, recorder.requests[0], "PUT", "/gateway/v2/keys/item", url.Values{"prevValue": {"old value"}}, url.Values{"value": {"new"}, "ttl": {"2"}}) ++ ++ resp, err = api.CompareAndSwap(context.Background(), "/item", "newer", -time.Second, "", 17) ++ if err != nil { ++ t.Fatalf("CompareAndSwap with prevIndex returned error: %v", err) ++ } ++ assertCodespecDecodedResponse(t, resp, "CompareAndSwap") ++ if len(recorder.requests) != 2 { ++ t.Fatalf("CompareAndSwap issued %d total requests, want 2", len(recorder.requests)) ++ } ++ assertCodespecRequest(t, recorder.requests[1], "PUT", "/gateway/v2/keys/item", url.Values{"prevIndex": {"17"}}, url.Values{"value": {"newer"}}) ++ ++ resp, err = api.CompareAndSwap(context.Background(), "/item", "newest", -time.Second, "oldest", 19) ++ if err != nil { ++ t.Fatalf("CompareAndSwap with both conditions returned error: %v", err) ++ } ++ assertCodespecDecodedResponse(t, resp, "CompareAndSwap") ++ if len(recorder.requests) != 3 { ++ t.Fatalf("CompareAndSwap issued %d total requests, want 3", len(recorder.requests)) ++ } ++ assertCodespecRequest(t, recorder.requests[2], "PUT", "/gateway/v2/keys/item", url.Values{"prevIndex": {"19"}, "prevValue": {"oldest"}}, url.Values{"value": {"newest"}}) ++} ++ ++func TestCodespecCompareAndDeleteConditions(t *testing.T) { ++ recorder := newCodespecRecordingHTTPClient() ++ recorder.header.Set("X-Etcd-Index", "41") ++ api, ok := client.NewKeysAPI(recorder).(codespecCompareAPI) ++ if !ok { ++ t.Fatal("NewKeysAPI result does not implement compare operations") ++ } ++ ++ resp, err := api.CompareAndDelete(context.Background(), "/item", "old & value", 0) ++ if err != nil { ++ t.Fatalf("CompareAndDelete with prevValue returned error: %v", err) ++ } ++ assertCodespecDecodedResponse(t, resp, "CompareAndDelete") ++ if len(recorder.requests) != 1 { ++ t.Fatalf("CompareAndDelete issued %d requests after prevValue case, want 1", len(recorder.requests)) ++ } ++ assertCodespecRequest(t, recorder.requests[0], "DELETE", "/gateway/v2/keys/item", url.Values{"prevValue": {"old & value"}}, nil) ++ ++ resp, err = api.CompareAndDelete(context.Background(), "/item", "", 23) ++ if err != nil { ++ t.Fatalf("CompareAndDelete with prevIndex returned error: %v", err) ++ } ++ assertCodespecDecodedResponse(t, resp, "CompareAndDelete") ++ if len(recorder.requests) != 2 { ++ t.Fatalf("CompareAndDelete issued %d total requests, want 2", len(recorder.requests)) ++ } ++ assertCodespecRequest(t, recorder.requests[1], "DELETE", "/gateway/v2/keys/item", url.Values{"prevIndex": {"23"}}, nil) ++ ++ resp, err = api.CompareAndDelete(context.Background(), "/item", "old", 29) ++ if err != nil { ++ t.Fatalf("CompareAndDelete with both conditions returned error: %v", err) ++ } ++ assertCodespecDecodedResponse(t, resp, "CompareAndDelete") ++ if len(recorder.requests) != 3 { ++ t.Fatalf("CompareAndDelete issued %d total requests, want 3", len(recorder.requests)) ++ } ++ assertCodespecRequest(t, recorder.requests[2], "DELETE", "/gateway/v2/keys/item", url.Values{"prevIndex": {"29"}, "prevValue": {"old"}}, nil) ++} ++ ++func TestCodespecCompareRequiresConditionBeforeIO(t *testing.T) { ++ recorder := newCodespecRecordingHTTPClient() ++ api, ok := client.NewKeysAPI(recorder).(codespecCompareAPI) ++ if !ok { ++ t.Fatal("NewKeysAPI result does not implement compare operations") ++ } ++ ++ if _, err := api.CompareAndSwap(context.Background(), "/item", "new", -time.Second, "", 0); err == nil { ++ t.Error("CompareAndSwap without a condition returned nil error") ++ } ++ if _, err := api.CompareAndDelete(context.Background(), "/item", "", 0); err == nil { ++ t.Error("CompareAndDelete without a condition returned nil error") ++ } ++ if len(recorder.requests) != 0 { ++ t.Fatalf("condition validation issued %d HTTP requests, want 0", len(recorder.requests)) ++ } ++} ++ ++func TestCodespecMutationErrorsPropagate(t *testing.T) { ++ sentinel := errors.New("transport failed") ++ operations := []struct { ++ name string ++ call func(client.KeysAPI) error ++ }{ ++ {"Set", func(api client.KeysAPI) error { ++ _, err := api.(codespecPutAPI).Set(context.Background(), "/item", "new", -time.Second) ++ return err ++ }}, ++ {"Update", func(api client.KeysAPI) error { ++ _, err := api.(codespecPutAPI).Update(context.Background(), "/item", "new", -time.Second) ++ return err ++ }}, ++ {"Delete", func(api client.KeysAPI) error { ++ _, err := api.(codespecDeleteAPI).Delete(context.Background(), "/item", false) ++ return err ++ }}, ++ {"CompareAndSwap", func(api client.KeysAPI) error { ++ _, err := api.(codespecCompareAPI).CompareAndSwap(context.Background(), "/item", "new", -time.Second, "old", 0) ++ return err ++ }}, ++ {"CompareAndDelete", func(api client.KeysAPI) error { ++ _, err := api.(codespecCompareAPI).CompareAndDelete(context.Background(), "/item", "old", 0) ++ return err ++ }}, ++ } ++ for _, operation := range operations { ++ recorder := newCodespecRecordingHTTPClient() ++ api := client.NewKeysAPI(recorder) ++ _, hasPut := api.(codespecPutAPI) ++ _, hasDelete := api.(codespecDeleteAPI) ++ _, hasCompare := api.(codespecCompareAPI) ++ if !hasPut || !hasDelete || !hasCompare { ++ t.Fatal("NewKeysAPI result does not implement mutation operations") ++ } ++ recorder.status = http.StatusNotFound ++ if err := operation.call(api); err != client.ErrKeyNoExist { ++ t.Errorf("%s 404 error = %v, want %v", operation.name, err, client.ErrKeyNoExist) ++ } ++ ++ recorder = newCodespecRecordingHTTPClient() ++ recorder.err = sentinel ++ api = client.NewKeysAPI(recorder) ++ if err := operation.call(api); err != sentinel { ++ t.Errorf("%s transport error = %v, want sentinel", operation.name, err) ++ } ++ } ++} ++ ++func assertCodespecRequest(t *testing.T, req *http.Request, method, wantPath string, wantQuery, wantForm url.Values) { ++ t.Helper() ++ if req == nil { ++ t.Fatal("HTTPRequest returned nil") ++ } ++ if req.Method != method || req.URL.Path != wantPath { ++ t.Errorf("request = %s %s, want %s %s", req.Method, req.URL.Path, method, wantPath) ++ } ++ if !reflect.DeepEqual(req.URL.Query(), wantQuery) { ++ t.Errorf("query = %#v, want %#v", req.URL.Query(), wantQuery) ++ } ++ if wantForm == nil { ++ if req.Body != nil { ++ t.Error("request body is present, want none") ++ } ++ return ++ } ++ if got := req.Header.Get("Content-Type"); got != "application/x-www-form-urlencoded" { ++ t.Errorf("Content-Type = %q, want form encoding", got) ++ } ++ body, err := ioutil.ReadAll(req.Body) ++ if err != nil { ++ t.Fatalf("reading request body: %v", err) ++ } ++ gotForm, err := url.ParseQuery(string(body)) ++ if err != nil { ++ t.Fatalf("parsing request body: %v", err) ++ } ++ if !reflect.DeepEqual(gotForm, wantForm) { ++ t.Errorf("form = %#v, want %#v", gotForm, wantForm) ++ } ++} ++ ++func assertCodespecDecodedResponse(t *testing.T, resp *client.Response, operation string) { ++ t.Helper() ++ if resp == nil || resp.Index != 41 || resp.Node == nil || resp.Node.Value != "stored" { ++ t.Fatalf("%s response = %#v, want decoded HTTP response", operation, resp) ++ } ++} +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,10 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++REPO_ROOT="$(git rev-parse --show-toplevel)" ++mkdir -p "${REPO_ROOT}/gopath/src/github.com/coreos" ++ln -sfn "${REPO_ROOT}" "${REPO_ROOT}/gopath/src/github.com/coreos/etcd" ++GO111MODULE=off \ ++ GOPATH="${REPO_ROOT}/gopath:${REPO_ROOT}/Godeps/_workspace" \ ++ go test github.com/coreos/etcd/client -run '^TestCodespec' -count=1 diff --git a/tasks/format-code-task-001054/tests/test.sh b/tasks/format-code-task-001054/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c755849e7e569ddeaf683efb96be7bc63e40042 --- /dev/null +++ b/tasks/format-code-task-001054/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' +client/codespec_mutation_api_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-001054/tests/test_command.sh b/tasks/format-code-task-001054/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001054/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-001062/environment/Dockerfile b/tasks/format-code-task-001062/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c103dc5655997611cc08e2a231c8c5938343685f --- /dev/null +++ b/tasks/format-code-task-001062/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:9f8aab3264e24618e69dd59f91a419c916dc5c6f8b6e6b455157dc3f054571b0 diff --git a/tasks/format-code-task-001062/environment/setup/files/blocklist b/tasks/format-code-task-001062/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001062/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-001062/environment/setup/setup.sh b/tasks/format-code-task-001062/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001062/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-001062/tests/test.patch b/tasks/format-code-task-001062/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..57ffd76370746308ce863777840bbe881b4d94fd --- /dev/null +++ b/tasks/format-code-task-001062/tests/test.patch @@ -0,0 +1,172 @@ +diff --git a/opal/static/js/test/codespec_paginator_contract.test.js b/opal/static/js/test/codespec_paginator_contract.test.js +new file mode 100644 +index 00000000..51fc5790 +--- /dev/null ++++ b/opal/static/js/test/codespec_paginator_contract.test.js +@@ -0,0 +1,131 @@ ++describe('Paginator contract', function() { ++ 'use strict'; ++ ++ var Paginator; ++ var callback; ++ ++ beforeEach(function() { ++ module('opal.services'); ++ inject(function($injector) { ++ Paginator = $injector.get('Paginator'); ++ }); ++ callback = jasmine.createSpy('callback'); ++ }); ++ ++ it('initializes a complete empty state without metadata', function() { ++ var paginator = new Paginator(callback); ++ ++ expect(paginator.pageNumber).toBe(1); ++ expect(paginator.totalCount).toBe(0); ++ expect(paginator.totalPages).toEqual([1]); ++ expect(paginator.hasPrevious).toBe(false); ++ expect(paginator.hasNext).toBe(false); ++ }); ++ ++ it('coerces numeric metadata and preserves the current page in a seven-page window', function() { ++ var paginator = new Paginator(callback, { ++ page_number: '8', ++ total_count: '141', ++ total_pages: '15' ++ }); ++ ++ expect(paginator.pageNumber).toBe(8); ++ expect(paginator.totalCount).toBe(141); ++ expect(paginator.totalPages).toEqual([8, 9, 10, 11, 12, 13, 14]); ++ expect(paginator.totalPages.length).toBeLessThan(8); ++ expect(paginator.totalPages).toContain(paginator.pageNumber); ++ }); ++ ++ it('anchors the page window at the beginning and end of a result set', function() { ++ var first = new Paginator(callback, {page_number: 2, total_count: 101, total_pages: 11}); ++ var last = new Paginator(callback, {page_number: 11, total_count: 101, total_pages: 11}); ++ ++ expect(first.totalPages).toEqual([1, 2, 3, 4, 5, 6, 7]); ++ expect(last.totalPages).toEqual([5, 6, 7, 8, 9, 10, 11]); ++ }); ++ ++ it('clamps a requested page outside the available range', function() { ++ var below = new Paginator(callback, {page_number: -4, total_count: 20, total_pages: 3}); ++ var above = new Paginator(callback, {page_number: 99, total_count: 20, total_pages: 3}); ++ ++ expect(below.pageNumber).toBe(1); ++ expect(below.totalPages).toEqual([1, 2, 3]); ++ expect(above.pageNumber).toBe(3); ++ expect(above.totalPages).toEqual([1, 2, 3]); ++ }); ++ ++ it('reports whether an adjacent page exists', function() { ++ var first = new Paginator(callback, {page_number: 1, total_count: 100, total_pages: 4}); ++ var middle = new Paginator(callback, {page_number: 2, total_count: 100, total_pages: 4}); ++ var windowed = new Paginator(callback, {page_number: 2, total_count: 101, total_pages: 11}); ++ var last = new Paginator(callback, {page_number: 4, total_count: 100, total_pages: 4}); ++ var endWindow = new Paginator(callback, {page_number: 11, total_count: 101, total_pages: 15}); ++ ++ expect(first.hasPrevious).toBe(false); ++ expect(first.hasNext).toBe(true); ++ expect(middle.hasPrevious).toBe(true); ++ expect(middle.hasNext).toBe(true); ++ expect(windowed.hasNext).toBe(true); ++ expect(last.hasPrevious).toBe(true); ++ expect(last.hasNext).toBe(false); ++ expect(endWindow.hasPrevious).toBe(true); ++ expect(endWindow.hasNext).toBe(true); ++ }); ++ ++ it('does not invoke navigation callbacks beyond either boundary', function() { ++ var first = new Paginator(callback, {page_number: 1, total_count: 20, total_pages: 2}); ++ first.goPrevious(); ++ expect(callback).not.toHaveBeenCalled(); ++ ++ var last = new Paginator(callback, {page_number: 2, total_count: 20, total_pages: 2}); ++ last.goNext(); ++ expect(callback).not.toHaveBeenCalled(); ++ }); ++ ++ it('invokes navigation callbacks with the adjacent valid page', function() { ++ var previous = new Paginator(callback, {page_number: 2, total_count: 40, total_pages: 4}); ++ var next = new Paginator(callback, {page_number: 2, total_count: 40, total_pages: 4}); ++ ++ previous.goPrevious(); ++ next.goNext(); ++ ++ expect(callback.calls.count()).toBe(2); ++ expect(callback.calls.argsFor(0)).toEqual([1]); ++ expect(callback.calls.argsFor(1)).toEqual([3]); ++ }); ++ ++ it('degrades invalid or zero-page metadata to an inert empty state', function() { ++ var invalid = new Paginator(callback, { ++ page_number: 'not-a-number', ++ total_count: '-5', ++ total_pages: '0' ++ }); ++ var nonFinite = new Paginator(callback, { ++ page_number: 1, ++ total_count: Infinity, ++ total_pages: 2 ++ }); ++ ++ expect(invalid.pageNumber).toBe(1); ++ expect(invalid.totalCount).toBe(0); ++ expect(invalid.totalPages).toEqual([]); ++ expect(invalid.hasPrevious).toBe(false); ++ expect(invalid.hasNext).toBe(false); ++ expect(nonFinite.totalCount).toBe(0); ++ invalid.goPrevious(); ++ invalid.goNext(); ++ expect(callback).not.toHaveBeenCalled(); ++ }); ++ ++ it('normalizes fractional metadata down to usable page integers', function() { ++ var paginator = new Paginator(callback, { ++ page_number: 2.9, ++ total_count: 12.8, ++ total_pages: 3.2 ++ }); ++ ++ expect(paginator.pageNumber).toBe(2); ++ expect(paginator.totalCount).toBe(12); ++ expect(paginator.totalPages).toEqual([1, 2, 3]); ++ }); ++}); +diff --git a/config/codespec_karma.conf.js b/config/codespec_karma.conf.js +new file mode 100644 +index 00000000..13be8ca1 +--- /dev/null ++++ b/config/codespec_karma.conf.js +@@ -0,0 +1,17 @@ ++module.exports = function(config) { ++ var root = process.cwd(); ++ var karmaDefaults = require(root + '/config/karma_defaults.js'); ++ var defaults = karmaDefaults([ ++ 'test/codespec_paginator_contract.test.js' ++ ], root, []); ++ ++ defaults.basePath = root + '/opal/static/js'; ++ defaults.files.splice(defaults.files.length - 1, 0, ++ '../../core/search/static/js/search/services/paginator.js'); ++ defaults.plugins = ['karma-jasmine', 'karma-jsdom-launcher']; ++ defaults.browsers = ['jsdom']; ++ defaults.reporters = ['progress']; ++ defaults.preprocessors = {}; ++ delete defaults.coverageReporter; ++ config.set(defaults); ++}; +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,7 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++NODE_PATH=/testbed/.build_env/test-runner/node_modules \ ++ /testbed/.build_env/test-runner/node_modules/.bin/karma start \ ++ "${PWD}/config/codespec_karma.conf.js" --single-run diff --git a/tasks/format-code-task-001062/tests/test.sh b/tasks/format-code-task-001062/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7b6763b3c9385293758242caf3a95697ff39c944 --- /dev/null +++ b/tasks/format-code-task-001062/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' +opal/static/js/test/codespec_paginator_contract.test.js +config/codespec_karma.conf.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-001062/tests/test_command.sh b/tasks/format-code-task-001062/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001062/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-001065/environment/Dockerfile b/tasks/format-code-task-001065/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..48278a0f3f59030f6887ea0b3a78b32efacad7db --- /dev/null +++ b/tasks/format-code-task-001065/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:87f41d993bc9f87f82600140f0363695282aa43b2a0953d3650f3c01c5592955 diff --git a/tasks/format-code-task-001065/environment/setup/files/blocklist b/tasks/format-code-task-001065/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001065/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-001065/environment/setup/setup.sh b/tasks/format-code-task-001065/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001065/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-001065/tests/test.patch b/tasks/format-code-task-001065/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ef891b25244bd1df918d6dc534d333610e4def64 --- /dev/null +++ b/tasks/format-code-task-001065/tests/test.patch @@ -0,0 +1,111 @@ +diff --git a/tests/utils/test_scheduler_contract.py b/tests/utils/test_scheduler_contract.py +new file mode 100644 +index 00000000..6a2aa4f1 +--- /dev/null ++++ b/tests/utils/test_scheduler_contract.py +@@ -0,0 +1,96 @@ ++import unittest ++ ++import torch ++ ++from lightly.utils.scheduler import CosineWarmupScheduler, cosine_schedule ++ ++ ++class TestCosineWarmupSchedulerContract(unittest.TestCase): ++ def _optimizer(self, learning_rates=(1.0,)): ++ parameters = [torch.nn.Parameter(torch.ones(1)) for _ in learning_rates] ++ return torch.optim.SGD( ++ [ ++ {"params": [parameter], "lr": learning_rate} ++ for parameter, learning_rate in zip(parameters, learning_rates) ++ ] ++ ) ++ ++ def _scheduler(self, optimizer, *args, **kwargs): ++ try: ++ return CosineWarmupScheduler(optimizer, *args, **kwargs) ++ except Exception as error: ++ self.fail(f"scheduler construction raised {type(error).__name__}: {error}") ++ ++ def test_constructor_and_warmup_decay_boundaries(self): ++ optimizer = self._optimizer() ++ scheduler = self._scheduler( ++ optimizer, ++ warmup_epochs=2, ++ max_epochs=5, ++ start_value=0.25, ++ end_value=0.05, ++ verbose=True, ++ ) ++ ++ observed = [scheduler.get_last_lr()[0]] ++ for _ in range(6): ++ scheduler.step() ++ observed.append(scheduler.get_last_lr()[0]) ++ ++ self.assertAlmostEqual(observed[0], 0.5) ++ self.assertAlmostEqual(observed[1], 1.0) ++ self.assertAlmostEqual(observed[2], 0.25) ++ self.assertAlmostEqual(observed[5], 0.05) ++ self.assertAlmostEqual(observed[6], 0.05) ++ ++ def test_zero_warmup_and_multiple_parameter_groups(self): ++ optimizer = self._optimizer((2.0, 4.0)) ++ scheduler = self._scheduler( ++ optimizer, ++ warmup_epochs=0, ++ max_epochs=2, ++ start_value=0.5, ++ end_value=0.0, ++ ) ++ ++ self.assertEqual(scheduler.get_last_lr(), [1.0, 2.0]) ++ scheduler.step() ++ self.assertEqual(scheduler.get_last_lr(), [0.0, 0.0]) ++ scheduler.step() ++ self.assertEqual(scheduler.get_last_lr(), [0.0, 0.0]) ++ ++ def test_invalid_horizon_is_rejected(self): ++ for warmup_epochs, max_epochs in [(-1, 3), (1, 0), (3, 2)]: ++ with self.subTest(warmup_epochs=warmup_epochs, max_epochs=max_epochs): ++ optimizer = self._optimizer() ++ try: ++ CosineWarmupScheduler(optimizer, warmup_epochs, max_epochs) ++ except ValueError: ++ pass ++ except Exception as error: ++ self.fail(f"invalid horizon raised {type(error).__name__}: {error}") ++ else: ++ self.fail("invalid horizon was accepted") ++ ++ def test_resume_from_last_epoch(self): ++ first_optimizer = self._optimizer() ++ first = self._scheduler(first_optimizer, 1, 4, end_value=0.0) ++ first.step() ++ state = first.state_dict() ++ ++ resumed_optimizer = self._optimizer() ++ resumed = self._scheduler(resumed_optimizer, 1, 4, end_value=0.0) ++ resumed.load_state_dict(state) ++ self.assertEqual(resumed.last_epoch, first.last_epoch) ++ first.step() ++ resumed.step() ++ self.assertEqual(resumed.get_last_lr(), first.get_last_lr()) ++ ++ def test_cosine_schedule_overrun_warns_and_clamps(self): ++ with self.assertWarns(RuntimeWarning): ++ value = cosine_schedule(6, 5, 0.2, 0.0) ++ self.assertEqual(value, 0.0) ++ ++ ++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,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++LIGHTLY_DID_VERSION_CHECK=True python -m unittest tests.utils.test_scheduler_contract diff --git a/tasks/format-code-task-001065/tests/test.sh b/tasks/format-code-task-001065/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b3370398f75c35f243eac1ffce40baf18cc3cd51 --- /dev/null +++ b/tasks/format-code-task-001065/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/utils/test_scheduler_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001065/tests/test_command.sh b/tasks/format-code-task-001065/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001065/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-001096/environment/Dockerfile b/tasks/format-code-task-001096/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bdcaff9587ec86846e5f2b44eda9e89ed72a3df3 --- /dev/null +++ b/tasks/format-code-task-001096/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:66021721491082138ef4b007f488898b30af33541ecf9007e6fcd7ec211698be diff --git a/tasks/format-code-task-001096/environment/setup/files/blocklist b/tasks/format-code-task-001096/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001096/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-001096/environment/setup/setup.sh b/tasks/format-code-task-001096/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001096/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-001096/tests/test.patch b/tasks/format-code-task-001096/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5e368b7d1658e32bbffae372521459f369c78a3e --- /dev/null +++ b/tasks/format-code-task-001096/tests/test.patch @@ -0,0 +1,342 @@ +diff --git a/__tests__/codespec-output-folder.test.ts b/__tests__/codespec-output-folder.test.ts +new file mode 100644 +index 0000000..d8afd0f +--- /dev/null ++++ b/__tests__/codespec-output-folder.test.ts +@@ -0,0 +1,320 @@ ++import { spawnSync, SpawnSyncReturns } from "child_process"; ++import fs from "fs"; ++import os from "os"; ++import path from "path"; ++import chokidar from "chokidar"; ++ ++import { watch } from "../lib/core/watch"; ++ ++jest.mock("chokidar"); ++ ++const repositoryRoot = path.resolve(__dirname, ".."); ++const cliPath = path.join(repositoryRoot, "lib", "cli.ts"); ++const tsNodeRegister = require.resolve("ts-node/register"); ++const temporaryDirectories: string[] = []; ++ ++const makeTemporaryDirectory = (): string => { ++ const directory = fs.mkdtempSync( ++ path.join(os.tmpdir(), "tsm-codespec-output-folder-") ++ ); ++ temporaryDirectories.push(directory); ++ return directory; ++}; ++ ++const makeDirectory = (directory: string): void => { ++ fs.mkdirSync(directory, { recursive: true } as any); ++}; ++ ++const writeSource = ( ++ root: string, ++ relativePath: string, ++ className: string ++): string => { ++ const sourcePath = path.join(root, relativePath); ++ makeDirectory(path.dirname(sourcePath)); ++ fs.writeFileSync(sourcePath, `.${className} { color: red; }\n`); ++ return sourcePath; ++}; ++ ++const writeDefinition = ( ++ root: string, ++ relativeSourcePath: string, ++ className: string ++): string => { ++ const definitionPath = path.join(root, `${relativeSourcePath}.d.ts`); ++ makeDirectory(path.dirname(definitionPath)); ++ fs.writeFileSync(definitionPath, `export const ${className}: string;\n`); ++ return definitionPath; ++}; ++ ++const runCli = ( ++ cwd: string, ++ args: string[] ++): SpawnSyncReturns => ++ spawnSync(process.execPath, ["-r", tsNodeRegister, cliPath, ...args], { ++ cwd, ++ encoding: "utf8", ++ env: { ++ ...process.env, ++ TS_NODE_PROJECT: path.join(repositoryRoot, "tsconfig.json"), ++ }, ++ }); ++ ++const combinedOutput = (result: SpawnSyncReturns): string => ++ `${result.stdout || ""}${result.stderr || ""}`; ++const readFile = (file: string): string => fs.readFileSync(file, "utf8"); ++ ++const waitFor = async (predicate: () => boolean): Promise => { ++ for (let attempt = 0; attempt < 50 && !predicate(); attempt += 1) { ++ await new Promise((resolve) => setImmediate(resolve)); ++ } ++ expect(predicate()).toBe(true); ++}; ++ ++afterEach(() => { ++ temporaryDirectories.splice(0).forEach((directory) => { ++ (fs as any).rmSync(directory, { recursive: true, force: true }); ++ }); ++ jest.clearAllMocks(); ++}); ++ ++describe("output folder CLI contract", () => { ++ test("documents the long option and short alias", () => { ++ const result = runCli(repositoryRoot, ["--help"]); ++ ++ expect(result.status).toBe(0); ++ expect(result.stdout).toMatch(/--outputFolder,\s+-o/); ++ }); ++ ++ test("maps a directory input into a relative output folder", () => { ++ const workspace = makeTemporaryDirectory(); ++ const sourceRoot = path.join(workspace, "styles"); ++ const outputRoot = path.join(workspace, "types"); ++ const rootSource = writeSource(sourceRoot, "base.scss", "base"); ++ const nestedSource = writeSource( ++ sourceRoot, ++ path.join("components", "button.scss"), ++ "button" ++ ); ++ ++ const result = runCli(workspace, [ ++ "styles", ++ "--outputFolder", ++ "types", ++ "--implementation", ++ "node-sass", ++ "--logLevel", ++ "silent", ++ ]); ++ ++ expect(result.status).toBe(0); ++ expect(readFile(path.join(outputRoot, "base.scss.d.ts"))).toBe( ++ "export const base: string;\n" ++ ); ++ expect( ++ readFile(path.join(outputRoot, "components", "button.scss.d.ts")) ++ ).toBe("export const button: string;\n"); ++ expect(fs.existsSync(`${rootSource}.d.ts`)).toBe(false); ++ expect(fs.existsSync(`${nestedSource}.d.ts`)).toBe(false); ++ }); ++ ++ test("uses the non-glob prefix as the root and retains ignore behavior", () => { ++ const workspace = makeTemporaryDirectory(); ++ const sourceRoot = path.join(workspace, "styles"); ++ const outputRoot = path.join(workspace, "types"); ++ const firstSource = writeSource(sourceRoot, "first.scss", "first"); ++ const nestedSource = writeSource( ++ sourceRoot, ++ path.join("nested", "second.scss"), ++ "second" ++ ); ++ const ignoredSource = writeSource( ++ sourceRoot, ++ path.join("nested", "ignored.scss"), ++ "ignored" ++ ); ++ ++ const result = runCli(workspace, [ ++ "styles/**/*.scss", ++ "-o", ++ "types", ++ "--ignore", ++ "**/ignored.scss", ++ "--implementation", ++ "node-sass", ++ "--logLevel", ++ "silent", ++ ]); ++ ++ expect(result.status).toBe(0); ++ expect(readFile(path.join(outputRoot, "first.scss.d.ts"))).toBe( ++ "export const first: string;\n" ++ ); ++ expect( ++ readFile(path.join(outputRoot, "nested", "second.scss.d.ts")) ++ ).toBe("export const second: string;\n"); ++ expect( ++ fs.existsSync(path.join(outputRoot, "nested", "ignored.scss.d.ts")) ++ ).toBe(false); ++ expect(fs.existsSync(`${firstSource}.d.ts`)).toBe(false); ++ expect(fs.existsSync(`${nestedSource}.d.ts`)).toBe(false); ++ expect(fs.existsSync(`${ignoredSource}.d.ts`)).toBe(false); ++ }); ++}); ++ ++describe("output folder watch contract", () => { ++ test("writes changes and removes the mapped declaration on unlink", async () => { ++ const workspace = makeTemporaryDirectory(); ++ const sourceRoot = path.join(workspace, "styles"); ++ const outputRoot = path.join(workspace, "types"); ++ const sourcePath = writeSource( ++ sourceRoot, ++ path.join("nested", "live.scss"), ++ "firstVersion" ++ ); ++ const outputPath = path.join( ++ outputRoot, ++ "nested", ++ "live.scss.d.ts" ++ ); ++ const handlers: { [event: string]: (file: string) => void } = {}; ++ let watcher: any; ++ watcher = { ++ on: jest.fn((event: string, handler: (file: string) => void) => { ++ handlers[event] = handler; ++ return watcher; ++ }), ++ }; ++ (chokidar.watch as jest.Mock).mockReturnValue(watcher); ++ const log = jest.spyOn(console, "log").mockImplementation(); ++ ++ watch(path.join(sourceRoot, "**/*.scss"), { ++ banner: "", ++ watch: true, ++ ignoreInitial: true, ++ exportType: "named", ++ exportTypeName: "ClassNames", ++ exportTypeInterface: "Styles", ++ listDifferent: false, ++ ignore: [], ++ includePaths: [sourceRoot], ++ implementation: "node-sass", ++ quoteType: "single", ++ logLevel: "silent", ++ outputFolder: outputRoot, ++ } as any); ++ ++ handlers.add(sourcePath); ++ await waitFor(() => fs.existsSync(outputPath)); ++ expect(fs.readFileSync(outputPath, "utf8")).toBe( ++ "export const firstVersion: string;\n" ++ ); ++ expect(fs.existsSync(`${sourcePath}.d.ts`)).toBe(false); ++ ++ fs.writeFileSync(sourcePath, ".secondVersion { color: blue; }\n"); ++ handlers.change(sourcePath); ++ await waitFor( ++ () => ++ fs.existsSync(outputPath) && ++ fs.readFileSync(outputPath, "utf8").indexOf("secondVersion") >= 0 ++ ); ++ expect(fs.readFileSync(outputPath, "utf8")).toBe( ++ "export const secondVersion: string;\n" ++ ); ++ ++ fs.unlinkSync(sourcePath); ++ handlers.unlink(sourcePath); ++ expect(fs.existsSync(outputPath)).toBe(false); ++ log.mockRestore(); ++ }); ++}); ++ ++describe("output folder listDifferent contract", () => { ++ const listArgs = [ ++ "styles/**/*.scss", ++ "--outputFolder", ++ "types", ++ "--listDifferent", ++ "--implementation", ++ "node-sass", ++ ]; ++ ++ test("accepts an up-to-date mapped declaration without writing", () => { ++ const workspace = makeTemporaryDirectory(); ++ const sourceRoot = path.join(workspace, "styles"); ++ const outputRoot = path.join(workspace, "types"); ++ const sourcePath = writeSource(sourceRoot, "valid.scss", "valid"); ++ const definitionPath = writeDefinition( ++ outputRoot, ++ "valid.scss", ++ "valid" ++ ); ++ const before = fs.statSync(definitionPath).mtimeMs; ++ ++ const result = runCli(workspace, listArgs); ++ ++ expect(result.status).toBe(0); ++ expect(combinedOutput(result)).not.toContain("[INVALID TYPES]"); ++ expect(fs.readFileSync(definitionPath, "utf8")).toBe( ++ "export const valid: string;\n" ++ ); ++ expect(fs.statSync(definitionPath).mtimeMs).toBe(before); ++ expect(fs.existsSync(`${sourcePath}.d.ts`)).toBe(false); ++ }); ++ ++ test("reports stale mapped content and exits with status one", () => { ++ const workspace = makeTemporaryDirectory(); ++ const sourceRoot = path.join(workspace, "styles"); ++ const outputRoot = path.join(workspace, "types"); ++ writeSource(sourceRoot, "stale.scss", "stale"); ++ const definitionPath = writeDefinition( ++ outputRoot, ++ "stale.scss", ++ "wrong" ++ ); ++ ++ const result = runCli(workspace, listArgs); ++ ++ expect(result.status).toBe(1); ++ expect(combinedOutput(result)).toContain("[INVALID TYPES]"); ++ expect(fs.readFileSync(definitionPath, "utf8")).toBe( ++ "export const wrong: string;\n" ++ ); ++ }); ++ ++ test("reports a missing mapped declaration without creating output", () => { ++ const workspace = makeTemporaryDirectory(); ++ const sourceRoot = path.join(workspace, "styles"); ++ const outputRoot = path.join(workspace, "types"); ++ writeSource(sourceRoot, "missing.scss", "missing"); ++ ++ const result = runCli(workspace, listArgs); ++ const output = combinedOutput(result); ++ ++ expect(result.status).toBe(1); ++ expect(output).toContain("[INVALID TYPES]"); ++ expect(output).not.toContain("ENOENT"); ++ expect(fs.existsSync(outputRoot)).toBe(false); ++ }); ++ ++ test("does not validate sources excluded by ignore patterns", () => { ++ const workspace = makeTemporaryDirectory(); ++ const sourceRoot = path.join(workspace, "styles"); ++ const outputRoot = path.join(workspace, "types"); ++ writeSource(sourceRoot, "included.scss", "included"); ++ writeSource(sourceRoot, "ignored.scss", "ignored"); ++ writeDefinition(outputRoot, "included.scss", "included"); ++ ++ const result = runCli(workspace, [ ++ ...listArgs, ++ "--ignore", ++ "**/ignored.scss", ++ ]); ++ ++ expect(result.status).toBe(0); ++ expect(combinedOutput(result)).not.toContain("[INVALID TYPES]"); ++ expect( ++ fs.existsSync(path.join(outputRoot, "ignored.scss.d.ts")) ++ ).toBe(false); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,11 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++./node_modules/.bin/jest __tests__/codespec-output-folder.test.ts --runInBand ++./node_modules/.bin/jest \ ++ __tests__/core/write-file.test.ts \ ++ __tests__/core/remove-file.test.ts \ ++ __tests__/core/list-different.test.ts \ ++ --runInBand ++./node_modules/.bin/tsc --noEmit diff --git a/tasks/format-code-task-001096/tests/test.sh b/tasks/format-code-task-001096/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1cad0f5b99167e213ffcc254d8ec2875a7c078f2 --- /dev/null +++ b/tasks/format-code-task-001096/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +__tests__/codespec-output-folder.test.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-001096/tests/test_command.sh b/tasks/format-code-task-001096/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001096/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-001098/environment/Dockerfile b/tasks/format-code-task-001098/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..410c62c8b85dd160afd79e8508373e991c42f6ec --- /dev/null +++ b/tasks/format-code-task-001098/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:55cd246bb58a67d4fc9005de0376806cee9af2e2160a2c89f500ca7add83370e diff --git a/tasks/format-code-task-001098/environment/setup/files/blocklist b/tasks/format-code-task-001098/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001098/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-001098/environment/setup/setup.sh b/tasks/format-code-task-001098/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001098/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-001098/tests/test.patch b/tasks/format-code-task-001098/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8445b6cae0677ab750dbf326034048eea2e21b7e --- /dev/null +++ b/tasks/format-code-task-001098/tests/test.patch @@ -0,0 +1,244 @@ +diff --git a/services/server/test/unit/utils/custom-api-contract-creation.spec.ts b/services/server/test/unit/utils/custom-api-contract-creation.spec.ts +new file mode 100644 +index 00000000..bc1f1081 +--- /dev/null ++++ b/services/server/test/unit/utils/custom-api-contract-creation.spec.ts +@@ -0,0 +1,201 @@ ++import chai from "chai"; ++import nock from "nock"; ++import { SourcifyChain } from "@ethereum-sourcify/lib-sourcify"; ++import { getCreatorTx } from "../../../src/server/services/utils/contract-creation-util"; ++ ++const ADDRESS = "0x00000000000000000000000000000000000000a1"; ++const FIRST_TX = ++ "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; ++const SECOND_TX = ++ "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; ++ ++function makeChain(fetchContractCreationTxUsing: Record) { ++ return new SourcifyChain({ ++ name: "Custom creator API test", ++ chainId: 42262, ++ supported: true, ++ rpc: ["http://localhost:8545"], ++ fetchContractCreationTxUsing: fetchContractCreationTxUsing as any, ++ }); ++} ++ ++describe("custom contract creation APIs", function () { ++ afterEach(() => { ++ nock.cleanAll(); ++ delete process.env.CUSTOM_CREATOR_TOKEN; ++ }); ++ ++ it("expands URL placeholders, sends configured headers, and resolves nested array paths", async function () { ++ process.env.CUSTOM_CREATOR_TOKEN = "verifier-secret"; ++ const chain = makeChain({ ++ customApi: [ ++ { ++ url: "https://custom.example/v1/chains/${CHAIN_ID}/accounts/${ADDRESS}", ++ responsePath: "data.deployments.0.transaction.hash", ++ headers: [ ++ { ++ headerName: "X-Creator-Token", ++ headerEnvName: "CUSTOM_CREATOR_TOKEN", ++ }, ++ ], ++ }, ++ ], ++ }); ++ const scope = nock("https://custom.example", { ++ reqheaders: { "X-Creator-Token": "verifier-secret" }, ++ }) ++ .get(`/v1/chains/42262/accounts/${ADDRESS}`) ++ .reply(200, { ++ data: { deployments: [{ transaction: { hash: FIRST_TX } }] }, ++ }); ++ ++ chai.expect(await getCreatorTx(chain, ADDRESS)).to.equal(FIRST_TX); ++ chai.expect(scope.isDone()).to.equal(true); ++ }); ++ ++ it("omits a configured header when its environment variable is unset", async function () { ++ const chain = makeChain({ ++ customApi: [ ++ { ++ url: "https://no-secret.example/account/${ADDRESS}", ++ responsePath: "hash", ++ headers: [ ++ { ++ headerName: "X-Creator-Token", ++ headerEnvName: "CUSTOM_CREATOR_TOKEN", ++ }, ++ ], ++ }, ++ ], ++ }); ++ const scope = nock("https://no-secret.example") ++ .matchHeader("X-Creator-Token", (value) => value === undefined) ++ .get(`/account/${ADDRESS}`) ++ .reply(200, { hash: FIRST_TX }); ++ ++ chai.expect(await getCreatorTx(chain, ADDRESS)).to.equal(FIRST_TX); ++ chai.expect(scope.isDone()).to.equal(true); ++ }); ++ ++ it("tries custom APIs in declaration order until one returns a valid hash", async function () { ++ const chain = makeChain({ ++ customApi: [ ++ { ++ url: "https://first.example/account/${ADDRESS}", ++ responsePath: "result.txHash", ++ }, ++ { ++ url: "https://second.example/account/${ADDRESS}", ++ responsePath: "result.txHash", ++ }, ++ ], ++ }); ++ const firstScope = nock("https://first.example") ++ .get(`/account/${ADDRESS}`) ++ .reply(200, { result: { txHash: "not-a-transaction-hash" } }); ++ const secondScope = nock("https://second.example") ++ .get(`/account/${ADDRESS}`) ++ .reply(200, { result: { txHash: SECOND_TX } }); ++ ++ chai.expect(await getCreatorTx(chain, ADDRESS)).to.equal(SECOND_TX); ++ chai.expect(firstScope.isDone()).to.equal(true); ++ chai.expect(secondScope.isDone()).to.equal(true); ++ }); ++ ++ it("falls through to an existing provider after custom API failures", async function () { ++ const chain = makeChain({ ++ customApi: [ ++ { ++ url: "https://missing.example/account/${ADDRESS}", ++ responsePath: "result.txHash", ++ }, ++ { ++ url: "https://unavailable.example/account/${ADDRESS}", ++ responsePath: "result.txHash", ++ }, ++ ], ++ blockscoutApi: { url: "https://fallback.example" }, ++ }); ++ const missingScope = nock("https://missing.example") ++ .get(`/account/${ADDRESS}`) ++ .reply(200, { result: {} }); ++ const unavailableScope = nock("https://unavailable.example") ++ .get(`/account/${ADDRESS}`) ++ .reply(503, { error: "temporarily unavailable" }); ++ const fallbackScope = nock("https://fallback.example") ++ .get(`/api/v2/addresses/${ADDRESS}`) ++ .reply(200, { creation_tx_hash: FIRST_TX }); ++ ++ chai.expect(await getCreatorTx(chain, ADDRESS)).to.equal(FIRST_TX); ++ chai.expect(missingScope.isDone()).to.equal(true); ++ chai.expect(unavailableScope.isDone()).to.equal(true); ++ chai.expect(fallbackScope.isDone()).to.equal(true); ++ }); ++ ++ it("stops after the first successful custom API", async function () { ++ const chain = makeChain({ ++ customApi: [ ++ { ++ url: "https://winner.example/account/${ADDRESS}", ++ responsePath: "hash", ++ }, ++ { ++ url: "https://unused.example/account/${ADDRESS}", ++ responsePath: "hash", ++ }, ++ ], ++ blockscoutApi: { url: "https://unused-fallback.example" }, ++ }); ++ const winnerScope = nock("https://winner.example") ++ .get(`/account/${ADDRESS}`) ++ .reply(200, { hash: FIRST_TX }); ++ const unusedCustom = nock("https://unused.example") ++ .get(`/account/${ADDRESS}`) ++ .reply(200, { hash: SECOND_TX }); ++ const unusedFallback = nock("https://unused-fallback.example") ++ .get(`/api/v2/addresses/${ADDRESS}`) ++ .reply(200, { creation_tx_hash: SECOND_TX }); ++ ++ chai.expect(await getCreatorTx(chain, ADDRESS)).to.equal(FIRST_TX); ++ chai.expect(winnerScope.isDone()).to.equal(true); ++ chai.expect(unusedCustom.isDone()).to.equal(false); ++ chai.expect(unusedFallback.isDone()).to.equal(false); ++ }); ++ ++ it("returns null when custom APIs produce no valid transaction hash", async function () { ++ const chain = makeChain({ ++ customApi: [ ++ { ++ url: "https://empty.example/account/${ADDRESS}", ++ responsePath: "hash", ++ }, ++ { ++ url: "https://wrong-type.example/account/${ADDRESS}", ++ responsePath: "hash", ++ }, ++ ], ++ }); ++ const emptyScope = nock("https://empty.example") ++ .get(`/account/${ADDRESS}`) ++ .reply(200, { hash: "" }); ++ const wrongTypeScope = nock("https://wrong-type.example") ++ .get(`/account/${ADDRESS}`) ++ .reply(200, { hash: 123 }); ++ ++ chai.expect(await getCreatorTx(chain, ADDRESS)).to.equal(null); ++ chai.expect(emptyScope.isDone()).to.equal(true); ++ chai.expect(wrongTypeScope.isDone()).to.equal(true); ++ }); ++ ++ it("keeps legacy-only creator lookup behavior unchanged", async function () { ++ const chain = makeChain({ ++ blockscoutApi: { url: "https://legacy.example" }, ++ }); ++ const scope = nock("https://legacy.example") ++ .get(`/api/v2/addresses/${ADDRESS}`) ++ .reply(200, { creation_tx_hash: SECOND_TX }); ++ ++ chai.expect(await getCreatorTx(chain, ADDRESS)).to.equal(SECOND_TX); ++ chai.expect(scope.isDone()).to.equal(true); ++ }); ++}); +diff --git a/services/server/test/verifier-types/custom-api-config.ts b/services/server/test/verifier-types/custom-api-config.ts +new file mode 100644 +index 00000000..438436ee +--- /dev/null ++++ b/services/server/test/verifier-types/custom-api-config.ts +@@ -0,0 +1,18 @@ ++import { FetchContractCreationTxMethods } from "@ethereum-sourcify/lib-sourcify"; ++ ++const customCreatorConfig: FetchContractCreationTxMethods = { ++ customApi: [ ++ { ++ url: "https://creator.example/chains/${CHAIN_ID}/accounts/${ADDRESS}", ++ responsePath: "data.deployments.0.hash", ++ headers: [ ++ { ++ headerName: "X-API-Key", ++ headerEnvName: "CREATOR_API_KEY", ++ }, ++ ], ++ }, ++ ], ++}; ++ ++void customCreatorConfig; +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++npm run build --workspace @ethereum-sourcify/lib-sourcify ++cd services/server ++npm run test:unit -- --grep 'custom contract creation APIs' ++../../node_modules/.bin/tsc --noEmit --strict --esModuleInterop --skipLibCheck --module commonjs --target es2017 test/verifier-types/custom-api-config.ts diff --git a/tasks/format-code-task-001098/tests/test.sh b/tasks/format-code-task-001098/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e854890e9fd3d9d998e40af944ef6d61dab56862 --- /dev/null +++ b/tasks/format-code-task-001098/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' +services/server/test/unit/utils/custom-api-contract-creation.spec.ts +services/server/test/verifier-types/custom-api-config.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-001098/tests/test_command.sh b/tasks/format-code-task-001098/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001098/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-001110/environment/Dockerfile b/tasks/format-code-task-001110/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b68d8177eab7c31816a47d2d02100a093abfb2bf --- /dev/null +++ b/tasks/format-code-task-001110/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:dffa0a8ea8fb55c02e4c1196e3c9b1980a2d3d62e970340f579dda020c2ed440 diff --git a/tasks/format-code-task-001110/environment/setup/files/blocklist b/tasks/format-code-task-001110/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001110/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-001110/environment/setup/setup.sh b/tasks/format-code-task-001110/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001110/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-001110/tests/test.patch b/tasks/format-code-task-001110/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..dae29fc7e72f20bb06f0c32fb1c5dce36f9e4a29 --- /dev/null +++ b/tasks/format-code-task-001110/tests/test.patch @@ -0,0 +1,143 @@ +diff --git a/whole-repo-tests/test_release_contract.py b/whole-repo-tests/test_release_contract.py +new file mode 100644 +index 000000000..4d78d4476 +--- /dev/null ++++ b/whole-repo-tests/test_release_contract.py +@@ -0,0 +1,128 @@ ++import tempfile ++import unittest ++from pathlib import Path ++ ++from hypothesistooling import releasemanagement as rm ++ ++ ++class ReleaseContractTests(unittest.TestCase): ++ def assert_result(self, expected, function, *args): ++ try: ++ actual = function(*args) ++ except Exception as error: ++ self.fail("unexpected %s: %s" % (type(error).__name__, error)) ++ self.assertEqual(actual, expected) ++ ++ def assert_value_error(self, function, *args): ++ try: ++ function(*args) ++ except ValueError: ++ return ++ except Exception as error: ++ self.fail("expected ValueError, got %s: %s" % (type(error).__name__, error)) ++ self.fail("expected ValueError") ++ ++ def test_release_header_accepts_bom_whitespace_and_crlf(self): ++ contents = "\ufeff RELEASE_TYPE: minor \r\n\r\nAdd feature. \r\n" ++ self.assert_result(("minor", "Add feature."), rm.parse_release_file_contents, contents, "release") ++ ++ def test_release_header_rejects_trailing_directive_text(self): ++ for header in ( ++ "RELEASE_TYPE: patch extra\nnotes", ++ "RELEASE_TYPE: major # comment\nnotes", ++ "RELEASE_TYPE: minor\ttrailing\nnotes", ++ ): ++ self.assert_value_error(rm.parse_release_file_contents, header, "release") ++ ++ def test_release_body_strips_line_endings_without_destroying_indentation(self): ++ contents = "RELEASE_TYPE: patch\n\n bullet\t \n\n continuation\n\n" ++ self.assert_result( ++ ("patch", " bullet\n\n continuation"), ++ rm.parse_release_file_contents, ++ contents, ++ "release", ++ ) ++ ++ def test_release_header_errors_include_missing_and_unknown_types(self): ++ for contents in ("", "notes first\n", "RELEASE_TYPE: feature\nnotes"): ++ self.assert_value_error(rm.parse_release_file_contents, contents, "release.md") ++ ++ def test_extract_assignment_rejects_duplicate_exact_assignments(self): ++ self.assert_value_error( ++ rm.extract_assignment_from_string, "version = '1'\nversion='2'", "version" ++ ) ++ self.assert_result( ++ "'2'", rm.extract_assignment_from_string, "myversion = '1'\nversion='2'", "version" ++ ) ++ ++ def test_replace_assignment_preserves_crlf_and_terminal_newline(self): ++ source = " version = '1'\r\nother=2\r\n" ++ self.assert_result( ++ " version = '3'\r\nother=2\r\n", ++ rm.replace_assignment_in_string, ++ source, ++ "version", ++ "'3'", ++ ) ++ ++ def test_replace_assignment_preserves_lf_without_terminal_newline(self): ++ source = "version=1\nother = 2" ++ self.assert_result( ++ "version=3\nother = 2", ++ rm.replace_assignment_in_string, ++ source, ++ "version", ++ "3", ++ ) ++ ++ def test_replace_assignment_rejects_missing_and_duplicate_targets(self): ++ for source in ("other = 1\n", "version=1\nversion=2\n"): ++ self.assert_value_error(rm.replace_assignment_in_string, source, "version", "3") ++ ++ def test_parse_version_requires_three_nonnegative_integer_components(self): ++ self.assert_result((1, 20, 3), rm.parse_version, "1.20.3") ++ self.assert_result((0, 0, 0), rm.parse_version, "0.0.0") ++ for value in ( ++ "1.2", ++ "1.2.3.4", ++ "1.-2.3", ++ "01.2.3", ++ "1.2.x", ++ " 1.2.3", ++ "1.2.3 ", ++ ): ++ self.assert_value_error(rm.parse_version, value) ++ ++ def test_bump_version_updates_requested_component_and_resets_lower(self): ++ self.assert_result(("1.2.4", (1, 2, 4)), rm.bump_version_info, (1, 2, 3), "patch") ++ self.assert_result(("1.3.0", (1, 3, 0)), rm.bump_version_info, (1, 2, 3), "minor") ++ self.assert_result(("2.0.0", (2, 0, 0)), rm.bump_version_info, (1, 2, 3), "major") ++ ++ def test_bump_version_rejects_invalid_release_type_or_shape(self): ++ for version, release_type in ( ++ ((1, 2), "patch"), ++ ((1, -1, 0), "minor"), ++ ((1, 2, 3), "feature"), ++ ((1, 2.0, 3), "patch"), ++ ): ++ self.assert_value_error(rm.bump_version_info, version, release_type) ++ ++ def test_changelog_update_prepends_entry_and_preserves_previous_text(self): ++ previous = "# old release\n\nold notes\n" ++ original_date = rm.release_date_string ++ rm.release_date_string = lambda: "2099-01-02" ++ try: ++ with tempfile.TemporaryDirectory() as directory: ++ path = Path(directory) / "CHANGELOG.md" ++ path.write_text(previous, encoding="utf-8") ++ rm.update_markdown_changelog(str(path), "Demo", "2.0.0", "new notes\n") ++ self.assertEqual( ++ path.read_text(encoding="utf-8"), ++ "# Demo 2.0.0 (2099-01-02)\n\nnew notes\n\n" + previous, ++ ) ++ finally: ++ rm.release_date_string = original_date ++ ++ ++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,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++PYTHONPATH=tooling/src python whole-repo-tests/test_release_contract.py diff --git a/tasks/format-code-task-001110/tests/test.sh b/tasks/format-code-task-001110/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e582dd5d6f80187e1f9a86c4f6dca2d85dd9d7a9 --- /dev/null +++ b/tasks/format-code-task-001110/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' +whole-repo-tests/test_release_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001110/tests/test_command.sh b/tasks/format-code-task-001110/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001110/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-001117/environment/Dockerfile b/tasks/format-code-task-001117/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2ea87e2db18e5c98e1c149e09e538bafbc1150b1 --- /dev/null +++ b/tasks/format-code-task-001117/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:e2179d92610343a2d541552ea340a45bc483168d3d5136409e4dcc28fc6359e3 diff --git a/tasks/format-code-task-001117/environment/setup/files/blocklist b/tasks/format-code-task-001117/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001117/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-001117/environment/setup/setup.sh b/tasks/format-code-task-001117/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001117/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-001117/tests/test.patch b/tasks/format-code-task-001117/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..da85a0090b0f96abbbd19969ed4a32a5fd5c401b --- /dev/null +++ b/tasks/format-code-task-001117/tests/test.patch @@ -0,0 +1,145 @@ +diff --git a/tests/DescriptorContractTest.php b/tests/DescriptorContractTest.php +new file mode 100644 +index 0000000..c59cdca +--- /dev/null ++++ b/tests/DescriptorContractTest.php +@@ -0,0 +1,129 @@ ++assertSame(3, $parsed['arguments_count']); ++ $this->assertSame('int', $parsed['arguments'][0]['type']); ++ $this->assertSame(0, $parsed['arguments'][0]['deep_array']); ++ $this->assertSame('class', $parsed['arguments'][1]['type']); ++ $this->assertSame('java/lang/String', $parsed['arguments'][1]['class_name']); ++ $this->assertSame(2, $parsed['arguments'][1]['deep_array']); ++ $this->assertSame('boolean', $parsed['arguments'][2]['type']); ++ $this->assertSame('class', $parsed[0]['type']); ++ $this->assertSame('java/util/Map', $parsed[0]['class_name']); ++ } ++ ++ public function testParsesEveryPrimitiveFieldDescriptor(): void ++ { ++ foreach ([ ++ 'B' => 'byte', 'C' => 'char', 'D' => 'double', 'F' => 'float', ++ 'I' => 'int', 'J' => 'long', 'S' => 'short', 'Z' => 'boolean', ++ ] as $descriptor => $type) { ++ $parsed = Formatter::parseSignature($descriptor); ++ $this->assertSame($type, $parsed[0]['type'], $descriptor); ++ $this->assertSame(0, $parsed[0]['deep_array'], $descriptor); ++ } ++ } ++ ++ public function testParsesObjectAndPrimitiveArrays(): void ++ { ++ $this->assertSame('int', Formatter::parseSignature('[I')[0]['type']); ++ $this->assertSame(1, Formatter::parseSignature('[I')[0]['deep_array']); ++ ++ $parsed = Formatter::parseSignature('[[D'); ++ $this->assertSame('double', $parsed[0]['type']); ++ $this->assertSame(2, $parsed[0]['deep_array']); ++ ++ $parsed = Formatter::parseSignature('Ljava/util/Map$Entry;'); ++ $this->assertSame('class', $parsed[0]['type']); ++ $this->assertSame('java/util/Map$Entry', $parsed[0]['class_name']); ++ } ++ ++ public function testParsesVoidReturnAndEmptyArguments(): void ++ { ++ $parsed = Formatter::parseSignature('()V'); ++ $this->assertSame([], $parsed['arguments']); ++ $this->assertSame(0, $parsed['arguments_count']); ++ $this->assertSame('void', $parsed[0]['type']); ++ } ++ ++ public function testBuildsCanonicalArgumentDescriptorAndRoundTrips(): void ++ { ++ $signatures = [ ++ ['type' => 'int', 'deep_array' => 0], ++ ['type' => 'class', 'class_name' => 'java.lang.String', 'deep_array' => 1], ++ ['type' => 'long', 'deep_array' => 2], ++ ]; ++ ++ $descriptor = Formatter::buildArgumentsSignature($signatures); ++ ++ $this->assertSame('I[Ljava/lang/String;[[J', $descriptor); ++ $parsed = Formatter::parseSignature($descriptor); ++ $this->assertSame('int', $parsed[0]['type']); ++ $this->assertSame('class', $parsed[1]['type']); ++ $this->assertSame('java/lang/String', $parsed[1]['class_name']); ++ $this->assertSame(1, $parsed[1]['deep_array']); ++ $this->assertSame('long', $parsed[2]['type']); ++ $this->assertSame(2, $parsed[2]['deep_array']); ++ } ++ ++ public function testAmbiguousPHPConversionPreservesArraysAndClasses(): void ++ { ++ $converted = Formatter::signatureConvertToAmbiguousForPHP([ ++ ['type' => 'long', 'deep_array' => 1], ++ ['type' => 'double', 'deep_array' => 0], ++ ['type' => 'class', 'class_name' => 'java/lang/String', 'deep_array' => 0], ++ ]); ++ ++ $this->assertSame('int', $converted[0]['type']); ++ $this->assertSame(1, $converted[0]['deep_array']); ++ $this->assertSame('float', $converted[1]['type']); ++ $this->assertSame('java/lang/String', $converted[2]['class_name']); ++ } ++ ++ /** ++ * @dataProvider malformedFieldDescriptorProvider ++ */ ++ public function testRejectsMalformedFieldDescriptors(string $descriptor): void ++ { ++ $this->expectException(FormatterException::class); ++ Formatter::parseSignature($descriptor); ++ } ++ ++ public function malformedFieldDescriptorProvider(): array ++ { ++ return [ ++ 'empty' => [''], ++ 'unknown field code' => ['Q'], ++ 'unterminated class' => ['Ljava/lang/String'], ++ 'trailing data' => ['I$I'], ++ ]; ++ } ++ ++ /** ++ * @dataProvider malformedMethodDescriptorProvider ++ */ ++ public function testRejectsMalformedMethodDescriptors(string $descriptor): void ++ { ++ $this->expectException(FormatterException::class); ++ Formatter::parseSignature($descriptor); ++ } ++ ++ public function malformedMethodDescriptorProvider(): array ++ { ++ return [ ++ 'missing method return' => ['(I)'], ++ 'void argument' => ['(V)I'], ++ 'missing close paren' => ['(I'], ++ ]; ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++./vendor/bin/phpunit tests/DescriptorContractTest.php --testdox diff --git a/tasks/format-code-task-001117/tests/test.sh b/tasks/format-code-task-001117/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7db7c3dce2184850b15d98b8b2736b6d7e45df3a --- /dev/null +++ b/tasks/format-code-task-001117/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/DescriptorContractTest.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-001117/tests/test_command.sh b/tasks/format-code-task-001117/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001117/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-001119/environment/Dockerfile b/tasks/format-code-task-001119/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e62a9e624295d04c579ae5ec1b791c19c2c14f71 --- /dev/null +++ b/tasks/format-code-task-001119/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:4ee5bda3f67955d73fbd03399ca01a99e1ba1f480029a7fc92258fdd71858746 diff --git a/tasks/format-code-task-001119/environment/setup/files/blocklist b/tasks/format-code-task-001119/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001119/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-001119/environment/setup/setup.sh b/tasks/format-code-task-001119/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001119/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-001119/tests/test.patch b/tasks/format-code-task-001119/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9f9094901011d7c83e6d2703071c4900f11b4f8d --- /dev/null +++ b/tasks/format-code-task-001119/tests/test.patch @@ -0,0 +1,92 @@ +diff --git a/test/unit/test_semver_precedence_contract.py b/test/unit/test_semver_precedence_contract.py +new file mode 100644 +index 000000000..0d06f6035 +--- /dev/null ++++ b/test/unit/test_semver_precedence_contract.py +@@ -0,0 +1,73 @@ ++from dbt.semver import ( ++ VersionSpecifier, ++ find_possible_versions, ++ reduce_versions, ++ resolve_to_specific_version, ++ versions_compatible, ++) ++ ++ ++def test_semver_prerelease_precedence_chain(): ++ ordered = [ ++ '1.0.0-alpha', ++ '1.0.0-alpha.1', ++ '1.0.0-alpha.beta', ++ '1.0.0-beta', ++ '1.0.0-beta.2', ++ '1.0.0-beta.11', ++ '1.0.0-rc.1', ++ '1.0.0', ++ ] ++ ++ for lower, higher in zip(ordered, ordered[1:]): ++ assert VersionSpecifier.from_version_string(lower).compare( ++ VersionSpecifier.from_version_string(higher) ++ ) == -1 ++ ++ ++def test_semver_numeric_core_precedence(): ++ assert VersionSpecifier.from_version_string('1.0.0').compare( ++ VersionSpecifier.from_version_string('1.1.0') ++ ) == -1 ++ assert VersionSpecifier.from_version_string('1.1.0').compare( ++ VersionSpecifier.from_version_string('2.0.0') ++ ) == -1 ++ ++ ++def test_exact_versions_use_prerelease_precedence(): ++ assert not versions_compatible('1.0.0-alpha', '1.0.0') ++ ++ ++def test_range_bounds_use_prerelease_precedence(): ++ assert not versions_compatible('>=1.0.0', '1.0.0-beta') ++ assert not versions_compatible('<=1.0.0-alpha', '1.0.0-alpha.1') ++ assert versions_compatible('>1.0.0-alpha', '1.0.0-alpha.1') ++ ++ ++def test_build_metadata_is_ignored_for_precedence_and_exact_compatibility(): ++ first = VersionSpecifier.from_version_string('1.0.0+linux') ++ second = VersionSpecifier.from_version_string('1.0.0+macos') ++ assert first.compare(second) == 0 ++ assert versions_compatible('1.0.0+linux', '1.0.0+macos') ++ ++ ++def test_find_possible_versions_filters_prereleases_and_sorts_semantically(): ++ stable_range = reduce_versions('>=1.0.0') ++ assert find_possible_versions( ++ stable_range, ++ ['1.0.0-beta', '0.9.9', '1.0.0', '1.0.0-alpha'], ++ ) == ['1.0.0'] ++ ++ prerelease_range = reduce_versions('>=1.0.0-alpha') ++ assert find_possible_versions( ++ prerelease_range, ++ ['1.0.0-alpha', '1.0.0', '1.0.0-beta'], ++ ) == ['1.0.0', '1.0.0-beta', '1.0.0-alpha'] ++ ++ ++def test_resolver_chooses_highest_precedence_and_keeps_original_text(): ++ requested = reduce_versions('>=1.0.0-alpha') ++ assert resolve_to_specific_version( ++ requested, ++ ['1.0.0-alpha', '1.0.0-beta', '1.0.0+linux'], ++ ) == '1.0.0+linux' +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++export PYTHONPATH="$(pwd)/core:$(pwd)/plugins/postgres:$(pwd)/.venv/lib/python3.8/site-packages" ++/root/.pyenv/versions/3.8.18/bin/python3 -m pytest -q \ ++ test/unit/test_semver_precedence_contract.py \ ++ test/unit/test_semver.py diff --git a/tasks/format-code-task-001119/tests/test.sh b/tasks/format-code-task-001119/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c1c8ee20e7b9c5474e544fba7bc74ecd3be9b81 --- /dev/null +++ b/tasks/format-code-task-001119/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/unit/test_semver_precedence_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001119/tests/test_command.sh b/tasks/format-code-task-001119/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001119/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-001121/environment/Dockerfile b/tasks/format-code-task-001121/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..25aff85236d92b3b2d8d1252b7f74842d26dccc3 --- /dev/null +++ b/tasks/format-code-task-001121/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:d96c08c46b9262c95a87c3061f5de501d468597c047862acb9ef2e5726c6d7a2 diff --git a/tasks/format-code-task-001121/environment/setup/files/blocklist b/tasks/format-code-task-001121/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001121/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-001121/environment/setup/setup.sh b/tasks/format-code-task-001121/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001121/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-001121/tests/test.patch b/tasks/format-code-task-001121/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8ae030e6abd88b02e5027e087e1d43ab5994af67 --- /dev/null +++ b/tasks/format-code-task-001121/tests/test.patch @@ -0,0 +1,220 @@ +diff --git a/libbeat/processors/actions/decode_json_fields_recursive_test.go b/libbeat/processors/actions/decode_json_fields_recursive_test.go +new file mode 100644 +index 000000000..f3d8a93a1 +--- /dev/null ++++ b/libbeat/processors/actions/decode_json_fields_recursive_test.go +@@ -0,0 +1,199 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package actions_test ++ ++import ( ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++ ++ "github.com/elastic/beats/libbeat/beat" ++ "github.com/elastic/beats/libbeat/common" ++ _ "github.com/elastic/beats/libbeat/processors/actions" ++ "github.com/elastic/beats/libbeat/processors" ++) ++ ++func runRecursiveDecoder(t *testing.T, yaml string, fields common.MapStr) *beat.Event { ++ t.Helper() ++ ++ config, err := common.NewConfigWithYAML([]byte(yaml), "test") ++ if !assert.NoError(t, err) { ++ return nil ++ } ++ processor, err := processors.New([]*common.Config{config}) ++ if !assert.NoError(t, err) { ++ return nil ++ } ++ ++ event, err := processor.Run(&beat.Event{Fields: fields}) ++ if !assert.NoError(t, err) { ++ return nil ++ } ++ if !assert.NotNil(t, event) { ++ return nil ++ } ++ return event ++} ++ ++func eventValue(t *testing.T, event *beat.Event, key string) interface{} { ++ t.Helper() ++ if event == nil { ++ return nil ++ } ++ value, err := event.GetValue(key) ++ if !assert.NoError(t, err) { ++ return nil ++ } ++ return value ++} ++ ++func mapValue(t *testing.T, value interface{}) common.MapStr { ++ t.Helper() ++ mapValue, ok := value.(map[string]interface{}) ++ if !assert.True(t, ok, "expected decoded object, got %T", value) { ++ return common.MapStr{} ++ } ++ return common.MapStr(mapValue) ++} ++ ++func arrayValue(t *testing.T, value interface{}) []interface{} { ++ t.Helper() ++ arrayValue, ok := value.([]interface{}) ++ if !assert.True(t, ok, "expected decoded array, got %T", value) { ++ return nil ++ } ++ return arrayValue ++} ++ ++func TestDecodeJSONFieldsRecursesThroughNestedObjects(t *testing.T) { ++payload := `{"outer":{"encoded":"{\"level\":\"one\",\"next\":\"{\\\"level\\\":\\\"two\\\",\\\"tail\\\":\\\"{\\\\\\\"level\\\\\\\":\\\\\\\"three\\\\\\\"}\\\"}\"}"},"plain":"not-json"}` ++ event := runRecursiveDecoder(t, ` ++decode_json_fields: ++ fields: [payload] ++ target: decoded ++ max_depth: 3 ++ process_array: true ++`, common.MapStr{ ++ "payload": payload, ++ }) ++ ++ decoded := mapValue(t, eventValue(t, event, "decoded")) ++ outer := mapValue(t, decoded["outer"]) ++ encoded := mapValue(t, outer["encoded"]) ++ next := mapValue(t, encoded["next"]) ++ assert.Equal(t, "one", encoded["level"]) ++ assert.Equal(t, "two", next["level"]) ++ assert.Equal(t, `{"level":"three"}`, next["tail"]) ++ assert.Equal(t, "not-json", decoded["plain"]) ++ assert.Equal(t, payload, eventValue(t, event, "payload")) ++} ++ ++func TestDecodeJSONFieldsRecursesIntoArraysOnlyWhenEnabled(t *testing.T) { ++ payload := `{"objects":[{"encoded":"{\"kind\":\"object\"}"},"{\"kind\":\"string\"}",7],"outside":"{\"kind\":\"map\"}"}` ++ ++ t.Run("enabled", func(t *testing.T) { ++ event := runRecursiveDecoder(t, ` ++decode_json_fields: ++ fields: [payload] ++ target: decoded ++ max_depth: 3 ++ process_array: true ++`, common.MapStr{"payload": payload}) ++ ++ decoded := mapValue(t, eventValue(t, event, "decoded")) ++ objects := arrayValue(t, decoded["objects"]) ++ first := mapValue(t, objects[0]) ++ encoded := mapValue(t, first["encoded"]) ++ second := mapValue(t, objects[1]) ++ outside := mapValue(t, decoded["outside"]) ++ assert.Equal(t, "object", encoded["kind"]) ++ assert.Equal(t, "string", second["kind"]) ++ assert.EqualValues(t, 7, objects[2]) ++ assert.Equal(t, "map", outside["kind"]) ++ }) ++ ++ t.Run("disabled", func(t *testing.T) { ++ event := runRecursiveDecoder(t, ` ++decode_json_fields: ++ fields: [payload] ++ target: decoded ++ max_depth: 3 ++ process_array: false ++`, common.MapStr{"payload": payload}) ++ ++ decoded := mapValue(t, eventValue(t, event, "decoded")) ++ objects := arrayValue(t, decoded["objects"]) ++ first := mapValue(t, objects[0]) ++ outside := mapValue(t, decoded["outside"]) ++ assert.Equal(t, `{"kind":"object"}`, first["encoded"]) ++ assert.Equal(t, `{"kind":"string"}`, objects[1]) ++ assert.EqualValues(t, 7, objects[2]) ++ assert.Equal(t, "map", outside["kind"]) ++ }) ++} ++ ++func TestDecodeJSONFieldsRecursiveRootTargetKeepsLegacyMergeRules(t *testing.T) { ++ payload := `{"existing":"replacement","nested":{"encoded":"{\"value\":2}"}}` ++ event := runRecursiveDecoder(t, ` ++decode_json_fields: ++ fields: [payload] ++ target: "" ++ max_depth: 3 ++ process_array: true ++ overwrite_keys: false ++`, common.MapStr{ ++ "payload": payload, ++ "existing": "preserved", ++ }) ++ ++ assert.Equal(t, "preserved", eventValue(t, event, "existing")) ++ assert.Equal(t, payload, eventValue(t, event, "payload")) ++ nested := mapValue(t, eventValue(t, event, "nested")) ++ encoded := mapValue(t, nested["encoded"]) ++ assert.EqualValues(t, 2, encoded["value"]) ++ ++ overwrite := runRecursiveDecoder(t, ` ++decode_json_fields: ++ fields: [payload] ++ target: "" ++ max_depth: 2 ++ overwrite_keys: true ++`, common.MapStr{ ++ "payload": `{"existing":"replacement"}`, ++ "existing": "preserved", ++ }) ++ assert.Equal(t, "replacement", eventValue(t, overwrite, "existing")) ++} ++ ++func TestDecodeJSONFieldsMaxDepthOneDoesNotDecodeChildren(t *testing.T) { ++ event := runRecursiveDecoder(t, ` ++decode_json_fields: ++ fields: [payload] ++ target: decoded ++ max_depth: 1 ++ process_array: true ++`, common.MapStr{ ++ "payload": `{"nested":{"encoded":"{\"value\":2}"},"array":["{\"value\":3}"]}`, ++ }) ++ ++ decoded := mapValue(t, eventValue(t, event, "decoded")) ++ nested := mapValue(t, decoded["nested"]) ++ array := arrayValue(t, decoded["array"]) ++ assert.Equal(t, `{"value":2}`, nested["encoded"]) ++ assert.Equal(t, `{"value":3}`, array[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,10 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++ ++ ++GO_TEST_GOPATH="$(mktemp -d)" ++mkdir -p "${GO_TEST_GOPATH}/src/github.com/elastic" ++ln -s "$(pwd)" "${GO_TEST_GOPATH}/src/github.com/elastic/beats" ++GO111MODULE=off GOPATH="${GO_TEST_GOPATH}" go test -vet=off github.com/elastic/beats/libbeat/processors/actions -run '^TestDecodeJSONFields(RecursesThroughNestedObjects|RecursesIntoArraysOnlyWhenEnabled|RecursiveRootTargetKeepsLegacyMergeRules|MaxDepthOneDoesNotDecodeChildren)$' diff --git a/tasks/format-code-task-001121/tests/test.sh b/tasks/format-code-task-001121/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..630def31c79e88f91e8f00ca6c71c37d1f18686b --- /dev/null +++ b/tasks/format-code-task-001121/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' +libbeat/processors/actions/decode_json_fields_recursive_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-001121/tests/test_command.sh b/tasks/format-code-task-001121/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001121/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-001126/environment/Dockerfile b/tasks/format-code-task-001126/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f247f805025aec75724b22ca120f47d7916bf549 --- /dev/null +++ b/tasks/format-code-task-001126/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:59928805ad0b2ae17195e6af1f8f0cf01b94177b28ba59c352e65e88b2467cbb diff --git a/tasks/format-code-task-001126/environment/setup/files/blocklist b/tasks/format-code-task-001126/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001126/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-001126/environment/setup/setup.sh b/tasks/format-code-task-001126/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001126/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-001126/tests/test.patch b/tasks/format-code-task-001126/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7a219078dffa19772e808d858d5e8b81faa68459 --- /dev/null +++ b/tasks/format-code-task-001126/tests/test.patch @@ -0,0 +1,277 @@ +diff --git a/ddtrace/tracer/w3c_baggage_codespec_test.go b/ddtrace/tracer/w3c_baggage_codespec_test.go +new file mode 100644 +index 000000000..5878deb71 +--- /dev/null ++++ b/ddtrace/tracer/w3c_baggage_codespec_test.go +@@ -0,0 +1,261 @@ ++ ++ ++ ++ ++ ++package tracer_test ++ ++import ( ++ "fmt" ++ "net/http" ++ "strings" ++ "testing" ++ ++ "github.com/DataDog/dd-trace-go/v2/ddtrace" ++ "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer" ++) ++ ++const codespecTraceparent = "00-12345678901234567890123456789012-1234567890123456-01" ++ ++func codespecPropagator(t *testing.T, extractStyle, injectStyle string) tracer.Propagator { ++ t.Helper() ++ t.Setenv("DD_TRACE_PROPAGATION_STYLE", "") ++ t.Setenv("DD_PROPAGATION_STYLE_EXTRACT", "") ++ t.Setenv("DD_PROPAGATION_STYLE_INJECT", "") ++ t.Setenv("DD_TRACE_PROPAGATION_STYLE_EXTRACT", extractStyle) ++ t.Setenv("DD_TRACE_PROPAGATION_STYLE_INJECT", injectStyle) ++ return tracer.NewPropagator(nil) ++} ++ ++func codespecBaggage(ctx ddtrace.SpanContext) map[string]string { ++ got := make(map[string]string) ++ ctx.ForeachBaggageItem(func(k, v string) bool { ++ got[k] = v ++ return true ++ }) ++ return got ++} ++ ++func codespecExtract(t *testing.T, p tracer.Propagator, carrier interface{}) ddtrace.SpanContext { ++ t.Helper() ++ ctx, err := p.Extract(carrier) ++ if err != nil { ++ t.Fatalf("Extract returned an error: %v", err) ++ } ++ return ctx ++} ++ ++func TestCodeSpecW3CBaggageRoundTripEncoding(t *testing.T) { ++ p := codespecPropagator(t, "tracecontext", "tracecontext") ++ in := http.Header{} ++ in.Set("Traceparent", codespecTraceparent) ++ in.Set("Baggage", "account=alpha%20team,opaque=a%2Cb%3Bc%3D1;vendor=meta,plus=a+b,unicode=caf%C3%A9") ++ ++ ctx := codespecExtract(t, p, tracer.HTTPHeadersCarrier(in)) ++ want := map[string]string{ ++ "account": "alpha team", ++ "opaque": "a,b;c=1", ++ "plus": "a+b", ++ "unicode": "caf\u00e9", ++ } ++ if got := codespecBaggage(ctx); !codespecMapsEqual(got, want) { ++ t.Fatalf("extracted baggage = %#v, want %#v", got, want) ++ } ++ ++ out := http.Header{} ++ if err := p.Inject(ctx, tracer.HTTPHeadersCarrier(out)); err != nil { ++ t.Fatalf("Inject returned an error: %v", err) ++ } ++ const wantHeader = "account=alpha%20team,opaque=a%2Cb%3Bc%3D1,plus=a%2Bb,unicode=caf%C3%A9" ++ if got := out.Get("Baggage"); got != wantHeader { ++ t.Fatalf("Baggage header = %q, want %q", got, wantHeader) ++ } ++ for key := range want { ++ if got := out.Get(tracer.DefaultBaggageHeaderPrefix + key); got != "" { ++ t.Errorf("tracecontext-only injection unexpectedly wrote legacy header for %q: %q", key, got) ++ } ++ } ++} ++ ++func TestCodeSpecW3CBaggageRepeatedFieldsAndRecovery(t *testing.T) { ++ p := codespecPropagator(t, "tracecontext", "tracecontext") ++ in := http.Header{} ++ in.Set("Traceparent", codespecTraceparent) ++ in.Add("Baggage", "dup=first, good = value ; prop=one, =empty, bad key=nope") ++ in.Add("Baggage", "dup=second, broken=%ZZ, tail=ok") ++ ++ ctx := codespecExtract(t, p, tracer.HTTPHeadersCarrier(in)) ++ want := map[string]string{"dup": "first", "good": "value", "tail": "ok"} ++ if got := codespecBaggage(ctx); !codespecMapsEqual(got, want) { ++ t.Fatalf("extracted baggage = %#v, want valid members %#v", got, want) ++ } ++} ++ ++func TestCodeSpecW3CBaggageMixedStylePrecedence(t *testing.T) { ++ p := codespecPropagator(t, "datadog,tracecontext", "datadog,tracecontext") ++ in := http.Header{} ++ in.Set("X-Datadog-Trace-Id", "123") ++ in.Set("X-Datadog-Parent-Id", "456") ++ in.Set("X-Datadog-Sampling-Priority", "1") ++ in.Set("Traceparent", codespecTraceparent) ++ in.Set("Baggage", "shared=standard,w3c=present") ++ in.Set("Ot-Baggage-Shared", "legacy") ++ in.Set("Ot-Baggage-Old", "kept") ++ ++ ctx := codespecExtract(t, p, tracer.HTTPHeadersCarrier(in)) ++ if ctx.TraceID() != 123 || ctx.SpanID() != 456 { ++ t.Fatalf("configured trace precedence changed: got trace/span %d/%d, want 123/456", ctx.TraceID(), ctx.SpanID()) ++ } ++ want := map[string]string{"old": "kept", "shared": "standard", "w3c": "present"} ++ if got := codespecBaggage(ctx); !codespecMapsEqual(got, want) { ++ t.Fatalf("mixed-style baggage = %#v, want %#v", got, want) ++ } ++ ++ out := http.Header{} ++ if err := p.Inject(ctx, tracer.HTTPHeadersCarrier(out)); err != nil { ++ t.Fatalf("Inject returned an error: %v", err) ++ } ++ if got, want := out.Get("Baggage"), "old=kept,shared=standard,w3c=present"; got != want { ++ t.Errorf("standard Baggage header = %q, want %q", got, want) ++ } ++ for key, wantValue := range want { ++ if got := out.Get(tracer.DefaultBaggageHeaderPrefix + key); got != wantValue { ++ t.Errorf("legacy baggage header %q = %q, want %q", key, got, wantValue) ++ } ++ } ++} ++ ++func TestCodeSpecW3CBaggageStyleIsolation(t *testing.T) { ++ p := codespecPropagator(t, "datadog", "datadog") ++ in := tracer.TextMapCarrier{ ++ "x-datadog-trace-id": "123", ++ "x-datadog-parent-id": "456", ++ "baggage": "standard=ignored", ++ "ot-baggage-legacy": "kept", ++ } ++ ctx := codespecExtract(t, p, in) ++ if got, want := codespecBaggage(ctx), map[string]string{"legacy": "kept"}; !codespecMapsEqual(got, want) { ++ t.Fatalf("Datadog-only extraction baggage = %#v, want %#v", got, want) ++ } ++ out := tracer.TextMapCarrier{} ++ if err := p.Inject(ctx, out); err != nil { ++ t.Fatalf("Inject returned an error: %v", err) ++ } ++ if _, ok := out["baggage"]; ok { ++ t.Errorf("Datadog-only injection unexpectedly wrote a W3C baggage header: %#v", out) ++ } ++ if got := out["ot-baggage-legacy"]; got != "kept" { ++ t.Errorf("legacy baggage header = %q, want kept", got) ++ } ++} ++ ++func TestCodeSpecW3CBaggageExtractionLimits(t *testing.T) { ++ t.Run("8192-byte-boundary", func(t *testing.T) { ++ p := codespecPropagator(t, "tracecontext", "tracecontext") ++ atLimit := "edge=" + strings.Repeat("x", 8192-len("edge=")) ++ ctx := codespecExtract(t, p, tracer.TextMapCarrier{ ++ "traceparent": codespecTraceparent, ++ "baggage": atLimit, ++ }) ++ if got := codespecBaggage(ctx)["edge"]; len(got) != 8192-len("edge=") { ++ t.Fatalf("8192-byte baggage value length = %d, want %d", len(got), 8192-len("edge=")) ++ } ++ ++ ctx = codespecExtract(t, p, tracer.TextMapCarrier{ ++ "traceparent": codespecTraceparent, ++ "baggage": atLimit + "x", ++ "ot-baggage-old": "kept", ++ }) ++ if got, want := codespecBaggage(ctx), map[string]string{"old": "kept"}; !codespecMapsEqual(got, want) { ++ t.Fatalf("over-limit extraction baggage = %#v, want %#v", got, want) ++ } ++ }) ++ ++ t.Run("64-member-boundary", func(t *testing.T) { ++ p := codespecPropagator(t, "tracecontext", "tracecontext") ++ members := make([]string, 65) ++ for i := range members { ++ members[i] = fmt.Sprintf("k%02d=v", i) ++ } ++ ctx := codespecExtract(t, p, tracer.TextMapCarrier{ ++ "traceparent": codespecTraceparent, ++ "baggage": strings.Join(members, ","), ++ }) ++ got := codespecBaggage(ctx) ++ if len(got) != 64 || got["k63"] != "v" { ++ t.Fatalf("member-limited baggage has %d entries and k63=%q, want 64 entries through k63", len(got), got["k63"]) ++ } ++ if _, ok := got["k64"]; ok { ++ t.Error("65th baggage member was not ignored") ++ } ++ }) ++} ++ ++func TestCodeSpecW3CBaggageInjectionLimitsAndValidation(t *testing.T) { ++ t.Run("count-and-key-validation", func(t *testing.T) { ++ p := codespecPropagator(t, "tracecontext", "tracecontext") ++ in := tracer.TextMapCarrier{ ++ "traceparent": codespecTraceparent, ++ "ot-baggage-bad key": "nope", ++ } ++ members := make([]string, 65) ++ for i := range members { ++ key := fmt.Sprintf("k%02d", i) ++ in["ot-baggage-"+key] = "v" ++ members[i] = key + "=v" ++ } ++ ctx := codespecExtract(t, p, in) ++ out := tracer.TextMapCarrier{} ++ if err := p.Inject(ctx, out); err != nil { ++ t.Fatalf("Inject returned an error: %v", err) ++ } ++ if got, want := out["baggage"], strings.Join(members[:64], ","); got != want { ++ t.Fatalf("count-limited Baggage header = %q, want %q", got, want) ++ } ++ if strings.Contains(out["baggage"], "bad key") || strings.Contains(out["baggage"], "k64=") { ++ t.Errorf("Baggage header contains an invalid or excess member: %q", out["baggage"]) ++ } ++ }) ++ ++ t.Run("oversized-item-does-not-hide-later-item", func(t *testing.T) { ++ p := codespecPropagator(t, "tracecontext", "tracecontext") ++ ctx := codespecExtract(t, p, tracer.TextMapCarrier{ ++ "traceparent": codespecTraceparent, ++ "ot-baggage-a-oversize": strings.Repeat("x", 8192), ++ "ot-baggage-z-small": "ok", ++ }) ++ out := tracer.TextMapCarrier{} ++ if err := p.Inject(ctx, out); err != nil { ++ t.Fatalf("Inject returned an error: %v", err) ++ } ++ if got, want := out["baggage"], "z-small=ok"; got != want { ++ t.Fatalf("Baggage header = %q, want %q", got, want) ++ } ++ }) ++ ++ t.Run("empty-baggage-omits-header", func(t *testing.T) { ++ p := codespecPropagator(t, "tracecontext", "tracecontext") ++ ctx := codespecExtract(t, p, tracer.TextMapCarrier{ ++ "traceparent": codespecTraceparent, ++ }) ++ out := tracer.TextMapCarrier{} ++ if err := p.Inject(ctx, out); err != nil { ++ t.Fatalf("Inject returned an error: %v", err) ++ } ++ if _, ok := out["baggage"]; ok { ++ t.Errorf("empty context produced a baggage header: %#v", out) ++ } ++ }) ++} ++ ++func codespecMapsEqual(a, b map[string]string) bool { ++ if len(a) != len(b) { ++ return false ++ } ++ for k, v := range a { ++ if b[k] != v { ++ return false ++ } ++ } ++ return true ++} + +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++go test ./ddtrace/tracer -run '^(TestCodeSpecW3CBaggage.*|TestW3CExtractsBaggage|TestPropagationDefaults)$' -count=1 diff --git a/tasks/format-code-task-001126/tests/test.sh b/tasks/format-code-task-001126/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0316d385eddfb7bfe61435655af0ee16d3e78dae --- /dev/null +++ b/tasks/format-code-task-001126/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' +ddtrace/tracer/w3c_baggage_codespec_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001126/tests/test_command.sh b/tasks/format-code-task-001126/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001126/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-001128/environment/Dockerfile b/tasks/format-code-task-001128/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bf5cccb86093cf0e885cd54d44cfeea2d1876914 --- /dev/null +++ b/tasks/format-code-task-001128/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:1c0d99b063156504da0053862e8611e8c723aca7b4fb6c5e533f31488cef883a diff --git a/tasks/format-code-task-001128/environment/setup/files/blocklist b/tasks/format-code-task-001128/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001128/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-001128/environment/setup/setup.sh b/tasks/format-code-task-001128/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001128/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-001128/tests/test.patch b/tasks/format-code-task-001128/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..55ffef9371e846ad007950af8027f7ed6eda3131 --- /dev/null +++ b/tasks/format-code-task-001128/tests/test.patch @@ -0,0 +1,111 @@ +diff --git a/tests/test_push_queue_contract.py b/tests/test_push_queue_contract.py +new file mode 100644 +index 00000000..963737ff +--- /dev/null ++++ b/tests/test_push_queue_contract.py +@@ -0,0 +1,96 @@ ++from io import StringIO ++from pathlib import Path ++ ++from gftools.push import PushCategory, PushItem, PushItems, PushList, PushStatus ++ ++ ++def _item(path, category=PushCategory.NEW, url="url"): ++ return PushItem(Path(path), category, PushStatus.IN_DEV, url) ++ ++ ++def test_add_normalizes_without_mutating_source_and_filters_special_paths(): ++ source = _item("ofl/demo/Demo[wght].ttf") ++ queue = PushItems() ++ queue.add(source) ++ ++ assert source.path == Path("ofl/demo/Demo[wght].ttf") ++ assert [item.path for item in queue] == [Path("ofl/demo")] ++ ++ queue.add(_item("lang/Lib/gflanguages/data/languages/en_Latn.textproto")) ++ queue.add(_item("axisregistry/Lib/axisregistry/data/grade.textproto")) ++ queue.add(_item("lang/authors.txt")) ++ queue.add(_item("ofl")) ++ assert [item.path for item in queue] == [ ++ Path("ofl/demo"), ++ Path("lang/languages/en_Latn.textproto"), ++ Path("axisregistry/grade.textproto"), ++ ] ++ ++ ++def test_add_collapses_true_ancestors_but_keeps_same_named_siblings(): ++ queue = PushItems() ++ queue.add(_item("ofl/family/subdir")) ++ queue.add(_item("ofl/family")) ++ assert [item.path for item in queue] == [Path("ofl/family")] ++ ++ queue = PushItems() ++ queue.add(_item("ofl/family")) ++ queue.add(_item("ofl/family/subdir")) ++ assert [item.path for item in queue] == [Path("ofl/family")] ++ ++ queue = PushItems() ++ queue.add(_item("ofl/alpha")) ++ queue.add(_item("apache/family")) ++ queue.add(_item("ofl/family/notes.bin")) ++ assert [item.path for item in queue] == [ ++ Path("ofl/alpha"), ++ Path("apache/family"), ++ Path("ofl/family/notes.bin"), ++ ] ++ ++ ++def test_add_replaces_duplicate_with_latest_metadata(): ++ queue = PushItems() ++ queue.add(_item("ofl/family", PushCategory.NEW, "first")) ++ queue.add(_item("ofl/family", PushCategory.UPGRADE, "latest")) ++ assert len(queue) == 1 ++ assert queue[0].category is PushCategory.UPGRADE ++ assert queue[0].url == "latest" ++ ++ ++def test_server_file_parser_preserves_hashes_in_urls(): ++ queue = PushItems.from_server_file( ++ StringIO( ++ "# Upgrade\nofl/family # https://example.test/pr/4#discussion\n" ++ "ofl/standalone\n" ++ ), ++ PushStatus.IN_DEV, ++ PushList.TO_PRODUCTION, ++ ) ++ assert len(queue) == 2 ++ assert queue[0].path == Path("ofl/family") ++ assert queue[0].category is PushCategory.UPGRADE ++ assert queue[0].status is PushStatus.IN_DEV ++ assert queue[0].push_list is PushList.TO_PRODUCTION ++ assert queue[0].url == "https://example.test/pr/4#discussion" ++ assert queue[1].path == Path("ofl/standalone") ++ assert queue[1].url == "" ++ ++ ++def test_queue_operators_do_not_mutate_operands(): ++ left = PushItems([_item("ofl/left/file.ttf")]) ++ right = PushItems([_item("ofl/right/file.ttf")]) ++ combined = left + right ++ ++ assert [item.path for item in left] == [Path("ofl/left/file.ttf")] ++ assert [item.path for item in right] == [Path("ofl/right/file.ttf")] ++ assert [item.path for item in combined] == [Path("ofl/left"), Path("ofl/right")] ++ ++ remainder = combined - PushItems([_item("ofl/left")]) ++ assert [item.path for item in combined] == [Path("ofl/left"), Path("ofl/right")] ++ assert [item.path for item in remainder] == [Path("ofl/right")] ++ ++ raw = PushItems([_item("ofl/raw/file.ttf")]) ++ normalized = raw - PushItems() ++ assert [item.path for item in raw] == [Path("ofl/raw/file.ttf")] ++ assert [item.path for item in normalized] == [Path("ofl/raw")] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++PYTHONPATH=Lib /opt/gftools-venv/bin/pytest -q tests/test_push_queue_contract.py diff --git a/tasks/format-code-task-001128/tests/test.sh b/tasks/format-code-task-001128/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..dee7b03fd9ded61456848ef7090dbc1c6fc7ae2e --- /dev/null +++ b/tasks/format-code-task-001128/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_push_queue_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001128/tests/test_command.sh b/tasks/format-code-task-001128/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001128/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-001143/environment/Dockerfile b/tasks/format-code-task-001143/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..21e11c64a8db5d282dd3ee2cbc565272e270b377 --- /dev/null +++ b/tasks/format-code-task-001143/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:23e00b810fa1585a7670883dcfda498f81965cf0ccd8f68dbd80ee4b5af99b95 diff --git a/tasks/format-code-task-001143/environment/setup/files/blocklist b/tasks/format-code-task-001143/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001143/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-001143/environment/setup/setup.sh b/tasks/format-code-task-001143/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001143/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-001143/tests/test.patch b/tasks/format-code-task-001143/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..018b745a652c4b83ccf9f1e4f0bc94b8aa2eb339 --- /dev/null +++ b/tasks/format-code-task-001143/tests/test.patch @@ -0,0 +1,92 @@ +diff --git a/test/test_iso_timezone.js b/test/test_iso_timezone.js +new file mode 100644 +index 0000000..f46dbb9 +--- /dev/null ++++ b/test/test_iso_timezone.js +@@ -0,0 +1,61 @@ ++var assert = require('assert'); ++var dateFormat = require('../lib/dateformat'); ++ ++var summer = new Date('2021-07-01T12:34:56.789Z'); ++var winter = new Date('2021-01-01T12:34:56.007Z'); ++ ++var failures = []; ++function check(name, actual, expected) { ++ try { ++ assert.strictEqual(actual, expected); ++ } catch (err) { ++ failures.push(name + ': ' + err.message); ++ } ++} ++ ++ ++ ++check('summer local preset', ++ dateFormat(summer, 'isoDateTime'), ++ '2021-07-01T08:34:56-04:00' ++); ++check('winter local preset', ++ dateFormat(winter, 'isoDateTime'), ++ '2021-01-01T07:34:56-05:00' ++); ++ ++check('summer local milliseconds preset', ++ dateFormat(summer, 'isoDateTimeMillis'), ++ '2021-07-01T08:34:56.789-04:00' ++); ++check('winter local milliseconds preset', ++ dateFormat(winter, 'isoDateTimeMillis'), ++ '2021-01-01T07:34:56.007-05:00' ++); ++check('UTC milliseconds preset', ++ dateFormat(summer, 'isoUtcDateTimeMillis'), ++ '2021-07-01T12:34:56.789Z' ++); ++ ++ ++check('colonized offset token', dateFormat(summer, 'P'), '-04:00'); ++check('legacy compact offset token', dateFormat(summer, 'o'), '-0400'); ++check('quoted literal P', dateFormat(summer, "P 'P'"), '-04:00 P'); ++ ++ ++check('UTC prefix with offset', ++ dateFormat(summer, 'UTC:yyyy-mm-dd HH:MM:ss.lP'), ++ '2021-07-01 12:34:56.789+00:00' ++); ++check('GMT prefix with offset', ++ dateFormat(summer, 'GMT:yyyy-mm-dd HH:MM:ssP Z'), ++ '2021-07-01 12:34:56+00:00 GMT' ++); ++check('explicit UTC with offset', ++ dateFormat(summer, 'yyyy-mm-dd HH:MM:ssP', true), ++ '2021-07-01 12:34:56+00:00' ++); ++ ++if (failures.length) { ++ throw new Error(failures.length + ' ISO timezone checks failed:\n' + failures.join('\n')); ++} +diff --git a/test/test_iso_timezone_positive.js b/test/test_iso_timezone_positive.js +new file mode 100644 +index 0000000..f3d2b3a +--- /dev/null ++++ b/test/test_iso_timezone_positive.js +@@ -0,0 +1,8 @@ ++var assert = require('assert'); ++var dateFormat = require('../lib/dateformat'); ++var instant = new Date('2021-07-01T12:34:56.789Z'); ++ ++assert.strictEqual(dateFormat(instant, 'isoDateTime'), '2021-07-01T18:04:56+05:30'); ++assert.strictEqual(dateFormat(instant, 'isoDateTimeMillis'), '2021-07-01T18:04:56.789+05:30'); ++assert.strictEqual(dateFormat(instant, 'P'), '+05:30'); ++assert.strictEqual(dateFormat(instant, 'o'), '+0530'); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++TZ=America/New_York node test/test_iso_timezone.js ++TZ=Asia/Kolkata node test/test_iso_timezone_positive.js diff --git a/tasks/format-code-task-001143/tests/test.sh b/tasks/format-code-task-001143/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..abf70a7248d8394cf37d5ba42e931f46ba4a7a18 --- /dev/null +++ b/tasks/format-code-task-001143/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_iso_timezone.js +test/test_iso_timezone_positive.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-001143/tests/test_command.sh b/tasks/format-code-task-001143/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001143/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-001172/environment/Dockerfile b/tasks/format-code-task-001172/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ac00c0652ed0fe142b9328683d28c434d0984c06 --- /dev/null +++ b/tasks/format-code-task-001172/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:e39f4f6c0d6e6c116fe32a30a41fd15a5c280619cd055275aafff42e64623cd6 diff --git a/tasks/format-code-task-001172/environment/setup/files/blocklist b/tasks/format-code-task-001172/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001172/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-001172/environment/setup/setup.sh b/tasks/format-code-task-001172/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001172/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-001172/tests/test.patch b/tasks/format-code-task-001172/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..be5d1057a2efd37efb6accd2691e9a446c89ee9e --- /dev/null +++ b/tasks/format-code-task-001172/tests/test.patch @@ -0,0 +1,241 @@ +diff --git a/.codespec-verifier-maven-settings.xml b/.codespec-verifier-maven-settings.xml +new file mode 100644 +index 00000000000..b86ac7f78e9 +--- /dev/null ++++ b/.codespec-verifier-maven-settings.xml +@@ -0,0 +1,11 @@ ++ ++ ++ ++ mi-maven-virtual ++ * ++ https://unused.invalid/repository/maven-public/ ++ ++ ++ +diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/bundle/BundleUtilProcessingOrderContractTest.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/bundle/BundleUtilProcessingOrderContractTest.java +new file mode 100644 +index 00000000000..0b275f6fb39 +--- /dev/null ++++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/bundle/BundleUtilProcessingOrderContractTest.java +@@ -0,0 +1,204 @@ ++package ca.uhn.fhir.util.bundle; ++ ++import ca.uhn.fhir.context.FhirContext; ++import ca.uhn.fhir.util.BundleUtil; ++import org.hl7.fhir.r4.model.Bundle; ++import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; ++import org.hl7.fhir.r4.model.Bundle.HTTPVerb; ++import org.hl7.fhir.r4.model.Observation; ++import org.hl7.fhir.r4.model.Organization; ++import org.hl7.fhir.r4.model.Patient; ++import org.hl7.fhir.r4.model.Practitioner; ++import org.hl7.fhir.r4.model.Reference; ++import org.hl7.fhir.r4.model.Resource; ++import org.junit.jupiter.api.Test; ++ ++import java.util.Arrays; ++import java.util.List; ++import java.util.Locale; ++import java.util.stream.Collectors; ++ ++import static org.junit.jupiter.api.Assertions.assertEquals; ++import static org.junit.jupiter.api.Assertions.assertNotNull; ++import static org.junit.jupiter.api.Assertions.assertSame; ++import static org.junit.jupiter.api.Assertions.assertThrows; ++import static org.junit.jupiter.api.Assertions.assertTrue; ++ ++class BundleUtilProcessingOrderContractTest { ++ ++ private static final FhirContext ourCtx = FhirContext.forR4Cached(); ++ ++ @Test ++ void sortsCreateDependencyChainUsingUrnFullUrls() { ++ Bundle bundle = new Bundle(); ++ Observation observation = new Observation(); ++ observation.setSubject(new Reference("urn:uuid:patient")); ++ Patient patient = new Patient(); ++ patient.setManagingOrganization(new Reference("urn:uuid:organization")); ++ Organization organization = new Organization(); ++ ++ addEntry(bundle, "urn:uuid:observation", HTTPVerb.POST, observation); ++ addEntry(bundle, "urn:uuid:patient", HTTPVerb.POST, patient); ++ addEntry(bundle, "urn:uuid:organization", HTTPVerb.POST, organization); ++ ++ BundleUtil.sortEntriesIntoProcessingOrder(ourCtx, bundle); ++ ++ assertFullUrlOrder(bundle, "urn:uuid:organization", "urn:uuid:patient", "urn:uuid:observation"); ++ } ++ ++ @Test ++ void resolvesRelativeAndAbsoluteVersionedAliases() { ++ Bundle bundle = new Bundle(); ++ Observation relativeReference = new Observation(); ++ relativeReference.setId("Observation/relative"); ++ relativeReference.setSubject(new Reference("Patient/p1/_history/99")); ++ Observation absoluteReference = new Observation(); ++ absoluteReference.setId("Observation/absolute"); ++ absoluteReference.setSubject(new Reference("https://example.test/fhir/Patient/p1/_history/12")); ++ Patient patient = new Patient(); ++ patient.setId("Patient/p1/_history/4"); ++ ++ addEntry(bundle, "urn:uuid:relative-observation", HTTPVerb.PUT, relativeReference); ++ addEntry(bundle, "urn:uuid:absolute-observation", HTTPVerb.PUT, absoluteReference); ++ addEntry(bundle, "https://example.test/fhir/Patient/p1/_history/7", HTTPVerb.PUT, patient); ++ ++ BundleUtil.sortEntriesIntoProcessingOrder(ourCtx, bundle); ++ ++ assertFullUrlOrder(bundle, ++ "https://example.test/fhir/Patient/p1/_history/7", ++ "urn:uuid:relative-observation", ++ "urn:uuid:absolute-observation"); ++ } ++ ++ @Test ++ void appliesMethodPrecedenceAndStableOrderToResourceLessEntries() { ++ Bundle bundle = new Bundle(); ++ BundleEntryComponent getOne = addEntry(bundle, "urn:test:get-1", HTTPVerb.GET, null); ++ BundleEntryComponent putOne = addEntry(bundle, "urn:test:put-1", HTTPVerb.PUT, patient("Patient/put-1")); ++ BundleEntryComponent deleteOne = addEntry(bundle, "urn:test:delete-1", HTTPVerb.DELETE, null); ++ BundleEntryComponent postOne = addEntry(bundle, "urn:test:post-1", HTTPVerb.POST, patient("Patient/post-1")); ++ BundleEntryComponent getTwo = addEntry(bundle, "urn:test:get-2", HTTPVerb.GET, null); ++ BundleEntryComponent deleteTwo = addEntry(bundle, "urn:test:delete-2", HTTPVerb.DELETE, null); ++ BundleEntryComponent postTwo = addEntry(bundle, "urn:test:post-2", HTTPVerb.POST, patient("Patient/post-2")); ++ BundleEntryComponent putTwo = addEntry(bundle, "urn:test:put-2", HTTPVerb.PUT, patient("Patient/put-2")); ++ List expectedEntries = Arrays.asList(deleteOne, deleteTwo, postOne, postTwo, putOne, putTwo, getOne, getTwo); ++ ++ BundleUtil.sortEntriesIntoProcessingOrder(ourCtx, bundle); ++ assertFullUrlOrder(bundle, ++ "urn:test:delete-1", "urn:test:delete-2", ++ "urn:test:post-1", "urn:test:post-2", ++ "urn:test:put-1", "urn:test:put-2", ++ "urn:test:get-1", "urn:test:get-2"); ++ assertEntryIdentityOrder(bundle, expectedEntries); ++ ++ BundleUtil.sortEntriesIntoProcessingOrder(ourCtx, bundle); ++ assertFullUrlOrder(bundle, ++ "urn:test:delete-1", "urn:test:delete-2", ++ "urn:test:post-1", "urn:test:post-2", ++ "urn:test:put-1", "urn:test:put-2", ++ "urn:test:get-1", "urn:test:get-2"); ++ assertEntryIdentityOrder(bundle, expectedEntries); ++ } ++ ++ @Test ++ void reversesDependenciesForDeletesIdentifiedByFullUrl() { ++ Bundle bundle = new Bundle(); ++ Organization organization = new Organization(); ++ Patient patient = new Patient(); ++ patient.setManagingOrganization(new Reference("urn:uuid:delete-organization")); ++ ++ addEntry(bundle, "urn:uuid:delete-organization", HTTPVerb.DELETE, organization); ++ addEntry(bundle, "urn:uuid:delete-patient", HTTPVerb.DELETE, patient); ++ ++ BundleUtil.sortEntriesIntoProcessingOrder(ourCtx, bundle); ++ ++ assertFullUrlOrder(bundle, "urn:uuid:delete-patient", "urn:uuid:delete-organization"); ++ } ++ ++ @Test ++ void detectsFullUrlCyclesWithoutPartiallyReorderingTheBundle() { ++ Bundle bundle = new Bundle(); ++ Observation first = new Observation(); ++ first.addHasMember(new Reference("urn:uuid:second")); ++ Observation second = new Observation(); ++ second.addHasMember(new Reference("urn:uuid:first")); ++ addEntry(bundle, "urn:uuid:first", HTTPVerb.POST, first); ++ addEntry(bundle, "urn:uuid:second", HTTPVerb.POST, second); ++ ++ IllegalStateException exception = assertThrows(IllegalStateException.class, ++ () -> BundleUtil.sortEntriesIntoProcessingOrder(ourCtx, bundle)); ++ ++ assertTrue(exception.getMessage().toLowerCase(Locale.ROOT).contains("cycle")); ++ assertFullUrlOrder(bundle, "urn:uuid:first", "urn:uuid:second"); ++ } ++ ++ @Test ++ void ignoresSelfReferences() { ++ Bundle bundle = new Bundle(); ++ Organization organization = new Organization(); ++ organization.setPartOf(new Reference("urn:uuid:self")); ++ ++ addEntry(bundle, "urn:uuid:self", HTTPVerb.POST, organization); ++ ++ BundleUtil.sortEntriesIntoProcessingOrder(ourCtx, bundle); ++ ++ assertFullUrlOrder(bundle, "urn:uuid:self"); ++ } ++ ++ @Test ++ void ignoresContainedReferences() { ++ Bundle bundle = new Bundle(); ++ Patient patient = new Patient(); ++ patient.addGeneralPractitioner(new Reference("#contained-practitioner")); ++ ++ addEntry(bundle, "urn:uuid:patient", HTTPVerb.POST, patient); ++ addEntry(bundle, "urn:uuid:contained-practitioner", HTTPVerb.POST, new Practitioner()); ++ ++ BundleUtil.sortEntriesIntoProcessingOrder(ourCtx, bundle); ++ ++ assertFullUrlOrder(bundle, "urn:uuid:patient", "urn:uuid:contained-practitioner"); ++ } ++ ++ @Test ++ void ignoresExternalReferencesThatOnlyShareAResourcePath() { ++ Bundle bundle = new Bundle(); ++ Patient patient = new Patient(); ++ patient.setManagingOrganization(new Reference("https://outside.test/fhir/Organization/other")); ++ ++ addEntry(bundle, "urn:uuid:patient", HTTPVerb.POST, patient); ++ addEntry(bundle, "https://inside.test/fhir/Organization/other", HTTPVerb.POST, new Organization()); ++ ++ BundleUtil.sortEntriesIntoProcessingOrder(ourCtx, bundle); ++ ++ assertFullUrlOrder(bundle, "urn:uuid:patient", "https://inside.test/fhir/Organization/other"); ++ } ++ ++ private static Patient patient(String theId) { ++ Patient patient = new Patient(); ++ patient.setId(theId); ++ return patient; ++ } ++ ++ private static BundleEntryComponent addEntry(Bundle theBundle, String theFullUrl, HTTPVerb theMethod, Resource theResource) { ++ BundleEntryComponent entry = theBundle.addEntry(); ++ entry.setFullUrl(theFullUrl); ++ entry.setResource(theResource); ++ entry.getRequest().setMethod(theMethod).setUrl(theResource != null ? theResource.fhirType() : theFullUrl); ++ return entry; ++ } ++ ++ private static void assertFullUrlOrder(Bundle theBundle, String... theExpected) { ++ assertEquals(theExpected.length, theBundle.getEntry().size(), "sorting must preserve every bundle entry"); ++ for (BundleEntryComponent entry : theBundle.getEntry()) { ++ assertNotNull(entry, "sorting must not replace an entry with null"); ++ } ++ List actual = theBundle.getEntry().stream().map(BundleEntryComponent::getFullUrl).collect(Collectors.toList()); ++ assertEquals(Arrays.asList(theExpected), actual); ++ } ++ ++ private static void assertEntryIdentityOrder(Bundle theBundle, List theExpected) { ++ for (int i = 0; i < theExpected.size(); i++) { ++ assertSame(theExpected.get(i), theBundle.getEntry().get(i), "sorting must retain the original entry objects"); ++ } ++ } ++} +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,9 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++mvn -s .codespec-verifier-maven-settings.xml -o \ ++ -pl hapi-fhir-structures-r4 -am \ ++ -Dsurefire.failIfNoSpecifiedTests=false \ ++ -Dtest=ca.uhn.fhir.util.bundle.BundleUtilProcessingOrderContractTest,ca.uhn.fhir.util.bundle.BundleUtilTest \ ++ test diff --git a/tasks/format-code-task-001172/tests/test.sh b/tasks/format-code-task-001172/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..54b2ad4a54d790d439e83b7c125c799be5087113 --- /dev/null +++ b/tasks/format-code-task-001172/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' +.codespec-verifier-maven-settings.xml +hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/util/bundle/BundleUtilProcessingOrderContractTest.java +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001172/tests/test_command.sh b/tasks/format-code-task-001172/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001172/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-001186/environment/Dockerfile b/tasks/format-code-task-001186/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8d7d4f1fded5a5719fb450ea75b1080eb53939c5 --- /dev/null +++ b/tasks/format-code-task-001186/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:c915508988ca4fa5be62678252ac7616d48b731961fc20e547dd6a6ba765b0a3 diff --git a/tasks/format-code-task-001186/environment/setup/files/blocklist b/tasks/format-code-task-001186/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001186/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-001186/environment/setup/setup.sh b/tasks/format-code-task-001186/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001186/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-001186/tests/test.patch b/tasks/format-code-task-001186/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8ff07c9b43082fec594b0d758d485a5fe27358a8 --- /dev/null +++ b/tasks/format-code-task-001186/tests/test.patch @@ -0,0 +1,126 @@ +diff --git a/server/cron/calendar_cron_test.go b/server/cron/calendar_cron_test.go +index 9b2e5dcb6ac2..e03d633569f5 100644 +--- a/server/cron/calendar_cron_test.go ++++ b/server/cron/calendar_cron_test.go +@@ -39,28 +39,28 @@ func TestGetPreferredCalendarEventDate(t *testing.T) { + expected time.Time + }{ + { +- name: "March 2024 (before 3rd Tuesday)", ++ name: "March 2024 (before 1st Tuesday)", + year: 2024, + month: 3, + daysStart: 1, +- daysEnd: 19, ++ daysEnd: 5, + +- expected: date(2024, 3, 19), ++ expected: date(2024, 3, 5), + }, + { +- name: "March 2024 (past 3rd Tuesday)", ++ name: "March 2024 (past 1st Tuesday)", + year: 2024, + month: 3, +- daysStart: 20, +- daysEnd: 31, ++ daysStart: 6, ++ daysEnd: 12, + +- expected: date(2024, 4, 16), ++ expected: date(2024, 3, 12), + }, + { + name: "April 2024 (before 3rd Tuesday)", + year: 2024, + month: 4, +- daysStart: 1, ++ daysStart: 10, + daysEnd: 16, + + expected: date(2024, 4, 16), +@@ -70,45 +70,45 @@ func TestGetPreferredCalendarEventDate(t *testing.T) { + year: 2024, + month: 4, + daysStart: 17, +- daysEnd: 30, ++ daysEnd: 23, + +- expected: date(2024, 5, 21), ++ expected: date(2024, 4, 23), + }, + { +- name: "May 2024 (before 3rd Tuesday)", ++ name: "May 2024 (before last Tuesday)", + year: 2024, + month: 5, +- daysStart: 1, +- daysEnd: 21, ++ daysStart: 22, ++ daysEnd: 28, + +- expected: date(2024, 5, 21), ++ expected: date(2024, 5, 28), + }, + { +- name: "May 2024 (after 3rd Tuesday)", ++ name: "May 2024 (after last Tuesday)", + year: 2024, + month: 5, +- daysStart: 22, ++ daysStart: 29, + daysEnd: 31, + +- expected: date(2024, 6, 18), ++ expected: date(2024, 6, 4), + }, + { +- name: "Dec 2024 (before 3rd Tuesday)", +- year: 2024, ++ name: "Dec 2025 (before last Tuesday)", ++ year: 2025, + month: 12, +- daysStart: 1, +- daysEnd: 17, ++ daysStart: 24, ++ daysEnd: 30, + +- expected: date(2024, 12, 17), ++ expected: date(2025, 12, 30), + }, + { +- name: "Dec 2024 (after 3rd Tuesday)", +- year: 2024, ++ name: "Dec 2025 (after last Tuesday)", ++ year: 2025, + month: 12, +- daysStart: 18, ++ daysStart: 31, + daysEnd: 31, + +- expected: date(2025, 1, 21), ++ expected: date(2026, 1, 6), + }, + } { + t.Run(tc.name, func(t *testing.T) { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3RsY7CMAwG4Mw8hV+gbdKSMt3EnVgZ2FFoDJwEieSmfX5KFxASxwI6If5vsSVH ++iq0/33S/B7/m0BfqVfRgZu1YB7d17I0tTalnU21rpY2pdaXIvmyjK12bnBApiTH99e7R/E3ll/wT ++t2ndxOPRBZ+3++f98Sh/U9aX/KtqyH9aG6NIP2+F+z48/8bTGPyG/WQX6dxSXrQsPUvRSAwFZdIF ++Wg2DBael8JZF2M/dgYN38tNzSN8uMWU9ZU3sQvoyk/++CgAAAAAAAAAAAAAAAAAAAADgM5wAEPrd ++wAAoAAA= +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-001186/tests/test.sh b/tasks/format-code-task-001186/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b87f40ac6ef68298c926663fa606c6ac64af804b --- /dev/null +++ b/tasks/format-code-task-001186/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +server/cron/calendar_cron_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-001186/tests/test_command.sh b/tasks/format-code-task-001186/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001186/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-001188/environment/Dockerfile b/tasks/format-code-task-001188/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8082b0cb71d05279f40fea5d5d90a7e38bb4827b --- /dev/null +++ b/tasks/format-code-task-001188/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:9a951d227f28cdf96050b22823e2a49ab824d1a7a4ca24d7f4efb18a383be8cf diff --git a/tasks/format-code-task-001188/environment/setup/files/blocklist b/tasks/format-code-task-001188/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001188/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-001188/environment/setup/setup.sh b/tasks/format-code-task-001188/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001188/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-001188/tests/test.patch b/tasks/format-code-task-001188/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..15f2556cb40465c7f4bde6c0cbedeffe0c068a50 --- /dev/null +++ b/tasks/format-code-task-001188/tests/test.patch @@ -0,0 +1,127 @@ +diff --git a/server/datastore/mysql/hosts_test.go b/server/datastore/mysql/hosts_test.go +index 85efd52a3567..3bbd473d39d6 100644 +--- a/server/datastore/mysql/hosts_test.go ++++ b/server/datastore/mysql/hosts_test.go +@@ -8848,6 +8848,90 @@ func testHostsEnrollOrbit(t *testing.T, ds *Datastore) { + scenarioD(platform) + }) + } ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ scenarioE := func(fromPlatform, toPlatform string) { ++ dupUUID := uuid.New().String() ++ dupHWSerial := uuid.New().String() ++ ++ h1Orbit, err := ds.EnrollOrbit(ctx, false, fleet.OrbitHostInfo{ ++ HardwareUUID: dupUUID, ++ HardwareSerial: dupHWSerial, ++ Platform: fromPlatform, ++ }, uuid.New().String(), nil) ++ require.NoError(t, err) ++ h1OrbitFetched, err := ds.Host(ctx, h1Orbit.ID) ++ require.NoError(t, err) ++ time.Sleep(1 * time.Second) ++ h1Osquery, err := ds.EnrollHost(ctx, false, dupUUID, dupUUID, dupHWSerial, uuid.New().String(), nil, 0) ++ require.NoError(t, err) ++ h1OsqueryFetched, err := ds.Host(ctx, h1Osquery.ID) ++ require.NoError(t, err) ++ require.NotEqual(t, h1OrbitFetched.LastEnrolledAt, h1OsqueryFetched.LastEnrolledAt) ++ require.Equal(t, h1Orbit.ID, h1Osquery.ID) ++ time.Sleep(1 * time.Second) ++ ++ ExecAdhocSQL(t, ds, func(q sqlx.ExtContext) error { ++ _, err := q.ExecContext(ctx, `INSERT INTO host_mdm(host_id, enrolled, server_url, installed_from_dep, mdm_id, is_server) ++ VALUES(?, 1, 'https://example.com/mdm', 0, ?, 0)`, h1Orbit.ID, h1Orbit.ID+100) ++ return err ++ }) ++ h1WithMdmFetched, err := ds.Host(ctx, h1Orbit.ID) ++ require.NoError(t, err) ++ require.NotNil(t, h1WithMdmFetched.MDM.ServerURL) ++ require.NotNil(t, h1WithMdmFetched.MDM.EnrollmentStatus) ++ ++ h2Orbit, err := ds.EnrollOrbit(ctx, false, fleet.OrbitHostInfo{ ++ HardwareUUID: dupUUID, ++ HardwareSerial: dupHWSerial, ++ Platform: toPlatform, ++ }, uuid.New().String(), nil) ++ require.NoError(t, err) ++ h2OrbitFetched, err := ds.Host(ctx, h2Orbit.ID) ++ require.NoError(t, err) ++ ++ ++ require.Equal(t, h1OsqueryFetched.LastEnrolledAt, h2OrbitFetched.LastEnrolledAt) ++ time.Sleep(1 * time.Second) ++ h2Osquery, err := ds.EnrollHost(ctx, false, dupUUID, dupUUID, dupHWSerial, uuid.New().String(), nil, 0) ++ require.NoError(t, err) ++ require.Equal(t, h2Orbit.ID, h2Osquery.ID) ++ h2OsqueryFetched, err := ds.Host(ctx, h2Osquery.ID) ++ require.NoError(t, err) ++ require.NotEqual(t, h2OrbitFetched.LastEnrolledAt, h2OsqueryFetched.LastEnrolledAt) ++ ++ ++ require.Equal(t, h1Orbit.ID, h2Orbit.ID) ++ require.Equal(t, h1Orbit.ID, h1Osquery.ID) ++ require.Equal(t, h2Orbit.ID, h2Osquery.ID) ++ ++ if fromPlatform == "windows" && toPlatform != "windows" { ++ assert.Nil(t, h2OrbitFetched.MDM.EnrollmentStatus) ++ assert.Nil(t, h2OrbitFetched.MDM.ServerURL) ++ } else { ++ require.NotNil(t, h2OrbitFetched.MDM.EnrollmentStatus) ++ assert.Equal(t, *h1WithMdmFetched.MDM.EnrollmentStatus, *h2OrbitFetched.MDM.EnrollmentStatus) ++ require.NotNil(t, h2OrbitFetched.MDM.ServerURL) ++ assert.Equal(t, *h1WithMdmFetched.MDM.ServerURL, *h2OrbitFetched.MDM.ServerURL) ++ } ++ } ++ for _, fromPlatform := range []string{"ubuntu", "windows", "darwin"} { ++ for _, toPlatform := range []string{"ubuntu", "windows", "darwin"} { ++ fromPlatform := fromPlatform ++ toPlatform := toPlatform ++ t.Run("scenarioE_from_"+fromPlatform+"_to_"+toPlatform, func(t *testing.T) { ++ t.Parallel() ++ scenarioE(fromPlatform, toPlatform) ++ }) ++ } ++ } + } + + func testHostsEnrollUpdatesMissingInfo(t *testing.T, ds *Datastore) { +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,16 @@ ++H4sIAAAAAAAAA+1W32/bNhD2s/+KqzO4WzbqRxzFgAcVKFYPfUiRrPbL0BUBLZ0jIpSokpSX/Pc7 ++SkqjFXGTAmmHYvz8YEHH4328O36nYNMImV9gtQtHXwsRYZ4k7T/h0//2OU6O4vgkmsfJyShyT8kI ++kq/GaIDGWK4BRlop+7l1D9m/UwR39c9VdoWamUKUgSmeMMYD9Y9ncXJb/5P5PKb6H8+S2QiiJ+Sw ++F//z+h88CzeiCjfcFOMDWFHtYas0PO+aATJV1sog4DVmwNZQ3pgP8sKisd0jBEHwHGzBLeimMiBV ++xmVnou3WBcKp4vkqK7DksG2qzApVQa7QLOCxIVjz9uxsDaw+f7la0a68yqEWNRpY/XEKO8HB2FxU ++wZhsr9BiZokQQs2tRV09Pg4dZSy28O4dTH44nECawuFk6DQ5hOl0YLvb4F4LvXz//ldHpRoD4QDe ++NtUwQZALTWTlzS/E1RhRXXYHIRetmsui9WrZ9nko4qN5ENEvBnY+m0VzSo1rS0qNVUqPUX45fY21 ++FBl//DG+hNBWuJr8zqXc8Oxq0R7z9nRgFWikXPTlIep8x4XkG4ljzAoFk97iBGkB1F1NXSttMXel ++LKkLFuCovpgejfFaWIjH//Vl+g4x0H/XAhd9ap90ADyk/8nx3fynaeD0/ySOvf5/Cwz1P8uhbYIN ++5u7eLunGaYQ3N05mhXECXzmRIgF39xDchXeC+eyRcgAMYbJani5/W0NM9zbMcRdWjZRw9GIaDySm ++vCJlJCcId1yHFDZsA+StkZTh76qLuOji3rdKl8C2n1r6v8PAkLDsNdYiJ0IfyXWMWhsw1hjUaX9c ++lnPLiWna7iTFJrw1uPSkbQL+at0dGHNR0ab3x2VueUds6ENk2FZI/KyXYzx0am3XaQTT9qWRiDUc ++92rcV3Wgra62NHXOX65fw49u+JtuXEua3FTvn7oa98IAbHfru7+AWf2xkcK9H5gQNobS5uZh24Kd ++ta9xqXL4+XrPku4gK6RvDvzQ0BDNgbYHypChSdD25ps/qWkv1svVOo3dYjd63UcB3fVL8nPk/tXu ++l6p9507HMtVUNqUepnTDZE2vXytjTbistJLyTG+EnUAQUifsUIeuCYxVGruShMCsKFE1dD+iyPiR ++5OHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4fFN8Q/qhpBOACgAAA== +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-001188/tests/test.sh b/tasks/format-code-task-001188/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5628d640c663343dd0a0af95b3da7c03b91bef99 --- /dev/null +++ b/tasks/format-code-task-001188/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +server/datastore/mysql/hosts_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-001188/tests/test_command.sh b/tasks/format-code-task-001188/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001188/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-001250/environment/Dockerfile b/tasks/format-code-task-001250/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8edd5b4b15190c204c2376cebf6623232e2f321e --- /dev/null +++ b/tasks/format-code-task-001250/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:f05a82a7ca5d2ba20a1245bc1195dc78b26e687f94d7616e1ab6fe47bd70e8be diff --git a/tasks/format-code-task-001250/environment/setup/files/blocklist b/tasks/format-code-task-001250/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001250/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-001250/environment/setup/setup.sh b/tasks/format-code-task-001250/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001250/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-001250/tests/test.patch b/tasks/format-code-task-001250/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..65173ec11247ba0e2eced3033b6c2647a76ecfc7 --- /dev/null +++ b/tasks/format-code-task-001250/tests/test.patch @@ -0,0 +1,123 @@ +diff --git a/geopandas/tests/test_apply_nan_regression.py b/geopandas/tests/test_apply_nan_regression.py +new file mode 100644 +index 00000000..4c80b257 +--- /dev/null ++++ b/geopandas/tests/test_apply_nan_regression.py +@@ -0,0 +1,95 @@ ++ ++ ++ ++ ++ ++ ++import math ++ ++import numpy as np ++import pandas as pd ++import pytest ++from shapely.geometry import Point ++ ++from geopandas import GeoDataFrame, GeoSeries ++ ++ ++@pytest.fixture ++def gdf(): ++ return GeoDataFrame( ++ { ++ "value1": [1, 2, 3], ++ "value2": [10, 20, 30], ++ "geometry": [Point(0, 0), Point(1, 1), Point(2, 2)], ++ }, ++ crs="EPSG:4326", ++ ) ++ ++ ++def test_apply_lambda_returns_float_nan_preserves_nan(gdf): ++ ++ result = gdf.apply(lambda x: float("nan"), axis=1) ++ ++ assert type(result) is pd.Series ++ ++ assert result.dtype != "geometry" ++ ++ assert result.iloc[0] is not None ++ assert math.isnan(result.iloc[0]) ++ assert result.isna().all() ++ ++ ++def test_apply_lambda_returns_numpy_nan_preserves_nan(gdf): ++ result = gdf.apply(lambda x: np.nan, axis=1) ++ assert type(result) is pd.Series ++ assert result.dtype != "geometry" ++ assert result.iloc[0] is not None ++ assert math.isnan(result.iloc[0]) ++ ++ ++def test_apply_lambda_returns_all_none_not_geoseries(gdf): ++ ++ result = gdf.apply(lambda x: None, axis=1) ++ assert type(result) is pd.Series ++ assert not isinstance(result, GeoSeries) ++ assert result.dtype != "geometry" ++ ++ assert result.iloc[0] is None ++ assert result.isna().all() ++ ++ ++def test_apply_lambda_returns_numeric_value_preserved(gdf): ++ ++ result = gdf.apply(lambda x: 1.5, axis=1) ++ assert type(result) is pd.Series ++ assert result.dtype != "geometry" ++ assert result.iloc[0] == 1.5 ++ ++ ++def test_apply_lambda_returns_geometry_still_geoseries(gdf): ++ ++ result = gdf.apply(lambda row: row["geometry"], axis=1) ++ assert isinstance(result, GeoSeries) ++ assert result.dtype == "geometry" ++ assert result.iloc[0].equals(Point(0, 0)) ++ ++ ++def test_apply_lambda_returns_string_not_geoseries(gdf): ++ ++ result = gdf.apply(lambda x: "a", axis=1) ++ assert type(result) is pd.Series ++ assert result.dtype != "geometry" ++ assert result.iloc[0] == "a" ++ ++ ++def test_apply_lambda_mixed_geometry_and_none_becomes_geoseries(gdf): ++ ++ def f(row): ++ if row["value1"] == 1: ++ return None ++ return row["geometry"] ++ ++ result = gdf.apply(f, axis=1) ++ assert isinstance(result, GeoSeries) ++ assert result.iloc[0] is None ++ assert result.iloc[1].equals(Point(1, 1)) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..cd23b545 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest geopandas/tests/test_apply_nan_regression.py -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -v -rA geopandas/tests/test_apply_nan_regression.py::test_apply_lambda_returns_float_nan_preserves_nan geopandas/tests/test_apply_nan_regression.py::test_apply_lambda_returns_numpy_nan_preserves_nan geopandas/tests/test_apply_nan_regression.py::test_apply_lambda_returns_all_none_not_geoseries geopandas/tests/test_apply_nan_regression.py::test_apply_lambda_returns_numeric_value_preserved geopandas/tests/test_apply_nan_regression.py::test_apply_lambda_returns_geometry_still_geoseries geopandas/tests/test_apply_nan_regression.py::test_apply_lambda_returns_string_not_geoseries geopandas/tests/test_apply_nan_regression.py::test_apply_lambda_mixed_geometry_and_none_becomes_geoseries ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001250/tests/test.sh b/tasks/format-code-task-001250/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4823276b2ed074dbe2891cb64ebc49ea0d4e488d --- /dev/null +++ b/tasks/format-code-task-001250/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' +geopandas/tests/test_apply_nan_regression.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001250/tests/test_command.sh b/tasks/format-code-task-001250/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001250/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-001259/environment/Dockerfile b/tasks/format-code-task-001259/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1a4e49b1a378c00d05852825e55afbe16db761c1 --- /dev/null +++ b/tasks/format-code-task-001259/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:ecec8924daa67f438502975ff09ef47e45da6388ced95d3fb8586ace88ededbf diff --git a/tasks/format-code-task-001259/environment/setup/files/blocklist b/tasks/format-code-task-001259/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001259/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-001259/environment/setup/setup.sh b/tasks/format-code-task-001259/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001259/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-001259/tests/test.patch b/tasks/format-code-task-001259/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f8f0e94eb7643f91bba74b3cc14c4fa1f9dede2d --- /dev/null +++ b/tasks/format-code-task-001259/tests/test.patch @@ -0,0 +1,201 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..4d618b0dd +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_s3/test_s3.py -k 'test_copy_object_in_place_applies_bucket_default_encryption_aes256 or test_copy_object_in_place_applies_bucket_default_encryption_kms or test_copy_object_to_different_key_applies_bucket_default_encryption or test_copy_object_no_bucket_encryption_no_change or test_copy_object_with_replace_metadata_directive_applies_default_encryption or test_put_object_after_enabling_aes256_default_encryption' -v"] ++} +diff --git a/tests/test_s3/test_s3.py b/tests/test_s3/test_s3.py +index 95887e929..288432345 100644 +--- a/tests/test_s3/test_s3.py ++++ b/tests/test_s3/test_s3.py +@@ -6538,3 +6538,174 @@ def test_request_partial_content_should_contain_all_metadata(): + assert response["LastModified"] == obj.last_modified + assert response["ContentLength"] == 4 + assert response["ContentRange"] == "bytes {}/{}".format(query_range, len(body)) ++ ++ ++@mock_s3 ++def test_copy_object_in_place_applies_bucket_default_encryption_aes256(): ++ ++ ++ ++ ++ bucket_name = "issue-sse-aes-bucket" ++ client = boto3.client("s3", region_name=DEFAULT_REGION_NAME) ++ client.create_bucket(Bucket=bucket_name) ++ ++ client.put_object(Bucket=bucket_name, Key="data/part-1.txt", Body=b"dummy") ++ ++ head = client.head_object(Bucket=bucket_name, Key="data/part-1.txt") ++ assert head.get("ServerSideEncryption") is None ++ ++ client.put_bucket_encryption( ++ Bucket=bucket_name, ++ ServerSideEncryptionConfiguration={ ++ "Rules": [ ++ {"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}} ++ ] ++ }, ++ ) ++ ++ client.copy_object( ++ Bucket=bucket_name, ++ CopySource={"Bucket": bucket_name, "Key": "data/part-1.txt"}, ++ Key="data/part-1.txt", ++ ) ++ ++ head = client.head_object(Bucket=bucket_name, Key="data/part-1.txt") ++ assert head["ServerSideEncryption"] == "AES256" ++ ++ ++@mock_s3 ++def test_copy_object_in_place_applies_bucket_default_encryption_kms(): ++ bucket_name = "issue-sse-kms-bucket" ++ client = boto3.client("s3", region_name=DEFAULT_REGION_NAME) ++ client.create_bucket(Bucket=bucket_name) ++ ++ client.put_object(Bucket=bucket_name, Key="part-2.txt", Body=b"dummy2") ++ ++ client.put_bucket_encryption( ++ Bucket=bucket_name, ++ ServerSideEncryptionConfiguration={ ++ "Rules": [ ++ { ++ "ApplyServerSideEncryptionByDefault": { ++ "SSEAlgorithm": "aws:kms", ++ "KMSMasterKeyID": "alias/test-kms-key-id", ++ } ++ } ++ ] ++ }, ++ ) ++ ++ client.copy_object( ++ Bucket=bucket_name, ++ CopySource={"Bucket": bucket_name, "Key": "part-2.txt"}, ++ Key="part-2.txt", ++ ) ++ ++ head = client.head_object(Bucket=bucket_name, Key="part-2.txt") ++ assert head["ServerSideEncryption"] == "aws:kms" ++ assert head["SSEKMSKeyId"] == "alias/test-kms-key-id" ++ ++ ++@mock_s3 ++def test_copy_object_to_different_key_applies_bucket_default_encryption(): ++ ++ ++ bucket_name = "issue-sse-newkey-bucket" ++ client = boto3.client("s3", region_name=DEFAULT_REGION_NAME) ++ client.create_bucket(Bucket=bucket_name) ++ ++ client.put_object(Bucket=bucket_name, Key="src.txt", Body=b"dummy") ++ client.put_bucket_encryption( ++ Bucket=bucket_name, ++ ServerSideEncryptionConfiguration={ ++ "Rules": [ ++ {"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}} ++ ] ++ }, ++ ) ++ ++ client.copy_object( ++ Bucket=bucket_name, ++ CopySource={"Bucket": bucket_name, "Key": "src.txt"}, ++ Key="dst.txt", ++ ) ++ ++ head = client.head_object(Bucket=bucket_name, Key="dst.txt") ++ assert head["ServerSideEncryption"] == "AES256" ++ ++ ++@mock_s3 ++def test_copy_object_no_bucket_encryption_no_change(): ++ ++ ++ bucket_name = "no-enc-bucket-issue" ++ client = boto3.client("s3", region_name=DEFAULT_REGION_NAME) ++ client.create_bucket(Bucket=bucket_name) ++ ++ client.put_object(Bucket=bucket_name, Key="src.txt", Body=b"dummy") ++ ++ client.copy_object( ++ Bucket=bucket_name, ++ CopySource={"Bucket": bucket_name, "Key": "src.txt"}, ++ Key="dst.txt", ++ ) ++ ++ head = client.head_object(Bucket=bucket_name, Key="dst.txt") ++ assert head.get("ServerSideEncryption") is None ++ ++ ++@mock_s3 ++def test_copy_object_with_replace_metadata_directive_applies_default_encryption(): ++ ++ ++ bucket_name = "issue-replace-md-bucket" ++ client = boto3.client("s3", region_name=DEFAULT_REGION_NAME) ++ client.create_bucket(Bucket=bucket_name) ++ ++ client.put_object(Bucket=bucket_name, Key="part.txt", Body=b"dummy") ++ ++ client.put_bucket_encryption( ++ Bucket=bucket_name, ++ ServerSideEncryptionConfiguration={ ++ "Rules": [ ++ {"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}} ++ ] ++ }, ++ ) ++ ++ client.copy_object( ++ Bucket=bucket_name, ++ CopySource={"Bucket": bucket_name, "Key": "part.txt"}, ++ Key="part.txt", ++ MetadataDirective="REPLACE", ++ Metadata={"foo": "bar"}, ++ ) ++ ++ head = client.head_object(Bucket=bucket_name, Key="part.txt") ++ assert head["ServerSideEncryption"] == "AES256" ++ assert head["Metadata"]["foo"] == "bar" ++ ++ ++@mock_s3 ++def test_put_object_after_enabling_aes256_default_encryption(): ++ ++ ++ ++ bucket_name = "issue-put-after-enc-bucket" ++ client = boto3.client("s3", region_name=DEFAULT_REGION_NAME) ++ client.create_bucket(Bucket=bucket_name) ++ ++ client.put_bucket_encryption( ++ Bucket=bucket_name, ++ ServerSideEncryptionConfiguration={ ++ "Rules": [ ++ {"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}} ++ ] ++ }, ++ ) ++ ++ client.put_object(Bucket=bucket_name, Key="new.txt", Body=b"hi") ++ ++ head = client.head_object(Bucket=bucket_name, Key="new.txt") ++ assert head["ServerSideEncryption"] == "AES256" +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_s3/test_s3.py::test_copy_object_in_place_applies_bucket_default_encryption_aes256 tests/test_s3/test_s3.py::test_copy_object_in_place_applies_bucket_default_encryption_kms tests/test_s3/test_s3.py::test_copy_object_to_different_key_applies_bucket_default_encryption tests/test_s3/test_s3.py::test_copy_object_no_bucket_encryption_no_change tests/test_s3/test_s3.py::test_copy_object_with_replace_metadata_directive_applies_default_encryption tests/test_s3/test_s3.py::test_put_object_after_enabling_aes256_default_encryption ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001259/tests/test.sh b/tasks/format-code-task-001259/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a44cc549c7311e052b3ba004b0403c46d2c1ea57 --- /dev/null +++ b/tasks/format-code-task-001259/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_s3/test_s3.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-001259/tests/test_command.sh b/tasks/format-code-task-001259/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001259/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-001266/environment/Dockerfile b/tasks/format-code-task-001266/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..20aeadb432564ec6d146467e09bd26c67b178648 --- /dev/null +++ b/tasks/format-code-task-001266/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:89be05deee252ca4ff4bce84f8b2a95abab5e77a167274d4d631358550ed16bb diff --git a/tasks/format-code-task-001266/environment/setup/files/blocklist b/tasks/format-code-task-001266/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001266/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-001266/environment/setup/setup.sh b/tasks/format-code-task-001266/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001266/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-001266/tests/test.patch b/tasks/format-code-task-001266/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1c80b69495dae755ab59c93a0cd713ba052854aa --- /dev/null +++ b/tasks/format-code-task-001266/tests/test.patch @@ -0,0 +1,117 @@ +diff --git a/pkg/exec/builder/flags_test.go b/pkg/exec/builder/flags_test.go +index 7295173b..ccd2857f 100644 +--- a/pkg/exec/builder/flags_test.go ++++ b/pkg/exec/builder/flags_test.go +@@ -82,3 +82,90 @@ func TestFlags_ToSlice(t *testing.T) { + // Flags should be sorted and sliced up on a platter + assert.Equal(t, []string{"-a", "1", "--bull", "2"}, args) + } ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++func TestFlags_UnmarshalYAML_BoolLikeKey_Empty(t *testing.T) { ++ input := []byte("yes:\n") ++ ++ var flags Flags ++ require.NotPanics(t, func() { ++ err := yaml.Unmarshal(input, &flags) ++ require.NoError(t, err, "yaml unmarshal should not error on bool-like key") ++ }) ++ ++ require.Len(t, flags, 1) ++ assert.Equal(t, "yes", flags[0].Name, "key 'yes' must be preserved as the string 'yes', not converted to 'true'") ++ assert.Empty(t, flags[0].Values, "empty value should produce a valueless flag") ++} ++ ++ ++func TestFlags_UnmarshalYAML_BoolLikeKey_EmptyString(t *testing.T) { ++ input := []byte("yes: \"\"\n") ++ ++ var flags Flags ++ require.NotPanics(t, func() { ++ err := yaml.Unmarshal(input, &flags) ++ require.NoError(t, err) ++ }) ++ ++ require.Len(t, flags, 1) ++ assert.Equal(t, "yes", flags[0].Name, "key 'yes' must be preserved as the string 'yes'") ++} ++ ++ ++func TestFlags_UnmarshalYAML_BoolLikeKey_ToSlice(t *testing.T) { ++ input := []byte("yes:\n") ++ ++ var flags Flags ++ err := yaml.Unmarshal(input, &flags) ++ require.NoError(t, err) ++ ++ args := flags.ToSlice(testStep.GetDashes()) ++ assert.Equal(t, []string{"--yes"}, args, "bool-like key 'yes' should produce --yes flag, not --true") ++} ++ ++ ++func TestFlags_UnmarshalYAML_OtherBoolLikeKeys(t *testing.T) { ++ cases := []struct { ++ yaml string ++ name string ++ }{ ++ {"no:\n", "no"}, ++ {"on:\n", "on"}, ++ {"off:\n", "off"}, ++ {"y:\n", "y"}, ++ {"n:\n", "n"}, ++ } ++ for _, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ var flags Flags ++ require.NotPanics(t, func() { ++ err := yaml.Unmarshal([]byte(tc.yaml), &flags) ++ require.NoError(t, err) ++ }) ++ require.Len(t, flags, 1) ++ assert.Equal(t, tc.name, flags[0].Name, ++ "yaml bool-like key %q must be preserved verbatim, not converted to 'true'/'false'", tc.name) ++ }) ++ } ++} ++ ++ ++func TestFlags_UnmarshalYAML_StringKey_StillWorks(t *testing.T) { ++ input := []byte("force: true\n") ++ ++ var flags Flags ++ err := yaml.Unmarshal(input, &flags) ++ require.NoError(t, err) ++ require.Len(t, flags, 1) ++ assert.Equal(t, "force", flags[0].Name) ++ assert.Equal(t, []string{"true"}, flags[0].Values) ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..3a4f66eb +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./pkg/exec/builder/ -run TestFlags -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test ./pkg/exec/builder/ -run TestFlags -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001266/tests/test.sh b/tasks/format-code-task-001266/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..18ecf7cf574e12396109be332686896ddf11ea75 --- /dev/null +++ b/tasks/format-code-task-001266/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/exec/builder/flags_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-001266/tests/test_command.sh b/tasks/format-code-task-001266/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001266/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-001292/environment/Dockerfile b/tasks/format-code-task-001292/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2b1e29273568c35f81fa91508a97cc35984fe31a --- /dev/null +++ b/tasks/format-code-task-001292/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:74e08549e048666500160aa92ff28f4598e85450e2f87ffb5f7f3f19971fcd70 diff --git a/tasks/format-code-task-001292/environment/setup/files/blocklist b/tasks/format-code-task-001292/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001292/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-001292/environment/setup/setup.sh b/tasks/format-code-task-001292/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001292/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-001292/tests/test.patch b/tasks/format-code-task-001292/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..36b98bad54d5f810ee4dfa504246b8fd23a476f4 --- /dev/null +++ b/tasks/format-code-task-001292/tests/test.patch @@ -0,0 +1,93 @@ +diff --git a/test/variableTests.js b/test/variableTests.js +index 200f3052a..b97e76544 100644 +--- a/test/variableTests.js ++++ b/test/variableTests.js +@@ -1,6 +1,16 @@ + var parser = require("./main"); + + describe("Test variables", function() { ++ describe("array destructuring", function() { ++ ++ var ast = parser.parseEval("[$id1, $name1] = $data[0];"); ++ it("should be assign with array", function() { ++ ast.children[0].kind.should.be.exactly("assign"); ++ ast.children[0].left.kind.should.be.exactly("array"); ++ ast.children[0].operator.should.be.exactly("="); ++ }); ++ }); ++ + describe("Default variables", function() { + var ast = parser.parseEval( + ['$a = "foo";', "$b = &$c;", "$a->b = true;"].join("\n") +@@ -197,11 +207,9 @@ describe("Test variables", function() { + astErr.errors[0].line.should.be.exactly(1); + astErr.errors[0].message.should.be.exactly(msg); + }); +- ++ + it("should fail on property lookup on static lookup", function() { +- var astErr = parser.parseEval([ +- "$this->foo::bar->baz;" +- ].join('\n'), { ++ var astErr = parser.parseEval(["$this->foo::bar->baz;"].join("\n"), { + parser: { + suppressErrors: true + } +@@ -213,27 +221,27 @@ describe("Test variables", function() { + astErr.errors[0].line.should.be.exactly(1); + astErr.errors[0].message.should.be.exactly(msg); + }); +- +- it('should fail $foo->bar::!', function() { +- var errAst = parser.parseEval('$foo->bar::!', { ++ ++ it("should fail $foo->bar::!", function() { ++ var errAst = parser.parseEval("$foo->bar::!", { + parser: { + suppressErrors: true + } + }); + errAst.errors.length.should.be.exactly(1); +- errAst.errors[0].token.should.be.exactly('\'!\''); +- errAst.children[0].kind.should.be.exactly('staticlookup'); +- errAst.children[0].offset.name.should.be.exactly('!'); ++ errAst.errors[0].token.should.be.exactly("'!'"); ++ errAst.children[0].kind.should.be.exactly("staticlookup"); ++ errAst.children[0].offset.name.should.be.exactly("!"); + }); + +- it('should fail foo::bar::baz', function() { +- var errAst = parser.parseEval('foo::bar::baz', { ++ it("should fail foo::bar::baz", function() { ++ var errAst = parser.parseEval("foo::bar::baz", { + parser: { + suppressErrors: true + } + }); + errAst.errors.length.should.be.exactly(1); +- errAst.children[0].kind.should.be.exactly('staticlookup'); ++ errAst.children[0].kind.should.be.exactly("staticlookup"); + }); + }); + }); +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+3RS26DMBSFYcZZhTcAwRYOo+6i88hgS9ACbm2Iqq4+DoM2itRmkqiq8n+T68eV ++/DhFs/SD3bvpsM3upUxqrdeaXNZ1LLWSSpaVVqlPSl3vMqHvdqMzS5xNECIL3s+/9V3b/6eK7/xn ++F+d968fRTLaI3e3OuJa/lPVX/lWtUv7VTqpMlLe7ws8ePP/WijX4xtnN9PYhRt92RpxWtgcTetMM ++7jlNYvESRZ6nv2pf89h/uiedgksrwb0vfXAidn4Z7OavnwMAAAAAAAAAAAAAAAA8lCOAcRG/ACgA ++AA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001292/tests/test.sh b/tasks/format-code-task-001292/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f9fb020643f8d5ed967d22bedff0231a33beb821 --- /dev/null +++ b/tasks/format-code-task-001292/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/variableTests.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-001292/tests/test_command.sh b/tasks/format-code-task-001292/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001292/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-001314/environment/Dockerfile b/tasks/format-code-task-001314/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5f2c84b44b04bc7970a33ec04f3a997df7f2af7a --- /dev/null +++ b/tasks/format-code-task-001314/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:44c6010831606841b44a84985a19e1f0afea48315cdc2fae01f880a723ff73f6 diff --git a/tasks/format-code-task-001314/environment/setup/files/blocklist b/tasks/format-code-task-001314/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001314/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-001314/environment/setup/setup.sh b/tasks/format-code-task-001314/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001314/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-001314/tests/test.patch b/tasks/format-code-task-001314/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c595c664e53420d07cb639e55da101b1f40b5f00 --- /dev/null +++ b/tasks/format-code-task-001314/tests/test.patch @@ -0,0 +1,534 @@ +diff --git a/usercase-test-coderl/local_infile_test.go b/usercase-test-coderl/local_infile_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/local_infile_test.go +@@ -0,0 +1,505 @@ ++package usercase_test_coderl ++ ++import ( ++ "context" ++ "database/sql" ++ "errors" ++ "fmt" ++ "io" ++ "net" ++ "os" ++ "path/filepath" ++ "strconv" ++ "strings" ++ "testing" ++ ++ mysql "github.com/go-sql-driver/mysql" ++) ++ ++ ++ ++ ++type infileServer struct { ++ requestPath string ++ expectUpload bool ++ expectCOMQuit bool ++ finalRows byte ++ clientConn net.Conn ++ serverConn net.Conn ++ uploaded chan string ++ queries chan string ++ done chan struct{} ++ errs chan error ++} ++ ++func newInfileServer(t *testing.T, requestPath string, expectUpload bool, finalRows byte) *infileServer { ++ t.Helper() ++ client, server := net.Pipe() ++ s := &infileServer{ ++ requestPath: requestPath, ++ expectUpload: expectUpload, ++ expectCOMQuit: true, ++ finalRows: finalRows, ++ clientConn: client, ++ serverConn: server, ++ uploaded: make(chan string, 1), ++ queries: make(chan string, 1), ++ done: make(chan struct{}), ++ errs: make(chan error, 1), ++ } ++ go s.serve(server) ++ t.Cleanup(func() { ++ _ = s.clientConn.Close() ++ _ = s.serverConn.Close() ++ <-s.done ++ select { ++ case err := <-s.errs: ++ t.Fatalf("fake MySQL server failed: %v", err) ++ default: ++ } ++ }) ++ return s ++} ++ ++func (s *infileServer) dialFunc(context.Context, string, string) (net.Conn, error) { ++ return s.clientConn, nil ++} ++ ++func (s *infileServer) serve(conn net.Conn) { ++ defer close(s.done) ++ if err := s.run(conn); err != nil { ++ s.errs <- err ++ } ++} ++ ++func (s *infileServer) run(conn net.Conn) error { ++ defer conn.Close() ++ ++ if err := writePacket(conn, 0, handshakePacket()); err != nil { ++ return err ++ } ++ if _, _, err := readPacket(conn); err != nil { ++ return fmt.Errorf("read handshake response: %w", err) ++ } ++ if err := writePacket(conn, 2, okPacket(0)); err != nil { ++ return err ++ } ++ ++ payload, _, err := readPacket(conn) ++ if err != nil { ++ return fmt.Errorf("read command: %w", err) ++ } ++ if len(payload) == 0 { ++ return errors.New("empty command packet") ++ } ++ if payload[0] == 0x01 { ++ return nil ++ } ++ if payload[0] == 0x0e { ++ s.queries <- "COM_PING" ++ return writePacket(conn, 1, okPacket(0)) ++ } ++ if payload[0] != 0x03 { ++ return fmt.Errorf("first command = %#x, want COM_QUERY", payload[0]) ++ } ++ s.queries <- string(payload[1:]) ++ if err := writePacket(conn, 1, append([]byte{0xfb}, []byte(s.requestPath)...)); err != nil { ++ return err ++ } ++ finalOKSeq := byte(2) ++ if s.expectUpload { ++ var b strings.Builder ++ for { ++ part, seq, err := readPacket(conn) ++ if err != nil { ++ return fmt.Errorf("read infile upload: %w", err) ++ } ++ if len(part) == 0 { ++ finalOKSeq = seq + 1 ++ break ++ } ++ b.Write(part) ++ } ++ s.uploaded <- b.String() ++ } else { ++ part, seq, err := readPacket(conn) ++ if err != nil { ++ return fmt.Errorf("read rejected infile terminator: %w", err) ++ } ++ if len(part) != 0 { ++ return fmt.Errorf("rejected infile packet = %q, want empty terminator", string(part)) ++ } ++ finalOKSeq = seq + 1 ++ s.uploaded <- "" ++ } ++ if err := writePacket(conn, finalOKSeq, okPacket(s.finalRows)); err != nil { ++ return err ++ } ++ ++ payload, _, err = readPacket(conn) ++ if err != nil { ++ return nil ++ } ++ if s.expectCOMQuit && (len(payload) == 0 || payload[0] != 0x01) { ++ return fmt.Errorf("close command = %x, want COM_QUIT", payload) ++ } ++ return nil ++} ++ ++func handshakePacket() []byte { ++ payload := []byte{0x0a} ++ payload = append(payload, []byte("8.0.0-usercase")...) ++ payload = append(payload, 0x00) ++ payload = append(payload, 0x01, 0x00, 0x00, 0x00) ++ payload = append(payload, []byte("abcdefgh")...) ++ payload = append(payload, 0x00) ++ payload = append(payload, 0x00, 0x82) ++ payload = append(payload, 0x21) ++ payload = append(payload, 0x00, 0x00) ++ payload = append(payload, 0x00, 0x00) ++ payload = append(payload, 21) ++ payload = append(payload, make([]byte, 6)...) ++ payload = append(payload, make([]byte, 4)...) ++ payload = append(payload, []byte("ijklmnopqrst")...) ++ payload = append(payload, 0x00) ++ payload = append(payload, []byte("mysql_native_password")...) ++ payload = append(payload, 0x00) ++ return payload ++} ++ ++func okPacket(rows byte) []byte { ++ return []byte{0x00, rows, 0x00, 0x02, 0x00, 0x00, 0x00} ++} ++ ++func writePacket(w io.Writer, seq byte, payload []byte) error { ++ header := []byte{byte(len(payload)), byte(len(payload) >> 8), byte(len(payload) >> 16), seq} ++ if _, err := w.Write(append(header, payload...)); err != nil { ++ return err ++ } ++ return nil ++} ++ ++func readPacket(r io.Reader) ([]byte, byte, error) { ++ header := make([]byte, 4) ++ if _, err := io.ReadFull(r, header); err != nil { ++ return nil, 0, err ++ } ++ n := int(header[0]) | int(header[1])<<8 | int(header[2])<<16 ++ payload := make([]byte, n) ++ if _, err := io.ReadFull(r, payload); err != nil { ++ return nil, 0, err ++ } ++ return payload, header[3], nil ++} ++ ++func execLocalInfile(t *testing.T, requestPath string, allowAllFiles bool, finalRows byte) (string, int64, string, error) { ++ t.Helper() ++ s := newInfileServer(t, requestPath, true, finalRows) ++ cfg := mysql.NewConfig() ++ cfg.Net = "tcp" ++ cfg.Addr = "usercase.invalid:3306" ++ cfg.User = "user" ++ cfg.DBName = "db" ++ cfg.AllowAllFiles = allowAllFiles ++ cfg.MaxAllowedPacket = 64 << 20 ++ cfg.DialFunc = s.dialFunc ++ connector, err := mysql.NewConnector(cfg) ++ if err != nil { ++ t.Fatalf("NewConnector failed: %v", err) ++ } ++ db := sql.OpenDB(connector) ++ defer db.Close() ++ ++ query := "LOAD DATA LOCAL INFILE '" + requestPath + "' INTO TABLE t" ++ result, err := db.ExecContext(context.Background(), query) ++ if err != nil { ++ return "", 0, "", err ++ } ++ rows, err := result.RowsAffected() ++ if err != nil { ++ return "", 0, "", err ++ } ++ return <-s.uploaded, rows, <-s.queries, nil ++} ++ ++func execLocalInfileReject(t *testing.T, requestPath string) error { ++ t.Helper() ++ s := newInfileServer(t, requestPath, false, 0) ++ cfg := mysql.NewConfig() ++ cfg.Net = "tcp" ++ cfg.Addr = "usercase.invalid:3306" ++ cfg.User = "user" ++ cfg.DBName = "db" ++ cfg.MaxAllowedPacket = 64 << 20 ++ cfg.DialFunc = s.dialFunc ++ connector, err := mysql.NewConnector(cfg) ++ if err != nil { ++ t.Fatalf("NewConnector failed: %v", err) ++ } ++ db := sql.OpenDB(connector) ++ defer db.Close() ++ ++ _, err = db.ExecContext(context.Background(), "LOAD DATA LOCAL INFILE '"+requestPath+"' INTO TABLE t") ++ return err ++} ++ ++func writeFixture(t *testing.T, name string, content string) string { ++ t.Helper() ++ path := filepath.Join(t.TempDir(), name) ++ if err := os.WriteFile(path, []byte(content), 0o600); err != nil { ++ t.Fatalf("write fixture: %v", err) ++ } ++ return path ++} ++ ++func TestRegisteredEmptyFilesystemSourceLoadsZeroRows(t *testing.T) { ++ ++ ++ path := writeFixture(t, "empty.tsv", "") ++ mysql.RegisterLocalFile(path) ++ defer mysql.DeregisterLocalFile(path) ++ ++ ++ uploaded, rows, query, err := execLocalInfile(t, path, false, 0) ++ if err != nil { ++ t.Fatalf("Exec failed: %v", err) ++ } ++ if uploaded != "" { ++ t.Fatalf("uploaded payload = %q, want %q", uploaded, "") ++ } ++ if rows != 0 { ++ t.Fatalf("RowsAffected = %d, want 0", rows) ++ } ++ if query != "LOAD DATA LOCAL INFILE '"+path+"' INTO TABLE t" { ++ t.Fatalf("query = %q, want LOAD DATA LOCAL INFILE %q INTO TABLE t", query, path) ++ } ++} ++ ++func TestRegisteredTabSeparatedFilesystemSourceUploadsRows(t *testing.T) { ++ ++ ++ path := writeFixture(t, "rows.tsv", "1\talpha\n2\tbeta\n") ++ mysql.RegisterLocalFile(path) ++ defer mysql.DeregisterLocalFile(path) ++ ++ ++ uploaded, rows, _, err := execLocalInfile(t, path, false, 2) ++ if err != nil { ++ t.Fatalf("Exec failed: %v", err) ++ } ++ if uploaded != "1\talpha\n2\tbeta\n" { ++ t.Fatalf("uploaded payload = %q, want %q", uploaded, "1\talpha\n2\tbeta\n") ++ } ++ ++ if rows < 0 { ++ t.Fatalf("RowsAffected = %d, want non-negative value", rows) ++ } ++} ++ ++func TestDeregisteredPathIsRejectedOnLaterRequest(t *testing.T) { ++ ++ ++ path := writeFixture(t, "removed.tsv", "9\tremoved\n") ++ mysql.RegisterLocalFile(path) ++ mysql.DeregisterLocalFile(path) ++ ++ ++ err := execLocalInfileReject(t, path) ++ if err == nil { ++ t.Fatal("Exec succeeded, want unregistered local file error") ++ } ++ ++ if !strings.Contains(err.Error(), path) || !strings.Contains(strings.ToLower(err.Error()), "not registered") { ++ t.Fatalf("Exec error = %q, want path and not-registered indication", err.Error()) ++ } ++} ++ ++func TestUnregisteredOrdinaryFilesystemPathIsRejected(t *testing.T) { ++ ++ ++ path := writeFixture(t, "unregistered.tsv", "3\tgamma\n") ++ mysql.DeregisterLocalFile(path) ++ ++ ++ err := execLocalInfileReject(t, path) ++ if err == nil { ++ t.Fatal("Exec succeeded, want unregistered local file error") ++ } ++ ++ if !strings.Contains(err.Error(), path) || !strings.Contains(strings.ToLower(err.Error()), "not registered") { ++ t.Fatalf("Exec error = %q, want path and not-registered indication", err.Error()) ++ } ++} ++ ++func TestAllowAllFilesDSNParsingFormattingAndUpload(t *testing.T) { ++ ++ ++ for _, dsn := range []string{"/db?allowAllFiles=true", "/db?allowAllFiles=TRUE", "/db?allowAllFiles=True", "/db?allowAllFiles=1"} { ++ cfg, err := mysql.ParseDSN(dsn) ++ if err != nil { ++ t.Fatalf("ParseDSN(%q) failed: %v", dsn, err) ++ } ++ if cfg.AllowAllFiles != true { ++ t.Fatalf("ParseDSN(%q).AllowAllFiles = %v, want true", dsn, cfg.AllowAllFiles) ++ } ++ } ++ cfg, err := mysql.ParseDSN("/db?allowAllFiles=false") ++ if err != nil { ++ t.Fatalf("ParseDSN false failed: %v", err) ++ } ++ if cfg.AllowAllFiles != false { ++ t.Fatalf("ParseDSN false AllowAllFiles = %v, want false", cfg.AllowAllFiles) ++ } ++ formatCfg := mysql.NewConfig() ++ formatCfg.AllowAllFiles = true ++ formatted := formatCfg.FormatDSN() ++ ++ if !strings.Contains(formatted, "allowAllFiles=true") { ++ t.Fatalf("FormatDSN = %q, want allowAllFiles=true parameter", formatted) ++ } ++ roundTripCfg, err := mysql.ParseDSN(formatted) ++ if err != nil { ++ t.Fatalf("ParseDSN(FormatDSN()) failed: %v", err) ++ } ++ if !roundTripCfg.AllowAllFiles { ++ t.Fatalf("ParseDSN(FormatDSN()).AllowAllFiles = false, want true") ++ } ++ ++ path := writeFixture(t, "allow-all.tsv", "7\topen\n") ++ mysql.DeregisterLocalFile(path) ++ ++ uploaded, rows, _, err := execLocalInfile(t, path, true, 1) ++ if err != nil { ++ t.Fatalf("Exec failed: %v", err) ++ } ++ if uploaded != "7\topen\n" { ++ t.Fatalf("uploaded payload = %q, want %q", uploaded, "7\topen\n") ++ } ++ ++ if rows < 0 { ++ t.Fatalf("RowsAffected = %d, want non-negative value", rows) ++ } ++} ++ ++func TestInvalidAllowAllFilesBooleanIsRejected(t *testing.T) { ++ ++ ++ _, err := mysql.ParseDSN("/db?allowAllFiles=maybe") ++ if err == nil { ++ t.Fatal("ParseDSN succeeded, want invalid bool error") ++ } ++ ++} ++ ++func TestAllowAllFilesStillSurfacesOpenFailures(t *testing.T) { ++ ++ ++ path := filepath.Join(t.TempDir(), "missing.tsv") ++ mysql.DeregisterLocalFile(path) ++ ++ ++ err := func() error { ++ s := newInfileServer(t, path, true, 0) ++ cfg := mysql.NewConfig() ++ cfg.Net = "tcp" ++ cfg.Addr = "usercase.invalid:3306" ++ cfg.User = "user" ++ cfg.DBName = "db" ++ cfg.AllowAllFiles = true ++ cfg.MaxAllowedPacket = 64 << 20 ++ cfg.DialFunc = s.dialFunc ++ connector, connectorErr := mysql.NewConnector(cfg) ++ if connectorErr != nil { ++ t.Fatalf("NewConnector failed: %v", connectorErr) ++ } ++ db := sql.OpenDB(connector) ++ defer db.Close() ++ _, execErr := db.ExecContext(context.Background(), "LOAD DATA LOCAL INFILE '"+path+"' INTO TABLE t") ++ return execErr ++ }() ++ if err == nil { ++ t.Fatal("Exec succeeded, want open failure") ++ } ++ ++ if !strings.Contains(err.Error(), path) { ++ t.Fatalf("Exec error = %q, want it to mention missing path %q", err.Error(), path) ++ } ++} ++ ++func TestLocalFileRegistrationIsIndependentByPath(t *testing.T) { ++ ++ ++ registered := writeFixture(t, "registered.tsv", "4\tkept\n") ++ unregistered := writeFixture(t, "other.tsv", "5\tblocked\n") ++ mysql.RegisterLocalFile(registered) ++ defer mysql.DeregisterLocalFile(registered) ++ mysql.DeregisterLocalFile(unregistered) ++ ++ ++ uploaded, rows, _, err := execLocalInfile(t, registered, false, 1) ++ if err != nil { ++ t.Fatalf("registered Exec failed: %v", err) ++ } ++ if uploaded != "4\tkept\n" { ++ t.Fatalf("registered uploaded payload = %q, want %q", uploaded, "4\tkept\n") ++ } ++ ++ if rows < 0 { ++ t.Fatalf("registered RowsAffected = %d, want non-negative value", rows) ++ } ++ err = execLocalInfileReject(t, unregistered) ++ if err == nil { ++ t.Fatal("unregistered Exec succeeded, want unregistered local file error") ++ } ++ ++ if !strings.Contains(err.Error(), unregistered) || !strings.Contains(strings.ToLower(err.Error()), "not registered") { ++ t.Fatalf("unregistered Exec error = %q, want path and not-registered indication", err.Error()) ++ } ++} ++ ++func TestDeregisterLocalFileIsIdempotent(t *testing.T) { ++ ++ ++ path := writeFixture(t, "idempotent-deregister.tsv", "6\tgone\n") ++ mysql.RegisterLocalFile(path) ++ mysql.DeregisterLocalFile(path) ++ ++ mysql.DeregisterLocalFile(path) ++ ++ err := execLocalInfileReject(t, path) ++ if err == nil { ++ t.Fatal("Exec succeeded, want unregistered local file error") ++ } ++ if !strings.Contains(err.Error(), path) || !strings.Contains(strings.ToLower(err.Error()), "not registered") { ++ t.Fatalf("Exec error = %q, want path and not-registered indication", err.Error()) ++ } ++} ++ ++func TestRepeatedRegisterUseDeregisterCycles(t *testing.T) { ++ ++ ++ for i := 0; i < 120; i++ { ++ path := writeFixture(t, "cycle-"+strconv.Itoa(i)+".tsv", "1\tcycle\n") ++ mysql.RegisterLocalFile(path) ++ uploaded, rows, _, err := execLocalInfile(t, path, false, 1) ++ mysql.DeregisterLocalFile(path) ++ if err != nil { ++ t.Fatalf("cycle %d Exec failed: %v", i, err) ++ } ++ if uploaded != "1\tcycle\n" { ++ t.Fatalf("cycle %d uploaded payload = %q, want %q", i, uploaded, "1\tcycle\n") ++ } ++ ++ if rows < 0 { ++ t.Fatalf("cycle %d RowsAffected = %d, want non-negative value", i, rows) ++ } ++ ++ err = execLocalInfileReject(t, path) ++ if err == nil { ++ t.Fatalf("cycle %d post-deregister Exec succeeded, want unregistered local file error", i) ++ } ++ if !strings.Contains(err.Error(), path) || !strings.Contains(strings.ToLower(err.Error()), "not registered") { ++ t.Fatalf("cycle %d post-deregister Exec error = %q, want path and not-registered indication", i, err.Error()) ++ } ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export PATH="/root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.0.linux-amd64/bin:${PATH}" ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001314/tests/test.sh b/tasks/format-code-task-001314/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..192c74359fb1c13373f292f2e6d74b235198c83a --- /dev/null +++ b/tasks/format-code-task-001314/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/local_infile_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-001314/tests/test_command.sh b/tasks/format-code-task-001314/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001314/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-001322/environment/Dockerfile b/tasks/format-code-task-001322/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4ed947f71eba27a742232cfb3bdf0ec841ffbee7 --- /dev/null +++ b/tasks/format-code-task-001322/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:a3b9ff1eaa73575847c493c71f217f26648d66518f82ff1ecbe0d449a3c2c04c diff --git a/tasks/format-code-task-001322/environment/setup/files/blocklist b/tasks/format-code-task-001322/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001322/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-001322/environment/setup/setup.sh b/tasks/format-code-task-001322/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001322/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-001322/tests/test.patch b/tasks/format-code-task-001322/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..01fa03c4fe6710d881bc3b3e62717ffd7bd7cd90 --- /dev/null +++ b/tasks/format-code-task-001322/tests/test.patch @@ -0,0 +1,111 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..d2da6ba +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_base_scanner.py::SignatureTests tests/test_base_scanner.py::ExcludedSignatureSuppressionTests -v"] ++} +diff --git a/tests/test_base_scanner.py b/tests/test_base_scanner.py +index 13f3bed..ad0e724 100644 +--- a/tests/test_base_scanner.py ++++ b/tests/test_base_scanner.py +@@ -265,6 +265,84 @@ class SignatureTests(ScannerTestCase): + test_scanner = TestScanner(self.options) + self.assertFalse(test_scanner.signature_is_excluded("blah", "stuff")) + ++ @mock.patch("tartufo.util.generate_signature") ++ def test_blob_not_matching_excluded_signature_and_no_fingerprint_match( ++ self, mock_signature: mock.MagicMock ++ ): ++ ++ ++ self.options.exclude_signatures = ("excluded_sig",) ++ mock_signature.return_value = "another_fingerprint" ++ test_scanner = TestScanner(self.options) ++ self.assertFalse(test_scanner.signature_is_excluded("plain_blob", "path")) ++ ++ ++class ExcludedSignatureSuppressionTests(ScannerTestCase): ++ """End-to-end coverage for the issue: when `exclude-signatures` contains ++ a hash, that literal hash string appearing in scanned content should not ++ generate an entropy or regex issue.""" ++ ++ def setUp(self) -> None: ++ super().setUp() ++ self.options.entropy = True ++ self.options.regex = True ++ self.options.default_regexes = True ++ ++ @mock.patch("tartufo.scanner.ScannerBase.calculate_entropy") ++ @mock.patch("tartufo.util.get_strings_of_set") ++ def test_scan_entropy_skips_string_matching_an_excluded_signature( ++ self, ++ mock_strings: mock.MagicMock, ++ mock_calculate: mock.MagicMock, ++ ): ++ ++ ++ excluded_sig = ( ++ "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" ++ ) ++ self.options.exclude_signatures = (excluded_sig,) ++ chunk = types.Chunk(excluded_sig, "some/file.py", {}) ++ ++ mock_strings.side_effect = ([excluded_sig], [], [], [], [], []) ++ mock_calculate.return_value = 9.0 ++ test_scanner = TestScanner(self.options) ++ issues = test_scanner.scan_entropy(chunk) ++ self.assertEqual(issues, []) ++ ++ @mock.patch("tartufo.scanner.ScannerBase.calculate_entropy") ++ @mock.patch("tartufo.util.get_strings_of_set") ++ def test_scan_entropy_still_yields_issue_for_non_excluded_string( ++ self, ++ mock_strings: mock.MagicMock, ++ mock_calculate: mock.MagicMock, ++ ): ++ ++ ++ self.options.exclude_signatures = ("some-other-sig",) ++ chunk = types.Chunk("payload", "some/file.py", {}) ++ mock_strings.side_effect = (["payload"], [], [], [], [], []) ++ mock_calculate.return_value = 9.0 ++ test_scanner = TestScanner(self.options) ++ issues = test_scanner.scan_entropy(chunk) ++ self.assertEqual(len(issues), 1) ++ self.assertEqual(issues[0].matched_string, "payload") ++ self.assertEqual(issues[0].issue_type, types.IssueType.Entropy) ++ ++ def test_scan_regex_skips_match_matching_an_excluded_signature(self): ++ excluded_sig = "abc123excluded" ++ self.options.exclude_signatures = (excluded_sig,) ++ test_scanner = TestScanner(self.options) ++ test_scanner._rules_regexes = { # pylint: disable=protected-access ++ "rule": Rule( ++ name=None, ++ pattern=re.compile(re.escape(excluded_sig)), ++ path_pattern=None, ++ ) ++ } ++ chunk = types.Chunk(excluded_sig, "file.py", {}) ++ issues = test_scanner.scan_regex(chunk) ++ self.assertEqual(issues, []) ++ + + class RegexScanTests(ScannerTestCase): + def setUp(self) -> None: +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_base_scanner.py::SignatureTests::test_blob_not_matching_excluded_signature_and_no_fingerprint_match tests/test_base_scanner.py::ExcludedSignatureSuppressionTests::test_scan_entropy_skips_string_matching_an_excluded_signature tests/test_base_scanner.py::ExcludedSignatureSuppressionTests::test_scan_entropy_still_yields_issue_for_non_excluded_string tests/test_base_scanner.py::ExcludedSignatureSuppressionTests::test_scan_regex_skips_match_matching_an_excluded_signature ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001322/tests/test.sh b/tasks/format-code-task-001322/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..881e8d9e82fde71a0a67c5a66704f1b309e018f5 --- /dev/null +++ b/tasks/format-code-task-001322/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_base_scanner.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-001322/tests/test_command.sh b/tasks/format-code-task-001322/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001322/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-001325/environment/Dockerfile b/tasks/format-code-task-001325/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e557e806c77231b7f70d11dd5c3563dbf6a6a5de --- /dev/null +++ b/tasks/format-code-task-001325/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:be4b3f674ad050021f5f96b5f06ad51466c5c8e83f9d84d01f93059a0fb11cf3 diff --git a/tasks/format-code-task-001325/environment/setup/files/blocklist b/tasks/format-code-task-001325/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001325/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-001325/environment/setup/setup.sh b/tasks/format-code-task-001325/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001325/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-001325/tests/test.patch b/tasks/format-code-task-001325/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..91739985d173f09372fc64bcf658e8fcfff6c02b --- /dev/null +++ b/tasks/format-code-task-001325/tests/test.patch @@ -0,0 +1,67 @@ +diff --git a/src/server/middleware/quota/put_manifest_test.go b/src/server/middleware/quota/put_manifest_test.go +index 5d6a988cd7a..52b575c3d40 100644 +--- a/src/server/middleware/quota/put_manifest_test.go ++++ b/src/server/middleware/quota/put_manifest_test.go +@@ -16,8 +16,10 @@ package quota + + import ( + "context" ++ std_err "errors" + "net/http" + "net/http/httptest" ++ "strings" + "testing" + + "github.com/docker/distribution/manifest/schema2" +@@ -272,6 +274,25 @@ func (suite *PutManifestMiddlewareTestSuite) TestResourcesWarning() { + } + } + ++func (suite *PutManifestMiddlewareTestSuite) TestPutInvalid() { ++ unmarshalManifest = func(r *http.Request) (distribution.Manifest, distribution.Descriptor, error) { ++ return nil, distribution.Descriptor{}, std_err.New("json: cannot unmarshal string into Go value of type map") ++ } ++ ++ mock.OnAnything(suite.quotaController, "IsEnabled").Return(true, nil) ++ ++ next := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ w.WriteHeader(http.StatusOK) ++ }) ++ ++ req := httptest.NewRequest(http.MethodPut, "/v2/library/photon/manifests/sha256:totallywrong", strings.NewReader("YmxhYmxhYmxh")) ++ rr := httptest.NewRecorder() ++ ++ PutManifestMiddleware()(next).ServeHTTP(rr, req) ++ suite.Equal(http.StatusBadRequest, rr.Code) ++ ++} ++ + func TestPutManifestMiddlewareTestSuite(t *testing.T) { + suite.Run(t, &PutManifestMiddlewareTestSuite{}) + } +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+3SX2/TMBAA8D7nU9w6HkCQOAltkEB7AAlVSAyhbRIPCFVOck0sEjv4T7t9e5w0 ++HVEF7GUTAu73Eie++M4+R7kTTblGuWWzhxJ7L5bL4ekdP4dxskyTJHueZcliFvtRnM1g+WAVTThj ++uQaYaaXs7+Lumv9LRT/6b9HYdaHalssyMvX95bij/0mySG/7v+zjkkWWLmYQ318Jv/af9//0hOVC ++spybOihKGC5BjmUQnMIKJWpuEQzqLWq2TaOYtarExsBGqxbMjlcVajAdFvBYKgudRoPSArfgV0To ++b5OwT/xiV/X+TcnDEh0vvvIKQbSd0tb8JMszMAqEhdb3CHKEaiyoDC4/vV6t3l6s37z7cDZnzmjW ++qII3w1bGquI0mQdiA5/hBMJrmD+a/DOHL6/A1igD8AqnGwjNe6it7cxLxipha5dHvlxWqXBcbzrU ++2KDfnmGl2slG8ZJt4yhNfOFjxLoR0l2veVtmCwjVUfZ91tpvEp4eVxZsRHBU62HbMJwKhBvgndif ++05guuuGtnwj9Ta7QgtEFm5xm38sLJ/sNwxjRd3nabuZ/CSo1fIdwC6H28Vf+5aOz51yKjR+ei7Js ++cMc19hOXTviKwkI5ac8SiA4J29so9s0py1nwp284IYQQQgghhBBCCCGEEEIIIYQQQsi/7Tv7JijT ++ACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001325/tests/test.sh b/tasks/format-code-task-001325/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e381458f429ed82dcdf44465d35ae5c1b34b8167 --- /dev/null +++ b/tasks/format-code-task-001325/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/server/middleware/quota/put_manifest_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-001325/tests/test_command.sh b/tasks/format-code-task-001325/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001325/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-001340/environment/Dockerfile b/tasks/format-code-task-001340/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..26df222d4a4c47261c44fb60a6c2d3decff2402d --- /dev/null +++ b/tasks/format-code-task-001340/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:ae77122f40f9d5bf2ca68c3b7c8403aac8a73e48c589d6591939ebbeeeee9e22 diff --git a/tasks/format-code-task-001340/environment/setup/files/blocklist b/tasks/format-code-task-001340/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001340/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-001340/environment/setup/setup.sh b/tasks/format-code-task-001340/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001340/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-001340/tests/test.patch b/tasks/format-code-task-001340/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c23664988c4209c150f796724f1b12ea96a01b16 --- /dev/null +++ b/tasks/format-code-task-001340/tests/test.patch @@ -0,0 +1,337 @@ +diff --git a/usercase-test-coderl/parameter_literals_test.go b/usercase-test-coderl/parameter_literals_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/parameter_literals_test.go +@@ -0,0 +1,307 @@ ++package usercase_test_coderl ++ ++import ( ++ "context" ++ "errors" ++ "os" ++ "path/filepath" ++ "reflect" ++ "sort" ++ "strconv" ++ "strings" ++ "testing" ++ ++ "github.com/google/cql" ++ "github.com/google/cql/model" ++ "github.com/google/cql/parser" ++ "github.com/google/cql/result" ++) ++ ++ ++ ++ ++ ++var ( ++ testLibKey = result.LibKey{Name: "TESTLIB", Version: "1.0.0"} ++ otherLibKey = result.LibKey{Name: "OTHERLIB", Version: "1.0.0"} ++ thresholdDefKey = result.DefKey{Name: "Threshold", Library: testLibKey} ++ tagsDefKey = result.DefKey{Name: "Tags", Library: testLibKey} ++ periodDefKey = result.DefKey{Name: "Period", Library: testLibKey} ++) ++ ++const thresholdLib = "library TESTLIB version '1.0.0'\nparameter Threshold Integer default 5\ndefine TESTRESULT: Threshold" ++const otherThresholdLib = "library OTHERLIB version '1.0.0'\nparameter Threshold Integer default 42\ndefine TESTRESULT: Threshold" ++const tagsLib = "library TESTLIB version '1.0.0'\nparameter Tags List\ndefine TESTRESULT: Tags" ++const periodLib = "library TESTLIB version '1.0.0'\nparameter Period Interval\ndefine TESTRESULT: Period" ++ ++func TestDefaultParameterEvaluatesToLibraryDefault(t *testing.T) { ++ ++ ++ got := evalInt(t, []string{thresholdLib}, nil, testLibKey) ++ ++ if got != 5 { ++ t.Fatalf("TESTRESULT = %d, want 5", got) ++ } ++} ++ ++func TestIntegerParameterOverrideEvaluatesToSuppliedLiteral(t *testing.T) { ++ ++ ++ got := evalInt(t, []string{thresholdLib}, map[result.DefKey]string{thresholdDefKey: "9"}, testLibKey) ++ ++ if got != 9 { ++ t.Fatalf("TESTRESULT = %d, want 9", got) ++ } ++} ++ ++func TestParameterOverrideUsesMatchingLibraryKey(t *testing.T) { ++ ++ ++ params := map[result.DefKey]string{thresholdDefKey: "9"} ++ ++ testGot := evalInt(t, []string{thresholdLib, otherThresholdLib}, params, testLibKey) ++ otherGot := evalInt(t, []string{thresholdLib, otherThresholdLib}, params, otherLibKey) ++ ++ if testGot != 9 { ++ t.Fatalf("TESTLIB TESTRESULT = %d, want 9", testGot) ++ } ++ if otherGot != 42 { ++ t.Fatalf("OTHERLIB TESTRESULT = %d, want 42", otherGot) ++ } ++} ++ ++func TestListStringParameterLiteralEvaluatesToTwoItemList(t *testing.T) { ++ ++ ++ got := evalValue(t, []string{tagsLib}, map[result.DefKey]string{tagsDefKey: "{'alpha', 'beta'}"}, testLibKey) ++ ++ ++ gotSlice, err := result.ToSlice(got) ++ if err != nil { ++ t.Fatalf("result.ToSlice returned error: %v", err) ++ } ++ if len(gotSlice) != 2 { ++ t.Fatalf("list length = %d, want 2", len(gotSlice)) ++ } ++ gotStrings := []string{mustString(t, gotSlice[0]), mustString(t, gotSlice[1])} ++ wantStrings := []string{"alpha", "beta"} ++ if !reflect.DeepEqual(gotStrings, wantStrings) { ++ t.Fatalf("list values = %#v, want %#v", gotStrings, wantStrings) ++ } ++} ++ ++func TestIntervalParameterLiteralEvaluatesToClosedDateInterval(t *testing.T) { ++ ++ ++ got := evalValue(t, []string{periodLib}, map[result.DefKey]string{periodDefKey: "Interval[@2017, @2019]"}, testLibKey) ++ ++ gotInterval, err := result.ToInterval(got) ++ if err != nil { ++ t.Fatalf("result.ToInterval returned error: %v", err) ++ } ++ if !gotInterval.LowInclusive || !gotInterval.HighInclusive { ++ t.Fatalf("interval inclusivity = (%t, %t), want closed interval", gotInterval.LowInclusive, gotInterval.HighInclusive) ++ } ++ assertYearDate(t, gotInterval.Low, 2017) ++ assertYearDate(t, gotInterval.High, 2019) ++} ++ ++func TestInvalidParameterDeclarationReturnsParameterErrors(t *testing.T) { ++ ++ ++ assertParameterError(t, "define X: 4", "single literal") ++} ++ ++func TestInvalidParameterMultipleTermsReturnsParameterErrors(t *testing.T) { ++ ++ ++ assertParameterError(t, "4 15", "single literal") ++} ++ ++func TestInvalidParameterEmptyStringReturnsParameterErrors(t *testing.T) { ++ ++ ++ assertParameterError(t, "", "") ++} ++ ++func TestInvalidParameterUnresolvedInvocationReturnsParameterErrors(t *testing.T) { ++ ++ ++ assertParameterError(t, "invo", "literal") ++} ++ ++func TestReferentialTransparencyForSameLibrariesAndParameters(t *testing.T) { ++ params := map[result.DefKey]string{thresholdDefKey: "9"} ++ ++ first := evalInt(t, []string{thresholdLib}, params, testLibKey) ++ second := evalInt(t, []string{thresholdLib}, params, testLibKey) ++ ++ if first != 9 || second != 9 { ++ t.Fatalf("repeated results = (%d, %d), want (9, 9)", first, second) ++ } ++ if first != second { ++ t.Fatalf("repeated results differ: first=%d second=%d", first, second) ++ } ++} ++ ++func TestParseDoesNotMutateParameterMap(t *testing.T) { ++ params := map[result.DefKey]string{thresholdDefKey: "9", tagsDefKey: "{'alpha', 'beta'}"} ++ before := map[result.DefKey]string{thresholdDefKey: "9", tagsDefKey: "{'alpha', 'beta'}"} ++ ++ _ = evalInt(t, []string{thresholdLib}, params, testLibKey) ++ ++ if !reflect.DeepEqual(params, before) { ++ t.Fatalf("parameter map mutated: got %#v, want %#v", params, before) ++ } ++} ++ ++func TestNoGlobalStateAcrossDifferentParameterShapes(t *testing.T) { ++ params := map[result.DefKey]string{thresholdDefKey: "9"} ++ first := evalInt(t, []string{thresholdLib}, params, testLibKey) ++ ++ _ = evalValue(t, []string{tagsLib}, map[result.DefKey]string{tagsDefKey: "{'alpha', 'beta'}"}, testLibKey) ++ _ = evalValue(t, []string{periodLib}, map[result.DefKey]string{periodDefKey: "Interval[@2017, @2019]"}, testLibKey) ++ _ = evalInt(t, []string{thresholdLib}, nil, testLibKey) ++ second := evalInt(t, []string{thresholdLib}, params, testLibKey) ++ ++ if first != 9 || second != 9 { ++ t.Fatalf("results around noise calls = (%d, %d), want (9, 9)", first, second) ++ } ++} ++ ++func TestParameterParsingDoesNotWriteWorkingDirectoryFiles(t *testing.T) { ++ tmp := t.TempDir() ++ originalWD, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("os.Getwd returned error: %v", err) ++ } ++ defer func() { ++ if err := os.Chdir(originalWD); err != nil { ++ t.Fatalf("restoring working directory: %v", err) ++ } ++ }() ++ if err := os.Chdir(tmp); err != nil { ++ t.Fatalf("os.Chdir(%q) returned error: %v", tmp, err) ++ } ++ before := snapshotDir(t, tmp) ++ ++ got := evalInt(t, []string{thresholdLib}, map[result.DefKey]string{thresholdDefKey: "9"}, testLibKey) ++ after := snapshotDir(t, tmp) ++ ++ if got != 9 { ++ t.Fatalf("TESTRESULT = %d, want 9", got) ++ } ++ if !reflect.DeepEqual(after, before) { ++ t.Fatalf("working directory changed: before=%#v after=%#v", before, after) ++ } ++} ++ ++func evalValue(t *testing.T, libs []string, params map[result.DefKey]string, libKey result.LibKey) result.Value { ++ t.Helper() ++ elm, err := cql.Parse(context.Background(), libs, cql.ParseConfig{Parameters: params}) ++ if err != nil { ++ t.Fatalf("Parse returned error: %v", err) ++ } ++ resultLibs, err := elm.Eval(context.Background(), nil, cql.EvalConfig{}) ++ if err != nil { ++ t.Fatalf("Eval returned error: %v", err) ++ } ++ libResults, ok := resultLibs[libKey] ++ if !ok { ++ t.Fatalf("result library %v missing from %#v", libKey, resultLibs) ++ } ++ got, ok := libResults["TESTRESULT"] ++ if !ok { ++ t.Fatalf("TESTRESULT missing from library %v results %#v", libKey, libResults) ++ } ++ return got ++} ++ ++func evalInt(t *testing.T, libs []string, params map[result.DefKey]string, libKey result.LibKey) int32 { ++ t.Helper() ++ got, err := result.ToInt32(evalValue(t, libs, params, libKey)) ++ if err != nil { ++ t.Fatalf("result.ToInt32 returned error: %v", err) ++ } ++ return got ++} ++ ++func assertParameterError(t *testing.T, input, wantMessageSubstring string) { ++ t.Helper() ++ _, err := cql.Parse(context.Background(), []string{thresholdLib}, cql.ParseConfig{ ++ Parameters: map[result.DefKey]string{thresholdDefKey: input}, ++ }) ++ if err == nil { ++ t.Fatalf("Parse(%q) succeeded, want *parser.ParameterErrors", input) ++ } ++ var parameterErr *parser.ParameterErrors ++ if !errors.As(err, ¶meterErr) { ++ t.Fatalf("Parse(%q) error type %T, want *parser.ParameterErrors: %v", input, err, err) ++ } ++ if parameterErr.DefKey != thresholdDefKey { ++ t.Fatalf("ParameterErrors.DefKey = %#v, want %#v", parameterErr.DefKey, thresholdDefKey) ++ } ++ if len(parameterErr.Errors) != 1 { ++ t.Fatalf("ParameterErrors count = %d, want 1: %#v", len(parameterErr.Errors), parameterErr.Errors) ++ } ++ got := parameterErr.Errors[0] ++ if strings.TrimSpace(got.Message) == "" { ++ t.Fatalf("ParsingError.Message is empty for input %q", input) ++ } ++ ++ if wantMessageSubstring != "" && !strings.Contains(strings.ToLower(got.Message), wantMessageSubstring) { ++ t.Fatalf("ParsingError.Message = %q, want substring %q", got.Message, wantMessageSubstring) ++ } ++} ++ ++func assertYearDate(t *testing.T, v result.Value, wantYear int) { ++ t.Helper() ++ gotDate, err := result.ToDate(v) ++ if err != nil { ++ t.Fatalf("result.ToDate returned error: %v", err) ++ } ++ got := result.DateTime(gotDate) ++ if got.Date.Year() != wantYear || got.Precision != model.YEAR { ++ t.Fatalf("date = year %d precision %q, want year %d precision %q", got.Date.Year(), got.Precision, wantYear, model.YEAR) ++ } ++} ++ ++func mustString(t *testing.T, v result.Value) string { ++ t.Helper() ++ s, err := result.ToString(v) ++ if err != nil { ++ t.Fatalf("result.ToString returned error: %v", err) ++ } ++ return s ++} ++ ++func snapshotDir(t *testing.T, root string) []string { ++ t.Helper() ++ var entries []string ++ if err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error { ++ if err != nil { ++ return err ++ } ++ if path == root { ++ return nil ++ } ++ rel, err := filepath.Rel(root, path) ++ if err != nil { ++ return err ++ } ++ if d.IsDir() { ++ entries = append(entries, rel+"/") ++ return nil ++ } ++ info, err := d.Info() ++ if err != nil { ++ return err ++ } ++ entries = append(entries, rel+":"+info.Mode().String()+":"+strconv.FormatInt(info.Size(), 10)) ++ return nil ++ }); err != nil { ++ t.Fatalf("snapshotDir(%q) returned error: %v", root, err) ++ } ++ sort.Strings(entries) ++ return entries ++} +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 GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++export GOTELEMETRY=off ++exec go test -mod=readonly -v ./usercase-test-coderl diff --git a/tasks/format-code-task-001340/tests/test.sh b/tasks/format-code-task-001340/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3eccc1d753ded28f4453d68e2dbd63a5a6783f25 --- /dev/null +++ b/tasks/format-code-task-001340/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/parameter_literals_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-001340/tests/test_command.sh b/tasks/format-code-task-001340/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001340/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-001371/environment/Dockerfile b/tasks/format-code-task-001371/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..482b3a7d94b00b7947362606247748c1cea290b0 --- /dev/null +++ b/tasks/format-code-task-001371/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:79b123782f443384910d09a3b70e15982be12a517acdff0ccfa0279de4e4ed7a diff --git a/tasks/format-code-task-001371/environment/setup/files/blocklist b/tasks/format-code-task-001371/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001371/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-001371/environment/setup/setup.sh b/tasks/format-code-task-001371/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001371/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-001371/tests/test.patch b/tasks/format-code-task-001371/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fc649b8d67a083539a5c8ff580d58d6809e9a13c --- /dev/null +++ b/tasks/format-code-task-001371/tests/test.patch @@ -0,0 +1,48 @@ +diff --git a/tests/contrib/django_util/test_django_util.py b/tests/contrib/django_util/test_django_util.py +index d708f62b9..15ac9cbd4 100644 +--- a/tests/contrib/django_util/test_django_util.py ++++ b/tests/contrib/django_util/test_django_util.py +@@ -101,6 +101,20 @@ def test_no_session_middleware(self, clientsecrets): + object.__new__(django_util.OAuth2Settings), + django.conf.settings) + ++ def test_no_middleware(self): ++ django.conf.settings.MIDDLEWARE_CLASSES = None ++ with self.assertRaises(exceptions.ImproperlyConfigured): ++ django_util.OAuth2Settings.__init__( ++ object.__new__(django_util.OAuth2Settings), ++ django.conf.settings) ++ ++ def test_middleware_no_classes(self): ++ django.conf.settings.MIDDLEWARE = ( ++ django.conf.settings.MIDDLEWARE_CLASSES) ++ django.conf.settings.MIDDLEWARE_CLASSES = None ++ ++ django_util.OAuth2Settings(django.conf.settings) ++ + def test_storage_model(self): + STORAGE_MODEL = { + 'model': 'tests.contrib.django_util.models.CredentialsModel', +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+3S70vCQBgH8L3eX/FkEvViP246B4GBoGiRGmivx+aGu5i3sZ2S0B/fbQVKVBIo ++EX0/b+52d8927PuY4ZqnkR+LjaWdiq14rluPysexnjPXYcxzPMdtaTZjHbujkXuyG+1ZlzIoiLQi ++y+R35w7t/1HmLn8Zl9JfZKtVICKzTI73jUP5t5m3y5+1Vf7tjsM0so93ha/98/zPz6yQCysMykRf ++RFQ3QRhHuh4/51kh6aE3H3UbzdF0PLDMfFv1iTp/3azWG3q8CVJqNC/rDeKCSzKMPJDJ1ed7alnP ++ea6e1F9PUzJiMsm5uWD0QjLgaoHp/bveZDj1Z4P5/HYynPnjaf/xftCtLlaai0zIgodm9BSIZeav ++JU/NMpaSi2VJ+VYmmWiRsaqm6jzVRdZ7kbVX9Nbs+2/Jt2Rs9N+OAwAAAAAAAAAAAAAAAAAAAADg ++R14BoPLJLQAoAAA= +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-001371/tests/test.sh b/tasks/format-code-task-001371/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..364b44f9b484c433af60e8241aee682dfe89be94 --- /dev/null +++ b/tasks/format-code-task-001371/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/contrib/django_util/test_django_util.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-001371/tests/test_command.sh b/tasks/format-code-task-001371/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001371/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-001406/environment/Dockerfile b/tasks/format-code-task-001406/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..27987c242ef33ff746a61bbda7924c6407b5d375 --- /dev/null +++ b/tasks/format-code-task-001406/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:b1bb7b4e031804917dfa4bd3dac3396001d6042048a219443f07054dd7647058 diff --git a/tasks/format-code-task-001406/environment/setup/files/blocklist b/tasks/format-code-task-001406/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001406/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-001406/environment/setup/setup.sh b/tasks/format-code-task-001406/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001406/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-001406/tests/test.patch b/tasks/format-code-task-001406/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..44ec05e1ac15943502ff51dfad910d0ce89880ed --- /dev/null +++ b/tasks/format-code-task-001406/tests/test.patch @@ -0,0 +1,212 @@ +diff --git a/tests/unit/engines/rag/test_provenance_normalization.py b/tests/unit/engines/rag/test_provenance_normalization.py +new file mode 100644 +index 00000000..036db7f7 +--- /dev/null ++++ b/tests/unit/engines/rag/test_provenance_normalization.py +@@ -0,0 +1,196 @@ ++from collections.abc import Sequence ++ ++import pytest ++from attrs import define, field ++ ++from griptape.artifacts import BaseArtifact, ListArtifact, TextArtifact ++from griptape.chunkers import MarkdownChunker, TextChunker ++from griptape.common import Reference ++from griptape.drivers import LocalVectorStoreDriver ++from griptape.engines.rag import RagContext ++from griptape.engines.rag.modules import ( ++ BaseRagModule, ++ BaseRetrievalRagModule, ++ FootnotePromptResponseRagModule, ++ TextLoaderRetrievalRagModule, ++) ++from griptape.engines.rag.stages import RetrievalRagStage ++from tests.mocks.mock_embedding_driver import MockEmbeddingDriver ++from tests.mocks.mock_tokenizer import MockTokenizer ++ ++ ++@define(kw_only=True) ++class _FixedRetrievalModule(BaseRetrievalRagModule): ++ artifacts: list[BaseArtifact] = field() ++ ++ def run(self, context: RagContext) -> Sequence[BaseArtifact]: ++ return self.artifacts ++ ++ ++@define(kw_only=True) ++class _FixedRerankModule(BaseRagModule): ++ artifacts: list[BaseArtifact] = field() ++ ++ def run(self, context: RagContext) -> Sequence[BaseArtifact]: ++ return self.artifacts ++ ++ ++class _FixedLoader: ++ def __init__(self, artifact: TextArtifact): ++ self.artifact = artifact ++ ++ def load(self, source: object) -> TextArtifact: ++ return self.artifact ++ ++ ++def _chunker(max_tokens: int = 8, chunker_type: type[TextChunker] = TextChunker) -> TextChunker: ++ return chunker_type(tokenizer=MockTokenizer(model="codespec-test"), max_tokens=max_tokens) ++ ++ ++@pytest.mark.parametrize("chunker_type", [TextChunker, MarkdownChunker]) ++def test_text_artifact_chunks_keep_independent_source_provenance(chunker_type): ++ reference = Reference(title="Operations manual", source="internal", year="2024") ++ source = TextArtifact( ++ "alpha beta gamma", ++ reference=reference, ++ meta={"location": {"page": 7}}, ++ name="operations-manual", ++ encoding="ascii", ++ encoding_error_handler="ignore", ++ ) ++ ++ chunks = _chunker(chunker_type=chunker_type).chunk(source) ++ ++ assert len(chunks) == 3 ++ assert [chunk.reference for chunk in chunks] == [reference, reference, reference] ++ assert [chunk.name for chunk in chunks] == ["operations-manual"] * 3 ++ assert [chunk.encoding for chunk in chunks] == ["ascii"] * 3 ++ assert [chunk.encoding_error_handler for chunk in chunks] == ["ignore"] * 3 ++ assert [chunk.meta for chunk in chunks] == [{"location": {"page": 7}}] * 3 ++ ++ chunks[0].meta["location"]["page"] = 99 ++ ++ assert source.meta == {"location": {"page": 7}} ++ assert chunks[1].meta == {"location": {"page": 7}} ++ assert chunks[2].meta == {"location": {"page": 7}} ++ assert len({chunk.id for chunk in chunks}) == len(chunks) ++ ++ ++def test_plain_and_combined_chunk_inputs_do_not_invent_source_provenance(): ++ chunker = _chunker() ++ ++ plain_chunks = chunker.chunk("alpha beta gamma") ++ combined_chunks = chunker.chunk(ListArtifact([TextArtifact("alpha"), TextArtifact(" beta gamma")])) ++ ++ assert all(chunk.reference is None and chunk.meta == {} for chunk in plain_chunks) ++ assert all(chunk.reference is None and chunk.meta == {} for chunk in combined_chunks) ++ ++ ++def test_loader_retrieval_round_trip_keeps_provenance_available_to_footnotes(): ++ reference = Reference(title="Runbook", authors=["Ada"], source="ops", year="2024") ++ module = TextLoaderRetrievalRagModule( ++ loader=_FixedLoader(TextArtifact("rotate the key", reference=reference, meta={"section": "keys"})), ++ chunker=_chunker(max_tokens=100), ++ vector_store_driver=LocalVectorStoreDriver(embedding_driver=MockEmbeddingDriver()), ++ source="ignored", ++ ) ++ ++ results = list(module.run(RagContext(query="key"))) ++ prompt = FootnotePromptResponseRagModule().default_system_template_generator( ++ RagContext(query="key", text_chunks=results), results ++ ) ++ ++ assert len(results) == 1 ++ assert results[0].reference == reference ++ assert results[0].meta == {"section": "keys"} ++ assert reference.id in prompt ++ assert "Runbook" in prompt ++ ++ ++def test_retrieval_stage_keeps_distinct_sources_and_uses_first_duplicate_before_reranking(): ++ first_source = Reference(title="First", id="source-a") ++ second_source = Reference(title="Second", id="source-b") ++ stage = RetrievalRagStage( ++ retrieval_modules=[ ++ _FixedRetrievalModule( ++ artifacts=[ ++ TextArtifact("same text", reference=first_source, meta={"winner": "first"}), ++ TextArtifact("same text", reference=second_source), ++ TextArtifact("same text", reference=Reference(title="Replacement", id="source-a")), ++ TextArtifact("plain text", meta={"winner": "first"}), ++ TextArtifact("plain text", meta={"winner": "last"}), ++ ] ++ ) ++ ] ++ ) ++ ++ result = stage.run(RagContext(query="same")) ++ ++ assert [(artifact.value, artifact.reference.id if artifact.reference else None) for artifact in result.text_chunks] == [ ++ ("same text", "source-a"), ++ ("same text", "source-b"), ++ ("plain text", None), ++ ] ++ assert result.text_chunks[0].meta == {"winner": "first"} ++ assert result.text_chunks[2].meta == {"winner": "first"} ++ ++ ++def test_reranked_results_are_normalized_before_zero_or_positive_limit(): ++ source_a = Reference(title="A", id="source-a") ++ source_b = Reference(title="B", id="source-b") ++ reranked = [ ++ TextArtifact("same text", reference=source_b), ++ TextArtifact("same text", reference=Reference(title="A replacement", id="source-a")), ++ TextArtifact("same text", reference=source_b, meta={"duplicate": True}), ++ TextArtifact("plain text"), ++ TextArtifact("plain text", meta={"duplicate": True}), ++ ] ++ retrieval = _FixedRetrievalModule(artifacts=[TextArtifact("seed", reference=source_a)]) ++ reranker = _FixedRerankModule(artifacts=reranked) ++ ++ limited = RetrievalRagStage(retrieval_modules=[retrieval], rerank_module=reranker, max_chunks=3).run( ++ RagContext(query="same") ++ ) ++ one = RetrievalRagStage(retrieval_modules=[retrieval], rerank_module=reranker, max_chunks=1).run( ++ RagContext(query="same") ++ ) ++ empty = RetrievalRagStage(retrieval_modules=[retrieval], rerank_module=reranker, max_chunks=0).run( ++ RagContext(query="same") ++ ) ++ ++ assert [(artifact.value, artifact.reference.id if artifact.reference else None) for artifact in limited.text_chunks] == [ ++ ("same text", "source-b"), ++ ("same text", "source-a"), ++ ("plain text", None), ++ ] ++ assert [(artifact.value, artifact.reference.id if artifact.reference else None) for artifact in one.text_chunks] == [ ++ ("same text", "source-b"), ++ ] ++ assert empty.text_chunks == [] ++ ++ ++def test_retrieval_stage_rejects_negative_max_chunks(): ++ with pytest.raises(ValueError, match="max_chunks"): ++ RetrievalRagStage(retrieval_modules=[], max_chunks=-1) ++ ++ ++def test_reference_lists_deduplicate_by_reference_id_with_first_source_winning(): ++ first = Reference(id="shared-source", title="Canonical title") ++ replacement = Reference(id="shared-source", title="Replacement title") ++ distinct = Reference(id="second-source", title="Second title") ++ context = RagContext( ++ query="test", ++ text_chunks=[ ++ TextArtifact("one", reference=first), ++ TextArtifact("two", reference=replacement), ++ TextArtifact("three", reference=distinct), ++ ], ++ ) ++ ++ references = context.get_references() ++ prompt = FootnotePromptResponseRagModule().default_system_template_generator(context, context.text_chunks) ++ ++ assert references == [first, distinct] ++ assert prompt.count("Canonical title") == 1 ++ assert "Replacement title" not in prompt ++ assert prompt.count("Second title") == 1 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++pytest -q tests/unit/engines/rag/test_provenance_normalization.py diff --git a/tasks/format-code-task-001406/tests/test.sh b/tasks/format-code-task-001406/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a6911cb62c3788dd3c7f01f8754beb2baec50772 --- /dev/null +++ b/tasks/format-code-task-001406/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/engines/rag/test_provenance_normalization.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-001406/tests/test_command.sh b/tasks/format-code-task-001406/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001406/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-001408/environment/Dockerfile b/tasks/format-code-task-001408/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8b3fe7353dba44ae369a19a42f6337cb8a6f1cc3 --- /dev/null +++ b/tasks/format-code-task-001408/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:251a3122e33b8769b04001e9f05f86ccc8bff375c8060f6cea50f0098a62bb25 diff --git a/tasks/format-code-task-001408/environment/setup/files/blocklist b/tasks/format-code-task-001408/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001408/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-001408/environment/setup/setup.sh b/tasks/format-code-task-001408/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001408/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-001408/tests/test.patch b/tasks/format-code-task-001408/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bef1e4f7202a9839060d920b8b3919b7190bd5b8 --- /dev/null +++ b/tasks/format-code-task-001408/tests/test.patch @@ -0,0 +1,127 @@ +diff --git a/src/js/components/Spinner/__tests__/Spinner-color-theme-test.js b/src/js/components/Spinner/__tests__/Spinner-color-theme-test.js +new file mode 100644 +index 000000000..ac2af12ba +--- /dev/null ++++ b/src/js/components/Spinner/__tests__/Spinner-color-theme-test.js +@@ -0,0 +1,99 @@ ++import React from 'react'; ++import { render } from '@testing-library/react'; ++import 'jest-styled-components'; ++import 'regenerator-runtime/runtime'; ++ ++import { Grommet } from '../../Grommet'; ++import { Spinner } from '..'; ++ ++ ++ ++const getSpinnerEl = (container) => container.firstChild.firstChild; ++ ++describe('Spinner color/theme border interaction', () => { ++ ++ ++ ++ test('color prop applies to top border when theme has no border config', () => { ++ const { container } = render( ++ ++ ++ , ++ ); ++ const el = getSpinnerEl(container); ++ ++ expect(el).toHaveStyleRule('border-top', 'solid 1px #6FFFB0'); ++ ++ expect(el).toHaveStyleRule('border', 'solid 1px #33333310'); ++ }); ++ ++ ++ ++ ++ test('color prop overrides theme border color (the bug fix)', () => { ++ const theme = { ++ spinner: { ++ container: { ++ border: [ ++ { side: 'all', color: 'background-contrast', size: 'small' }, ++ { side: 'top', color: 'brand', size: 'small' }, ++ ], ++ }, ++ }, ++ }; ++ const { container } = render( ++ ++ ++ , ++ ); ++ const el = getSpinnerEl(container); ++ ++ ++ expect(el).toHaveStyleRule('border-top', 'solid 2px #6FFFB0'); ++ ++ expect(el).not.toHaveStyleRule('border-top', 'solid 2px #7D4CDB'); ++ }); ++ ++ ++ ++ test('color prop does not override theme border all-side color', () => { ++ const theme = { ++ spinner: { ++ container: { ++ border: [ ++ { side: 'all', color: 'background-contrast', size: 'small' }, ++ { side: 'top', color: 'brand', size: 'small' }, ++ ], ++ }, ++ }, ++ }; ++ const { container } = render( ++ ++ ++ , ++ ); ++ const el = getSpinnerEl(container); ++ ++ expect(el).toHaveStyleRule('border', 'solid 2px #33333310'); ++ expect(el).not.toHaveStyleRule('border', 'solid 2px #6FFFB0'); ++ }); ++ ++ ++ test('theme border:false does not set border styles', () => { ++ const theme = { ++ spinner: { ++ container: { ++ border: false, ++ }, ++ }, ++ }; ++ const { container } = render( ++ ++ ++ , ++ ); ++ const el = getSpinnerEl(container); ++ ++ expect(el).not.toHaveStyleRule('border-top'); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..c95d4fbee +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest src/js/components/Spinner/__tests__/Spinner-color-theme-test.js --no-coverage"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx jest src/js/components/Spinner/__tests__/Spinner-color-theme-test.js --no-coverage ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001408/tests/test.sh b/tasks/format-code-task-001408/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..62d56a13ffdecb51d61101078f415dadee830f11 --- /dev/null +++ b/tasks/format-code-task-001408/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/js/components/Spinner/__tests__/Spinner-color-theme-test.js +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001408/tests/test_command.sh b/tasks/format-code-task-001408/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001408/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-001439/environment/Dockerfile b/tasks/format-code-task-001439/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..77911f5e9de1669caceffd5266c0b39b29cc8687 --- /dev/null +++ b/tasks/format-code-task-001439/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:6449313ec1a5877ed43a7807a8bece1620439f6a6e1ae660ec67b982cfc8c198 diff --git a/tasks/format-code-task-001439/environment/setup/files/blocklist b/tasks/format-code-task-001439/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001439/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-001439/environment/setup/setup.sh b/tasks/format-code-task-001439/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001439/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-001439/tests/test.patch b/tasks/format-code-task-001439/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3fa78681603d72828f20d9bf123293635814c85c --- /dev/null +++ b/tasks/format-code-task-001439/tests/test.patch @@ -0,0 +1,174 @@ +diff --git a/internal/catalog/internal/controllers/nodehealth/controller_test.go b/internal/catalog/internal/controllers/nodehealth/controller_test.go +index 4219a2f1d2ca..895e55fff3ba 100644 +--- a/internal/catalog/internal/controllers/nodehealth/controller_test.go ++++ b/internal/catalog/internal/controllers/nodehealth/controller_test.go +@@ -11,8 +11,6 @@ import ( + "github.com/oklog/ulid/v2" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" +- "google.golang.org/grpc/codes" +- "google.golang.org/grpc/status" + + svctest "github.com/hashicorp/consul/agent/grpc-external/services/resource/testing" + "github.com/hashicorp/consul/internal/catalog/internal/types" +@@ -70,7 +68,7 @@ type nodeHealthControllerTestSuite struct { + resourceClient *resourcetest.Client + runtime controller.Runtime + +- ctl nodeHealthReconciler ++ ctl *controller.TestController + + nodeNoHealth *pbresource.ID + nodePassing *pbresource.ID +@@ -97,30 +95,13 @@ func (suite *nodeHealthControllerTestSuite) SetupTest() { + WithTenancies(suite.tenancies...). + Run(suite.T()) + +- suite.resourceClient = resourcetest.NewClient(client) +- suite.runtime = controller.Runtime{Client: suite.resourceClient, Logger: testutil.Logger(suite.T())} ++ suite.ctl = controller.NewTestController(NodeHealthController(), client). ++ WithLogger(testutil.Logger(suite.T())) ++ suite.runtime = suite.ctl.Runtime() ++ suite.resourceClient = resourcetest.NewClient(suite.runtime.Client) + suite.isEnterprise = versiontest.IsEnterprise() + } + +-func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthListError() { +- suite.runTestCaseWithTenancies(func(tenancy *pbresource.Tenancy) { +- // This resource id references a resource type that will not be +- // registered with the resource service. The ListByOwner call +- // should produce an InvalidArgument error. This test is meant +- // to validate how that error is handled (its propagated back +- // to the caller) +- ref := resourceID( +- &pbresource.Type{Group: "not", GroupVersion: "v1", Kind: "found"}, +- "irrelevant", +- tenancy, +- ) +- health, err := getNodeHealth(context.Background(), suite.runtime, ref) +- require.Equal(suite.T(), pbcatalog.Health_HEALTH_CRITICAL, health) +- require.Error(suite.T(), err) +- require.Equal(suite.T(), codes.InvalidArgument, status.Code(err)) +- }) +-} +- + func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthNoNode() { + suite.runTestCaseWithTenancies(func(tenancy *pbresource.Tenancy) { + // This test is meant to ensure that when the node doesn't exist +@@ -131,7 +112,7 @@ func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthNoNode() { + Partition: tenancy.Partition, + }) + ref.Uid = ulid.Make().String() +- health, err := getNodeHealth(context.Background(), suite.runtime, ref) ++ health, err := getNodeHealth(suite.runtime, ref) + + require.NoError(suite.T(), err) + require.Equal(suite.T(), pbcatalog.Health_HEALTH_PASSING, health) +@@ -141,7 +122,7 @@ func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthNoNode() { + func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthNoStatus() { + suite.runTestCaseWithTenancies(func(tenancy *pbresource.Tenancy) { + +- health, err := getNodeHealth(context.Background(), suite.runtime, suite.nodeNoHealth) ++ health, err := getNodeHealth(suite.runtime, suite.nodeNoHealth) + require.NoError(suite.T(), err) + require.Equal(suite.T(), pbcatalog.Health_HEALTH_PASSING, health) + }) +@@ -150,7 +131,7 @@ func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthNoStatus() { + func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthPassingStatus() { + suite.runTestCaseWithTenancies(func(tenancy *pbresource.Tenancy) { + +- health, err := getNodeHealth(context.Background(), suite.runtime, suite.nodePassing) ++ health, err := getNodeHealth(suite.runtime, suite.nodePassing) + require.NoError(suite.T(), err) + require.Equal(suite.T(), pbcatalog.Health_HEALTH_PASSING, health) + }) +@@ -159,7 +140,7 @@ func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthPassingStatus() { + func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthCriticalStatus() { + suite.runTestCaseWithTenancies(func(tenancy *pbresource.Tenancy) { + +- health, err := getNodeHealth(context.Background(), suite.runtime, suite.nodeCritical) ++ health, err := getNodeHealth(suite.runtime, suite.nodeCritical) + require.NoError(suite.T(), err) + require.Equal(suite.T(), pbcatalog.Health_HEALTH_CRITICAL, health) + }) +@@ -168,7 +149,7 @@ func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthCriticalStatus() { + func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthWarningStatus() { + suite.runTestCaseWithTenancies(func(tenancy *pbresource.Tenancy) { + +- health, err := getNodeHealth(context.Background(), suite.runtime, suite.nodeWarning) ++ health, err := getNodeHealth(suite.runtime, suite.nodeWarning) + require.NoError(suite.T(), err) + require.Equal(suite.T(), pbcatalog.Health_HEALTH_WARNING, health) + }) +@@ -177,7 +158,7 @@ func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthWarningStatus() { + func (suite *nodeHealthControllerTestSuite) TestGetNodeHealthMaintenanceStatus() { + suite.runTestCaseWithTenancies(func(tenancy *pbresource.Tenancy) { + +- health, err := getNodeHealth(context.Background(), suite.runtime, suite.nodeMaintenance) ++ health, err := getNodeHealth(suite.runtime, suite.nodeMaintenance) + require.NoError(suite.T(), err) + require.Equal(suite.T(), pbcatalog.Health_HEALTH_MAINTENANCE, health) + }) +@@ -187,7 +168,7 @@ func (suite *nodeHealthControllerTestSuite) TestReconcileNodeNotFound() { + suite.runTestCaseWithTenancies(func(tenancy *pbresource.Tenancy) { + // This test ensures that removed nodes are ignored. In particular we don't + // want to propagate the error and indefinitely keep re-reconciling in this case. +- err := suite.ctl.Reconcile(context.Background(), suite.runtime, controller.Request{ ++ err := suite.ctl.Reconcile(context.Background(), controller.Request{ + ID: resourceID(pbcatalog.NodeType, "not-found", &pbresource.Tenancy{ + Partition: tenancy.Partition, + }), +@@ -196,31 +177,10 @@ func (suite *nodeHealthControllerTestSuite) TestReconcileNodeNotFound() { + }) + } + +-func (suite *nodeHealthControllerTestSuite) TestReconcilePropagateReadError() { +- suite.runTestCaseWithTenancies(func(tenancy *pbresource.Tenancy) { +- // This test aims to ensure that errors other than NotFound errors coming +- // from the initial resource read get propagated. This case is very unrealistic +- // as the controller should not have given us a request ID for a resource type +- // that doesn't exist but this was the easiest way I could think of to synthesize +- // a Read error. +- ref := resourceID( +- &pbresource.Type{Group: "not", GroupVersion: "v1", Kind: "found"}, +- "irrelevant", +- tenancy, +- ) +- +- err := suite.ctl.Reconcile(context.Background(), suite.runtime, controller.Request{ +- ID: ref, +- }) +- require.Error(suite.T(), err) +- require.Equal(suite.T(), codes.InvalidArgument, status.Code(err)) +- }) +-} +- + func (suite *nodeHealthControllerTestSuite) testReconcileStatus(id *pbresource.ID, expectedStatus *pbresource.Condition) *pbresource.Resource { + suite.T().Helper() + +- err := suite.ctl.Reconcile(context.Background(), suite.runtime, controller.Request{ ++ err := suite.ctl.Reconcile(context.Background(), controller.Request{ + ID: id, + }) + require.NoError(suite.T(), err) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3RQW7DIBAFUNY5xVzABlxDVj1LRAyKLWGQYJzzx/WiiSK12SSq2v63mREgMaPf ++Hpcp+kNIZyleRa32xmx1dV+3XptOddYqq3uhtLbqTZB52UQ3lsquEImSM3/37tH9L9Ve8+dQ+TDk ++eXbJt3V83h+P8td995m/2es1/95qK0g9b4Sv/fP8B09b8Mfgd6dMHy21ckocSnJRDo5dzKebg5y4 ++5BhDqTJlH8bgIo+SmiEvid81NWdqeJpDXph0p+rupzcEAAAAAAAAAAAAAAAAAAAAAPi7LvVe7hkA ++KAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001439/tests/test.sh b/tasks/format-code-task-001439/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ccc924075096cf5ebf6c16a10b9357ced43a9ae --- /dev/null +++ b/tasks/format-code-task-001439/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' +internal/catalog/internal/controllers/nodehealth/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-001439/tests/test_command.sh b/tasks/format-code-task-001439/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001439/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-001516/environment/Dockerfile b/tasks/format-code-task-001516/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bb911d59e549e2ce0688f8956b14b74d0d50475f --- /dev/null +++ b/tasks/format-code-task-001516/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:bea921538a36a75b4c41c7ddcff80626d617a36df6a70cda17ed2e68b40b89be diff --git a/tasks/format-code-task-001516/environment/setup/files/blocklist b/tasks/format-code-task-001516/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001516/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-001516/environment/setup/setup.sh b/tasks/format-code-task-001516/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001516/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-001516/tests/test.patch b/tasks/format-code-task-001516/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b9a4fd7a08dffeba89cabe9065c8b19d00ae80f5 --- /dev/null +++ b/tasks/format-code-task-001516/tests/test.patch @@ -0,0 +1,137 @@ +diff --git a/src/helper/css/index.test.tsx b/src/helper/css/index.test.tsx +index 679f99e1..a76fe90a 100644 +--- a/src/helper/css/index.test.tsx ++++ b/src/helper/css/index.test.tsx +@@ -251,4 +251,78 @@ d.replaceWith(c.content) + ) + }) + }) ++ ++ describe('CSP nonce support', () => { ++ it('Should render CSS styles with CSP nonce', async () => { ++ const { css: cssCtx, Style: StyleCtx } = createCssContext({ id: 'nonce-ctx-1' }) ++ const headerClass = cssCtx` ++ background-color: blue; ++ ` ++ const template = ( ++ <> ++ ++

Hello!

++ ++ ) ++ expect(await toString(template)).toBe( ++ '

Hello!

' ++ ) ++ }) ++ ++ it('Should render empty Style tag with nonce when no css used', async () => { ++ const { Style: StyleCtx } = createCssContext({ id: 'nonce-ctx-2' }) ++ const template = ( ++ <> ++ ++ ++ ) ++ expect(await toString(template)).toBe('') ++ }) ++ ++ it('Should not include nonce attribute when not provided', async () => { ++ const { css: cssCtx, Style: StyleCtx } = createCssContext({ id: 'nonce-ctx-3' }) ++ const headerClass = cssCtx` ++ background-color: blue; ++ ` ++ const template = ( ++ <> ++ ++

Hello!

++ ++ ) ++ expect(await toString(template)).toBe( ++ '

Hello!

' ++ ) ++ }) ++ ++ it('Should propagate nonce to streaming ' ++ ) ++ }) ++ }) + }) +diff --git a/src/jsx/dom/css.test.tsx b/src/jsx/dom/css.test.tsx +index f7c3298f..a6057614 100644 +--- a/src/jsx/dom/css.test.tsx ++++ b/src/jsx/dom/css.test.tsx +@@ -74,6 +74,27 @@ describe('Style and css for jsx/dom', () => { + '
red
' + ) + }) ++ ++ it('
red
' ++ ) ++ }) + }) + + describe('render', () => { +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..44715530 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx vitest run src/helper/css/index.test.tsx src/jsx/dom/css.test.tsx"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx vitest run src/helper/css/index.test.tsx src/jsx/dom/css.test.tsx ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001516/tests/test.sh b/tasks/format-code-task-001516/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3ef240a500ac3f1164e85b564828e9602464e953 --- /dev/null +++ b/tasks/format-code-task-001516/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/helper/css/index.test.tsx +src/jsx/dom/css.test.tsx +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001516/tests/test_command.sh b/tasks/format-code-task-001516/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001516/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-001518/environment/Dockerfile b/tasks/format-code-task-001518/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a6d58d9a25f8a36a7ae478351e5856edb70f5fd1 --- /dev/null +++ b/tasks/format-code-task-001518/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:1d45e31c7605a08a1d460fbbb4ffa9b6f5df8a0b8ff5a1e99e9d7e2e14bfb83c diff --git a/tasks/format-code-task-001518/environment/setup/files/blocklist b/tasks/format-code-task-001518/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001518/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-001518/environment/setup/setup.sh b/tasks/format-code-task-001518/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001518/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-001518/tests/test.patch b/tasks/format-code-task-001518/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6aacbe2de05bcd97f1a03e5f753ac812626906ec --- /dev/null +++ b/tasks/format-code-task-001518/tests/test.patch @@ -0,0 +1,458 @@ +diff --git a/usercase-test-coderl/page_text_drawing.test.ts b/usercase-test-coderl/page_text_drawing.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/page_text_drawing.test.ts +@@ -0,0 +1,423 @@ ++import { ++ BlendMode, ++ PDFArray, ++ PDFDict, ++ PDFDocument, ++ PDFName, ++ PDFRawStream, ++ PDFStream, ++ StandardFonts, ++ decodePDFRawStream, ++ degrees, ++ grayscale, ++ rgb, ++} from 'src/index'; ++ ++const ascii = (bytes: Uint8Array) => Buffer.from(bytes).toString('latin1'); ++ ++const savedPdfAscii = async (pdfDoc: PDFDocument) => ++ ascii(await pdfDoc.save({ useObjectStreams: false })); ++ ++const pageContent = async (pdfDoc: PDFDocument, pageIndex = 0) => { ++ const saved = await pdfDoc.save({ useObjectStreams: false }); ++ const loaded = await PDFDocument.load(saved); ++ const page = loaded.getPages()[pageIndex]; ++ const contents = page.node.Contents(); ++ const streams: PDFStream[] = []; ++ ++ if (contents instanceof PDFArray) { ++ for (let idx = 0; idx < contents.size(); idx++) { ++ streams.push(contents.lookup(idx, PDFStream)); ++ } ++ } else if (contents instanceof PDFStream) { ++ streams.push(contents); ++ } ++ ++ return streams ++ .map((stream) => { ++ if (stream instanceof PDFRawStream) { ++ return ascii(decodePDFRawStream(stream).decode()); ++ } ++ return ascii(stream.getContents()); ++ }) ++ .join('\n---stream---\n'); ++}; ++ ++const normalizeFontNames = (content: string) => ++ content.replace(/\/GS-\d+/g, '/GS-N'); ++ ++const pageFontBaseNames = async (pdfDoc: PDFDocument, pageIndex = 0) => { ++ const saved = await pdfDoc.save({ useObjectStreams: false }); ++ const loaded = await PDFDocument.load(saved); ++ const page = loaded.getPages()[pageIndex]; ++ const fontResources = page.node ++ .Resources() ++ ?.lookupMaybe(PDFName.Font, PDFDict); ++ const fonts = new Map(); ++ ++ if (fontResources) { ++ for (const [key, value] of fontResources.entries()) { ++ const fontDict = loaded.context.lookup(value, PDFDict); ++ const baseFont = fontDict.lookupMaybe(PDFName.of('BaseFont'), PDFName); ++ if (baseFont) fonts.set(key.asString(), baseFont.decodeText()); ++ } ++ } ++ ++ return fonts; ++}; ++ ++const numberPattern = '-?\\d+(?:\\.\\d+)?'; ++ ++const operatorMatrices = (content: string, operator: 'Tm' | 'cm') => ++ (content.match( ++ new RegExp( ++ `${numberPattern}\\s+${numberPattern}\\s+${numberPattern}\\s+${numberPattern}\\s+${numberPattern}\\s+${numberPattern}\\s+${operator}`, ++ 'g', ++ ), ++ ) || []).map((matrix) => matrix.match(new RegExp(numberPattern, 'g'))!.map(Number)); ++ ++const hasTextMatrixAt = (content: string, x: number, y: number) => ++ operatorMatrices(content, 'Tm').some( ++ ([, , , , matrixX, matrixY]) => matrixX === x && matrixY === y, ++ ) || ++ operatorMatrices(content, 'cm').some( ++ ([, , , , matrixX, matrixY]) => matrixX === x && matrixY === y, ++ ); ++ ++const hasNonIdentityTransformAt = (content: string, x: number, y: number) => ++ operatorMatrices(content, 'Tm').some( ++ ([a, b, c, d, matrixX, matrixY]) => ++ matrixX === x && ++ matrixY === y && ++ !(a === 1 && b === 0 && c === 0 && d === 1), ++ ) || ++ operatorMatrices(content, 'cm').some( ++ ([a, b, c, d]) => !(a === 1 && b === 0 && c === 0 && d === 1), ++ ); ++ ++const hasLineHeightEffect = ( ++ content: string, ++ lineHeight: number, ++ x?: number, ++ y?: number, ++) => ++ content.includes(`${lineHeight} TL`) || ++ content.includes(`0 -${lineHeight} Td`) || ++ content.includes(`0 -${lineHeight} TD`) || ++ (x !== undefined && y !== undefined ++ ? hasTextMatrixAt(content, x, y - lineHeight) ++ : false); ++ ++const fontKeysAtSize = (content: string, size: number) => { ++ const keys: string[] = []; ++ const pattern = new RegExp(`(/\\S+)\\s+${size}\\s+Tf`, 'g'); ++ let match: RegExpExecArray | null; ++ while ((match = pattern.exec(content))) keys.push(match[1]); ++ return keys; ++}; ++ ++const expectFontAndSize = async ( ++ pdfDoc: PDFDocument, ++ content: string, ++ baseFont: string, ++ size: number, ++ pageIndex = 0, ++) => { ++ const fonts = await pageFontBaseNames(pdfDoc, pageIndex); ++ const usesExpectedFont = fontKeysAtSize(content, size).some( ++ (key) => fonts.get(key) === baseFont, ++ ); ++ expect(usesExpectedFont).toBe(true); ++}; ++ ++const expectTextInOrder = (content: string, hexLines: string[]) => { ++ let previousIndex = -1; ++ for (const hexLine of hexLines) { ++ const nextIndex = content.indexOf(`<${hexLine}>`, previousIndex + 1); ++ expect(nextIndex).toBeGreaterThan(previousIndex); ++ previousIndex = nextIndex; ++ } ++}; ++ ++const shownHexPayload = (content: string) => ++ (content.match(/<[0-9A-Fa-f]+>/g) || []).join(''); ++ ++const countOccurrences = (content: string, needle: string) => ++ content.split(needle).length - 1; ++ ++describe('usercase page-level text drawing and defaults', () => { ++ it('draws explicit positioned text with the implicit Helvetica page font', async () => { ++ ++ ++ ++ ++ const pdfDoc = await PDFDocument.create(); ++ const page = pdfDoc.addPage([300, 800]); ++ ++ page.drawText('Hello', { x: 40, y: 700, size: 18 }); ++ ++ const content = normalizeFontNames(await pageContent(pdfDoc)); ++ ++ await expectFontAndSize(pdfDoc, content, 'Helvetica', 18); ++ expect(hasTextMatrixAt(content, 40, 700)).toBe(true); ++ expectTextInOrder(content, ['48656C6C6F']); ++ }); ++ ++ it('uses current position, default font size, and default line height for later multiline text', async () => { ++ ++ ++ ++ ++ const pdfDoc = await PDFDocument.create(); ++ const page = pdfDoc.addPage([300, 800]); ++ ++ page.moveTo(50, 600); ++ page.setFontSize(12); ++ page.setLineHeight(20); ++ page.drawText('A\nB'); ++ ++ const content = normalizeFontNames(await pageContent(pdfDoc)); ++ ++ await expectFontAndSize(pdfDoc, content, 'Helvetica', 12); ++ expect(hasTextMatrixAt(content, 50, 600)).toBe(true); ++ expect(hasLineHeightEffect(content, 20, 50, 600)).toBe(true); ++ expectTextInOrder(content, ['41', '42']); ++ }); ++ ++ it('lets defaults evolve across calls while explicit options override only one draw', async () => { ++ ++ ++ ++ ++ const pdfDoc = await PDFDocument.create(); ++ const page = pdfDoc.addPage([300, 800]); ++ const times = await pdfDoc.embedFont(StandardFonts.TimesRoman); ++ const courier = await pdfDoc.embedFont(StandardFonts.Courier); ++ ++ page.setFont(times); ++ page.setFontSize(11); ++ page.setFontColor(rgb(1, 0, 0)); ++ page.setLineHeight(13); ++ page.drawText('Default', { x: 10, y: 700 }); ++ page.drawText('Override', { ++ x: 20, ++ y: 650, ++ font: courier, ++ size: 17, ++ color: grayscale(0.5), ++ lineHeight: 19, ++ }); ++ page.drawText('Again', { x: 30, y: 600 }); ++ ++ const content = normalizeFontNames(await pageContent(pdfDoc)); ++ ++ expect(content).toContain('1 0 0 rg'); ++ expect(content).toContain('0.5 g'); ++ await expectFontAndSize(pdfDoc, content, 'Times-Roman', 11); ++ await expectFontAndSize(pdfDoc, content, 'Courier', 17); ++ expect(hasTextMatrixAt(content, 10, 700)).toBe(true); ++ expect(hasTextMatrixAt(content, 20, 650)).toBe(true); ++ expect(hasTextMatrixAt(content, 30, 600)).toBe(true); ++ expectTextInOrder(content, [ ++ '44656661756C74', ++ '4F76657272696465', ++ '416761696E', ++ ]); ++ }); ++ ++ it('applies opacity, blend mode, rotation, skew, max-width wrapping, and supplied word breaks', async () => { ++ ++ ++ ++ ++ const pdfDoc = await PDFDocument.create(); ++ const page = pdfDoc.addPage([300, 800]); ++ ++ page.drawText('AA|BB|CC', { ++ x: 15, ++ y: 720, ++ size: 12, ++ maxWidth: 32, ++ wordBreaks: ['|'], ++ lineHeight: 17, ++ opacity: 0.5, ++ blendMode: BlendMode.Multiply, ++ rotate: degrees(30), ++ xSkew: degrees(10), ++ ySkew: degrees(20), ++ }); ++ ++ const content = normalizeFontNames(await pageContent(pdfDoc)); ++ const saved = await savedPdfAscii(pdfDoc); ++ ++ expect(content).toContain('/GS-N gs'); ++ expect(saved).toMatch(/\/ca\s+0\.5\b/); ++ expect(saved).toMatch(/\/BM\s*\/Multiply/); ++ await expectFontAndSize(pdfDoc, content, 'Helvetica', 12); ++ expect(hasNonIdentityTransformAt(content, 15, 720)).toBe(true); ++ expect(hasLineHeightEffect(content, 17, 15, 720)).toBe(true); ++ expectTextInOrder(content, ['41417C', '42427C', '4343']); ++ }); ++ ++ it('normalizes tabs and unicode separators, removes controls, and splits newline boundaries', async () => { ++ ++ ++ ++ ++ const pdfDoc = await PDFDocument.create(); ++ const page = pdfDoc.addPage([300, 800]); ++ ++ page.drawText('A\tB\u2028C\bD\u000BE\nF\fG\rH', { ++ x: 10, ++ y: 700, ++ size: 10, ++ }); ++ ++ const content = normalizeFontNames(await pageContent(pdfDoc)); ++ ++ await expectFontAndSize(pdfDoc, content, 'Helvetica', 10); ++ expect(hasTextMatrixAt(content, 10, 700)).toBe(true); ++ expectTextInOrder(content, [ ++ '41202020204220202020434445', ++ '46', ++ '47', ++ '48', ++ ]); ++ const shownText = shownHexPayload(content); ++ expect(shownText).not.toContain('08'); ++ expect(shownText).not.toContain('0B'); ++ }); ++ ++ it('keeps page default text state independent across separate PDFPage instances', async () => { ++ ++ ++ ++ ++ const pdfDoc = await PDFDocument.create(); ++ const pageA = pdfDoc.addPage([300, 800]); ++ const pageB = pdfDoc.addPage([300, 800]); ++ const times = await pdfDoc.embedFont(StandardFonts.TimesRoman); ++ const courier = await pdfDoc.embedFont(StandardFonts.Courier); ++ ++ pageA.setFont(times); ++ pageA.setFontSize(9); ++ pageA.setFontColor(rgb(1, 0, 0)); ++ pageA.setLineHeight(14); ++ pageB.setFont(courier); ++ pageB.setFontSize(16); ++ pageB.setFontColor(rgb(0, 0, 1)); ++ pageB.setLineHeight(22); ++ pageA.drawText('PageA', { x: 10, y: 700 }); ++ pageB.drawText('PageB', { x: 20, y: 600 }); ++ ++ const contentA = normalizeFontNames(await pageContent(pdfDoc, 0)); ++ const contentB = normalizeFontNames(await pageContent(pdfDoc, 1)); ++ ++ expect(contentA).toContain('1 0 0 rg'); ++ await expectFontAndSize(pdfDoc, contentA, 'Times-Roman', 9, 0); ++ expect(hasTextMatrixAt(contentA, 10, 700)).toBe(true); ++ expectTextInOrder(contentA, ['5061676541']); ++ expect(contentA).not.toContain('<5061676542>'); ++ expect(contentB).toContain('0 0 1 rg'); ++ await expectFontAndSize(pdfDoc, contentB, 'Courier', 16, 1); ++ expect(hasTextMatrixAt(contentB, 20, 600)).toBe(true); ++ expectTextInOrder(contentB, ['5061676542']); ++ expect(contentB).not.toContain('<5061676541>'); ++ }); ++ ++ it('preserves page text drawing behavior for pages returned by getPages()', async () => { ++ ++ ++ ++ ++ const firstDoc = await PDFDocument.create(); ++ firstDoc.addPage([300, 800]); ++ const loadedDoc = await PDFDocument.load( ++ await firstDoc.save({ useObjectStreams: false }), ++ ); ++ const page = loadedDoc.getPages()[0]; ++ const courier = await loadedDoc.embedFont(StandardFonts.Courier); ++ ++ page.setFont(courier); ++ page.setFontSize(15); ++ page.setFontColor(rgb(0, 0.5, 0)); ++ page.setLineHeight(18); ++ page.drawText('Loaded', { x: 40, y: 500 }); ++ ++ const content = normalizeFontNames(await pageContent(loadedDoc)); ++ ++ expect(content).toContain('0 0.5 0 rg'); ++ await expectFontAndSize(loadedDoc, content, 'Courier', 15); ++ expect(hasTextMatrixAt(content, 40, 500)).toBe(true); ++ expectTextInOrder(content, ['4C6F61646564']); ++ }); ++ ++ it('rejects invalid drawText and default-styling inputs with specific TypeError contracts', async () => { ++ ++ ++ ++ ++ const pdfDoc = await PDFDocument.create(); ++ const page = pdfDoc.addPage([300, 800]); ++ ++ expect(() => page.drawText(123 as any)).toThrow(TypeError); ++ expect(() => page.setFont({} as any)).toThrow(TypeError); ++ expect(() => page.setFontSize('12' as any)).toThrow(TypeError); ++ expect(() => page.setFontColor('red' as any)).toThrow(TypeError); ++ expect(() => page.setLineHeight('20' as any)).toThrow(TypeError); ++ expect(() => page.drawText('Bad', { x: '40' as any })).toThrow(TypeError); ++ expect(() => page.drawText('Bad', { y: '700' as any })).toThrow(TypeError); ++ expect(() => page.drawText('Bad', { size: '18' as any })).toThrow(TypeError); ++ expect(() => page.drawText('Bad', { lineHeight: '20' as any })).toThrow( ++ TypeError, ++ ); ++ expect(() => page.drawText('Bad', { maxWidth: '50' as any })).toThrow( ++ TypeError, ++ ); ++ ++ expect(() => page.drawText('Bad', { opacity: 1.5 })).toThrow(); ++ expect(() => page.drawText('Bad', { wordBreaks: '|' as any })).toThrow( ++ TypeError, ++ ); ++ expect(() => page.drawText('Bad', { blendMode: 'Bad' as any })).toThrow( ++ TypeError, ++ ); ++ }); ++ ++ it('preserves drawn text across repeated save calls', async () => { ++ ++ ++ ++ ++ const pdfDoc = await PDFDocument.create(); ++ const page = pdfDoc.addPage([300, 800]); ++ ++ page.drawText('Stable', { x: 40, y: 700, size: 18 }); ++ ++ await pdfDoc.save({ useObjectStreams: false }); ++ await pdfDoc.save({ useObjectStreams: false }); ++ const content = normalizeFontNames(await pageContent(pdfDoc)); ++ ++ await expectFontAndSize(pdfDoc, content, 'Helvetica', 18); ++ expect(hasTextMatrixAt(content, 40, 700)).toBe(true); ++ expect(countOccurrences(content, '<537461626C65>')).toBe(1); ++ }); ++ ++ it('supports repeated create/draw/save cycles', async () => { ++ ++ ++ ++ ++ ++ for (let idx = 0; idx < 10; idx++) { ++ const pdfDoc = await PDFDocument.create(); ++ const page = pdfDoc.addPage([300, 800]); ++ page.drawText('Cycle', { x: 40, y: 700, size: 18 }); ++ await pdfDoc.save({ useObjectStreams: false }); ++ const content = normalizeFontNames(await pageContent(pdfDoc)); ++ await expectFontAndSize(pdfDoc, content, 'Helvetica', 18); ++ expect(hasTextMatrixAt(content, 40, 700)).toBe(true); ++ expectTextInOrder(content, ['4379636C65']); ++ } ++ }); ++}); +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 ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++if [ ! -x ./node_modules/.bin/jest ]; then ++ echo "Missing local Jest dependency: ./node_modules/.bin/jest" >&2 ++ exit 127 ++fi ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --expose-gc" ++exec ./node_modules/.bin/jest --config jest.json --runInBand \ ++ --roots /workspace/repo/usercase-test-coderl \ ++ --testMatch '**/*.test.ts' \ ++ /workspace/repo/usercase-test-coderl/page_text_drawing.test.ts diff --git a/tasks/format-code-task-001518/tests/test.sh b/tasks/format-code-task-001518/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d247c1fbcaf08dc7c561ccb86c2b5d4916b7c3a5 --- /dev/null +++ b/tasks/format-code-task-001518/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/page_text_drawing.test.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-001518/tests/test_command.sh b/tasks/format-code-task-001518/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001518/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-001527/environment/Dockerfile b/tasks/format-code-task-001527/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..785632971cf6bfa3248ed2a8e41de0b7e7a3dc3c --- /dev/null +++ b/tasks/format-code-task-001527/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:06c010dc88ac320d2228add8e4a34a449f71d7d963e043b6f73f4384bb39422d diff --git a/tasks/format-code-task-001527/environment/setup/files/blocklist b/tasks/format-code-task-001527/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001527/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-001527/environment/setup/setup.sh b/tasks/format-code-task-001527/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001527/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-001527/tests/test.patch b/tasks/format-code-task-001527/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f99a1fc229045c354e6806f8020f2ada6caef7bc --- /dev/null +++ b/tasks/format-code-task-001527/tests/test.patch @@ -0,0 +1,196 @@ +diff --git a/tests/test_inception_next.py b/tests/test_inception_next.py +new file mode 100644 +index 00000000..f8ffaa1f +--- /dev/null ++++ b/tests/test_inception_next.py +@@ -0,0 +1,162 @@ ++ ++ ++ ++ ++ ++ ++ ++import pytest ++import torch ++ ++import timm ++from timm import create_model, list_models ++ ++ ++VARIANTS = ['inception_next_tiny', 'inception_next_small', 'inception_next_base'] ++ ++ ++ ++EXPECTED_DIMS = { ++ 'inception_next_tiny': (96, 192, 384, 768), ++ 'inception_next_small': (96, 192, 384, 768), ++ 'inception_next_base': (128, 256, 512, 1024), ++} ++EXPECTED_REDUCTION = (4, 8, 16, 32) ++ ++ ++def test_variants_registered(): ++ listed = set(list_models('inception_next*')) ++ for name in VARIANTS: ++ assert name in listed, f'{name} not registered with timm' ++ ++ ++@pytest.mark.parametrize('name', VARIANTS) ++def test_default_forward_shape(name): ++ model = create_model(name, pretrained=False).eval() ++ x = torch.randn(2, 3, 64, 64) ++ with torch.no_grad(): ++ out = model(x) ++ assert out.shape == (2, 1000) ++ assert not torch.isnan(out).any() ++ ++ ++@pytest.mark.parametrize('name', VARIANTS) ++def test_custom_num_classes(name): ++ model = create_model(name, pretrained=False, num_classes=17).eval() ++ x = torch.randn(2, 3, 64, 64) ++ with torch.no_grad(): ++ out = model(x) ++ assert out.shape == (2, 17) ++ clf = model.get_classifier() ++ assert clf.out_features == 17 ++ ++ ++@pytest.mark.parametrize('name', VARIANTS) ++def test_forward_features_unpooled(name): ++ model = create_model(name, pretrained=False).eval() ++ x = torch.randn(2, 3, 64, 64) ++ with torch.no_grad(): ++ feat = model.forward_features(x) ++ assert feat.ndim == 4 ++ ++ assert feat.shape[2] == 2 and feat.shape[3] == 2 ++ assert feat.shape[1] == model.num_features ++ ++ ++@pytest.mark.parametrize('name', VARIANTS) ++def test_num_features_matches_published(name): ++ model = create_model(name, pretrained=False).eval() ++ assert model.num_features == EXPECTED_DIMS[name][-1] ++ ++ ++@pytest.mark.parametrize('name', VARIANTS) ++def test_reset_classifier_pooled(name): ++ model = create_model(name, pretrained=False).eval() ++ x = torch.randn(2, 3, 64, 64) ++ model.reset_classifier(0) ++ with torch.no_grad(): ++ out = model(x) ++ assert out.ndim == 2 ++ assert out.shape == (2, model.num_features) ++ ++ ++@pytest.mark.parametrize('name', VARIANTS) ++def test_reset_classifier_unpooled(name): ++ model = create_model(name, pretrained=False).eval() ++ x = torch.randn(2, 3, 64, 64) ++ model.reset_classifier(0, '') ++ with torch.no_grad(): ++ out = model(x) ++ assert out.ndim == 4 ++ assert out.shape == (2, model.num_features, 2, 2) ++ ++ ++@pytest.mark.parametrize('name', VARIANTS) ++def test_create_unpooled_no_head(name): ++ model = create_model(name, pretrained=False, num_classes=0, global_pool='').eval() ++ x = torch.randn(2, 3, 64, 64) ++ with torch.no_grad(): ++ out = model(x) ++ assert out.ndim == 4 ++ assert out.shape == (2, model.num_features, 2, 2) ++ ++ ++@pytest.mark.parametrize('name', VARIANTS) ++def test_features_only(name): ++ model = create_model(name, pretrained=False, features_only=True).eval() ++ assert model.feature_info.channels() == list(EXPECTED_DIMS[name]) ++ assert tuple(model.feature_info.reduction()) == EXPECTED_REDUCTION ++ ++ x = torch.randn(1, 3, 64, 64) ++ with torch.no_grad(): ++ outs = model(x) ++ assert len(outs) == 4 ++ for o, ch, r in zip(outs, EXPECTED_DIMS[name], EXPECTED_REDUCTION): ++ assert o.shape[0] == 1 ++ assert o.shape[1] == ch ++ assert o.shape[2] == 64 // r and o.shape[3] == 64 // r ++ assert not torch.isnan(o).any() ++ ++ ++@pytest.mark.parametrize('name', VARIANTS) ++def test_in_chans(name): ++ model = create_model(name, pretrained=False, in_chans=1).eval() ++ x = torch.randn(2, 1, 64, 64) ++ with torch.no_grad(): ++ out = model(x) ++ assert out.shape == (2, 1000) ++ ++ ++@pytest.mark.parametrize('name', VARIANTS) ++def test_default_cfg(name): ++ model = create_model(name, pretrained=False).eval() ++ cfg = model.default_cfg ++ assert cfg['num_classes'] == 1000 ++ assert cfg['input_size'] == (3, 224, 224) ++ sd = model.state_dict() ++ first_conv = cfg['first_conv'] ++ classifier = cfg['classifier'] ++ assert first_conv + '.weight' in sd ++ assert classifier + '.weight' in sd ++ ++ ++def test_variant_architecture_distinct(): ++ def nparams(name): ++ return sum(p.numel() for p in create_model(name, pretrained=False).parameters()) ++ ++ tiny = nparams('inception_next_tiny') ++ small = nparams('inception_next_small') ++ base = nparams('inception_next_base') ++ ++ assert small > tiny ++ assert base > small ++ ++ ++@pytest.mark.parametrize('name', VARIANTS) ++def test_backward(name): ++ model = create_model(name, pretrained=False, num_classes=8).train() ++ x = torch.randn(2, 3, 64, 64) ++ out = model(x) ++ out.mean().backward() ++ grads = [p.grad is not None for p in model.parameters()] ++ assert all(grads) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,23 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++PY=/testbed/.venv/bin/python ++ ++ ++"$PY" -m pytest tests/test_models.py \ ++ -k "convnext_atto and (test_model_forward or test_model_default_cfgs or test_model_forward_features)" \ ++ -p no:cacheprovider -q ++ ++ ++"$PY" -m pytest tests/test_inception_next.py -p no:cacheprovider -q diff --git a/tasks/format-code-task-001527/tests/test.sh b/tasks/format-code-task-001527/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4db4a8eb3f4d815fdb4df5bf843cb3f2d76eb221 --- /dev/null +++ b/tasks/format-code-task-001527/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_inception_next.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-001527/tests/test_command.sh b/tasks/format-code-task-001527/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001527/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-001542/environment/Dockerfile b/tasks/format-code-task-001542/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3545f02a6ef733b8f1bf8d0d18ffae33082ec598 --- /dev/null +++ b/tasks/format-code-task-001542/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:be10e29641ce37743e8e06e389674d959a66db5e5d89ce761348d8a3d583ffbb diff --git a/tasks/format-code-task-001542/environment/setup/files/blocklist b/tasks/format-code-task-001542/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001542/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-001542/environment/setup/setup.sh b/tasks/format-code-task-001542/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001542/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-001542/tests/test.patch b/tasks/format-code-task-001542/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8b58f5716a6db342da421d1f2694e1a1f55c662f --- /dev/null +++ b/tasks/format-code-task-001542/tests/test.patch @@ -0,0 +1,371 @@ +diff --git a/usercase-test-coderl/key_iterator_test.go b/usercase-test-coderl/key_iterator_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/key_iterator_test.go +@@ -0,0 +1,342 @@ ++package usercase_test_coderl ++ ++import ( ++ "fmt" ++ "testing" ++ ++ badger "github.com/dgraph-io/badger/v4" ++) ++ ++type observedItem struct { ++ Key string ++ Value string ++ Version uint64 ++} ++ ++func openDB(t *testing.T) *badger.DB { ++ t.Helper() ++ db, err := badger.Open(badger.DefaultOptions(""). ++ WithInMemory(true). ++ WithLogger(nil). ++ WithNumVersionsToKeep(5)) ++ if err != nil { ++ t.Fatalf("open badger: %v", err) ++ } ++ t.Cleanup(func() { ++ if err := db.Close(); err != nil { ++ t.Fatalf("close badger: %v", err) ++ } ++ }) ++ seedAccountKeys(t, db) ++ return db ++} ++ ++func seedAccountKeys(t *testing.T, db *badger.DB) { ++ t.Helper() ++ for _, kv := range []observedItem{ ++ {Key: "acct", Value: "v1"}, ++ {Key: "acct", Value: "v2"}, ++ {Key: "acct:meta", Value: "meta"}, ++ {Key: "other", Value: "other"}, ++ } { ++ if err := db.Update(func(txn *badger.Txn) error { ++ return txn.Set([]byte(kv.Key), []byte(kv.Value)) ++ }); err != nil { ++ t.Fatalf("seed %q: %v", kv.Key, err) ++ } ++ } ++} ++ ++func readCurrentItem(t *testing.T, it *badger.Iterator) observedItem { ++ t.Helper() ++ item := it.Item() ++ val, err := item.ValueCopy(nil) ++ if err != nil { ++ t.Fatalf("value copy: %v", err) ++ } ++ return observedItem{ ++ Key: string(item.Key()), ++ Value: string(val), ++ Version: item.Version(), ++ } ++} ++ ++func assertObservedKeyValue(t *testing.T, label string, got observedItem, wantKey, wantValue string) { ++ t.Helper() ++ if got.Key != wantKey || got.Value != wantValue { ++ t.Fatalf("%s = %#v, want key/value %q/%q", label, got, wantKey, wantValue) ++ } ++} ++ ++func assertPanicValue(t *testing.T, want any, fn func()) { ++ t.Helper() ++ defer func() { ++ got := recover() ++ if got != want { ++ t.Fatalf("panic value mismatch: got %#v, want %#v", got, want) ++ } ++ }() ++ fn() ++ t.Fatalf("expected panic value %#v", want) ++} ++ ++func assertPanics(t *testing.T, fn func()) { ++ t.Helper() ++ defer func() { ++ if recover() == nil { ++ t.Fatalf("expected panic") ++ } ++ }() ++ fn() ++} ++ ++func TestNewKeyIteratorDefaultExactKeyHistoricalSession(t *testing.T) { ++ ++ ++ db := openDB(t) ++ ++ if err := db.View(func(txn *badger.Txn) error { ++ it := txn.NewKeyIterator([]byte("acct"), badger.DefaultIteratorOptions) ++ defer it.Close() ++ ++ if it.Valid() != false { ++ t.Fatalf("fresh Valid() = %t, want false", it.Valid()) ++ } ++ ++ it.Rewind() ++ if it.Valid() != true { ++ t.Fatalf("after Rewind Valid() = %t, want true", it.Valid()) ++ } ++ ++ assertObservedKeyValue(t, "first item", readCurrentItem(t, it), "acct", "v2") ++ ++ it.Next() ++ if it.Valid() != true { ++ t.Fatalf("after first Next Valid() = %t, want true", it.Valid()) ++ } ++ ++ assertObservedKeyValue(t, "second item", readCurrentItem(t, it), "acct", "v1") ++ ++ it.Next() ++ if it.Valid() != false { ++ t.Fatalf("after second Next Valid() = %t, want false", it.Valid()) ++ } ++ return nil ++ }); err != nil { ++ t.Fatalf("view: %v", err) ++ } ++} ++ ++func TestNewKeyIteratorSeekStopsAtPrefixSharingKey(t *testing.T) { ++ ++ ++ db := openDB(t) ++ ++ if err := db.View(func(txn *badger.Txn) error { ++ it := txn.NewKeyIterator([]byte("acct"), badger.DefaultIteratorOptions) ++ defer it.Close() ++ ++ it.Seek([]byte("acct:meta")) ++ if it.Valid() != false { ++ t.Fatalf("Seek(acct:meta) Valid() = %t, want false", it.Valid()) ++ } ++ ++ it.Seek([]byte("acct")) ++ if it.Valid() != true { ++ t.Fatalf("Seek(acct) Valid() = %t, want true", it.Valid()) ++ } ++ ++ assertObservedKeyValue(t, "Seek(acct) item", readCurrentItem(t, it), "acct", "v2") ++ return nil ++ }); err != nil { ++ t.Fatalf("view: %v", err) ++ } ++} ++ ++func TestNewKeyIteratorForwardsReverseAndPrefetchOptions(t *testing.T) { ++ ++ ++ db := openDB(t) ++ ++ if err := db.View(func(txn *badger.Txn) error { ++ opt := badger.DefaultIteratorOptions ++ opt.PrefetchValues = false ++ opt.Reverse = true ++ it := txn.NewKeyIterator([]byte("acct"), opt) ++ defer it.Close() ++ ++ it.Rewind() ++ if it.Valid() != true { ++ t.Fatalf("reverse Rewind Valid() = %t, want true", it.Valid()) ++ } ++ ++ assertObservedKeyValue(t, "reverse first item", readCurrentItem(t, it), "acct", "v1") ++ ++ it.Next() ++ if it.Valid() != true { ++ t.Fatalf("reverse first Next Valid() = %t, want true", it.Valid()) ++ } ++ ++ assertObservedKeyValue(t, "reverse second item", readCurrentItem(t, it), "acct", "v2") ++ ++ it.Next() ++ if it.Valid() != false { ++ t.Fatalf("reverse exhausted Valid() = %t, want false", it.Valid()) ++ } ++ return nil ++ }); err != nil { ++ t.Fatalf("view: %v", err) ++ } ++} ++ ++func TestNewKeyIteratorForwardsSinceTsCutoff(t *testing.T) { ++ ++ ++ db := openDB(t) ++ ++ if err := db.View(func(txn *badger.Txn) error { ++ all := txn.NewKeyIterator([]byte("acct"), badger.DefaultIteratorOptions) ++ all.Rewind() ++ if all.Valid() != true { ++ t.Fatalf("baseline Rewind Valid() = %t, want true", all.Valid()) ++ } ++ ++ newest := readCurrentItem(t, all) ++ assertObservedKeyValue(t, "baseline first item", newest, "acct", "v2") ++ all.Next() ++ if all.Valid() != true { ++ t.Fatalf("baseline first Next Valid() = %t, want true", all.Valid()) ++ } ++ ++ oldest := readCurrentItem(t, all) ++ assertObservedKeyValue(t, "baseline second item", oldest, "acct", "v1") ++ all.Close() ++ ++ opt := badger.DefaultIteratorOptions ++ opt.SinceTs = oldest.Version ++ it := txn.NewKeyIterator([]byte("acct"), opt) ++ defer it.Close() ++ ++ it.Rewind() ++ if it.Valid() != true { ++ t.Fatalf("SinceTs Rewind Valid() = %t, want true", it.Valid()) ++ } ++ ++ got := readCurrentItem(t, it) ++ assertObservedKeyValue(t, "SinceTs first item", got, "acct", "v2") ++ if got.Version <= oldest.Version { ++ t.Fatalf("SinceTs first item version = %d, want > cutoff %d", got.Version, oldest.Version) ++ } ++ ++ it.Next() ++ if it.Valid() != false { ++ t.Fatalf("SinceTs exhausted Valid() = %t, want false", it.Valid()) ++ } ++ return nil ++ }); err != nil { ++ t.Fatalf("view: %v", err) ++ } ++} ++ ++func TestNewKeyIteratorPanicsWhenPrefixAlreadySet(t *testing.T) { ++ ++ ++ db := openDB(t) ++ ++ if err := db.View(func(txn *badger.Txn) error { ++ assertPanicValue(t, "opt.Prefix should be nil for NewKeyIterator.", func() { ++ opt := badger.DefaultIteratorOptions ++ opt.Prefix = []byte("acct") ++ _ = txn.NewKeyIterator([]byte("acct"), opt) ++ }) ++ return nil ++ }); err != nil { ++ t.Fatalf("view: %v", err) ++ } ++} ++ ++func TestNewKeyIteratorPanicsAfterTransactionDiscard(t *testing.T) { ++ ++ ++ db := openDB(t) ++ ++ txn := db.NewTransaction(false) ++ txn.Discard() ++ ++ assertPanics(t, func() { ++ _ = txn.NewKeyIterator([]byte("acct"), badger.DefaultIteratorOptions) ++ }) ++} ++ ++func TestNewKeyIteratorCloseIsIdempotent(t *testing.T) { ++ ++ ++ db := openDB(t) ++ ++ if err := db.View(func(txn *badger.Txn) error { ++ it := txn.NewKeyIterator([]byte("acct"), badger.DefaultIteratorOptions) ++ it.Rewind() ++ if it.Valid() != true { ++ t.Fatalf("before Close Valid() = %t, want true", it.Valid()) ++ } ++ it.Close() ++ it.Close() ++ return nil ++ }); err != nil { ++ t.Fatalf("view: %v", err) ++ } ++} ++ ++func TestNewKeyIteratorInstancesHaveIndependentCursorState(t *testing.T) { ++ ++ ++ db := openDB(t) ++ ++ if err := db.View(func(txn *badger.Txn) error { ++ a := txn.NewKeyIterator([]byte("acct"), badger.DefaultIteratorOptions) ++ defer a.Close() ++ b := txn.NewKeyIterator([]byte("acct:meta"), badger.DefaultIteratorOptions) ++ defer b.Close() ++ ++ a.Rewind() ++ b.Rewind() ++ ++ assertObservedKeyValue(t, "iterator a initial item", readCurrentItem(t, a), "acct", "v2") ++ ++ assertObservedKeyValue(t, "iterator b initial item", readCurrentItem(t, b), "acct:meta", "meta") ++ ++ a.Next() ++ ++ assertObservedKeyValue(t, "iterator a after Next", readCurrentItem(t, a), "acct", "v1") ++ ++ assertObservedKeyValue(t, "iterator b after a.Next", readCurrentItem(t, b), "acct:meta", "meta") ++ return nil ++ }); err != nil { ++ t.Fatalf("view: %v", err) ++ } ++} ++ ++func TestNewKeyIteratorRepeatedCloseReleasesTransactionIterator(t *testing.T) { ++ ++ ++ db := openDB(t) ++ ++ ++ for i := 0; i < 120; i++ { ++ if err := db.View(func(txn *badger.Txn) error { ++ it := txn.NewKeyIterator([]byte("acct"), badger.DefaultIteratorOptions) ++ it.Rewind() ++ if it.Valid() != true { ++ return fmt.Errorf("cycle %d Valid() = %t, want true", i, it.Valid()) ++ } ++ ++ if got := readCurrentItem(t, it); got.Key != "acct" || got.Value != "v2" { ++ return fmt.Errorf("cycle %d item = %#v, want key/value acct/v2", i, got) ++ } ++ it.Close() ++ return nil ++ }); err != nil { ++ t.Fatalf("cycle %d view: %v", i, err) ++ } ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++exec go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001542/tests/test.sh b/tasks/format-code-task-001542/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..463725941a3b41e46e049a36c17c1684d3e53e10 --- /dev/null +++ b/tasks/format-code-task-001542/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/key_iterator_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-001542/tests/test_command.sh b/tasks/format-code-task-001542/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001542/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-001573/environment/Dockerfile b/tasks/format-code-task-001573/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ca5a84db7e2a4d4aa101b9c4ce7f010c315137b8 --- /dev/null +++ b/tasks/format-code-task-001573/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:8d44eff7ec010f4eed1f4e419ff9bf1bcec6fddd3e845f2c513dfafa7815f172 diff --git a/tasks/format-code-task-001573/environment/setup/files/blocklist b/tasks/format-code-task-001573/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001573/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-001573/environment/setup/setup.sh b/tasks/format-code-task-001573/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001573/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-001573/tests/test.patch b/tasks/format-code-task-001573/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1b73ff595f9456597241f2860b8b0bdd69726483 --- /dev/null +++ b/tasks/format-code-task-001573/tests/test.patch @@ -0,0 +1,86 @@ +diff --git a/python/nano/test/automl/tf/test_usecases.py b/python/nano/test/automl/tf/test_usecases.py +index 3148a217ade..5da72c490dc 100644 +--- a/python/nano/test/automl/tf/test_usecases.py ++++ b/python/nano/test/automl/tf/test_usecases.py +@@ -205,5 +205,58 @@ def test_custom(self): + score = model.evaluate(x_valid, y_valid, verbose=0) + # print("The final score is on test data is", score[1]) + ++ def test_fit_without_search_with_space(self): ++ n_samples_train=self.TRAIN_TOTAL_SAMPLES ++ n_samples_test=self.TEST_TOTAL_SAMPLES ++ ++ x_train = self.x_train[:n_samples_train].reshape(n_samples_train, 784) ++ x_test = self.x_test[:n_samples_test].reshape(n_samples_test, 784) ++ y_train = self.y_train[:n_samples_train] ++ y_test = self.y_test[:n_samples_test] ++ ++ ++ inputs = Input(shape=(784,)) ++ x = Dense(units=space.Categorical(8,16), activation="linear")(inputs) ++ x = Dense(units=space.Categorical(32,64), activation="tanh")(x) ++ outputs = Dense(units=10)(x) ++ model = Model(inputs=inputs, outputs=outputs, name="mnist_model") ++ model.compile( ++ loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True), ++ optimizer=keras.optimizers.RMSprop(), ++ metrics=["accuracy"], ++ ) ++ ++ ++ with self.assertRaises(ValueError): ++ history = model.fit(x_train, y_train, ++ batch_size=128, epochs=2, validation_split=0.2) ++ ++ ++ def test_fit_without_search_without_space(self): ++ n_samples_train=self.TRAIN_TOTAL_SAMPLES ++ n_samples_test=self.TEST_TOTAL_SAMPLES ++ ++ x_train = self.x_train[:n_samples_train].reshape(n_samples_train, 784) ++ x_test = self.x_test[:n_samples_test].reshape(n_samples_test, 784) ++ y_train = self.y_train[:n_samples_train] ++ y_test = self.y_test[:n_samples_test] ++ ++ ++ inputs = Input(shape=(784,)) ++ x = Dense(units=8, activation="linear")(inputs) ++ x = Dense(units=32, activation="tanh")(x) ++ outputs = Dense(units=10)(x) ++ model = Model(inputs=inputs, outputs=outputs, name="mnist_model") ++ model.compile( ++ loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True), ++ optimizer=keras.optimizers.RMSprop(), ++ metrics=["accuracy"], ++ ) ++ ++ ++ history = model.fit(x_train, y_train, ++ batch_size=128, epochs=2, validation_split=0.2) ++ test_scores = model.evaluate(x_test, y_test, verbose=2) ++ + if __name__ == '__main__': + pytest.main([__file__]) +\ No newline at end of file +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SQUvDMBgG4J77K+IcoocmS7u0KEzwIOwievA+0jXaQpuMJi367007UBF1l00R ++3+eS9PsC+egbmndVXayU7llwKDMvE2JcvY/ruOci5lxkWcazYMZ5ytOAiINN9E5nnWwJCVpj3Hfn ++dvX/KPqWv1PWrdamaaQuqC33d8eu/JNYvOafzrnPf57GPv/Z/kb42j/P//iI5ZVmubRluC7I+Ahy ++VYTqaWNaR+6u7peLyXR5e3PN6OZ5eCb++MV0qE9C1cuaTKanY4NUunIkijbSlWef93x5+/lYm9y3 ++E3pOY+5rrjQ6IVFD/NYPQLYVpqU240RMds40NXMP21faWbWWVlk/Eol6f6nLF7YcBo4vT3j42z8V ++AAAAAAAAAAAAAAAAAAAAAOCHvABplsjxACgAAA== +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-001573/tests/test.sh b/tasks/format-code-task-001573/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3314877fdcf58c0d92cf0bef2245247e565e47cd --- /dev/null +++ b/tasks/format-code-task-001573/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +python/nano/test/automl/tf/test_usecases.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-001573/tests/test_command.sh b/tasks/format-code-task-001573/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001573/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-001574/environment/Dockerfile b/tasks/format-code-task-001574/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f231a9b8e0a98b1d27a3da893a8c818d7e236b09 --- /dev/null +++ b/tasks/format-code-task-001574/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:51c4c0c2d9bec418cb82dd50e33c793fae748c8ce11b13c39a1bcf5b8e5e7dda diff --git a/tasks/format-code-task-001574/environment/setup/files/blocklist b/tasks/format-code-task-001574/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001574/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-001574/environment/setup/setup.sh b/tasks/format-code-task-001574/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001574/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-001574/tests/test.patch b/tasks/format-code-task-001574/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3271ece50b803bc920e9c594684c1f0726079826 --- /dev/null +++ b/tasks/format-code-task-001574/tests/test.patch @@ -0,0 +1,132 @@ +diff --git a/tests/analyzers_manager/test_phishing_army.py b/tests/analyzers_manager/test_phishing_army.py +new file mode 100644 +index 00000000..28056b1b +--- /dev/null ++++ b/tests/analyzers_manager/test_phishing_army.py +@@ -0,0 +1,91 @@ ++ ++ ++ ++import os ++from unittest.mock import MagicMock, patch ++ ++from django.conf import settings ++from kombu import uuid ++ ++from api_app.analyzers_manager.classes import ObservableAnalyzer ++from api_app.analyzers_manager.models import AnalyzerConfig ++from api_app.models import Job ++from tests import CustomTestCase ++ ++ ++BLOCKLIST = b"bad.example.com\nevil.test\n91.192.100.61" ++ ++ ++def _get_phishing_army_class(): ++ ++ for subclass in ObservableAnalyzer.all_subclasses(): ++ if subclass.__name__ == "PhishingArmy": ++ return subclass ++ return None ++ ++ ++class PhishingArmyAnalyzerTestCase(CustomTestCase): ++ fixtures = [ ++ "api_app/fixtures/0001_user.json", ++ ] ++ ++ def setUp(self): ++ super().setUp() ++ ++ ++ os.makedirs(settings.MEDIA_ROOT, exist_ok=True) ++ ++ def _run_analyzer(self, observable_name, classification, content=BLOCKLIST): ++ cls = _get_phishing_army_class() ++ self.assertIsNotNone( ++ cls, ++ "an observable analyzer named 'PhishingArmy' must be available", ++ ) ++ config = AnalyzerConfig.objects.first() ++ job = Job.objects.create( ++ user=self.superuser, ++ observable_name=observable_name, ++ observable_classification=classification, ++ ) ++ analyzer = cls(config, job.pk, runtime_configuration={}, task_id=uuid()) ++ response = MagicMock() ++ response.content = content ++ response.text = content.decode() ++ response.status_code = 200 ++ response.raise_for_status = lambda: None ++ try: ++ with patch("requests.get", return_value=response): ++ return analyzer.run() ++ finally: ++ job.delete() ++ ++ def test_returns_found_flag(self): ++ result = self._run_analyzer("bad.example.com", "domain") ++ self.assertIsInstance(result, dict) ++ self.assertIn("found", result) ++ self.assertIsInstance(result["found"], bool) ++ ++ def test_domain_on_blocklist(self): ++ result = self._run_analyzer("bad.example.com", "domain") ++ self.assertTrue(result["found"]) ++ ++ def test_domain_not_on_blocklist(self): ++ result = self._run_analyzer("good.example.com", "domain") ++ self.assertFalse(result["found"]) ++ ++ def test_ip_on_blocklist(self): ++ result = self._run_analyzer("91.192.100.61", "ip") ++ self.assertTrue(result["found"]) ++ ++ def test_url_matches_on_hostname(self): ++ ++ result = self._run_analyzer("http://bad.example.com/some/path?a=1", "url") ++ self.assertTrue(result["found"]) ++ ++ def test_url_only_hostname_is_considered(self): ++ ++ ++ result = self._run_analyzer( ++ "http://good.example.com/redirect?to=bad.example.com", "url" ++ ) ++ self.assertFalse(result["found"]) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,30 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++pg_ctlcluster 16 main start >/dev/null 2>&1 || true ++for _ in $(seq 1 30); do ++ if pg_isready -q; then break; fi ++ sleep 1 ++done ++su postgres -c "psql -v ON_ERROR_STOP=1 -c \"ALTER ROLE intelowl WITH SUPERUSER CREATEDB LOGIN PASSWORD 'intelowl';\"" >/dev/null ++ ++export DB_HOST=127.0.0.1 ++export DB_PORT=5432 ++export DB_USER=intelowl ++export DB_PASSWORD=intelowl ++export DB_NAME=intel_owl_db ++ ++ ++python manage.py test tests.analyzers_manager.test_models --noinput ++ ++ ++python manage.py test tests.analyzers_manager.test_phishing_army --noinput diff --git a/tasks/format-code-task-001574/tests/test.sh b/tasks/format-code-task-001574/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5eb3fe65d485daaeb4a90911d04190e59b4d4b02 --- /dev/null +++ b/tasks/format-code-task-001574/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/analyzers_manager/test_phishing_army.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-001574/tests/test_command.sh b/tasks/format-code-task-001574/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001574/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-001580/environment/Dockerfile b/tasks/format-code-task-001580/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0b5489406dc862e6ad846e0dee544466bce9ad6d --- /dev/null +++ b/tasks/format-code-task-001580/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:d8333b50861463e74d6080aa1edd127af1a7e6bf6fce9b333e4cceff905033d3 diff --git a/tasks/format-code-task-001580/environment/setup/files/blocklist b/tasks/format-code-task-001580/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001580/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-001580/environment/setup/setup.sh b/tasks/format-code-task-001580/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001580/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-001580/tests/test.patch b/tasks/format-code-task-001580/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..958b9a2011256c632201ea7f77702f06b0347ff1 --- /dev/null +++ b/tasks/format-code-task-001580/tests/test.patch @@ -0,0 +1,54 @@ +diff --git a/message_test.go b/message_test.go +index ba2a170f8..4e8836e85 100644 +--- a/message_test.go ++++ b/message_test.go +@@ -81,6 +81,7 @@ func TestMessage_UnmarshalJSON(t *testing.T) { + data := ` + { + "version": 1, ++ "networkId": "1337133713371337", + "parent1MessageId": "f532a53545103276b46876c473846d98648ee418468bce76df4868648dd73e5d", + "parent2MessageId": "78d546b46aec4557872139a48f66bc567687e8413578a14323548732358914a2", + "payload": { +diff --git a/util_test.go b/util_test.go +index aaaff8149..6d72ba538 100644 +--- a/util_test.go ++++ b/util_test.go +@@ -269,6 +269,7 @@ func randMessage(withPayloadType uint32) (*iota.Message, []byte) { + + m := &iota.Message{} + m.Version = iota.MessageVersion ++ m.NetworkID = 1 + copy(m.Parent1[:], randBytes(iota.MessageIDLength)) + copy(m.Parent2[:], randBytes(iota.MessageIDLength)) + m.Payload = payload +@@ -278,6 +279,9 @@ func randMessage(withPayloadType uint32) (*iota.Message, []byte) { + if err := b.WriteByte(iota.MessageVersion); err != nil { + panic(err) + } ++ if err := binary.Write(&b, binary.LittleEndian, m.NetworkID); err != nil { ++ panic(err) ++ } + if _, err := b.Write(m.Parent1[:]); err != nil { + panic(err) + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3SMQvCMBCG4cz+isO9tanGTi7ubu5S26CCNtCkTv542y4WQV0UEd9nuSMJ5MKX ++eNscjuXGVueJ+pSklRnT19Z97XttUp1Ou3NzlWg9T1Il5mMTDTQ+5LWIqp0Lz8692v9R8S3/YH3Y ++FO50yqsy9vv33fEqf60H+etpm//MZJmS5H0jPPbn+Rel9MFvbTnaOelaic4SFa6pwkJLVDeVjNft ++8sp6n+/sZdAvu79j67HEo2+/AwAAAAAAAAAAAAAAAPhHVyHR6akAKAAA +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-001580/tests/test.sh b/tasks/format-code-task-001580/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d3e84d169b1b5426c8f826b8c3b8b32e261dbc8f --- /dev/null +++ b/tasks/format-code-task-001580/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' +message_test.go +util_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-001580/tests/test_command.sh b/tasks/format-code-task-001580/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001580/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-001587/environment/Dockerfile b/tasks/format-code-task-001587/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..48b3ba7554fb97ba6e664107c7707445e96581ae --- /dev/null +++ b/tasks/format-code-task-001587/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:b2be1f452f630da02b12ed08ae451dc1b9332967a6ec326fc67684eb28fcb641 diff --git a/tasks/format-code-task-001587/environment/setup/files/blocklist b/tasks/format-code-task-001587/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001587/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-001587/environment/setup/setup.sh b/tasks/format-code-task-001587/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001587/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-001587/tests/test.patch b/tasks/format-code-task-001587/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ce22736af6a3d3fe37db0ca35e5a41440f276900 --- /dev/null +++ b/tasks/format-code-task-001587/tests/test.patch @@ -0,0 +1,102 @@ +diff --git a/irrd/server/whois/tests/test_query_parser.py b/irrd/server/whois/tests/test_query_parser.py +index 32e044e..92ab3d5 100644 +--- a/irrd/server/whois/tests/test_query_parser.py ++++ b/irrd/server/whois/tests/test_query_parser.py +@@ -639,6 +639,75 @@ class TestWhoisQueryParserIRRD: + assert response.remove_auth_hashes + assert response.result == 'Invalid argument for object lookup: foo' + ++ def test_exact_key_route_v4_concatenated(self, prepare_parser): ++ mock_query_resolver, mock_dh, parser = prepare_parser ++ mock_query_resolver.key_lookup = Mock(return_value=MOCK_DATABASE_RESPONSE) ++ ++ response = parser.handle_query('!mroute,192.0.2.0/24AS65530') ++ assert response.response_type == WhoisQueryResponseType.SUCCESS ++ mock_query_resolver.key_lookup.assert_called_once_with('route', '192.0.2.0/24AS65530') ++ ++ def test_exact_key_route_legacy_dash_separator(self, prepare_parser): ++ mock_query_resolver, mock_dh, parser = prepare_parser ++ mock_query_resolver.key_lookup = Mock(return_value=MOCK_DATABASE_RESPONSE) ++ ++ response = parser.handle_query('!mroute,192.0.2.0/24-AS65530') ++ assert response.response_type == WhoisQueryResponseType.SUCCESS ++ mock_query_resolver.key_lookup.assert_called_once_with('route', '192.0.2.0/24AS65530') ++ ++ def test_exact_key_route_legacy_space_separator(self, prepare_parser): ++ mock_query_resolver, mock_dh, parser = prepare_parser ++ mock_query_resolver.key_lookup = Mock(return_value=MOCK_DATABASE_RESPONSE) ++ ++ response = parser.handle_query('!mroute,192.0.2.0/24 AS65530') ++ assert response.response_type == WhoisQueryResponseType.SUCCESS ++ mock_query_resolver.key_lookup.assert_called_once_with('route', '192.0.2.0/24AS65530') ++ ++ def test_exact_key_route_multiple_dash_separators(self, prepare_parser): ++ mock_query_resolver, mock_dh, parser = prepare_parser ++ mock_query_resolver.key_lookup = Mock(return_value=MOCK_DATABASE_RESPONSE) ++ ++ response = parser.handle_query('!mroute,192.0.2.0/24--AS65530') ++ assert response.response_type == WhoisQueryResponseType.SUCCESS ++ mock_query_resolver.key_lookup.assert_called_once_with('route', '192.0.2.0/24AS65530') ++ ++ def test_exact_key_route6_legacy_dash_separator(self, prepare_parser): ++ mock_query_resolver, mock_dh, parser = prepare_parser ++ mock_query_resolver.key_lookup = Mock(return_value=MOCK_DATABASE_RESPONSE) ++ ++ response = parser.handle_query('!mroute6,2001:DB8::/32-AS65530') ++ assert response.response_type == WhoisQueryResponseType.SUCCESS ++ mock_query_resolver.key_lookup.assert_called_once_with('route6', '2001:DB8::/32AS65530') ++ ++ def test_exact_key_route6_legacy_space_separator(self, prepare_parser): ++ mock_query_resolver, mock_dh, parser = prepare_parser ++ mock_query_resolver.key_lookup = Mock(return_value=MOCK_DATABASE_RESPONSE) ++ ++ response = parser.handle_query('!mroute6,2001:DB8::/32 AS65530') ++ assert response.response_type == WhoisQueryResponseType.SUCCESS ++ mock_query_resolver.key_lookup.assert_called_once_with('route6', '2001:DB8::/32AS65530') ++ ++ def test_exact_key_single_key_class_dash_preserved(self, prepare_parser): ++ mock_query_resolver, mock_dh, parser = prepare_parser ++ mock_query_resolver.key_lookup = Mock(return_value=MOCK_DATABASE_RESPONSE) ++ ++ ++ ++ ++ response = parser.handle_query('!mas-set,AS-FOO') ++ assert response.response_type == WhoisQueryResponseType.SUCCESS ++ mock_query_resolver.key_lookup.assert_called_once_with('as-set', 'AS-FOO') ++ ++ def test_exact_key_unknown_class_passes_through(self, prepare_parser): ++ mock_query_resolver, mock_dh, parser = prepare_parser ++ mock_query_resolver.key_lookup = Mock(return_value=[]) ++ ++ ++ ++ response = parser.handle_query('!munknown-class,SOMEKEY') ++ assert response.response_type == WhoisQueryResponseType.KEY_NOT_FOUND ++ mock_query_resolver.key_lookup.assert_called_once_with('unknown-class', 'SOMEKEY') ++ + def test_user_agent(self, prepare_parser): + mock_query_resolver, mock_dh, parser = prepare_parser + +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..c0c63a9 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest irrd/server/whois/tests/test_query_parser.py -k 'exact_key'"] ++} +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 irrd/server/whois/tests/test_query_parser.py::TestWhoisQueryParserIRRD::test_exact_key_route_v4_concatenated irrd/server/whois/tests/test_query_parser.py::TestWhoisQueryParserIRRD::test_exact_key_route_legacy_dash_separator irrd/server/whois/tests/test_query_parser.py::TestWhoisQueryParserIRRD::test_exact_key_route_legacy_space_separator irrd/server/whois/tests/test_query_parser.py::TestWhoisQueryParserIRRD::test_exact_key_route_multiple_dash_separators irrd/server/whois/tests/test_query_parser.py::TestWhoisQueryParserIRRD::test_exact_key_route6_legacy_dash_separator irrd/server/whois/tests/test_query_parser.py::TestWhoisQueryParserIRRD::test_exact_key_route6_legacy_space_separator irrd/server/whois/tests/test_query_parser.py::TestWhoisQueryParserIRRD::test_exact_key_single_key_class_dash_preserved irrd/server/whois/tests/test_query_parser.py::TestWhoisQueryParserIRRD::test_exact_key_unknown_class_passes_through ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001587/tests/test.sh b/tasks/format-code-task-001587/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ee8961816bd6b3cbc2e2d896d5bb05a715d17035 --- /dev/null +++ b/tasks/format-code-task-001587/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' +irrd/server/whois/tests/test_query_parser.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001587/tests/test_command.sh b/tasks/format-code-task-001587/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001587/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-001589/environment/Dockerfile b/tasks/format-code-task-001589/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a39de045e00c56e0d66668b5faa70e5f35c2a9c7 --- /dev/null +++ b/tasks/format-code-task-001589/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:f5c8f4ec11f91faf6c0be0394e7ab1a9ee3eb787fc60407fa9c75c09d5f2c4a6 diff --git a/tasks/format-code-task-001589/environment/setup/files/blocklist b/tasks/format-code-task-001589/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001589/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-001589/environment/setup/setup.sh b/tasks/format-code-task-001589/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001589/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-001589/tests/test.patch b/tasks/format-code-task-001589/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..818021aac71e6c31d6c13cfb1a0c687ff77f37ae --- /dev/null +++ b/tasks/format-code-task-001589/tests/test.patch @@ -0,0 +1,241 @@ +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,219 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++REPO=/workspace/repo ++VENV=${ARK_USECASE_VENV:-/opt/ark-unpacker-usecase-venv} ++ ++ ++[ -x "$VENV/bin/python" ] || fail "missing preinstalled venv at $VENV" ++ ++BIN="$VENV/bin/python $REPO/Main.py" ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++ ++run_cmd() { ++ # shellcheck disable=SC2086 ++ $BIN "$@" ++} ++ ++assert_no_crash_stderr() { ++ local path=$1 ++ ++ ! grep -Eiq 'traceback|unhandled exception' "$path" || fail "unexpected crash output in $path" ++} ++ ++assert_json_shape() { ++ local path=$1 ++ local top_key=$2 ++ local expected_count=$3 ++ "$VENV/bin/python" - "$path" "$top_key" "$expected_count" <<'PY' ++import json ++import sys ++path, top_key, expected_count = sys.argv[1], sys.argv[2], int(sys.argv[3]) ++with open(path, "rb") as f: ++ data = json.loads(f.read().decode("utf-8", "surrogateescape")) ++if list(data.keys()) != [top_key]: ++ raise SystemExit(f"top keys {list(data.keys())!r}") ++objects = data[top_key] ++if len(objects) != expected_count: ++ raise SystemExit(f"object count {len(objects)}") ++if not all(isinstance(k, str) for k in objects.keys()): ++ raise SystemExit("path id keys are not strings") ++if not all(isinstance(v, dict) and v for v in objects.values()): ++ raise SystemExit("typetree values are not non-empty objects") ++PY ++} ++ ++assert_json_matches_bundle_typetrees() { ++ local json_path=$1 ++ local top_key=$2 ++ local bundle_path=$3 ++ "$VENV/bin/python" - "$json_path" "$top_key" "$bundle_path" <<'PY' ++import json ++import sys ++ ++import UnityPy ++ ++json_path, top_key, bundle_path = sys.argv[1:4] ++ ++def serialize(value): ++ if isinstance(value, dict): ++ return {k: serialize(v) for k, v in value.items()} ++ if isinstance(value, list): ++ return [serialize(v) for v in value] ++ if isinstance(value, bytes): ++ return str(value, "utf-8", errors="surrogateescape") ++ return value ++ ++with open(json_path, "rb") as f: ++ actual = json.loads(f.read().decode("utf-8", "surrogateescape")) ++ ++with open(bundle_path, "rb") as f: ++ env = UnityPy.load(f) ++ ++objects = {} ++for obj in env.objects: ++ read_typetree = getattr(obj, "read_typetree", None) ++ if not callable(read_typetree): ++ continue ++ try: ++ tree = read_typetree() ++ except Exception: ++ continue ++ if tree: ++ objects[str(obj.path_id)] = serialize(tree) ++ ++expected = {top_key: objects} ++ ++expected = json.loads(json.dumps(expected, ensure_ascii=False)) ++if actual != expected: ++ actual_objects = actual.get(top_key, {}) if isinstance(actual, dict) else {} ++ raise SystemExit( ++ f"typetree data mismatch: top keys={list(actual) if isinstance(actual, dict) else type(actual).__name__}, " ++ f"object count={len(actual_objects) if isinstance(actual_objects, dict) else type(actual_objects).__name__}, " ++ f"expected count={len(objects)}" ++ ) ++PY ++} ++ ++ ++ ++ ++run_cmd --help >"$TMP/help.out" 2>"$TMP/help.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F_help exit $ec; want 0" ++assert_no_crash_stderr "$TMP/help.err" ++grep -Fq -- "--typetree" "$TMP/help.out" || fail "F_help missing --typetree" ++grep -Fq -- "--image" "$TMP/help.out" || fail "F_help missing --image" ++grep -Fq -- "--text" "$TMP/help.out" || fail "F_help missing --text" ++grep -Fq -- "--audio" "$TMP/help.out" || fail "F_help missing --audio" ++grep -Fq -- "--mesh" "$TMP/help.out" || fail "F_help missing --mesh" ++grep -Fq -- "-d" "$TMP/help.out" || fail "F_help missing -d" ++grep -Fq -- "-g" "$TMP/help.out" || fail "F_help missing -g" ++ ++ ++ ++ ++OUT_SINGLE="$TMP/out_single" ++run_cmd -m ab -i "$REPO/test/res/client-2.2/chararts-char_002_amiya.ab" -o "$OUT_SINGLE" --typetree -l 0 >"$TMP/single.out" 2>"$TMP/single.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F_single exit $ec; want 0" ++assert_no_crash_stderr "$TMP/single.err" ++[ "$(find "$OUT_SINGLE" -type f -printf '%P\n' | sort)" = "TT_char_002_amiya.ab.json" ] || fail "F_single file list mismatch" ++ ++assert_json_matches_bundle_typetrees "$OUT_SINGLE/TT_char_002_amiya.ab.json" "char_002_amiya.ab" "$REPO/test/res/client-2.2/chararts-char_002_amiya.ab" || fail "F_single typetree data mismatch" ++assert_json_shape "$OUT_SINGLE/TT_char_002_amiya.ab.json" "char_002_amiya.ab" 120 || fail "F_single JSON shape mismatch" ++ ++ ++ ++ ++SRC_GROUP="$TMP/src_group" ++OUT_GROUP="$TMP/out_group" ++mkdir -p "$SRC_GROUP/client-2.2" "$SRC_GROUP/client-2.4" ++cp "$REPO/test/res/client-2.2/chararts-char_002_amiya.ab" "$SRC_GROUP/client-2.2/chararts-char_002_amiya.ab" ++cp "$REPO/test/res/client-2.4/chararts-char_388_mint.ab" "$SRC_GROUP/client-2.4/chararts-char_388_mint.ab" ++run_cmd -m ab -i "$SRC_GROUP" -o "$OUT_GROUP" --typetree -g -l 0 >"$TMP/group.out" 2>"$TMP/group.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F_group exit $ec; want 0" ++assert_no_crash_stderr "$TMP/group.err" ++EXPECTED_GROUP_FILES=$(cat <<'EOF' ++client-2.2/chararts-char_002_amiya/TT_char_002_amiya.ab.json ++client-2.4/chararts-char_388_mint/TT_char_388_mint.ab.json ++EOF ++) ++[ "$(find "$OUT_GROUP" -type f -printf '%P\n' | sort)" = "$EXPECTED_GROUP_FILES" ] || fail "F_group file list mismatch" ++ ++assert_json_matches_bundle_typetrees "$OUT_GROUP/client-2.2/chararts-char_002_amiya/TT_char_002_amiya.ab.json" "char_002_amiya.ab" "$SRC_GROUP/client-2.2/chararts-char_002_amiya.ab" || fail "F_group amiya typetree data mismatch" ++assert_json_matches_bundle_typetrees "$OUT_GROUP/client-2.4/chararts-char_388_mint/TT_char_388_mint.ab.json" "char_388_mint.ab" "$SRC_GROUP/client-2.4/chararts-char_388_mint.ab" || fail "F_group mint typetree data mismatch" ++assert_json_shape "$OUT_GROUP/client-2.4/chararts-char_388_mint/TT_char_388_mint.ab.json" "char_388_mint.ab" 190 || fail "F_group mint JSON shape mismatch" ++ ++ ++ ++ ++OUT_NONE="$TMP/out_none" ++run_cmd -m ab -i "$REPO/test/res/client-2.2/chararts-char_002_amiya.ab" -o "$OUT_NONE" -l 0 >"$TMP/none.out" 2>"$TMP/none.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F_no_typetree exit $ec; want 0" ++assert_no_crash_stderr "$TMP/none.err" ++[ -z "$(find "$OUT_NONE" -type f -printf '%P\n' 2>/dev/null | sort)" ] || fail "F_no_typetree unexpectedly exported files" ++ ++ ++ ++ ++CFG_WORK="$TMP/cfg_work" ++OUT_INDENT="$TMP/out_indent" ++mkdir -p "$CFG_WORK" ++cat >"$CFG_WORK/ArkUnpackerConfig.json" <<'JSON' ++{ ++ "log_file": "ArkUnpackerLogs.log", ++ "log_level": 1, ++ "min_spare_memory_mb": 256, ++ "performance_level": 0, ++ "usm_encoding": "gbk", ++ "usm_export_video_codec": "vp9", ++ "usm_export_audio_codec": "libvorbis", ++ "usm_export_video_ext": ".mkv", ++ "usm_export_audio_ext": ".ogg", ++ "export_encoding": "utf-8", ++ "export_json_indent": 2 ++} ++JSON ++( cd "$CFG_WORK" && run_cmd -m ab -i "$REPO/test/res/client-2.2/chararts-char_002_amiya.ab" -o "$OUT_INDENT" --typetree -l 0 >"$TMP/indent.out" 2>"$TMP/indent.err" ); ec=$? ++[ "$ec" -eq 0 ] || fail "F_indent exit $ec; want 0" ++assert_no_crash_stderr "$TMP/indent.err" ++ ++assert_json_matches_bundle_typetrees "$OUT_INDENT/TT_char_002_amiya.ab.json" "char_002_amiya.ab" "$REPO/test/res/client-2.2/chararts-char_002_amiya.ab" || fail "F_indent typetree data mismatch" ++"$VENV/bin/python" - "$OUT_INDENT/TT_char_002_amiya.ab.json" <<'PY' || fail "F_indent indentation mismatch" ++import pathlib ++import sys ++b = pathlib.Path(sys.argv[1]).read_bytes() ++if b'\n "char_002_amiya.ab"' not in b: ++ raise SystemExit("missing 2-space top-level indentation") ++if b'\n "char_002_amiya.ab"' in b: ++ raise SystemExit("found default 4-space top-level indentation") ++PY ++ ++ ++ ++ ++OUT_INTER="$TMP/out_interactive" ++printf '2\n%s\n%s\nj\ny\n\n0\n' "$REPO/test/res/client-2.2/chararts-char_002_amiya.ab" "$OUT_INTER" | run_cmd -l 0 >"$TMP/inter.out" 2>"$TMP/inter.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F_interactive exit $ec; want 0" ++assert_no_crash_stderr "$TMP/inter.err" ++grep -Fq "j=Typetree JSON" "$TMP/inter.out" || fail "F_interactive prompt did not advertise typetree" ++ ++[ "$(grep -F "Typetree JSON" "$TMP/inter.out" | wc -l)" -ge 2 ] || fail "F_interactive summary did not mention typetree" ++[ "$(find "$OUT_INTER" -type f -printf '%P\n' | sort)" = "TT_char_002_amiya.ab.json" ] || fail "F_interactive file list mismatch" ++ ++assert_json_matches_bundle_typetrees "$OUT_INTER/TT_char_002_amiya.ab.json" "char_002_amiya.ab" "$REPO/test/res/client-2.2/chararts-char_002_amiya.ab" || fail "F_interactive typetree data mismatch" ++ ++ ++ ++ ++run_cmd -m ab -i "$TMP/does-not-exist" -o "$TMP/out_error" --typetree -l 0 >"$TMP/error.out" 2>"$TMP/error.err"; ec=$? ++ ++[ "$ec" -ne 0 ] || fail "F_error exit $ec; want non-zero" ++[ -s "$TMP/error.out" ] || [ -s "$TMP/error.err" ] || fail "F_error missing diagnostic" ++ ++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-001589/tests/test.sh b/tasks/format-code-task-001589/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-001589/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-001589/tests/test_command.sh b/tasks/format-code-task-001589/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001589/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-001602/environment/Dockerfile b/tasks/format-code-task-001602/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2a23f4537aa324b3c595e0cb3dd69c0ad6923bd2 --- /dev/null +++ b/tasks/format-code-task-001602/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:45fde49f4f2861ce7b5b11c8b08a561ae7a52b42763b3f013d69fe913db03c5d diff --git a/tasks/format-code-task-001602/environment/setup/files/blocklist b/tasks/format-code-task-001602/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001602/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-001602/environment/setup/setup.sh b/tasks/format-code-task-001602/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001602/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-001602/tests/test.patch b/tasks/format-code-task-001602/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..61db947efc216ad4b0ddec6b936932e32eb93e7b --- /dev/null +++ b/tasks/format-code-task-001602/tests/test.patch @@ -0,0 +1,67 @@ +diff --git a/ivy_tests/test_ivy/test_frontends/test_jax/test_nn/test_non_linear_activations.py b/ivy_tests/test_ivy/test_frontends/test_jax/test_nn/test_non_linear_activations.py +index 5c2d7545cfc16..be20daaabf52e 100644 +--- a/ivy_tests/test_ivy/test_frontends/test_jax/test_nn/test_non_linear_activations.py ++++ b/ivy_tests/test_ivy/test_frontends/test_jax/test_nn/test_non_linear_activations.py +@@ -245,7 +245,7 @@ def test_jax_hard_silu( + @handle_frontend_test( + fn_tree="jax.nn.hard_swish", + dtype_and_x=helpers.dtype_and_values( +- available_dtypes=helpers.get_dtypes("float"), ++ available_dtypes=helpers.get_dtypes("float_and_complex"), + min_value=-10, + max_value=10, + safety_factor_scale="linear", +diff --git a/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py b/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py +index 8254cc3141a04..8c47ca2f40447 100644 +--- a/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py ++++ b/ivy_tests/test_ivy/test_functional/test_nn/test_activations.py +@@ -48,15 +48,17 @@ def test_gelu( + @handle_test( + fn_tree="functional.ivy.hardswish", + dtype_and_x=helpers.dtype_and_values( +- available_dtypes=helpers.get_dtypes("float"), ++ available_dtypes=helpers.get_dtypes("float_and_complex"), + large_abs_safety_factor=8, + small_abs_safety_factor=8, + safety_factor_scale="log", + ), ++ complex_mode=st.sampled_from(["jax", "split", "magnitude"]), + ) + def test_hardswish( + *, + dtype_and_x, ++ complex_mode, + test_flags, + backend_fw, + fn_name, +@@ -70,6 +72,7 @@ def test_hardswish( + fn_name=fn_name, + on_device=on_device, + x=x[0], ++ complex_mode=complex_mode, + ) + + +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+3S3U6DMBQHcK55il55NT4nmCzRVyGldCkKLWkLG29vgWVO49zNFqP7/0LSr8M5 ++JYew7OumKrgcIu9WYucpy+bR+TrO8yRL4zRP3OPikiSPE49kN7vRid5YqgnxtFL2p7hL539U+NF/ ++y40tmGpbKqvQiOvVuNT/bJ0f+5+tp/4/5mnqkfh6VzjvzvvPKjI3vuSVb1SvGSfR9KlRWFIjNDtu ++HoKicJj+lbKWEWW2Hqjlvm5JoLcnIWLslBXc1MbvRiuUJEFL3Mydk3oYi2lilv/NLZfJtpcun5K0 ++WdZSLuOhijsxYTduNvOmoLoyu9qI8+m0kpbL6rD/Svef00oli6aWnOrvK7gX5irFUiYISsreXD4i +++7YbVy61UXrbqN3KKs1cwJ4Egwuz5bMRSluSvjwk/m93FwAAAAAAAAAAAAAAAAAAAAD+u3dwFhNu ++ACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001602/tests/test.sh b/tasks/format-code-task-001602/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..755e71f6f4524e90e98795285156ff1e261b7e85 --- /dev/null +++ b/tasks/format-code-task-001602/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' +ivy_tests/test_ivy/test_frontends/test_jax/test_nn/test_non_linear_activations.py +ivy_tests/test_ivy/test_functional/test_nn/test_activations.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-001602/tests/test_command.sh b/tasks/format-code-task-001602/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001602/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-001605/environment/Dockerfile b/tasks/format-code-task-001605/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..be342305f25fd3cc48bf8a9298b0e1d30773273b --- /dev/null +++ b/tasks/format-code-task-001605/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:0ccde4df4097ef21c7f817a2bcfa2afabd0640618a54bad05b3cdfdb797ec1a0 diff --git a/tasks/format-code-task-001605/environment/setup/files/blocklist b/tasks/format-code-task-001605/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001605/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-001605/environment/setup/setup.sh b/tasks/format-code-task-001605/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001605/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-001605/tests/test.patch b/tasks/format-code-task-001605/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..74d380da9a6cad220d5261954608c8a151570926 --- /dev/null +++ b/tasks/format-code-task-001605/tests/test.patch @@ -0,0 +1,462 @@ +diff --git a/usercase-test-coderl/mock_redirect_followthrough.test.js b/usercase-test-coderl/mock_redirect_followthrough.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/mock_redirect_followthrough.test.js +@@ -0,0 +1,428 @@ ++const QUnit = require('qunit') ++const { JSDOM } = require('jsdom') ++const jqueryFactory = require('jquery3') ++ ++const dom = new JSDOM('', { ++ url: 'http://localhost/' ++}) ++const $ = jqueryFactory(dom.window) ++ ++global.window = dom.window ++global.document = dom.window.document ++global.XMLHttpRequest = dom.window.XMLHttpRequest ++global.$ = $ ++global.jQuery = $ ++ ++const attachModuleReady = import('../src/attach.mjs').then((attach) => { ++ if (!$.mockjax) { ++ attach.init() ++ } ++}) ++ ++function resetMockjaxState() { ++ $.mockjax.clearAll() ++ $.mockjax.clearRetainedAjaxCalls() ++ $.mockjax.resetSettings(true) ++ $.mockjaxSettings.logLevel = -1 ++ $.mockjaxSettings.responseTime = 0 ++ $.mockjaxSettings.retainAjaxCalls = -1 ++ $.mockjaxSettings.throwUnmocked = false ++} ++ ++function ajaxResult(options) { ++ return new Promise((resolve) => { ++ const result = { ++ successData: null, ++ successTextStatus: null, ++ successStatus: null, ++ successResponseText: null, ++ errorTextStatus: null, ++ errorThrown: null, ++ errorStatus: null, ++ errorResponseText: null, ++ completeTextStatus: null, ++ completeStatus: null, ++ completeResponseText: null ++ } ++ ++ $.ajax({ ++ ...options, ++ success(data, textStatus, xhr) { ++ result.successData = data ++ result.successTextStatus = textStatus ++ result.successStatus = xhr.status ++ result.successResponseText = xhr.responseText ++ }, ++ error(xhr, textStatus, errorThrown) { ++ result.errorTextStatus = textStatus ++ result.errorThrown = String(errorThrown || '') ++ result.errorStatus = xhr.status ++ result.errorResponseText = xhr.responseText ++ }, ++ complete(xhr, textStatus) { ++ result.completeTextStatus = textStatus ++ result.completeStatus = xhr.status ++ result.completeResponseText = xhr.responseText ++ setTimeout(() => resolve(result), 0) ++ } ++ }) ++ }) ++} ++ ++function retainedCallByUrl(calls, url) { ++ return calls.find((call) => call.url === url) ++} ++ ++QUnit.module('usercase redirect follow-through', (hooks) => { ++ hooks.before(async () => { ++ await attachModuleReady ++ $.mockjax.getLogger().disable() ++ resetMockjaxState() ++ }) ++ ++ hooks.afterEach(() => { ++ resetMockjaxState() ++ }) ++ ++ QUnit.test('global followRedirects setting exists and validates as boolean', (assert) => { ++ ++ ++ assert.strictEqual($.mockjaxSettings.followRedirects, true) ++ ++ $.mockjaxSettings.followRedirects = 'yes' ++ let thrown = null ++ try { ++ $.mockjax.validateSettings() ++ } catch (error) { ++ thrown = error ++ } ++ ++ ++ assert.ok(thrown instanceof TypeError) ++ assert.ok(thrown && /followRedirects/.test(thrown.message)) ++ }) ++ ++ QUnit.test('GET 301 with uppercase Location follows to mocked final response', async (assert) => { ++ ++ ++ ++ assert.strictEqual(typeof $.mockjax, 'function') ++ assert.strictEqual(typeof $.ajax, 'function') ++ assert.strictEqual($.mockjaxSettings.followRedirects, true) ++ ++ $.mockjax({ ++ url: '/redirect-me', ++ method: 'GET', ++ status: 301, ++ responseHeaders: { Location: '/final' }, ++ responseText: 'original redirect' ++ }) ++ $.mockjax({ ++ url: '/final', ++ method: 'GET', ++ status: 201, ++ responseText: 'redirected' ++ }) ++ ++ const result = await ajaxResult({ url: '/redirect-me', method: 'GET' }) ++ ++ assert.strictEqual(result.successData, 'redirected') ++ assert.strictEqual(result.successStatus, 201) ++ assert.strictEqual(result.successResponseText, 'redirected') ++ assert.strictEqual(result.completeStatus, 201) ++ assert.strictEqual(result.completeResponseText, 'redirected') ++ ++ const mockedCalls = $.mockjax.mockedAjaxCalls() ++ const redirectCall = retainedCallByUrl(mockedCalls, '/redirect-me') ++ const finalCall = retainedCallByUrl(mockedCalls, '/final') ++ ++ assert.strictEqual(mockedCalls.length, 2) ++ assert.strictEqual(redirectCall && redirectCall.method, 'GET') ++ assert.strictEqual(finalCall && finalCall.method, 'GET') ++ assert.strictEqual(finalCall && finalCall.headers.Referer, '/redirect-me') ++ assert.strictEqual($.mockjax.unmockedAjaxCalls().length, 0) ++ }) ++ ++ QUnit.test('GET 302 with lowercase location follows to mocked final response', async (assert) => { ++ ++ ++ $.mockjax({ ++ url: '/old', ++ method: 'GET', ++ status: 302, ++ responseHeaders: { location: '/new' }, ++ responseText: 'old body' ++ }) ++ $.mockjax({ ++ url: '/new', ++ method: 'GET', ++ status: 202, ++ responseText: 'new body' ++ }) ++ ++ const result = await ajaxResult({ url: '/old', method: 'GET' }) ++ ++ assert.strictEqual(result.successData, 'new body') ++ assert.strictEqual(result.successStatus, 202) ++ assert.strictEqual(result.completeStatus, 202) ++ assert.strictEqual(result.completeResponseText, 'new body') ++ ++ const mockedCalls = $.mockjax.mockedAjaxCalls() ++ const oldCall = retainedCallByUrl(mockedCalls, '/old') ++ const newCall = retainedCallByUrl(mockedCalls, '/new') ++ ++ assert.strictEqual(mockedCalls.length, 2) ++ assert.strictEqual(oldCall && oldCall.method, 'GET') ++ assert.strictEqual(newCall && newCall.method, 'GET') ++ assert.strictEqual(newCall && newCall.headers.Referer, '/old') ++ assert.strictEqual($.mockjax.unmockedAjaxCalls().length, 0) ++ }) ++ ++ QUnit.test('HEAD redirect follows and supplies Referer to the target mock', async (assert) => { ++ ++ ++ $.mockjax({ ++ url: '/head-old', ++ method: 'HEAD', ++ status: 302, ++ responseHeaders: { location: '/head-new' }, ++ responseText: 'head old body' ++ }) ++ $.mockjax({ ++ url: '/head-new', ++ method: 'HEAD', ++ requestHeaders: { Referer: '/head-old' }, ++ status: 202, ++ responseText: 'head new body' ++ }) ++ ++ const result = await ajaxResult({ url: '/head-old', method: 'HEAD' }) ++ ++ assert.strictEqual(result.successStatus, 202) ++ assert.strictEqual(result.successResponseText, 'head new body') ++ assert.strictEqual(result.completeStatus, 202) ++ assert.strictEqual(result.completeResponseText, 'head new body') ++ ++ const mockedCalls = $.mockjax.mockedAjaxCalls() ++ const headOldCall = retainedCallByUrl(mockedCalls, '/head-old') ++ const headNewCall = retainedCallByUrl(mockedCalls, '/head-new') ++ ++ assert.strictEqual(mockedCalls.length, 2) ++ assert.strictEqual(headOldCall && headOldCall.method, 'HEAD') ++ assert.strictEqual(headNewCall && headNewCall.method, 'HEAD') ++ assert.strictEqual(headNewCall && headNewCall.headers.Referer, '/head-old') ++ assert.strictEqual($.mockjax.unmockedAjaxCalls().length, 0) ++ }) ++ ++ QUnit.test('unmocked redirect target falls through as the target URL', async (assert) => { ++ ++ ++ $.mockjax({ ++ url: '/to-network', ++ method: 'GET', ++ status: 301, ++ responseHeaders: { Location: '/missing-target' }, ++ responseText: 'go away' ++ }) ++ ++ const result = await ajaxResult({ url: '/to-network', method: 'GET' }) ++ ++ ++ assert.notStrictEqual(result.completeStatus, 301) ++ assert.notStrictEqual(result.completeResponseText, 'go away') ++ ++ const mockedCalls = $.mockjax.mockedAjaxCalls() ++ const toNetworkCall = retainedCallByUrl(mockedCalls, '/to-network') ++ assert.strictEqual(toNetworkCall && toNetworkCall.method, 'GET') ++ ++ const unmockedCalls = $.mockjax.unmockedAjaxCalls() ++ assert.strictEqual(unmockedCalls.length, 1) ++ assert.strictEqual(unmockedCalls[0].url, '/missing-target') ++ assert.strictEqual(unmockedCalls[0].method, 'GET') ++ assert.strictEqual(unmockedCalls[0].headers.Referer, '/to-network') ++ }) ++ ++ QUnit.test('followRedirects false returns the original redirect response', async (assert) => { ++ ++ ++ $.mockjaxSettings.followRedirects = false ++ $.mockjax({ ++ url: '/redirect-disabled', ++ method: 'GET', ++ status: 301, ++ responseHeaders: { Location: '/disabled-final' }, ++ responseText: 'stay here' ++ }) ++ $.mockjax({ ++ url: '/disabled-final', ++ method: 'GET', ++ status: 299, ++ responseText: 'should not see' ++ }) ++ ++ const result = await ajaxResult({ url: '/redirect-disabled', method: 'GET' }) ++ ++ ++ assert.strictEqual(result.completeStatus, 301) ++ assert.strictEqual(result.completeResponseText, 'stay here') ++ ++ const mockedCalls = $.mockjax.mockedAjaxCalls() ++ ++ assert.ok(retainedCallByUrl(mockedCalls, '/redirect-disabled')) ++ assert.strictEqual(retainedCallByUrl(mockedCalls, '/disabled-final'), undefined) ++ assert.strictEqual($.mockjax.unmockedAjaxCalls().length, 0) ++ }) ++ ++ QUnit.test('redirect status without Location header returns original response', async (assert) => { ++ ++ ++ $.mockjax({ ++ url: '/redirect-no-location', ++ method: 'GET', ++ status: 302, ++ responseHeaders: { 'X-Other': '/not-used' }, ++ responseText: 'no location body' ++ }) ++ $.mockjax({ ++ url: '/not-used', ++ method: 'GET', ++ status: 298, ++ responseText: 'unused' ++ }) ++ ++ const result = await ajaxResult({ url: '/redirect-no-location', method: 'GET' }) ++ ++ ++ assert.strictEqual(result.completeStatus, 302) ++ assert.strictEqual(result.completeResponseText, 'no location body') ++ ++ const mockedCalls = $.mockjax.mockedAjaxCalls() ++ ++ assert.ok(retainedCallByUrl(mockedCalls, '/redirect-no-location')) ++ assert.strictEqual(retainedCallByUrl(mockedCalls, '/not-used'), undefined) ++ assert.strictEqual($.mockjax.unmockedAjaxCalls().length, 0) ++ }) ++ ++ QUnit.test('POST redirect response is not followed', async (assert) => { ++ ++ ++ $.mockjax({ ++ url: '/redirect-post', ++ method: 'POST', ++ status: 301, ++ responseHeaders: { Location: '/post-final' }, ++ responseText: 'post original' ++ }) ++ $.mockjax({ ++ url: '/post-final', ++ method: 'POST', ++ status: 297, ++ responseText: 'post final' ++ }) ++ ++ const result = await ajaxResult({ url: '/redirect-post', method: 'POST' }) ++ ++ ++ assert.strictEqual(result.completeStatus, 301) ++ assert.strictEqual(result.completeResponseText, 'post original') ++ ++ const mockedCalls = $.mockjax.mockedAjaxCalls() ++ const redirectPostCall = retainedCallByUrl(mockedCalls, '/redirect-post') ++ ++ assert.strictEqual(redirectPostCall && redirectPostCall.method, 'POST') ++ assert.strictEqual(retainedCallByUrl(mockedCalls, '/post-final'), undefined) ++ assert.strictEqual($.mockjax.unmockedAjaxCalls().length, 0) ++ }) ++ ++ QUnit.test('registered redirect and direct handlers keep independent state', async (assert) => { ++ ++ ++ $.mockjax({ ++ url: '/alpha-redirect', ++ method: 'GET', ++ status: 301, ++ responseHeaders: { Location: '/alpha-final' }, ++ responseText: 'alpha original' ++ }) ++ $.mockjax({ ++ url: '/alpha-final', ++ method: 'GET', ++ status: 211, ++ responseText: 'alpha final' ++ }) ++ $.mockjax({ ++ url: '/beta-direct', ++ method: 'GET', ++ status: 212, ++ responseText: 'beta direct' ++ }) ++ ++ const alpha = await ajaxResult({ url: '/alpha-redirect', method: 'GET' }) ++ ++ assert.strictEqual(alpha.successData, 'alpha final') ++ assert.strictEqual(alpha.successStatus, 211) ++ ++ const beta = await ajaxResult({ url: '/beta-direct', method: 'GET' }) ++ ++ assert.strictEqual(beta.successData, 'beta direct') ++ assert.strictEqual(beta.successStatus, 212) ++ ++ assert.strictEqual(retainedCallByUrl($.mockjax.mockedAjaxCalls(), '/beta-direct').method, 'GET') ++ }) ++ ++ QUnit.test('GET 302 with uppercase Location follows to mocked final response', async (assert) => { ++ ++ $.mockjax({ ++ url: '/upper-302-old', ++ method: 'GET', ++ status: 302, ++ responseHeaders: { Location: '/upper-302-new' }, ++ responseText: 'upper 302 original' ++ }) ++ $.mockjax({ ++ url: '/upper-302-new', ++ method: 'GET', ++ status: 203, ++ responseText: 'upper 302 final' ++ }) ++ ++ const result = await ajaxResult({ url: '/upper-302-old', method: 'GET' }) ++ ++ assert.strictEqual(result.successData, 'upper 302 final') ++ assert.strictEqual(result.successStatus, 203) ++ assert.strictEqual(result.completeStatus, 203) ++ assert.strictEqual(result.completeResponseText, 'upper 302 final') ++ ++ const mockedCalls = $.mockjax.mockedAjaxCalls() ++ assert.strictEqual(mockedCalls.length, 2) ++ assert.strictEqual(retainedCallByUrl(mockedCalls, '/upper-302-new').headers.Referer, '/upper-302-old') ++ }) ++ ++ QUnit.test('GET 301 with lowercase location follows to mocked final response', async (assert) => { ++ ++ $.mockjax({ ++ url: '/lower-301-old', ++ method: 'GET', ++ status: 301, ++ responseHeaders: { location: '/lower-301-new' }, ++ responseText: 'lower 301 original' ++ }) ++ $.mockjax({ ++ url: '/lower-301-new', ++ method: 'GET', ++ status: 201, ++ responseText: 'lower 301 final' ++ }) ++ ++ const result = await ajaxResult({ url: '/lower-301-old', method: 'GET' }) ++ ++ assert.strictEqual(result.successStatus, 201) ++ assert.strictEqual(result.successResponseText, 'lower 301 final') ++ assert.strictEqual(result.completeStatus, 201) ++ assert.strictEqual(result.completeResponseText, 'lower 301 final') ++ ++ const mockedCalls = $.mockjax.mockedAjaxCalls() ++ assert.strictEqual(mockedCalls.length, 2) ++ assert.strictEqual(retainedCallByUrl(mockedCalls, '/lower-301-new').headers.Referer, '/lower-301-old') ++ }) ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,24 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export npm_config_offline=true ++export npm_config_audit=false ++export npm_config_fund=false ++export npm_config_update_notifier=false ++ ++test -x /workspace/repo/node_modules/.bin/qunit ++node -e "require.resolve('qunit'); require.resolve('jsdom'); require.resolve('jquery3')" ++ ++exec /workspace/repo/node_modules/.bin/qunit --reporter tap /workspace/repo/usercase-test-coderl/mock_redirect_followthrough.test.js diff --git a/tasks/format-code-task-001605/tests/test.sh b/tasks/format-code-task-001605/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..818ef8a9e1c913d1388d3f4fa4e7a4140300df83 --- /dev/null +++ b/tasks/format-code-task-001605/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/mock_redirect_followthrough.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-001605/tests/test_command.sh b/tasks/format-code-task-001605/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001605/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-001715/environment/Dockerfile b/tasks/format-code-task-001715/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6589c390db449b12359ee73ad7707114464e54c7 --- /dev/null +++ b/tasks/format-code-task-001715/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:65f897d01aae52342f6bde4d55157f0e2b6d256b84f4e18c38d05ad4a98d2d06 diff --git a/tasks/format-code-task-001715/environment/setup/files/blocklist b/tasks/format-code-task-001715/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001715/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-001715/environment/setup/setup.sh b/tasks/format-code-task-001715/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001715/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-001715/tests/test.patch b/tasks/format-code-task-001715/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..642aaadc91c3c7fdb0c7ffb3557a291dcedff8fd --- /dev/null +++ b/tasks/format-code-task-001715/tests/test.patch @@ -0,0 +1,52 @@ +diff --git a/ktor-utils/common/test/io/ktor/util/StringValuesTest.kt b/ktor-utils/common/test/io/ktor/util/StringValuesTest.kt +index 9118973bb93..aa61d70ad94 100644 +--- a/ktor-utils/common/test/io/ktor/util/StringValuesTest.kt ++++ b/ktor-utils/common/test/io/ktor/util/StringValuesTest.kt +@@ -116,4 +116,27 @@ class StringValuesTest { + assertFalse { map.contains("kEy1", "value2") } + assertFalse { map.contains("kEy1", "value3") } + } ++ ++ @Test ++ fun appendAllExtensions() { ++ val map = StringValues.build(true) { ++ appendAll("foo" to "bar") ++ appendAll("baz" to listOf("bar", "bor")) ++ appendAll(mapOf("rar" to listOf("boo", "too"))) ++ appendAll(mapOf("goo" to "boo", "doo" to "dah")) ++ } ++ ++ assertTrue { map.contains("foo") } ++ assertTrue { map.contains("foo", "bar") } ++ assertTrue { map.contains("baz") } ++ assertTrue { map.contains("baz", "bar") } ++ assertTrue { map.contains("baz", "bor") } ++ assertEquals(listOf("bar", "bor"), map.getAll("baz")) ++ assertTrue { map.contains("rar") } ++ assertTrue { map.contains("rar", "boo") } ++ assertTrue { map.contains("rar", "too") } ++ assertEquals(listOf("boo", "too"), map.getAll("rar")) ++ assertTrue { map.contains("goo", "boo") } ++ assertTrue { map.contains("doo", "dah") } ++ } + } +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+3R0QrCIBgFYK/3FNL9TLfZYK9RdDu2lFptE9TV6zcHUQTVTRHR+W5+4T+gclg9 ++NK0qdX+ck0/ho1zKaY7u53QWMhEi55nIBOFCyFwSKj/2ohuD85WllFhj/LPcq/2PYtf+vXa+3Jiu ++q3rF3O59d7zqXyTJpf9UpqH/bMEXhPL3PeGxP+9/o+hUfK1VxOZbW6lWn2hx8MbGg29aV+yP3WoM ++0DgOOUdnjWFhzcKaLb1t+u26agftQmwWfftHAAAAAAAAAAAAAAAAAAAAAAD/4wyTyMWOACgAAA== +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 ++# Verifier for the opensource-code dataset. Exit 0 means resolved. ++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-001715/tests/test.sh b/tasks/format-code-task-001715/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..97c275c0f6be1ca3ca370acc571798ea12edd737 --- /dev/null +++ b/tasks/format-code-task-001715/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' +ktor-utils/common/test/io/ktor/util/StringValuesTest.kt +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-001715/tests/test_command.sh b/tasks/format-code-task-001715/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001715/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-001724/environment/Dockerfile b/tasks/format-code-task-001724/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c92d96433b69f09f661177797e687f239262b5a6 --- /dev/null +++ b/tasks/format-code-task-001724/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:045a3a0e7fa34f9b235ac6e6e1e5aac6e23ea7687ec6a1d77b2ff277592e1d96 diff --git a/tasks/format-code-task-001724/environment/setup/files/blocklist b/tasks/format-code-task-001724/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001724/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-001724/environment/setup/setup.sh b/tasks/format-code-task-001724/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001724/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-001724/tests/test.sh b/tasks/format-code-task-001724/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a2d81584bc3a1d6b410682fffa272b7b2b1405b8 --- /dev/null +++ b/tasks/format-code-task-001724/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' +controlplane/kubeadm/internal/workload_cluster_coredns_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-001741/environment/Dockerfile b/tasks/format-code-task-001741/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a3dc04515a240e31083eb457a7fb6f6a757383a3 --- /dev/null +++ b/tasks/format-code-task-001741/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:91b8d62d6fc74d4e5f7cf777a5cde2d2f5712490e8a29036cba29282dd110522 diff --git a/tasks/format-code-task-001741/environment/setup/files/blocklist b/tasks/format-code-task-001741/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001741/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-001741/environment/setup/setup.sh b/tasks/format-code-task-001741/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001741/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-001741/tests/test.patch b/tasks/format-code-task-001741/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..36441d23be07bb4e424ba4c26e6cfc443f0af797 --- /dev/null +++ b/tasks/format-code-task-001741/tests/test.patch @@ -0,0 +1,230 @@ +diff --git a/pkg/validation/validate_cluster_test.go b/pkg/validation/validate_cluster_test.go +index dc909af54d..6daf11a81a 100644 +--- a/pkg/validation/validate_cluster_test.go ++++ b/pkg/validation/validate_cluster_test.go +@@ -334,6 +334,203 @@ func makePodList(pods []map[string]string) []runtime.Object { + return list + } + ++func Test_ValidateNodeWithSpotWorkerLabel(t *testing.T) { ++ ++ ++ ++ groups := make(map[string]*cloudinstances.CloudInstanceGroup) ++ groups["node-1"] = &cloudinstances.CloudInstanceGroup{ ++ MinSize: 1, ++ InstanceGroup: &kopsapi.InstanceGroup{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "node-1", ++ }, ++ Spec: kopsapi.InstanceGroupSpec{ ++ Role: kopsapi.InstanceGroupRoleNode, ++ }, ++ }, ++ Ready: []*cloudinstances.CloudInstanceGroupMember{ ++ { ++ ID: "i-00001", ++ Node: &v1.Node{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "node-1a", ++ Labels: map[string]string{ ++ "node-role.kubernetes.io/spot-worker": "true", ++ }, ++ }, ++ Status: v1.NodeStatus{ ++ Conditions: []v1.NodeCondition{ ++ {Type: "Ready", Status: v1.ConditionTrue}, ++ }, ++ }, ++ }, ++ }, ++ }, ++ } ++ ++ v, err := testValidate(t, groups, nil) ++ require.NoError(t, err) ++ ++ if !assert.Empty(t, v.Failures, "spot-worker node should not produce failures") { ++ printDebug(t, v) ++ } ++ ++ ++ if !assert.Len(t, v.Nodes, 1, "spot-worker node should be included in validation result") { ++ printDebug(t, v) ++ return ++ } ++ assert.Equal(t, "node-1a", v.Nodes[0].Name) ++ assert.Equal(t, "node", v.Nodes[0].Role, ++ "node's role should be derived from InstanceGroup spec (node), not the spot-worker label") ++} ++ ++func Test_ValidateNotReadyNodeWithSpotWorkerLabel(t *testing.T) { ++ ++ ++ ++ groups := make(map[string]*cloudinstances.CloudInstanceGroup) ++ groups["node-1"] = &cloudinstances.CloudInstanceGroup{ ++ MinSize: 1, ++ InstanceGroup: &kopsapi.InstanceGroup{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "node-1", ++ }, ++ Spec: kopsapi.InstanceGroupSpec{ ++ Role: kopsapi.InstanceGroupRoleNode, ++ }, ++ }, ++ Ready: []*cloudinstances.CloudInstanceGroupMember{ ++ { ++ ID: "i-00001", ++ Node: &v1.Node{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "node-1a", ++ Labels: map[string]string{ ++ "node-role.kubernetes.io/spot-worker": "true", ++ }, ++ }, ++ Status: v1.NodeStatus{ ++ Conditions: []v1.NodeCondition{ ++ {Type: "Ready", Status: v1.ConditionFalse}, ++ }, ++ }, ++ }, ++ }, ++ }, ++ } ++ ++ v, err := testValidate(t, groups, nil) ++ require.NoError(t, err) ++ ++ if !assert.Len(t, v.Failures, 1, "not-ready spot-worker node should produce one failure") { ++ printDebug(t, v) ++ return ++ } ++ assert.Equal(t, "Node", v.Failures[0].Kind) ++ assert.Equal(t, "node-1a", v.Failures[0].Name) ++ assert.Equal(t, "node \"node-1a\" is not ready", v.Failures[0].Message) ++ ++ if !assert.Len(t, v.Nodes, 1) { ++ printDebug(t, v) ++ return ++ } ++ assert.Equal(t, "node", v.Nodes[0].Role) ++} ++ ++func Test_ValidateMasterNodeWithMultipleRoleLabels(t *testing.T) { ++ ++ ++ ++ groups := make(map[string]*cloudinstances.CloudInstanceGroup) ++ groups["master-1"] = &cloudinstances.CloudInstanceGroup{ ++ MinSize: 1, ++ InstanceGroup: &kopsapi.InstanceGroup{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "master-1", ++ }, ++ Spec: kopsapi.InstanceGroupSpec{ ++ Role: kopsapi.InstanceGroupRoleMaster, ++ }, ++ }, ++ Ready: []*cloudinstances.CloudInstanceGroupMember{ ++ { ++ ID: "i-00001", ++ Node: &v1.Node{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "master-1a", ++ Labels: map[string]string{ ++ "node-role.kubernetes.io/master": "true", ++ }, ++ }, ++ Status: v1.NodeStatus{ ++ Conditions: []v1.NodeCondition{ ++ {Type: "Ready", Status: v1.ConditionTrue}, ++ }, ++ }, ++ }, ++ }, ++ }, ++ } ++ ++ v, err := testValidate(t, groups, nil) ++ require.NoError(t, err) ++ if !assert.Empty(t, v.Failures) { ++ printDebug(t, v) ++ } ++ if !assert.Len(t, v.Nodes, 1) { ++ printDebug(t, v) ++ return ++ } ++ assert.Equal(t, "master-1a", v.Nodes[0].Name) ++ assert.Equal(t, "master", v.Nodes[0].Role) ++} ++ ++func Test_ValidateNotReadyMasterStillFails(t *testing.T) { ++ ++ ++ ++ groups := make(map[string]*cloudinstances.CloudInstanceGroup) ++ groups["master-1"] = &cloudinstances.CloudInstanceGroup{ ++ MinSize: 1, ++ InstanceGroup: &kopsapi.InstanceGroup{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "master-1", ++ }, ++ Spec: kopsapi.InstanceGroupSpec{ ++ Role: kopsapi.InstanceGroupRoleMaster, ++ }, ++ }, ++ Ready: []*cloudinstances.CloudInstanceGroupMember{ ++ { ++ ID: "i-00001", ++ Node: &v1.Node{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "master-1a", ++ Labels: map[string]string{ ++ "node-role.kubernetes.io/master": "true", ++ }, ++ }, ++ Status: v1.NodeStatus{ ++ Conditions: []v1.NodeCondition{ ++ {Type: "Ready", Status: v1.ConditionFalse}, ++ }, ++ }, ++ }, ++ }, ++ }, ++ } ++ ++ v, err := testValidate(t, groups, nil) ++ require.NoError(t, err) ++ if !assert.Len(t, v.Failures, 1) { ++ printDebug(t, v) ++ return ++ } ++ assert.Equal(t, "master \"master-1a\" is not ready", v.Failures[0].Message) ++} ++ + func Test_ValidateBastionNodes(t *testing.T) { + groups := make(map[string]*cloudinstances.CloudInstanceGroup) + groups["ig1"] = &cloudinstances.CloudInstanceGroup{ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..2b5f0dee9a +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./pkg/validation/... -run 'Test_Validate(NodeWithSpotWorker|NotReadyNodeWithSpotWorker|MasterNodeWithMultipleRole|NotReadyMasterStillFails)' -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test ./pkg/validation/... -run 'Test_Validate(NodeWithSpotWorker|NotReadyNodeWithSpotWorker|MasterNodeWithMultipleRole|NotReadyMasterStillFails)' -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001741/tests/test.sh b/tasks/format-code-task-001741/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1a5a76043c13ba7d8af31c9ced17895a5f1fc79c --- /dev/null +++ b/tasks/format-code-task-001741/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/validation/validate_cluster_test.go +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001741/tests/test_command.sh b/tasks/format-code-task-001741/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001741/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-001746/environment/Dockerfile b/tasks/format-code-task-001746/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c343413844ae698f9ad6828354c805358e1c84f1 --- /dev/null +++ b/tasks/format-code-task-001746/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:bc2642720c188c78067ff56dd6f23be0c60c5fadc062d4e0e258e09af46a9143 diff --git a/tasks/format-code-task-001746/environment/setup/files/blocklist b/tasks/format-code-task-001746/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001746/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-001746/environment/setup/setup.sh b/tasks/format-code-task-001746/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001746/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-001746/tests/test.patch b/tasks/format-code-task-001746/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c3db63ca698bf9f4c78fcf449ebd820e3bf48bb0 --- /dev/null +++ b/tasks/format-code-task-001746/tests/test.patch @@ -0,0 +1,265 @@ +diff --git a/benchmark/pkg/metricsfetcher/runselector/schemes/last_n_hours_sparse_test.go b/benchmark/pkg/metricsfetcher/runselector/schemes/last_n_hours_sparse_test.go +new file mode 100644 +index 000000000..3d71fc59d +--- /dev/null ++++ b/benchmark/pkg/metricsfetcher/runselector/schemes/last_n_hours_sparse_test.go +@@ -0,0 +1,88 @@ ++package schemes ++ ++import ( ++ "reflect" ++ "testing" ++ "time" ++ ++ "k8s.io/perf-tests/benchmark/pkg/metricsfetcher/util" ++) ++ ++func sparseTimedUtils(builds []int, timestamps map[int]uint64, finished ...int) util.MockJobLogUtils { ++ statuses := map[int]bool{} ++ for _, run := range finished { ++ statuses[run] = true ++ } ++ return util.MockJobLogUtils{ ++ MockBuildNumbers: builds, ++ MockStartTimestamps: timestamps, ++ MockFinishedStatuses: statuses, ++ } ++} ++ ++func TestGetJobRunsFromLastNHoursUsesSparseAvailableBuildNumbers(t *testing.T) { ++ now := uint64(time.Now().Unix()) ++ utils := sparseTimedUtils( ++ []int{4, 10, 25}, ++ map[int]uint64{ ++ 25: now - 10*60, ++ 10: now - 20*60, ++ 4: now - 3*60*60, ++ }, ++ 25, 10, 4) ++ ++ runs, err := GetJobRunsFromLastNHours("sparse-job", 2, utils) ++ if err != nil { ++ t.Fatalf("GetJobRunsFromLastNHours returned error: %v", err) ++ } ++ ++ want := []int{25, 10} ++ if !reflect.DeepEqual(runs, want) { ++ t.Fatalf("GetJobRunsFromLastNHours() = %v, want %v", runs, want) ++ } ++} ++ ++func TestGetJobRunsFromLastNHoursDoesNotBackfillPastOlderAvailableBuild(t *testing.T) { ++ now := uint64(time.Now().Unix()) ++ utils := sparseTimedUtils( ++ []int{1, 50, 100}, ++ map[int]uint64{ ++ 100: now - 5*60, ++ 50: now - 3*60*60, ++ 1: now - 10*60, ++ }, ++ 100, 50, 1) ++ ++ runs, err := GetJobRunsFromLastNHours("sparse-job", 2, utils) ++ if err != nil { ++ t.Fatalf("GetJobRunsFromLastNHours returned error: %v", err) ++ } ++ ++ want := []int{100} ++ if !reflect.DeepEqual(runs, want) { ++ t.Fatalf("GetJobRunsFromLastNHours() = %v, want %v", runs, want) ++ } ++} ++ ++func TestGetJobRunsFromLastNHoursDoesNotUseLatestNumberFallback(t *testing.T) { ++ now := uint64(time.Now().Unix()) ++ utils := sparseTimedUtils( ++ []int{2, 70, 40, 60}, ++ map[int]uint64{ ++ 70: now - 5*60, ++ 60: now - 15*60, ++ 40: now - 3*60*60, ++ 2: now - 10*60, ++ }, ++ 70, 60, 40, 2) ++ ++ runs, err := GetJobRunsFromLastNHours("another-sparse-job", 2, utils) ++ if err != nil { ++ t.Fatalf("GetJobRunsFromLastNHours returned error: %v", err) ++ } ++ ++ want := []int{70, 60} ++ if !reflect.DeepEqual(runs, want) { ++ t.Fatalf("GetJobRunsFromLastNHours() = %v, want %v", runs, want) ++ } ++} +diff --git a/benchmark/pkg/metricsfetcher/runselector/schemes/last_n_runs_sparse_test.go b/benchmark/pkg/metricsfetcher/runselector/schemes/last_n_runs_sparse_test.go +new file mode 100644 +index 000000000..3dacc995a +--- /dev/null ++++ b/benchmark/pkg/metricsfetcher/runselector/schemes/last_n_runs_sparse_test.go +@@ -0,0 +1,61 @@ ++package schemes ++ ++import ( ++ "reflect" ++ "testing" ++ ++ "k8s.io/perf-tests/benchmark/pkg/metricsfetcher/util" ++) ++ ++func sparseFinishedUtils(builds []int, finished ...int) util.MockJobLogUtils { ++ statuses := map[int]bool{} ++ for _, run := range finished { ++ statuses[run] = true ++ } ++ return util.MockJobLogUtils{ ++ MockBuildNumbers: builds, ++ MockFinishedStatuses: statuses, ++ } ++} ++ ++func TestGetLastNJobRunsUsesSparseAvailableBuildNumbers(t *testing.T) { ++ utils := sparseFinishedUtils([]int{3, 15, 7, 9}, 3, 15, 7, 9) ++ ++ runs, err := GetLastNJobRuns("sparse-job", 3, utils) ++ if err != nil { ++ t.Fatalf("GetLastNJobRuns returned error: %v", err) ++ } ++ ++ want := []int{15, 9, 7} ++ if !reflect.DeepEqual(runs, want) { ++ t.Fatalf("GetLastNJobRuns() = %v, want %v", runs, want) ++ } ++} ++ ++func TestGetLastNJobRunsSkipsUnavailableAndUnfinishedSparseRuns(t *testing.T) { ++ utils := sparseFinishedUtils([]int{2, 5, 11, 20}, 20, 5) ++ ++ runs, err := GetLastNJobRuns("sparse-job", 2, utils) ++ if err != nil { ++ t.Fatalf("GetLastNJobRuns returned error: %v", err) ++ } ++ ++ want := []int{20, 5} ++ if !reflect.DeepEqual(runs, want) { ++ t.Fatalf("GetLastNJobRuns() = %v, want %v", runs, want) ++ } ++} ++ ++func TestGetLastNJobRunsDoesNotUseLatestNumberFallback(t *testing.T) { ++ utils := sparseFinishedUtils([]int{12, 30, 18, 25}, 12, 18, 25, 30) ++ ++ runs, err := GetLastNJobRuns("another-sparse-job", 3, utils) ++ if err != nil { ++ t.Fatalf("GetLastNJobRuns returned error: %v", err) ++ } ++ ++ want := []int{30, 25, 18} ++ if !reflect.DeepEqual(runs, want) { ++ t.Fatalf("GetLastNJobRuns() = %v, want %v", runs, want) ++ } ++} +diff --git a/benchmark/pkg/metricsfetcher/util/build_numbers_test.go b/benchmark/pkg/metricsfetcher/util/build_numbers_test.go +new file mode 100644 +index 000000000..3f7cb204f +--- /dev/null ++++ b/benchmark/pkg/metricsfetcher/util/build_numbers_test.go +@@ -0,0 +1,61 @@ ++package util ++ ++import ( ++ "net/http" ++ "net/http/httptest" ++ "reflect" ++ "sort" ++ "testing" ++ ++ gcsutils "k8s.io/contrib/test-utils/utils" ++) ++ ++type buildNumberProvider interface { ++ GetBuildNumbersForJob(string) ([]int, error) ++} ++ ++var _ JobLogUtils = MockJobLogUtils{} ++var _ JobLogUtils = GCSLogUtils{} ++var _ buildNumberProvider = MockJobLogUtils{} ++var _ buildNumberProvider = GCSLogUtils{} ++ ++func TestMockJobLogUtilsReturnsAvailableBuildNumbers(t *testing.T) { ++ utils := MockJobLogUtils{MockBuildNumbers: []int{8, 2, 13}} ++ ++ got, err := utils.GetBuildNumbersForJob("sparse-job") ++ if err != nil { ++ t.Fatalf("GetBuildNumbersForJob returned error: %v", err) ++ } ++ ++ want := []int{8, 2, 13} ++ if !reflect.DeepEqual(got, want) { ++ t.Fatalf("GetBuildNumbersForJob() = %v, want %v", got, want) ++ } ++} ++ ++func TestGCSLogUtilsReturnsAvailableBuildNumbers(t *testing.T) { ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ w.Header().Set("Content-Type", "application/json") ++ w.Write([]byte(`{"prefixes":["logs/sparse-job/101/","logs/sparse-job/77/","logs/sparse-job/9/"]}`)) ++ })) ++ defer server.Close() ++ ++ utils := GCSLogUtils{ ++ googleGCSBucketUtils: gcsutils.NewTestUtils("test-bucket", "logs", server.URL), ++ } ++ got, err := utils.GetBuildNumbersForJob("sparse-job") ++ if err != nil { ++ t.Fatalf("GetBuildNumbersForJob returned error: %v", err) ++ } ++ ++ want := []int{101, 77, 9} ++ if !reflect.DeepEqual(sortedInts(got), sortedInts(want)) { ++ t.Fatalf("GetBuildNumbersForJob() = %v, want %v", got, want) ++ } ++} ++ ++func sortedInts(values []int) []int { ++ result := append([]int(nil), values...) ++ sort.Ints(result) ++ return result ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,32 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++ ++ ++ ++ ++rm -rf /root/gopath/src/k8s.io/perf-tests ++mkdir -p /root/gopath/src/k8s.io ++cp -a /testbed /root/gopath/src/k8s.io/perf-tests ++ ++export GOPATH=/root/gopath ++export GO111MODULE=off ++ ++ ++case "${1:-}" in ++ base) ++ go test -v k8s.io/perf-tests/benchmark/pkg/metricsfetcher/runselector/schemes \ ++ -run '^(TestGetLastNJobRuns|TestGetJobRunsFromLastNHours)$' ++ ;; ++ new) ++ go test -v k8s.io/perf-tests/benchmark/pkg/metricsfetcher/runselector/schemes \ ++ -run '^(TestGetLastNJobRunsUsesSparseAvailableBuildNumbers|TestGetLastNJobRunsSkipsUnavailableAndUnfinishedSparseRuns|TestGetLastNJobRunsDoesNotUseLatestNumberFallback|TestGetJobRunsFromLastNHoursUsesSparseAvailableBuildNumbers|TestGetJobRunsFromLastNHoursDoesNotBackfillPastOlderAvailableBuild|TestGetJobRunsFromLastNHoursDoesNotUseLatestNumberFallback)$' ++ go test -v k8s.io/perf-tests/benchmark/pkg/metricsfetcher/util \ ++ -run '^(TestMockJobLogUtilsReturnsAvailableBuildNumbers|TestGCSLogUtilsReturnsAvailableBuildNumbers)$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001746/tests/test.sh b/tasks/format-code-task-001746/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c0e50d178571e3c03bb720c49754ba43ec838a5 --- /dev/null +++ b/tasks/format-code-task-001746/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' +benchmark/pkg/metricsfetcher/runselector/schemes/last_n_hours_sparse_test.go +benchmark/pkg/metricsfetcher/runselector/schemes/last_n_runs_sparse_test.go +benchmark/pkg/metricsfetcher/util/build_numbers_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-001746/tests/test_command.sh b/tasks/format-code-task-001746/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001746/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-001748/environment/Dockerfile b/tasks/format-code-task-001748/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b212adb551a92dd3bce9d03a5a7c901ca1bb5d08 --- /dev/null +++ b/tasks/format-code-task-001748/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:0a1f38965663a4d7e5b1dbb69f8329f9f4c2e62f8f7ce2bb067c546e19b298c2 diff --git a/tasks/format-code-task-001748/environment/setup/files/blocklist b/tasks/format-code-task-001748/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001748/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-001748/environment/setup/setup.sh b/tasks/format-code-task-001748/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001748/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-001748/tests/test.patch b/tasks/format-code-task-001748/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..16e4edc40199eebf0b0c81241ed7d36735e21569 --- /dev/null +++ b/tasks/format-code-task-001748/tests/test.patch @@ -0,0 +1,69 @@ +diff --git a/pkg/virt-api/webhooks/validating-webhook/admitters/vmexport-admitter_test.go b/pkg/virt-api/webhooks/validating-webhook/admitters/vmexport-admitter_test.go +index 11aa10e3611b..a41c5a019944 100644 +--- a/pkg/virt-api/webhooks/validating-webhook/admitters/vmexport-admitter_test.go ++++ b/pkg/virt-api/webhooks/validating-webhook/admitters/vmexport-admitter_test.go +@@ -40,6 +40,7 @@ import ( + + var _ = Describe("Validating VirtualMachineExport Admitter", func() { + apiGroup := "v1" ++ snapshotApiGroup := "snapshot.kubevirt.io" + kubevirtApiGroup := "kubevirt.io" + + config, _, kvInformer := testutils.NewFakeClusterConfigUsingKVConfig(&v1.KubeVirtConfiguration{}) +@@ -229,12 +230,32 @@ var _ = Describe("Validating VirtualMachineExport Admitter", func() { + + ar := createExportAdmissionReview(export) + resp := createTestVMExportAdmitter(config).Admit(ar) +- Expect(resp.Allowed).To(BeTrue()) ++ Expect(resp.Allowed).To(BeTrue(), "should allow APIGroup: %s, Kind: %s", apiGroup, kind) + }, +- Entry("persistent volume claim", "v1", pvc), +- Entry("virtual machine snapshot", kubevirtApiGroup, vmSnapshotKind), ++ Entry("persistent volume claim blank", "", pvc), ++ Entry("virtual machine snapshot", snapshotApiGroup, vmSnapshotKind), ++ Entry("virtual machine", kubevirtApiGroup, vmKind), + ) + ++ DescribeTable("it should reject invalid apigroups", func(apiGroup, kind string) { ++ export := &exportv1.VirtualMachineExport{ ++ Spec: exportv1.VirtualMachineExportSpec{ ++ Source: corev1.TypedLocalObjectReference{ ++ APIGroup: &apiGroup, ++ Kind: kind, ++ Name: "test", ++ }, ++ }, ++ } ++ ++ ar := createExportAdmissionReview(export) ++ resp := createTestVMExportAdmitter(config).Admit(ar) ++ Expect(resp.Allowed).To(BeFalse(), "should reject APIGroup: %s, Kind: %s", apiGroup, kind) ++ }, ++ Entry("persistent volume claim", "invalid", pvc), ++ Entry("virtual machine snapshot", "invalid", vmSnapshotKind), ++ Entry("virtual machine", "invalid", vmKind), ++ ) + }) + }) + +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+3SQU+DMBQH8J35FM95hlJmx2kHDx697roUWqEBWkIL+vFFskxjortsUeP/d3kN ++vJYX/k2K0bTqoO3EVteSznIhljr7XJc1FxnPMp7yfO7jXMyFxNUm+mD0QQ5Eq8G58F3fufd/VPKe ++f9A+HErXddKqxNeX+8a5/LPN5pR/KvI5/7ttul1RerkRvvbP87+9YYWxrJC+jkpFyyUotIoqR29L ++iieKSzfasOOUsL6p2GSGEMvesGdd1M41nk2yNUoGY6v4+IxJ1ZkQ9OAZxZWxTeWSJ1eOntb7UzPt ++55NG2T7KsjZWP7z0bgh0f9y5jn761wAAAAAAAAAAAAAAAAAAAAAA/HqvVlzciAAoAAA= +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-001748/tests/test.sh b/tasks/format-code-task-001748/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bb0edc2c47f366b87cddbe1177f07d556fc7b7d6 --- /dev/null +++ b/tasks/format-code-task-001748/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/virt-api/webhooks/validating-webhook/admitters/vmexport-admitter_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-001748/tests/test_command.sh b/tasks/format-code-task-001748/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001748/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-001770/environment/Dockerfile b/tasks/format-code-task-001770/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5775e53ab2ed451c7db16bf1705e8c7ed94b264b --- /dev/null +++ b/tasks/format-code-task-001770/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:f3a1a127688d21536645a3e79b2fa2d8384cd1067ba8975e79ede44257a9cd4e diff --git a/tasks/format-code-task-001770/environment/setup/files/blocklist b/tasks/format-code-task-001770/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001770/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-001770/environment/setup/setup.sh b/tasks/format-code-task-001770/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001770/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-001770/tests/test.patch b/tasks/format-code-task-001770/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a182d6df37a4c5291c206a00dd3afd437566de7d --- /dev/null +++ b/tasks/format-code-task-001770/tests/test.patch @@ -0,0 +1,431 @@ +diff --git a/usercase-test-coderl/test_interferometry_natwt_linear_fit.py b/usercase-test-coderl/test_interferometry_natwt_linear_fit.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_interferometry_natwt_linear_fit.py +@@ -0,0 +1,401 @@ ++ ++ ++ ++ ++ ++ ++ ++import numpy as np ++import numpy.testing as npt ++ ++from lenstronomy.Data.imaging_data import ImageData ++from lenstronomy.Data.psf import PSF ++from lenstronomy.ImSim.Numerics.convolution import PixelKernelConvolution ++from lenstronomy.ImSim.differential_extinction import DifferentialExtinction ++from lenstronomy.ImSim.image_linear_solve import ImageLinearFit ++from lenstronomy.LightModel.light_model import LightModel ++from lenstronomy.PointSource.point_source import PointSource ++from lenstronomy.Util import primary_beam_util, util ++ ++ ++def _session(scale=1.0, with_primary_beam=True): ++ num_pix = 9 ++ delta_pix = 0.1 ++ image_data = ( ++ scale ++ * np.arange(num_pix * num_pix, dtype=float).reshape(num_pix, num_pix) ++ / 10.0 ++ ) ++ kwargs_data = { ++ "image_data": image_data, ++ "exposure_time": np.inf, ++ "background_rms": 2.0, ++ "transform_pix2angle": np.array([[delta_pix, 0], [0, delta_pix]]), ++ "ra_at_xy_0": -(num_pix // 2) * delta_pix, ++ "dec_at_xy_0": -(num_pix // 2) * delta_pix, ++ "likelihood_method": "interferometry_natwt", ++ } ++ if with_primary_beam: ++ kwargs_data["antenna_primary_beam"] = np.linspace( ++ 0.75, 1.15, num_pix * num_pix ++ ).reshape(num_pix, num_pix) ++ ++ data_class = ImageData(**kwargs_data) ++ psf_class = PSF( ++ psf_type="PIXEL", ++ pixel_size=delta_pix, ++ kernel_point_source=np.array( ++ [[0.0, 0.1, 0.0], [0.1, 1.0, 0.1], [0.0, 0.1, 0.0]] ++ ), ++ kernel_point_source_normalisation=False, ++ ) ++ source_model_class = LightModel(light_model_list=["GAUSSIAN"]) ++ lens_light_model_class = LightModel(light_model_list=["SERSIC"]) ++ point_source_class = PointSource(point_source_type_list=["UNLENSED"]) ++ extinction_class = DifferentialExtinction(optical_depth_model=["GAUSSIAN"]) ++ ++ image_linear_fit = ImageLinearFit( ++ data_class, ++ psf_class, ++ source_model_class=source_model_class, ++ lens_light_model_class=lens_light_model_class, ++ point_source_class=point_source_class, ++ extinction_class=extinction_class, ++ kwargs_numerics={"supersampling_factor": 1, "supersampling_convolution": False}, ++ ) ++ kwargs_source = [ ++ {"amp": 3.0, "sigma": 0.16, "center_x": 0.02, "center_y": -0.01} ++ ] ++ kwargs_lens_light = [ ++ { ++ "amp": 4.0, ++ "R_sersic": 0.22, ++ "n_sersic": 1.5, ++ "center_x": -0.05, ++ "center_y": 0.04, ++ } ++ ] ++ kwargs_ps = [ ++ {"ra_image": [0.11], "dec_image": [-0.09], "point_amp": [5.0]} ++ ] ++ kwargs_extinction = [ ++ {"amp": 0.25, "sigma": 0.3, "center_x": 0.0, "center_y": 0.0} ++ ] ++ kwargs_special = {"tau0_list": [0.7]} ++ return ( ++ image_linear_fit, ++ kwargs_source, ++ kwargs_lens_light, ++ kwargs_ps, ++ kwargs_extinction, ++ kwargs_special, ++ ) ++ ++ ++def _manual_response_matrix( ++ fit, ++ kwargs_lens, ++ kwargs_source, ++ kwargs_lens_light, ++ kwargs_ps, ++ kwargs_extinction, ++ kwargs_special, ++): ++ ++ x_grid, y_grid = fit.ImageNumerics.coordinates_evaluate ++ source_response, n_source = fit.source_mapping.image_flux_split( ++ x_grid, y_grid, kwargs_lens, kwargs_source, kwargs_special ++ ) ++ lens_light_response, n_lens_light = fit.LensLightModel.functions_split( ++ x_grid, y_grid, kwargs_lens_light ++ ) ++ extinction = fit._extinction.extinction( ++ x_grid, ++ y_grid, ++ kwargs_extinction=kwargs_extinction, ++ kwargs_special=kwargs_special, ++ ) ++ ra_pos, dec_pos, amp, n_points = fit.point_source_linear_response_set( ++ kwargs_ps, kwargs_lens, kwargs_special, with_amp=False ++ ) ++ ++ rows = [] ++ primary_beam = fit.Data.primary_beam ++ primary_beam_1d = None if primary_beam is None else util.image2array(primary_beam) ++ ++ for i in range(n_source): ++ image = np.array(source_response[i], copy=True) ++ if primary_beam_1d is not None: ++ image *= primary_beam_1d ++ image *= extinction ++ image = fit.ImageNumerics.re_size_convolve(image, unconvolved=True) ++ rows.append(np.nan_to_num(fit.image2array_masked(image), copy=False)) ++ ++ for i in range(n_lens_light): ++ image = np.array(lens_light_response[i], copy=True) ++ if primary_beam_1d is not None: ++ image *= primary_beam_1d ++ image = fit.ImageNumerics.re_size_convolve(image, unconvolved=True) ++ rows.append(np.nan_to_num(fit.image2array_masked(image), copy=False)) ++ ++ for i in range(n_points): ++ amp_effective = amp[i] ++ if primary_beam is not None: ++ x_pos, y_pos = fit.Data.map_coord2pix(ra_pos[i], dec_pos[i]) ++ amp_effective = amp[i] * primary_beam_util.primary_beam_value_at_coords( ++ x_pos, y_pos, primary_beam ++ ) ++ image = fit.ImageNumerics.point_source_rendering_unconvolved_for_interferometry( ++ ra_pos[i], dec_pos[i], amp_effective ++ ) ++ rows.append(np.nan_to_num(fit.image2array_masked(image), copy=False)) ++ ++ return np.asarray(rows) * getattr(fit, "_flux_scaling", 1) ++ ++ ++def _manual_convolved_responses(fit, response): ++ convolution = PixelKernelConvolution(kernel=fit.PSF.kernel_point_source) ++ return np.asarray( ++ [ ++ util.image2array(convolution.convolution2d(util.array2image(row))) ++ for row in response ++ ] ++ ) ++ ++ ++def _manual_natwt_solution(fit, response, inv_bool=False): ++ ++ convolved_response = _manual_convolved_responses(fit, response) ++ background_rms = fit.Data.background_rms ++ matrix = response @ convolved_response.T / background_rms**2 ++ vector = response @ fit.data_response / background_rms**2 ++ param = np.linalg.solve(matrix, vector) ++ unconvolved_model = util.array2image(param @ response) ++ convolved_model = util.array2image(param @ convolved_response) ++ cov_param = np.linalg.inv(matrix) if inv_bool else None ++ return [unconvolved_model, convolved_model], cov_param, param ++ ++ ++def test_response_matrix_applies_primary_beam_extinction_and_point_source_scaling(): ++ ++ ++ ++ fit, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special = ( ++ _session(with_primary_beam=True) ++ ) ++ ++ response = fit.linear_response_matrix_interferometry_unconvolved( ++ None, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special ++ ) ++ expected = _manual_response_matrix( ++ fit, None, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special ++ ) ++ ++ assert response.shape == (3, 81) ++ ++ ++ npt.assert_allclose(response, expected, rtol=1e-12, atol=1e-12) ++ assert np.count_nonzero(response[2]) == 4 ++ ++ ++def test_response_matrix_without_primary_beam_uses_unscaled_basis_responses(): ++ ++ ++ ++ fit, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special = ( ++ _session(with_primary_beam=False) ++ ) ++ ++ response = fit.linear_response_matrix_interferometry_unconvolved( ++ None, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special ++ ) ++ expected = _manual_response_matrix( ++ fit, None, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special ++ ) ++ ++ assert response.shape == (3, 81) ++ ++ ++ npt.assert_allclose(response, expected, rtol=1e-12, atol=1e-12) ++ assert np.count_nonzero(response[2]) == 4 ++ ++ ++def test_image_linear_solve_returns_models_amplitudes_and_updates_kwargs(): ++ ++ ++ ++ fit, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special = ( ++ _session(with_primary_beam=True) ++ ) ++ ++ expected_response = _manual_response_matrix( ++ fit, None, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special ++ ) ++ expected_model, expected_cov, expected_param = _manual_natwt_solution( ++ fit, expected_response ++ ) ++ model, model_error, cov_param, param = fit.image_linear_solve( ++ None, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special ++ ) ++ ++ assert len(model) == 2 ++ assert model[0].shape == (9, 9) ++ assert model[1].shape == (9, 9) ++ assert model_error == 0 ++ assert cov_param is None ++ assert expected_cov is None ++ ++ ++ npt.assert_allclose(param, expected_param, rtol=1e-11, atol=1e-11) ++ npt.assert_allclose(model[0], expected_model[0], rtol=1e-11, atol=1e-11) ++ npt.assert_allclose(model[1], expected_model[1], rtol=1e-11, atol=1e-11) ++ npt.assert_allclose(kwargs_source[0]["amp"], expected_param[0], rtol=0, atol=1e-11) ++ npt.assert_allclose( ++ kwargs_lens_light[0]["amp"], expected_param[1], rtol=0, atol=1e-11 ++ ) ++ npt.assert_allclose( ++ kwargs_ps[0]["point_amp"], [expected_param[2]], rtol=0, atol=1e-11 ++ ) ++ ++ repeated_model, repeated_error, repeated_cov, repeated_param = fit.image_linear_solve( ++ None, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special ++ ) ++ assert repeated_error == 0 ++ assert repeated_cov is None ++ npt.assert_allclose(repeated_param, param, rtol=0, atol=1e-11) ++ npt.assert_allclose(repeated_model[0], model[0], rtol=0, atol=1e-11) ++ npt.assert_allclose(repeated_model[1], model[1], rtol=0, atol=1e-11) ++ ++ ++def test_image_linear_solve_with_inv_bool_returns_covariance_from_same_solution(): ++ ++ ++ ++ fit, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special = ( ++ _session(with_primary_beam=True) ++ ) ++ ++ expected_response = _manual_response_matrix( ++ fit, None, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special ++ ) ++ expected_model, expected_cov, expected_param = _manual_natwt_solution( ++ fit, expected_response, inv_bool=True ++ ) ++ model, model_error, cov_param, param = fit.image_linear_solve( ++ None, ++ kwargs_source, ++ kwargs_lens_light, ++ kwargs_ps, ++ kwargs_extinction, ++ special, ++ inv_bool=True, ++ ) ++ ++ assert model_error == 0 ++ ++ ++ npt.assert_allclose(param, expected_param, rtol=1e-11, atol=1e-11) ++ npt.assert_allclose(cov_param, expected_cov, rtol=1e-9, atol=1e-9) ++ npt.assert_allclose(model[0], expected_model[0], rtol=1e-11, atol=1e-11) ++ npt.assert_allclose(model[1], expected_model[1], rtol=1e-11, atol=1e-11) ++ ++ ++def test_two_image_linear_fit_instances_keep_independent_solved_state(): ++ ++ ++ ++ fit_a, a_source, a_lens_light, a_ps, a_extinction, a_special = _session(scale=1.0) ++ fit_b, b_source, b_lens_light, b_ps, b_extinction, b_special = _session(scale=0.5) ++ ++ expected_a = _manual_natwt_solution( ++ fit_a, ++ _manual_response_matrix( ++ fit_a, None, a_source, a_lens_light, a_ps, a_extinction, a_special ++ ), ++ )[2] ++ expected_b = _manual_natwt_solution( ++ fit_b, ++ _manual_response_matrix( ++ fit_b, None, b_source, b_lens_light, b_ps, b_extinction, b_special ++ ), ++ )[2] ++ _, _, _, param_a = fit_a.image_linear_solve( ++ None, a_source, a_lens_light, a_ps, a_extinction, a_special ++ ) ++ _, _, _, param_b = fit_b.image_linear_solve( ++ None, b_source, b_lens_light, b_ps, b_extinction, b_special ++ ) ++ ++ ++ ++ npt.assert_allclose(param_a, expected_a, rtol=1e-11, atol=1e-11) ++ npt.assert_allclose(param_b, expected_b, rtol=1e-11, atol=1e-11) ++ npt.assert_allclose(param_b, 0.5 * param_a, rtol=1e-11, atol=1e-11) ++ npt.assert_allclose(a_source[0]["amp"], param_a[0], rtol=0, atol=1e-11) ++ npt.assert_allclose(a_lens_light[0]["amp"], param_a[1], rtol=0, atol=1e-11) ++ npt.assert_allclose(a_ps[0]["point_amp"], [param_a[2]], rtol=0, atol=1e-11) ++ npt.assert_allclose(b_source[0]["amp"], param_b[0], rtol=0, atol=1e-11) ++ npt.assert_allclose(b_lens_light[0]["amp"], param_b[1], rtol=0, atol=1e-11) ++ npt.assert_allclose(b_ps[0]["point_amp"], [param_b[2]], rtol=0, atol=1e-11) ++ ++ ++def test_natwt_image_data_constructs_supported_linear_fit_session(): ++ ++ ++ ++ ++ ++ fit, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special = _session() ++ ++ assert fit.Data.likelihood_method() == "interferometry_natwt" ++ model, model_error, cov_param, param = fit.image_linear_solve( ++ None, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special ++ ) ++ assert len(model) == 2 ++ assert model_error == 0 ++ assert cov_param is None ++ assert param.shape == (3,) ++ ++ ++def test_construct_solve_cycles_remain_numerically_repeatable(): ++ ++ ++ ++ expected_param = None ++ ++ for _ in range(5): ++ fit, kwargs_source, kwargs_lens_light, kwargs_ps, kwargs_extinction, special = ( ++ _session() ++ ) ++ expected_model, _, expected_param_for_fit = _manual_natwt_solution( ++ fit, ++ _manual_response_matrix( ++ fit, ++ None, ++ kwargs_source, ++ kwargs_lens_light, ++ kwargs_ps, ++ kwargs_extinction, ++ special, ++ ), ++ ) ++ model, model_error, cov_param, param = fit.image_linear_solve( ++ None, ++ kwargs_source, ++ kwargs_lens_light, ++ kwargs_ps, ++ kwargs_extinction, ++ special, ++ ) ++ ++ ++ ++ assert model_error == 0 ++ assert cov_param is None ++ npt.assert_allclose(param, expected_param_for_fit, rtol=1e-11, atol=1e-11) ++ npt.assert_allclose(model[0], expected_model[0], rtol=1e-11, atol=1e-11) ++ npt.assert_allclose(model[1], expected_model[1], rtol=1e-11, atol=1e-11) ++ if expected_param is None: ++ expected_param = param ++ else: ++ npt.assert_allclose(param, expected_param, rtol=1e-11, atol=1e-11) +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 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PIP_NO_INDEX=1 ++ ++exec python -m pytest -p no:cacheprovider /workspace/repo/usercase-test-coderl/test_interferometry_natwt_linear_fit.py -v diff --git a/tasks/format-code-task-001770/tests/test.sh b/tasks/format-code-task-001770/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8081357173a4d79743894508497eb3cac097703a --- /dev/null +++ b/tasks/format-code-task-001770/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_interferometry_natwt_linear_fit.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-001770/tests/test_command.sh b/tasks/format-code-task-001770/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001770/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-001777/environment/Dockerfile b/tasks/format-code-task-001777/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1b3ddf121cdfe86333618f47873304abc60a05cd --- /dev/null +++ b/tasks/format-code-task-001777/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:f2bfbe6ffabf17a620964f8a0c21807f4a02f4fe841f0d6aac70c594647bec86 diff --git a/tasks/format-code-task-001777/environment/setup/files/blocklist b/tasks/format-code-task-001777/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001777/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-001777/environment/setup/setup.sh b/tasks/format-code-task-001777/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001777/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-001777/tests/test.patch b/tasks/format-code-task-001777/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8f5183ce97d3f40efd9ec026931186af15c0a918 --- /dev/null +++ b/tasks/format-code-task-001777/tests/test.patch @@ -0,0 +1,209 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..6cbb084f4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test -run 'TestDirectoryPOSTAsGET|TestNoncePOSTAsGET|TestDirectoryPOSTGarbageBody|TestNoncePOSTGarbageBody|TestDirectoryGETPreserved|TestNonceGETPreserved|TestDirectoryPOSTAsGETNonEmptyPayload|TestNoncePOSTAsGETNonEmptyPayload' ./wfe2/"] ++} +diff --git a/wfe2/wfe_test.go b/wfe2/wfe_test.go +index 965abe45e..cf785860b 100644 +--- a/wfe2/wfe_test.go ++++ b/wfe2/wfe_test.go +@@ -3088,3 +3088,182 @@ func TestPrepAccountForDisplay(t *testing.T) { + // The ID field should now be zeroed + test.AssertEquals(t, acct.ID, int64(0)) + } ++ ++ ++ ++func signedPostAsGet(t *testing.T, wfe *WebFrontEndImpl, path string) *http.Request { ++ signedURL := fmt.Sprintf("http://localhost%s", path) ++ _, _, body := signRequestKeyID(t, 1, nil, signedURL, "", wfe.nonceService) ++ return makePostRequestWithPath(path, body) ++} ++ ++ ++ ++func signedPostAsGetWithBody(t *testing.T, wfe *WebFrontEndImpl, path string, body string) *http.Request { ++ signedURL := fmt.Sprintf("http://localhost%s", path) ++ _, _, jwsBody := signRequestKeyID(t, 1, nil, signedURL, body, wfe.nonceService) ++ return makePostRequestWithPath(path, jwsBody) ++} ++ ++ ++ ++func TestDirectoryPOSTAsGET(t *testing.T) { ++ wfe, _ := setupWFE(t) ++ mux := wfe.Handler() ++ core.RandReader = fakeRand{} ++ defer func() { core.RandReader = rand.Reader }() ++ ++ expectedJSON := `{ ++ "keyChange": "http://localhost/acme/key-change", ++ "meta": { ++ "termsOfService": "http://example.invalid/terms" ++ }, ++ "newNonce": "http://localhost/acme/new-nonce", ++ "newAccount": "http://localhost/acme/new-acct", ++ "newOrder": "http://localhost/acme/new-order", ++ "revokeCert": "http://localhost/acme/revoke-cert", ++ "AAAAAAAAAAA": "https://community.letsencrypt.org/t/adding-random-entries-to-the-directory/33417" ++}` ++ ++ req := signedPostAsGet(t, &wfe, directoryPath) ++ responseWriter := httptest.NewRecorder() ++ mux.ServeHTTP(responseWriter, req) ++ ++ ++ test.AssertEquals(t, responseWriter.Code, http.StatusOK) ++ test.AssertEquals(t, responseWriter.Header().Get("Content-Type"), "application/json") ++ test.AssertUnmarshaledEquals(t, responseWriter.Body.String(), expectedJSON) ++} ++ ++ ++ ++func TestNoncePOSTAsGET(t *testing.T) { ++ wfe, _ := setupWFE(t) ++ mux := wfe.Handler() ++ ++ req := signedPostAsGet(t, &wfe, newNoncePath) ++ responseWriter := httptest.NewRecorder() ++ mux.ServeHTTP(responseWriter, req) ++ ++ ++ ++ ++ test.AssertEquals(t, responseWriter.Code, http.StatusNoContent) ++ nonce := responseWriter.Header().Get("Replay-Nonce") ++ test.AssertNotEquals(t, nonce, "") ++ test.AssertEquals(t, wfe.nonceService.Valid(nonce), true) ++} ++ ++ ++ ++func TestDirectoryPOSTAsGETNonEmptyPayload(t *testing.T) { ++ wfe, _ := setupWFE(t) ++ mux := wfe.Handler() ++ ++ req := signedPostAsGetWithBody(t, &wfe, directoryPath, `{"foo":"bar"}`) ++ responseWriter := httptest.NewRecorder() ++ mux.ServeHTTP(responseWriter, req) ++ ++ ++ test.AssertEquals(t, responseWriter.Header().Get("Content-Type"), "application/problem+json") ++ var prob probs.ProblemDetails ++ err := json.Unmarshal(responseWriter.Body.Bytes(), &prob) ++ test.AssertNotError(t, err, "Failed to unmarshal problem") ++ test.AssertEquals(t, prob.Type, probs.V2ErrorNS+probs.MalformedProblem) ++ test.AssertEquals(t, prob.HTTPStatus, http.StatusBadRequest) ++ ++ test.Assert(t, ++ !strings.Contains(responseWriter.Body.String(), `"newAccount"`), ++ "Directory JSON was returned despite invalid POST-as-GET payload") ++} ++ ++ ++ ++func TestNoncePOSTAsGETNonEmptyPayload(t *testing.T) { ++ wfe, _ := setupWFE(t) ++ mux := wfe.Handler() ++ ++ req := signedPostAsGetWithBody(t, &wfe, newNoncePath, `{"hello":"world"}`) ++ responseWriter := httptest.NewRecorder() ++ mux.ServeHTTP(responseWriter, req) ++ ++ test.AssertEquals(t, responseWriter.Header().Get("Content-Type"), "application/problem+json") ++ var prob probs.ProblemDetails ++ err := json.Unmarshal(responseWriter.Body.Bytes(), &prob) ++ test.AssertNotError(t, err, "Failed to unmarshal problem") ++ test.AssertEquals(t, prob.Type, probs.V2ErrorNS+probs.MalformedProblem) ++ test.AssertEquals(t, prob.HTTPStatus, http.StatusBadRequest) ++} ++ ++ ++ ++func TestDirectoryPOSTGarbageBody(t *testing.T) { ++ wfe, _ := setupWFE(t) ++ mux := wfe.Handler() ++ ++ req := makePostRequestWithPath(directoryPath, "this is not a JWS") ++ responseWriter := httptest.NewRecorder() ++ mux.ServeHTTP(responseWriter, req) ++ ++ ++ test.AssertNotEquals(t, responseWriter.Code, http.StatusOK) ++ test.AssertEquals(t, responseWriter.Header().Get("Content-Type"), "application/problem+json") ++ ++ test.Assert(t, ++ !strings.Contains(responseWriter.Body.String(), `"newAccount"`), ++ "Directory JSON was returned despite invalid JWS body") ++} ++ ++ ++ ++func TestNoncePOSTGarbageBody(t *testing.T) { ++ wfe, _ := setupWFE(t) ++ mux := wfe.Handler() ++ ++ req := makePostRequestWithPath(newNoncePath, "this is not a JWS") ++ responseWriter := httptest.NewRecorder() ++ mux.ServeHTTP(responseWriter, req) ++ ++ ++ ++ test.AssertEquals(t, responseWriter.Code, http.StatusBadRequest) ++ test.AssertEquals(t, responseWriter.Header().Get("Content-Type"), "application/problem+json") ++} ++ ++ ++ ++func TestDirectoryGETPreserved(t *testing.T) { ++ wfe, _ := setupWFE(t) ++ mux := wfe.Handler() ++ core.RandReader = fakeRand{} ++ defer func() { core.RandReader = rand.Reader }() ++ ++ req := &http.Request{ ++ Method: "GET", ++ URL: mustParseURL(directoryPath), ++ Host: "localhost", ++ } ++ responseWriter := httptest.NewRecorder() ++ mux.ServeHTTP(responseWriter, req) ++ test.AssertEquals(t, responseWriter.Code, http.StatusOK) ++ test.AssertEquals(t, responseWriter.Header().Get("Content-Type"), "application/json") ++ test.Assert(t, strings.Contains(responseWriter.Body.String(), `"newAccount"`), ++ "GET /directory should still return directory JSON") ++} ++ ++ ++ ++func TestNonceGETPreserved(t *testing.T) { ++ wfe, _ := setupWFE(t) ++ mux := wfe.Handler() ++ ++ responseWriter := httptest.NewRecorder() ++ mux.ServeHTTP(responseWriter, &http.Request{ ++ Method: "GET", ++ URL: mustParseURL(newNoncePath), ++ }) ++ test.AssertEquals(t, responseWriter.Code, http.StatusNoContent) ++ nonce := responseWriter.Header().Get("Replay-Nonce") ++ test.AssertEquals(t, wfe.nonceService.Valid(nonce), true) ++} ++ +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test -run 'TestDirectoryPOSTAsGET|TestNoncePOSTAsGET|TestDirectoryPOSTGarbageBody|TestNoncePOSTGarbageBody|TestDirectoryGETPreserved|TestNonceGETPreserved|TestDirectoryPOSTAsGETNonEmptyPayload|TestNoncePOSTAsGETNonEmptyPayload' ./wfe2/ ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001777/tests/test.sh b/tasks/format-code-task-001777/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d45e084a8909c77037bdf875ef161110d1feb771 --- /dev/null +++ b/tasks/format-code-task-001777/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 +wfe2/wfe_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-001777/tests/test_command.sh b/tasks/format-code-task-001777/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001777/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-001779/environment/Dockerfile b/tasks/format-code-task-001779/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9a0330594fd8781b0784ff9f5b91f8b221304b6a --- /dev/null +++ b/tasks/format-code-task-001779/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:e0ea7ab9f337cee031da03485b50a5ae7df2f3bd3ff615c082afc41848a2f227 diff --git a/tasks/format-code-task-001779/environment/setup/files/blocklist b/tasks/format-code-task-001779/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001779/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-001779/environment/setup/setup.sh b/tasks/format-code-task-001779/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001779/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-001779/tests/test.patch b/tasks/format-code-task-001779/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0b6493122f1f1bf606a6b83e84e2fe7fb9aafe3c --- /dev/null +++ b/tasks/format-code-task-001779/tests/test.patch @@ -0,0 +1,103 @@ +diff --git a/tests/tests.py b/tests/tests.py +index c04c4e6e..c0a4a10e 100644 +--- a/tests/tests.py ++++ b/tests/tests.py +@@ -70,6 +70,12 @@ def test_find_entries_by_path(self): + self.assertIsInstance(results, Entry) + self.assertEqual('group_entry', results.title) + ++ def test_find_entry_by_uuid(self): ++ results = self.kp.find_entry_by_uuid('CC5F7ECD2A0048CA9621C222A347B0BB') ++ self.assertIsInstance(results, Entry) ++ self.assertEqual('zF9+zSoASMqWIcIio0ewuw==', results.uuid) ++ self.assertEqual('foobar_user', results.username) ++ + def test_find_entry_by(self): + results = self.kp._find_entry_by('Title', 'Root_entry', regex=True) + self.assertEqual(len(results), 0) +@@ -83,30 +89,30 @@ def test_add_delete_entry(self): + unique_str = 'test_add_entry_' + expiry_time = datetime.now() + entry = self.kp.add_entry(self.kp.root_group, +- unique_str+'title', +- unique_str+'user', +- unique_str+'pass', +- url=unique_str+'url', +- notes=unique_str+'notes', +- tags=unique_str+'tags', ++ unique_str + 'title', ++ unique_str + 'user', ++ unique_str + 'pass', ++ url=unique_str + 'url', ++ notes=unique_str + 'notes', ++ tags=unique_str + 'tags', + expiry_time=expiry_time, + icon=icons.KEY) +- results = self.kp.find_entries_by_title(unique_str+'title') ++ results = self.kp.find_entries_by_title(unique_str + 'title') + self.assertEqual(len(results), 1) +- results = self.kp.find_entries_by_title(unique_str+'title', first=True) +- +- self.assertEqual(results.title, unique_str+'title') +- self.assertEqual(results.username, unique_str+'user') +- self.assertEqual(results.password, unique_str+'pass') +- self.assertEqual(results.url, unique_str+'url') +- self.assertEqual(results.notes, unique_str+'notes') +- self.assertEqual(results.tags, [unique_str+'tags']) ++ results = self.kp.find_entries_by_title(unique_str + 'title', first=True) ++ ++ self.assertEqual(results.title, unique_str + 'title') ++ self.assertEqual(results.username, unique_str + 'user') ++ self.assertEqual(results.password, unique_str + 'pass') ++ self.assertEqual(results.url, unique_str + 'url') ++ self.assertEqual(results.notes, unique_str + 'notes') ++ self.assertEqual(results.tags, [unique_str + 'tags']) + # convert naive datetime to utc + expiry_time_utc = expiry_time.replace(tzinfo=tz.gettz()).astimezone(tz.gettz('UTC')) + self.assertEqual(results.icon, icons.KEY) + + self.kp.delete_entry(entry) +- results = self.kp.find_entries_by_title(unique_str+'title', first=True) ++ results = self.kp.find_entries_by_title(unique_str + 'title', first=True) + self.assertIsNone(results) + + #---------- Entries name collision exception ----------- +@@ -114,12 +120,12 @@ def test_add_delete_entry(self): + def test_raise_exception_entry(self): + unique_str = 'test_add_entry_' + entry = self.kp.add_entry(self.kp.root_group, +- unique_str+'title', +- unique_str+'user', +- unique_str+'pass', +- url=unique_str+'url', +- notes=unique_str+'notes', +- tags=unique_str+'tags', ++ unique_str + 'title', ++ unique_str + 'user', ++ unique_str + 'pass', ++ url=unique_str + 'url', ++ notes=unique_str + 'notes', ++ tags=unique_str + 'tags', + icon=icons.KEY) + self.assertRaises(Exception, entry) + +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+3R0QqCMBTG8V33FOcFNLeaPU6UCgap0Zbg27d2YwTljRLR/3exc9gZ7MCXHm+n ++c7mv2n6tlpIFO2tjDV5r7LU1WufGGL1VmdZ2Z5XYxTZ6cnP+cBVR167zn95NzX9UOubvK+f3Rdc0 ++h7ZMXT3fH5P552P+2uYh/22ujZJsvhXe+/P8i1Ji8MeqXF0GX3ftRpJGQhsu5XG4OHfpZZCkX317 ++XwAAAAAAAAAAAAAAAACjO9/xaI0AKAAA +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-001779/tests/test.sh b/tasks/format-code-task-001779/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e2e709d7e7e4e1a39557f1daceab0b24a25658d7 --- /dev/null +++ b/tasks/format-code-task-001779/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/tests.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-001779/tests/test_command.sh b/tasks/format-code-task-001779/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001779/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-001783/environment/Dockerfile b/tasks/format-code-task-001783/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c3852b5e015e0f25a1a9f0e4b2c61572cc386dc4 --- /dev/null +++ b/tasks/format-code-task-001783/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:1d21803fcce49b213beb507e5c1976286927efc1d66fa4f9a52664e58ec5b40c diff --git a/tasks/format-code-task-001783/environment/setup/files/blocklist b/tasks/format-code-task-001783/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001783/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-001783/environment/setup/setup.sh b/tasks/format-code-task-001783/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001783/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-001783/tests/test.patch b/tasks/format-code-task-001783/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5a60e3f30b270da04971362f4343378f60f21c6c --- /dev/null +++ b/tasks/format-code-task-001783/tests/test.patch @@ -0,0 +1,88 @@ +diff --git a/lightkurve/tests/test_lightcurve.py b/lightkurve/tests/test_lightcurve.py +index 950b607e6..9ac531649 100644 +--- a/lightkurve/tests/test_lightcurve.py ++++ b/lightkurve/tests/test_lightcurve.py +@@ -471,7 +471,34 @@ def test_from_fits(): + lcf = KeplerLightCurveFile.from_fits(TABBY_Q8) + assert isinstance(lcf, KeplerLightCurveFile) + assert lcf.keplerid == KeplerLightCurveFile(TABBY_Q8).keplerid ++ assert lcf.keplerid == lcf.targetid + # Execute the same test for TESS + lcf = TessLightCurveFile.from_fits(TESS_SIM) + assert isinstance(lcf, TessLightCurveFile) + assert lcf.ticid == TessLightCurveFile(TESS_SIM).ticid ++ assert lcf.ticid == lcf.targetid ++ ++ ++def test_targetid(): ++ """Is a generic targetid available on each type of LighCurve object?""" ++ lc = LightCurve(time=[], targetid=5) ++ assert lc.targetid == 5 ++ ++ lc.targetid = 99 ++ assert lc.targetid == 99 ++ ++ lc = KeplerLightCurve(time=[], keplerid=10) ++ assert lc.targetid == 10 ++ assert lc.keplerid == 10 ++ ++ lc.keplerid = 99 ++ assert lc.keplerid == 99 ++ assert lc.targetid == 99 ++ ++ lc = TessLightCurve(time=[], ticid=20) ++ assert lc.targetid == 20 ++ assert lc.ticid == 20 ++ ++ lc.targetid = 99 ++ assert lc.ticid == 99 ++ assert lc.targetid == 99 +diff --git a/lightkurve/tests/test_targetpixelfile.py b/lightkurve/tests/test_targetpixelfile.py +index 5e5f6cc43..75b6793cb 100644 +--- a/lightkurve/tests/test_targetpixelfile.py ++++ b/lightkurve/tests/test_targetpixelfile.py +@@ -247,10 +247,12 @@ def test_from_fits(): + tpf = KeplerTargetPixelFile.from_fits(filename_tpf_one_center) + assert isinstance(tpf, KeplerTargetPixelFile) + assert tpf.keplerid == KeplerTargetPixelFile(filename_tpf_one_center).keplerid ++ assert tpf.keplerid == tpf.targetid + # Execute the same test for TESS + tpf = TessTargetPixelFile.from_fits(filename_tpf_one_center) + assert isinstance(tpf, TessTargetPixelFile) + assert tpf.ticid == TessTargetPixelFile(filename_tpf_one_center).ticid ++ assert tpf.ticid == tpf.targetid + + + def test_get_models(): +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,16 @@ ++H4sIAAAAAAAAA+1XUWvbMBDus3/FsT4kGa2XtE0Kg73sIaOMQVi7vZRiVFtJRGTLSHK6/PudFCux ++DE0C89jG9EFr6/zd6XSnOynxc8V4ltBi/e7sd2GIuB2P7RPRftr30fhqdDW6mQxvb8+Go9FkODmD ++8W/zqIFKaSIBzqQQ+hDv2Pd/FPE+/5oqnaQiz0mRxWrZ3RxH8j+ejK9c/sdjm/+byTXmf9idC6/j ++P89/moFN/DPNonKjl6K4hssU3kQsL4XUoDbKvepNSVUUncNM0stSlBUnmgJni6VeVXJN41LO4YXp ++JeQiXSnQAkpJ17TQkImXgguSgZjD7OsUpncP9zBnHO2dw8OSWmFKOHuWRDNRbL8BkRQKAVwUCyqB ++rAnj5JlT6N8Mb4Bo/J4uGU6stEpZTLNqEKEPSS4y+LB1N/4isorTB3zv93xXe1uyLufIp/wEjdhx ++a1X8O1nVcVEVl3y3jaikhGOMmJAK5lLkIFYa46qgr5dUUQxb0dNQUJrhP/0i5ApImlKlBpFHrxP0 ++iVRKMVLMjMUL+FawuZC5HUVRyolSMCUr+pmWnEqM+PsIEBmdQ5Kwgukk6SvK5xfwlsiFwsfb1Yt5 ++G2yJBiUaadq6x6l5Bxab4Yx35jCwnsM+rTV3TW5JfZUkIZwnCVIfeztK7wJ6La3ek7dI7BA2ih0E ++bCrSSnVl7IswxdKVtY8kXS2kqIqsK4v3KS3QSYx8B8YeZtOuTGGGZ0uhRU613HSRVPaDZt8Jr+iv ++Ra7Zj2K33npfu6FP2m1Nt/vd2Kftd13N2wt8YmNH1cyGxKe2tktNb0lb3u72g3N3J/CJXoJqrifz ++6V7jQ7o39qnNpohMr0f6IfNz6uLmS32VZndx6bLNxSXFDPaRN6NGdM2wFT2rvAuRGXlBMAJvqUbQ ++XJGdz/fYdDY80+PcHlXqsX0oPqH39Rl6iLc/Cp2CExzU2p2CTssJIndwH2n+hnF63zfsQ2VkrR2s ++IMM4VjyGc7xuDOv0krGeHakWwzmtUAzzeI0Y1rHysPE4uTIM++QjF0V/c9HUdyy8I+Nt2W5y+oPp ++/nYc54QV/cfe5dpo7ze9vVqr7S8rK023pbB5nYbLXlBdogPcXIIN92kwiN5Ef/qXQkBAQEBAQEBA ++QEBAQEBAQEBAQEBAQEDAv4KfzoHudgAoAAA= +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-001783/tests/test.sh b/tasks/format-code-task-001783/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c96206f6e23937a150ea389a89a5ed1f9a39b4b5 --- /dev/null +++ b/tasks/format-code-task-001783/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' +lightkurve/tests/test_lightcurve.py +lightkurve/tests/test_targetpixelfile.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-001783/tests/test_command.sh b/tasks/format-code-task-001783/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001783/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-001784/environment/Dockerfile b/tasks/format-code-task-001784/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..900a52398e64b9e4749a385658194d06427f303b --- /dev/null +++ b/tasks/format-code-task-001784/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:9801d2226d2806351062e95ca0c27d4e22485ca41021c9bc516696b7276d93a2 diff --git a/tasks/format-code-task-001784/environment/setup/files/blocklist b/tasks/format-code-task-001784/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001784/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-001784/environment/setup/setup.sh b/tasks/format-code-task-001784/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001784/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-001784/tests/test.patch b/tasks/format-code-task-001784/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..98377832e946854d0cbdba79b690643d1d979b11 --- /dev/null +++ b/tasks/format-code-task-001784/tests/test.patch @@ -0,0 +1,227 @@ +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,205 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++CLI=/workspace/repo/backup/backup-cli ++CLI_PYTHON=/workspace/repo/backup/.venv/bin/python ++[ -x "$CLI" ] || fail "backup-cli is not executable" ++[ -x "$CLI_PYTHON" ] || fail "backup virtualenv python is not executable" ++ ++backup_cli() { ++ ++ ++ "$CLI_PYTHON" "$CLI" "$@" ++} ++ ++( cd /workspace/repo/backup && backup_cli restore --help > /tmp/backup-cli-restore-help.out 2> /tmp/backup-cli-restore-help.err ) \ ++ || fail "backup-cli restore help is unavailable" ++ ++ ++[ -s /tmp/backup-cli-restore-help.out ] || fail "backup-cli restore help is empty" ++grep -Eiq 'backend[-_ ]?url|backend' /tmp/backup-cli-restore-help.out \ ++ || fail "restore help does not mention the backend URL argument" ++grep -Eiq 'restore[-_ ]?destination|destination' /tmp/backup-cli-restore-help.out \ ++ || fail "restore help does not mention the restore destination argument" ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP" /tmp/backup-cli-restore-help.out /tmp/backup-cli-restore-help.err' EXIT ++cd "$TMP" || exit 1 ++ ++python3 - "$TMP" <<'PY' ++import os ++import sqlite3 ++import struct ++import sys ++ ++base = sys.argv[1] ++ ++ ++def snapshot_db(path): ++ db = sqlite3.connect(path) ++ db.execute("CREATE TABLE kv (key TEXT PRIMARY KEY, val TEXT NOT NULL)") ++ db.execute("CREATE TABLE audit (id INTEGER PRIMARY KEY, note TEXT NOT NULL)") ++ db.execute("INSERT INTO kv VALUES ('phase', 'snapshot')") ++ db.execute("INSERT INTO audit VALUES (1, 'snapshot-row')") ++ db.commit() ++ db.close() ++ ++ ++def write_backup(path, changes): ++ offset = 512 ++ version = 0 ++ prev_offset = 0 ++ with open(path, "wb") as f: ++ f.write(b"\0" * 512) ++ for version, typ, payload in changes: ++ prev_offset = offset ++ f.seek(offset) ++ f.write(struct.pack("!IIb", len(payload), version, typ)) ++ f.write(payload) ++ offset += 9 + len(payload) ++ ++ prev_version = changes[-2][0] if len(changes) > 1 else 0 ++ header = struct.pack( ++ "!IIQIQQ", ++ 1, ++ version, ++ offset, ++ prev_version, ++ prev_offset if changes else 0, ++ len(changes), ++ ) ++ f.seek(0) ++ f.write(header + b"\0" * (512 - len(header))) ++ ++ ++snapshot_path = os.path.join(base, "snapshot.sqlite3") ++snapshot_db(snapshot_path) ++ ++snapshot_changes = [ ++ (4, 2, open(snapshot_path, "rb").read()), ++ ( ++ 5, ++ 1, ++ b"\0".join( ++ s.encode("utf-8") ++ for s in [ ++ "UPDATE kv SET val = val || '|tx1' WHERE key = 'phase'", ++ "INSERT INTO audit(id, note) VALUES (2, 'first transaction')", ++ ] ++ ), ++ ), ++ ( ++ 6, ++ 1, ++ b"\0".join( ++ s.encode("utf-8") ++ for s in [ ++ "UPDATE kv SET val = val || '|tx2' WHERE key = 'phase'", ++ "INSERT INTO audit(id, note) VALUES (3, 'second transaction')", ++ ] ++ ), ++ ), ++] ++write_backup(os.path.join(base, "snapshot-and-transactions.dbak"), snapshot_changes) ++ ++transaction_only_changes = [ ++ ( ++ 1, ++ 1, ++ b"\0".join( ++ s.encode("utf-8") ++ for s in [ ++ "CREATE TABLE kv (key TEXT PRIMARY KEY, val TEXT NOT NULL)", ++ "INSERT INTO kv VALUES ('created', 'from-tx')", ++ ] ++ ), ++ ), ++ ( ++ 2, ++ 1, ++ b"\0".join( ++ s.encode("utf-8") ++ for s in [ ++ "UPDATE kv SET val = val || '-second' WHERE key = 'created'", ++ ] ++ ), ++ ), ++] ++write_backup(os.path.join(base, "transactions-only.dbak"), transaction_only_changes) ++PY ++ ++db_dump() { ++ python3 - "$1" <<'PY' ++import sqlite3 ++import sys ++ ++db = sqlite3.connect(sys.argv[1]) ++for row in db.execute("SELECT key, val FROM kv ORDER BY key"): ++ print("kv|{}|{}".format(*row)) ++if db.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='audit'").fetchone(): ++ for row in db.execute("SELECT id, note FROM audit ORDER BY id"): ++ print("audit|{}|{}".format(*row)) ++db.close() ++PY ++} ++ ++ ++ ++ ++backup_cli restore "file://$TMP/snapshot-and-transactions.dbak" "$TMP/explicit.sqlite3" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++[ ! -s out ] || fail "F1 stdout: $(cat out)" ++[ ! -s err ] || fail "F1 stderr: $(cat err)" ++[ -f "$TMP/explicit.sqlite3" ] || fail "F1 did not create explicit destination database" ++EXPECTED_F1='kv|phase|snapshot|tx1|tx2 ++audit|1|snapshot-row ++audit|2|first transaction ++audit|3|second transaction' ++ACTUAL_F1=$(db_dump "$TMP/explicit.sqlite3") ++[ "$ACTUAL_F1" = "$EXPECTED_F1" ] || fail "F1 database dump: $ACTUAL_F1" ++ ++ ++ ++ ++mkdir "$TMP/node" ++backup_cli restore "file://$TMP/snapshot-and-transactions.dbak" "$TMP/node" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++[ ! -s out ] || fail "F2 stdout: $(cat out)" ++[ ! -s err ] || fail "F2 stderr: $(cat err)" ++[ -f "$TMP/node/lightningd.sqlite3" ] || fail "F2 did not create lightningd.sqlite3 inside directory" ++ACTUAL_F2=$(db_dump "$TMP/node/lightningd.sqlite3") ++[ "$ACTUAL_F2" = "$EXPECTED_F1" ] || fail "F2 database dump: $ACTUAL_F2" ++ ++ ++ ++ ++backup_cli restore "file://$TMP/transactions-only.dbak" "$TMP/transactions-only.sqlite3" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++[ ! -s out ] || fail "F3 stdout: $(cat out)" ++[ ! -s err ] || fail "F3 stderr: $(cat err)" ++EXPECTED_F3='kv|created|from-tx-second' ++ACTUAL_F3=$(db_dump "$TMP/transactions-only.sqlite3") ++[ "$ACTUAL_F3" = "$EXPECTED_F3" ] || fail "F3 database dump: $ACTUAL_F3" ++ ++ ++ ++ ++backup_cli restore "file://$TMP/snapshot-and-transactions.dbak" "$TMP/explicit.sqlite3" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F4 exit $ec; want non-zero" ++grep -Fq "Destination for backup restore exists: $TMP/explicit.sqlite3" err \ ++ || fail "F4 stderr missing existing-destination error: $(cat err)" ++ ++ ++ ++ ++backup_cli restore "file://$TMP/snapshot-and-transactions.dbak" "$TMP/node" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F5 exit $ec; want non-zero" ++grep -Fq "Destination for backup restore exists: $TMP/node/lightningd.sqlite3" err \ ++ || fail "F5 stderr missing existing-destination error: $(cat err)" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-001784/tests/test.sh b/tasks/format-code-task-001784/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-001784/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-001784/tests/test_command.sh b/tasks/format-code-task-001784/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001784/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-001850/environment/Dockerfile b/tasks/format-code-task-001850/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5bfdf733511272000c60f50a95d0fd2420ec98df --- /dev/null +++ b/tasks/format-code-task-001850/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:51bd423a8c1477da6259ab03afb594f06652deb228f156932f4a606ad3ee5567 diff --git a/tasks/format-code-task-001850/environment/setup/files/blocklist b/tasks/format-code-task-001850/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001850/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-001850/environment/setup/setup.sh b/tasks/format-code-task-001850/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001850/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-001850/tests/test.patch b/tasks/format-code-task-001850/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9e3dc6639453cba611e8ed22f22a9096772eb251 --- /dev/null +++ b/tasks/format-code-task-001850/tests/test.patch @@ -0,0 +1,52 @@ +diff --git a/tests/_ast/test_sql_visitor.py b/tests/_ast/test_sql_visitor.py +index cfd824e926f..58f321b3340 100644 +--- a/tests/_ast/test_sql_visitor.py ++++ b/tests/_ast/test_sql_visitor.py +@@ -345,7 +345,7 @@ def test_find_sql_defs_many_comments( + + @staticmethod + def test_find_sql_defs_weird_names() -> None: +- sql = """ ++ sql = r""" + CREATE TABLE "my--table" ( + "column/*with*/comment" INT, + "another--column" VARCHAR +@@ -362,6 +362,9 @@ def test_find_sql_defs_weird_names() -> None: + CREATE TABLE "my/*weird*/table" (id INT); + + CREATE TABLE "with a space" (id INT); ++ ++ CREATE TABLE 'single-quotes' (id INT); ++ CREATE TABLE e'escaped\ntable' (id INT); + """ + assert find_sql_defs(sql) == SQLDefs( + [ +@@ -369,6 +372,8 @@ def test_find_sql_defs_weird_names() -> None: + "my_table_with_select", + "my/*weird*/table", + "with a space", ++ "single-quotes", ++ r"escaped\ntable", + ], + [], + [], +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+3S0QrCIBQGYK/3FOcFcnPL9jjDbUJCmzXPhN4+WxdFUN0UEf3fheeAB1R+ZTu7 ++Xd/YMebiU4qk1nqpyX1deqVLpTZ1WdZKFKkrtCD9sRvdmAObiUhM3vOzuVf7P0pe82cbuOn8MJix ++l2H7vjNe5a8qdc2/qlL+640qBRXvu8Jjf55/19MSfGv7LPh56izJeP4NrRtz07GLhm22P/LWj7Qa ++KHVpms5LyBsT+PJtwmHXRBcc+0nuj7SK2bcfBgAAAAAAAAAAAAAAAAAAAADwB04sf1nWACgAAA== +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-001850/tests/test.sh b/tasks/format-code-task-001850/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d149f616d5b60dcb31986a0075110066906c35da --- /dev/null +++ b/tasks/format-code-task-001850/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/_ast/test_sql_visitor.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-001850/tests/test_command.sh b/tasks/format-code-task-001850/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001850/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-001857/environment/Dockerfile b/tasks/format-code-task-001857/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ba4fe0559a52e8a2e87e2db4359182eb28f9c4e1 --- /dev/null +++ b/tasks/format-code-task-001857/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:a02373f4ea13d2089d967801b39df01d1aab6167fc601a68cbec816353039555 diff --git a/tasks/format-code-task-001857/environment/setup/files/blocklist b/tasks/format-code-task-001857/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001857/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-001857/environment/setup/setup.sh b/tasks/format-code-task-001857/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001857/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-001857/tests/test.patch b/tasks/format-code-task-001857/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e3d75acdca4777b101d3ca7563f99330e0cd7503 --- /dev/null +++ b/tasks/format-code-task-001857/tests/test.patch @@ -0,0 +1,454 @@ +diff --git a/usercase-test-coderl/curtains_scroll_lifecycle.test.js b/usercase-test-coderl/curtains_scroll_lifecycle.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/curtains_scroll_lifecycle.test.js +@@ -0,0 +1,428 @@ ++import assert from "node:assert/strict"; ++import test from "node:test"; ++ ++ ++ ++ ++ ++ ++ ++ ++class FakeElement { ++ constructor(tagName = "div") { ++ this.tagName = tagName.toUpperCase(); ++ this.children = []; ++ this.parentNode = null; ++ this.style = {}; ++ this.attributes = new Map(); ++ this._listeners = new Map(); ++ this.width = 0; ++ this.height = 0; ++ } ++ ++ setAttribute(name, value) { ++ this.attributes.set(name, String(value)); ++ if(name === "id") { ++ this.id = String(value); ++ globalThis.document?._elements?.set(this.id, this); ++ } ++ } ++ ++ appendChild(child) { ++ this.children.push(child); ++ child.parentNode = this; ++ return child; ++ } ++ ++ removeChild(child) { ++ const index = this.children.indexOf(child); ++ if(index !== -1) { ++ this.children.splice(index, 1); ++ } ++ child.parentNode = null; ++ return child; ++ } ++ ++ getBoundingClientRect() { ++ return {width: 320, height: 240, top: 7, left: 11}; ++ } ++ ++ addEventListener(type, handler, options) { ++ const listeners = this._listeners.get(type) || []; ++ listeners.push({handler, options}); ++ this._listeners.set(type, listeners); ++ } ++ ++ removeEventListener(type, handler) { ++ const listeners = this._listeners.get(type) || []; ++ this._listeners.set(type, listeners.filter((entry) => entry.handler !== handler)); ++ } ++ ++ dispatchEvent(event) { ++ const listeners = this._listeners.get(event.type) || []; ++ for(const {handler} of [...listeners]) { ++ handler.call(this, event); ++ } ++ } ++ ++ getContext() { ++ if(this.tagName !== "CANVAS") { ++ return null; ++ } ++ ++ return createFakeGL(); ++ } ++} ++ ++function createFakeGL() { ++ return { ++ MAX_TEXTURE_SIZE: 0x0D33, ++ DEPTH_TEST: 0x0B71, ++ BLEND: 0x0BE2, ++ LEQUAL: 0x0203, ++ ONE: 1, ++ ONE_MINUS_SRC_ALPHA: 0x0303, ++ SRC_ALPHA: 0x0302, ++ COLOR_BUFFER_BIT: 0x4000, ++ DEPTH_BUFFER_BIT: 0x0100, ++ CULL_FACE: 0x0B44, ++ FRONT: 0x0404, ++ BACK: 0x0405, ++ FRAMEBUFFER: 0x8D40, ++ drawingBufferWidth: 320, ++ drawingBufferHeight: 240, ++ ++ getParameter(parameter) { ++ return parameter === this.MAX_TEXTURE_SIZE ? 4096 : 0; ++ }, ++ ++ getExtension(name) { ++ return name === "WEBGL_lose_context" ++ ? {loseContext() {}, restoreContext() {}} ++ : {}; ++ }, ++ ++ viewport() {}, ++ enable() {}, ++ disable() {}, ++ depthFunc() {}, ++ blendFuncSeparate() {}, ++ clear() {}, ++ deleteProgram() {}, ++ bindFramebuffer() {}, ++ cullFace() {}, ++ useProgram() {}, ++ }; ++} ++ ++function installBrowserHarness() { ++ const windowListeners = new Map(); ++ let rafId = 0; ++ ++ globalThis.Element = FakeElement; ++ globalThis.navigator = {userAgent: "node-test"}; ++ globalThis.document = { ++ _elements: new Map(), ++ body: new FakeElement("body"), ++ createElement(tagName) { ++ return new FakeElement(tagName); ++ }, ++ getElementById(id) { ++ return this._elements.get(id) || null; ++ }, ++ }; ++ ++ globalThis.window = { ++ devicePixelRatio: 1, ++ pageXOffset: 10, ++ pageYOffset: 20, ++ MSStream: false, ++ ++ addEventListener(type, handler, options) { ++ const listeners = windowListeners.get(type) || []; ++ listeners.push({handler, options}); ++ windowListeners.set(type, listeners); ++ }, ++ ++ removeEventListener(type, handler) { ++ const listeners = windowListeners.get(type) || []; ++ windowListeners.set(type, listeners.filter((entry) => entry.handler !== handler)); ++ }, ++ ++ dispatchEvent(event) { ++ const listeners = windowListeners.get(event.type) || []; ++ for(const {handler} of [...listeners]) { ++ handler.call(globalThis.window, event); ++ } ++ }, ++ ++ requestAnimationFrame() { ++ rafId += 1; ++ return rafId; ++ }, ++ ++ cancelAnimationFrame() {}, ++ }; ++ ++ return { ++ listenerCount(type) { ++ return (windowListeners.get(type) || []).length; ++ }, ++ async flushDispose(curtains) { ++ await new Promise((resolve) => setTimeout(resolve, 0)); ++ curtains.render(); ++ }, ++ }; ++} ++ ++const harness = installBrowserHarness(); ++const {Curtains} = await import("../src/index.mjs"); ++ ++function createCurtains(options = {}) { ++ const container = new FakeElement("div"); ++ return new Curtains({ ++ container, ++ autoRender: false, ++ autoResize: false, ++ production: true, ++ ...options, ++ }); ++} ++ ++async function disposeCurtains(curtains) { ++ curtains.dispose(); ++ await harness.flushDispose(curtains); ++} ++ ++test("manual scroll updates track values, deltas, planes, forced render, and callback", async () => { ++ ++ ++ ++ ++ window.pageXOffset = 10; ++ window.pageYOffset = 20; ++ ++ const curtains = createCurtains({watchScroll: true}); ++ let callbackCalls = 0; ++ const returned = curtains.onScroll(() => { ++ callbackCalls += 1; ++ }); ++ const watchedPlane = { ++ watchScroll: true, ++ calls: [], ++ updateScrollPosition(x, y) { ++ this.calls.push([x, y]); ++ }, ++ }; ++ const ignoredPlane = { ++ watchScroll: false, ++ calls: [], ++ updateScrollPosition(x, y) { ++ this.calls.push([x, y]); ++ }, ++ }; ++ curtains.planes.push(watchedPlane, ignoredPlane); ++ curtains.disableDrawing(); ++ ++ assert.deepEqual(curtains.getScrollValues(), {x: 10, y: 20}); ++ assert.deepEqual(curtains.getScrollDeltas(), {x: 0, y: 0}); ++ assert.equal(returned, curtains); ++ assert.equal(callbackCalls, 0); ++ assert.equal(curtains.renderer.state.forceRender, false); ++ ++ curtains.updateScrollValues(15, 5); ++ ++ assert.deepEqual(curtains.getScrollValues(), {x: 15, y: 5}); ++ assert.deepEqual(curtains.getScrollDeltas(), {x: -5, y: 15}); ++ assert.deepEqual(watchedPlane.calls, [[-5, 15]]); ++ assert.deepEqual(ignoredPlane.calls, []); ++ assert.equal(curtains.renderer.state.forceRender, true); ++ assert.equal(callbackCalls, 1); ++ ++ await disposeCurtains(curtains); ++}); ++ ++test("watchScroll false skips native scroll listener but still accepts manual updates", async () => { ++ ++ ++ ++ ++ window.pageXOffset = 10; ++ window.pageYOffset = 20; ++ const listenerBaseline = harness.listenerCount("scroll"); ++ ++ const curtains = createCurtains({watchScroll: false}); ++ let callbackCalls = 0; ++ curtains.onScroll(() => { ++ callbackCalls += 1; ++ }); ++ ++ assert.equal(harness.listenerCount("scroll"), listenerBaseline); ++ assert.deepEqual(curtains.getScrollValues(), {x: 10, y: 20}); ++ assert.deepEqual(curtains.getScrollDeltas(), {x: 0, y: 0}); ++ ++ curtains.updateScrollValues(17, 25); ++ ++ assert.deepEqual(curtains.getScrollValues(), {x: 17, y: 25}); ++ assert.deepEqual(curtains.getScrollDeltas(), {x: -7, y: -5}); ++ assert.equal(callbackCalls, 1); ++ ++ window.pageXOffset = 30; ++ window.pageYOffset = 40; ++ window.dispatchEvent({type: "scroll"}); ++ ++ assert.deepEqual(curtains.getScrollValues(), {x: 17, y: 25}); ++ assert.deepEqual(curtains.getScrollDeltas(), {x: -7, y: -5}); ++ assert.equal(callbackCalls, 1); ++ ++ await disposeCurtains(curtains); ++}); ++ ++test("omitted watchScroll behaves like true and native scroll events use window offsets", async () => { ++ ++ ++ ++ ++ window.pageXOffset = 10; ++ window.pageYOffset = 20; ++ const listenerBaseline = harness.listenerCount("scroll"); ++ ++ const curtains = createCurtains(); ++ let callbackCalls = 0; ++ curtains.onScroll(() => { ++ callbackCalls += 1; ++ }); ++ ++ assert.equal(harness.listenerCount("scroll"), listenerBaseline + 1); ++ assert.deepEqual(curtains.getScrollValues(), {x: 10, y: 20}); ++ assert.deepEqual(curtains.getScrollDeltas(), {x: 0, y: 0}); ++ ++ window.pageXOffset = 30; ++ window.pageYOffset = 40; ++ window.dispatchEvent({type: "scroll"}); ++ ++ assert.deepEqual(curtains.getScrollValues(), {x: 30, y: 40}); ++ assert.deepEqual(curtains.getScrollDeltas(), {x: -20, y: -20}); ++ assert.equal(callbackCalls, 1); ++ ++ await disposeCurtains(curtains); ++}); ++ ++test("resize refreshes watched scroll offsets from the window without changing deltas", async () => { ++ ++ ++ ++ ++ window.pageXOffset = 10; ++ window.pageYOffset = 20; ++ ++ const curtains = createCurtains({watchScroll: true}); ++ assert.deepEqual(curtains.getScrollValues(), {x: 10, y: 20}); ++ assert.deepEqual(curtains.getScrollDeltas(), {x: 0, y: 0}); ++ ++ window.pageXOffset = 100; ++ window.pageYOffset = 200; ++ curtains.resize(false); ++ ++ assert.deepEqual(curtains.getScrollValues(), {x: 100, y: 200}); ++ assert.deepEqual(curtains.getScrollDeltas(), {x: 0, y: 0}); ++ ++ await disposeCurtains(curtains); ++}); ++ ++test("scroll state is independent across Curtains instances", async () => { ++ ++ ++ ++ ++ window.pageXOffset = 10; ++ window.pageYOffset = 20; ++ ++ const a = createCurtains({watchScroll: false}); ++ const b = createCurtains({watchScroll: false}); ++ ++ assert.deepEqual(a.getScrollValues(), {x: 10, y: 20}); ++ assert.deepEqual(b.getScrollValues(), {x: 10, y: 20}); ++ ++ a.updateScrollValues(2, 3); ++ ++ assert.deepEqual(a.getScrollValues(), {x: 2, y: 3}); ++ assert.deepEqual(a.getScrollDeltas(), {x: 8, y: 17}); ++ assert.deepEqual(b.getScrollValues(), {x: 10, y: 20}); ++ assert.deepEqual(b.getScrollDeltas(), {x: 0, y: 0}); ++ ++ await disposeCurtains(a); ++ await disposeCurtains(b); ++}); ++ ++test("native scroll listener is removed during dispose and dispose is idempotent", async () => { ++ ++ ++ ++ ++ window.pageXOffset = 10; ++ window.pageYOffset = 20; ++ const listenerBaseline = harness.listenerCount("scroll"); ++ ++ const curtains = createCurtains({watchScroll: true}); ++ let callbackCalls = 0; ++ curtains.onScroll(() => { ++ callbackCalls += 1; ++ }); ++ ++ assert.equal(harness.listenerCount("scroll"), listenerBaseline + 1); ++ ++ await disposeCurtains(curtains); ++ assert.equal(harness.listenerCount("scroll"), listenerBaseline); ++ ++ window.pageXOffset = 90; ++ window.pageYOffset = 100; ++ window.dispatchEvent({type: "scroll"}); ++ ++ assert.equal(callbackCalls, 0); ++ ++ curtains.dispose(); ++ assert.equal(harness.listenerCount("scroll"), listenerBaseline); ++}); ++ ++test("watchScroll option survives delayed container initialization", async () => { ++ ++ ++ ++ ++ window.pageXOffset = 10; ++ window.pageYOffset = 20; ++ const listenerBaseline = harness.listenerCount("scroll"); ++ ++ const curtains = new Curtains({watchScroll: false, autoRender: false, autoResize: false, production: true}); ++ ++ curtains.setContainer(new FakeElement("div")); ++ ++ ++ assert.equal(harness.listenerCount("scroll"), listenerBaseline); ++ curtains.updateScrollValues(1, 2); ++ assert.deepEqual(curtains.getScrollValues(), {x: 1, y: 2}); ++ assert.deepEqual(curtains.getScrollDeltas(), {x: 9, y: 18}); ++ ++ await disposeCurtains(curtains); ++}); ++ ++test("repeated construct-use-dispose cycles do not leak scroll listeners", async () => { ++ ++ ++ ++ ++ window.pageXOffset = 10; ++ window.pageYOffset = 20; ++ const listenerBaseline = harness.listenerCount("scroll"); ++ ++ for(let i = 0; i < 100; i++) { ++ const curtains = createCurtains({watchScroll: true}); ++ curtains.updateScrollValues(15, 5); ++ assert.deepEqual(curtains.getScrollValues(), {x: 15, y: 5}); ++ assert.deepEqual(curtains.getScrollDeltas(), {x: -5, y: 15}); ++ await disposeCurtains(curtains); ++ } ++ ++ assert.equal(harness.listenerCount("scroll"), listenerBaseline); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++exec node --test /workspace/repo/usercase-test-coderl/curtains_scroll_lifecycle.test.js diff --git a/tasks/format-code-task-001857/tests/test.sh b/tasks/format-code-task-001857/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c5b11f3e8fecc548ced8296d4d6bb140f8d0c8d --- /dev/null +++ b/tasks/format-code-task-001857/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/curtains_scroll_lifecycle.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-001857/tests/test_command.sh b/tasks/format-code-task-001857/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001857/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-001859/environment/Dockerfile b/tasks/format-code-task-001859/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3c3bb5e4ee92beaf33104725031c81b21544a152 --- /dev/null +++ b/tasks/format-code-task-001859/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:38e0c0ef7104e5094151e961940dd71c742a16c39c4d886af7c9bee0240b1e0d diff --git a/tasks/format-code-task-001859/environment/setup/setup.sh b/tasks/format-code-task-001859/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001859/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-001859/tests/test.patch b/tasks/format-code-task-001859/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..def5b529340ec73cdb611558e1a25403878a5c5e --- /dev/null +++ b/tasks/format-code-task-001859/tests/test.patch @@ -0,0 +1,132 @@ +diff --git a/tests/test_evaluate_neg_sampling.py b/tests/test_evaluate_neg_sampling.py +new file mode 100644 +index 0000000..0584f68 +--- /dev/null ++++ b/tests/test_evaluate_neg_sampling.py +@@ -0,0 +1,106 @@ ++ ++ ++ ++ ++ ++ ++ ++import numpy as np ++import pandas as pd ++import pytest ++ ++from libreco.data import DatasetPure, TransformedSet, split_by_ratio_chrono ++from libreco.evaluation import evaluate ++ ++ ++@pytest.fixture(scope="module") ++def data_info(): ++ rng = np.random.default_rng(42) ++ size = 200 ++ pd_data = pd.DataFrame( ++ { ++ "user": rng.integers(0, 20, size), ++ "item": rng.integers(0, 30, size), ++ "label": rng.integers(1, 6, size), ++ "time": rng.integers(10000, 20000, size), ++ } ++ ) ++ train_data, _ = split_by_ratio_chrono(pd_data, test_size=0.2) ++ _, info = DatasetPure.build_trainset(train_data) ++ return info ++ ++ ++class FakeModel: ++ ++ ++ def __init__(self, task, data_info): ++ self.task = task ++ self.data_info = data_info ++ self.n_users = data_info.n_users ++ self.n_items = data_info.n_items ++ ++ def predict(self, users, items, inner_id=True): ++ users = np.atleast_1d(users) ++ return np.full(len(users), 0.5, dtype=np.float32) ++ ++ ++def make_transformed(user_indices, item_indices, labels): ++ return TransformedSet( ++ np.asarray(user_indices, dtype=np.int64), ++ np.asarray(item_indices, dtype=np.int64), ++ np.asarray(labels, dtype=np.float32), ++ train=False, ++ ) ++ ++ ++def test_neg_sampling_is_required(data_info): ++ model = FakeModel("ranking", data_info) ++ data = make_transformed([0, 1, 2], [0, 1, 2], [1, 0, 1]) ++ with pytest.raises(TypeError): ++ evaluate(model, data) ++ ++ ++def test_ranking_non_binary_without_neg_sampling_raises(data_info): ++ model = FakeModel("ranking", data_info) ++ ++ data = make_transformed([0, 1, 2, 3], [0, 1, 2, 3], [5, 3, 1, 4]) ++ with pytest.raises(ValueError): ++ evaluate(model, data, neg_sampling=False, metrics=["roc_auc"]) ++ ++ ++def test_ranking_only_positive_without_neg_sampling_raises(data_info): ++ model = FakeModel("ranking", data_info) ++ ++ data = make_transformed([0, 1, 2, 3], [0, 1, 2, 3], [1, 1, 1, 1]) ++ with pytest.raises(ValueError): ++ evaluate(model, data, neg_sampling=False, metrics=["roc_auc"]) ++ ++ ++def test_ranking_binary_without_neg_sampling_ok(data_info): ++ model = FakeModel("ranking", data_info) ++ data = make_transformed([0, 0, 1, 1, 2, 2], [0, 1, 2, 3, 4, 5], ++ [1, 0, 1, 0, 1, 0]) ++ result = evaluate(model, data, neg_sampling=False, metrics=["roc_auc"]) ++ assert isinstance(result, dict) ++ assert "roc_auc" in result ++ ++ ++def test_rating_without_neg_sampling_allows_non_binary(data_info): ++ model = FakeModel("rating", data_info) ++ data = make_transformed([0, 1, 2, 3], [0, 1, 2, 3], [5, 3, 1, 4]) ++ result = evaluate(model, data, neg_sampling=False, metrics=["rmse"]) ++ assert isinstance(result, dict) ++ assert "rmse" in result ++ ++ ++def test_neg_sampling_true_generates_negatives_for_positive_only_ranking(data_info): ++ model = FakeModel("ranking", data_info) ++ ++ ++ users = list(range(10)) ++ items = list(range(10)) ++ labels = [1] * 10 ++ data = make_transformed(users, items, labels) ++ result = evaluate(model, data, neg_sampling=True, metrics=["roc_auc"]) ++ assert isinstance(result, dict) ++ assert "roc_auc" in result +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,15 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++python -m pytest tests/test_data.py -q ++ ++ ++python -m pytest tests/test_evaluate_neg_sampling.py -q diff --git a/tasks/format-code-task-001859/tests/test.sh b/tasks/format-code-task-001859/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..71d2dfe3a1895df7792a1f23d439133a9f9345c8 --- /dev/null +++ b/tasks/format-code-task-001859/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_evaluate_neg_sampling.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-001859/tests/test_command.sh b/tasks/format-code-task-001859/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001859/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-001861/environment/Dockerfile b/tasks/format-code-task-001861/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ab81ae4fa43f8840aa446b0ed3725e117d2eb29a --- /dev/null +++ b/tasks/format-code-task-001861/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:bfb0d39920e7764535d270db62ff1eab125ff39ea136b67e02d04c3639c98d7a diff --git a/tasks/format-code-task-001861/environment/setup/files/blocklist b/tasks/format-code-task-001861/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001861/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-001861/environment/setup/setup.sh b/tasks/format-code-task-001861/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001861/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-001861/tests/test.patch b/tasks/format-code-task-001861/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8bd429c31974584bb4ec4e8cf04ec87c3946d624 --- /dev/null +++ b/tasks/format-code-task-001861/tests/test.patch @@ -0,0 +1,143 @@ +diff --git a/tests/rest/admin/test_event_reports.py b/tests/rest/admin/test_event_reports.py +index 29341bc6e98f..f15d1cf6f7c8 100644 +--- a/tests/rest/admin/test_event_reports.py ++++ b/tests/rest/admin/test_event_reports.py +@@ -64,7 +64,7 @@ def prepare(self, reactor, clock, hs): + user_tok=self.admin_user_tok, + ) + for _ in range(5): +- self._create_event_and_report( ++ self._create_event_and_report_without_parameters( + room_id=self.room_id2, + user_tok=self.admin_user_tok, + ) +@@ -378,6 +378,19 @@ def _create_event_and_report(self, room_id, user_tok): + ) + self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"]) + ++ def _create_event_and_report_without_parameters(self, room_id, user_tok): ++ """Create and report an event, but omit reason and score""" ++ resp = self.helper.send(room_id, tok=user_tok) ++ event_id = resp["event_id"] ++ ++ channel = self.make_request( ++ "POST", ++ "rooms/%s/report/%s" % (room_id, event_id), ++ json.dumps({}), ++ access_token=user_tok, ++ ) ++ self.assertEqual(200, int(channel.result["code"]), msg=channel.result["body"]) ++ + def _check_fields(self, content): + """Checks that all attributes are present in an event report""" + for c in content: +diff --git a/tests/rest/client/v2_alpha/test_report_event.py b/tests/rest/client/v2_alpha/test_report_event.py +new file mode 100644 +index 000000000000..1ec6b05e5bd2 +--- /dev/null ++++ b/tests/rest/client/v2_alpha/test_report_event.py +@@ -0,0 +1,83 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import json ++ ++import synapse.rest.admin ++from synapse.rest.client.v1 import login, room ++from synapse.rest.client.v2_alpha import report_event ++ ++from tests import unittest ++ ++ ++class ReportEventTestCase(unittest.HomeserverTestCase): ++ servlets = [ ++ synapse.rest.admin.register_servlets, ++ login.register_servlets, ++ room.register_servlets, ++ report_event.register_servlets, ++ ] ++ ++ def prepare(self, reactor, clock, hs): ++ self.admin_user = self.register_user("admin", "pass", admin=True) ++ self.admin_user_tok = self.login("admin", "pass") ++ self.other_user = self.register_user("user", "pass") ++ self.other_user_tok = self.login("user", "pass") ++ ++ self.room_id = self.helper.create_room_as( ++ self.other_user, tok=self.other_user_tok, is_public=True ++ ) ++ self.helper.join(self.room_id, user=self.admin_user, tok=self.admin_user_tok) ++ resp = self.helper.send(self.room_id, tok=self.admin_user_tok) ++ self.event_id = resp["event_id"] ++ self.report_path = "rooms/{}/report/{}".format(self.room_id, self.event_id) ++ ++ def test_reason_str_and_score_int(self): ++ data = {"reason": "this makes me sad", "score": -100} ++ self._assert_status(200, data) ++ ++ def test_no_reason(self): ++ data = {"score": 0} ++ self._assert_status(200, data) ++ ++ def test_no_score(self): ++ data = {"reason": "this makes me sad"} ++ self._assert_status(200, data) ++ ++ def test_no_reason_and_no_score(self): ++ data = {} ++ self._assert_status(200, data) ++ ++ def test_reason_int_and_score_str(self): ++ data = {"reason": 10, "score": "string"} ++ self._assert_status(400, data) ++ ++ def test_reason_zero_and_score_blank(self): ++ data = {"reason": 0, "score": ""} ++ self._assert_status(400, data) ++ ++ def test_reason_and_score_null(self): ++ data = {"reason": None, "score": None} ++ self._assert_status(400, data) ++ ++ def _assert_status(self, response_status, data): ++ channel = self.make_request( ++ "POST", ++ self.report_path, ++ json.dumps(data), ++ access_token=self.other_user_tok, ++ ) ++ self.assertEqual( ++ response_status, int(channel.result["code"]), msg=channel.result["body"] ++ ) +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+3SzYrDIBQFYNd5CodZN/404uMEE4UEEg1qA337sQm0ZWCmm5ahzPkWKvFelBzr ++7jROtnV+ZeRVeKGV2ubi+7ythZJCCsEl14QLoTQnVL3sRndOKZtIKYkh5N/qHu2/qfqWf3Ypt32Y ++Z+NtnYbnnfEof8mba/7i2JT8G6U1ofx5V/jZP8//84N1o2edSUPVW7o9gs7ZajnnIfgjPcy0LMtH ++ehkSi2Vkxs6lZ3svbnU+t9EtIeZUL+f7sn4ayyZbZWumZTB7w166913qD2v11/8AAAAAAAAAAAAA ++AAAAAAAAAOBdfQFSbZ43ACgAAA== +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-001861/tests/test.sh b/tasks/format-code-task-001861/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..00156bf1133a5d11eec88f36ef45555bbc966093 --- /dev/null +++ b/tasks/format-code-task-001861/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/rest/admin/test_event_reports.py +tests/rest/client/v2_alpha/test_report_event.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-001861/tests/test_command.sh b/tasks/format-code-task-001861/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001861/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-001868/environment/Dockerfile b/tasks/format-code-task-001868/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e298f74f2609a64320527d150312b483cfa10c09 --- /dev/null +++ b/tasks/format-code-task-001868/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:cce7dd60c880e4b461020c203d8644f0e7bee7cba06f2ac0e090b2298d35befd diff --git a/tasks/format-code-task-001868/environment/setup/files/blocklist b/tasks/format-code-task-001868/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001868/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-001868/environment/setup/setup.sh b/tasks/format-code-task-001868/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001868/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-001868/tests/test.patch b/tasks/format-code-task-001868/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e84ae4c577388eeb30d94cf14239e3fa0bb3e7ea --- /dev/null +++ b/tasks/format-code-task-001868/tests/test.patch @@ -0,0 +1,416 @@ +diff --git a/usercase-test-coderl/fixtures/acceptance_settings.py b/usercase-test-coderl/fixtures/acceptance_settings.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/acceptance_settings.py +@@ -0,0 +1,22 @@ ++SECRET_KEY = "acceptance" ++DEBUG = False ++USE_TZ = True ++DEFAULT_AUTO_FIELD = "django.db.models.AutoField" ++INSTALLED_APPS = ( ++ "styles", ++) ++DATABASES = { ++ "default": { ++ "ENGINE": "django.db.backends.sqlite3", ++ "NAME": ":memory:", ++ } ++} ++LANGUAGE_CODE = "en" ++LANGUAGES = ( ++ ("en", "English"), ++ ("cs", "Czech"), ++) ++ROOT_URLCONF = "acceptance_urls" ++MIDDLEWARE = () ++MIDDLEWARE_CLASSES = () ++LOGGING_CONFIG = None +diff --git a/usercase-test-coderl/fixtures/acceptance_urls.py b/usercase-test-coderl/fixtures/acceptance_urls.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/acceptance_urls.py +@@ -0,0 +1,1 @@ ++urlpatterns = [] +diff --git a/usercase-test-coderl/fixtures/sitecustomize.py b/usercase-test-coderl/fixtures/sitecustomize.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/sitecustomize.py +@@ -0,0 +1,182 @@ ++import csv ++import importlib.machinery ++import json ++import os ++import sys ++import types ++ ++ ++class CompatDict(dict): ++ def iteritems(self): ++ return self.items() ++ ++ ++_RealDictReader = csv.DictReader ++ ++ ++class CompatDictReader(_RealDictReader): ++ def __next__(self): ++ row = super(CompatDictReader, self).__next__() ++ return CompatDict(row) ++ ++ next = __next__ ++ ++ ++csv.DictReader = CompatDictReader ++ ++ ++class QuerySet(object): ++ def __init__(self, model, rows): ++ self.model = model ++ self.rows = rows ++ ++ def count(self): ++ return len(self.rows) ++ ++ ++ def exists(self): ++ return bool(self.rows) ++ ++ ++ def first(self): ++ if not self.rows: ++ return None ++ return self.model._from_row(self.rows[0]) ++ ++ ++ def __iter__(self): ++ for row in self.rows: ++ yield self.model._from_row(row) ++ ++ def __getitem__(self, index): ++ return self.model._from_row(self.rows[index]) ++ ++ def update(self, **changed): ++ for row in self.rows: ++ row.update(changed) ++ self.model._save_db() ++ ++ ++class Manager(object): ++ def __init__(self, model): ++ self.model = model ++ ++ def filter(self, **kwargs): ++ self.model._load_db() ++ rows = [ ++ row ++ for row in self.model._rows ++ if all(str(row.get(key)) == str(value) for key, value in kwargs.items()) ++ ] ++ return QuerySet(self.model, rows) ++ ++ def get(self, **kwargs): ++ qs = self.filter(**kwargs) ++ if qs.count() != 1: ++ raise self.model.DoesNotExist() ++ return qs[0] ++ ++ ++ def create(self, **kwargs): ++ instance = self.model(**kwargs) ++ instance.save() ++ return instance ++ ++ ++ def get_or_create(self, defaults=None, **kwargs): ++ try: ++ return self.get(**kwargs), False ++ except self.model.DoesNotExist: ++ data = dict(kwargs) ++ if defaults: ++ data.update(defaults) ++ return self.create(**data), True ++ ++ ++ def update_or_create(self, defaults=None, **kwargs): ++ defaults = defaults or {} ++ try: ++ instance = self.get(**kwargs) ++ for key, value in defaults.items(): ++ setattr(instance, key, value) ++ instance.save() ++ return instance, False ++ except self.model.DoesNotExist: ++ data = dict(kwargs) ++ data.update(defaults) ++ return self.create(**data), True ++ ++ ++class LegendItemName(object): ++ class DoesNotExist(Exception): ++ pass ++ ++ _rows = [] ++ objects = None ++ ++ def __init__(self, **data): ++ self._persisted_slug = data.get("slug") ++ for key, value in data.items(): ++ setattr(self, key, value) ++ ++ def __getattr__(self, name): ++ if name.startswith("name_"): ++ return None ++ raise AttributeError(name) ++ ++ @classmethod ++ def _db_path(cls): ++ path = os.environ.get("LEGEND_DB") ++ if not path: ++ raise RuntimeError("LEGEND_DB is required") ++ return path ++ ++ @classmethod ++ def _load_db(cls): ++ path = cls._db_path() ++ if os.path.exists(path): ++ with open(path, "r") as handle: ++ cls._rows = json.load(handle) ++ else: ++ cls._rows = [] ++ ++ @classmethod ++ def _save_db(cls): ++ path = cls._db_path() ++ directory = os.path.dirname(path) ++ if directory and not os.path.exists(directory): ++ os.makedirs(directory) ++ with open(path, "w") as handle: ++ json.dump(cls._rows, handle, sort_keys=True, separators=(",", ":")) ++ ++ @classmethod ++ def _from_row(cls, row): ++ instance = cls(**row) ++ instance._persisted_slug = row.get("slug") ++ return instance ++ ++ ++ def save(self, *args, **kwargs): ++ self.__class__._load_db() ++ row = dict(self.__dict__) ++ row.pop("_persisted_slug", None) ++ slug = self._persisted_slug or row.get("slug") ++ replaced = False ++ for index, existing in enumerate(self.__class__._rows): ++ if existing.get("slug") == slug: ++ self.__class__._rows[index] = row ++ replaced = True ++ break ++ if not replaced: ++ self.__class__._rows.append(row) ++ self._persisted_slug = row.get("slug") ++ self.__class__._save_db() ++ ++ ++LegendItemName.objects = Manager(LegendItemName) ++ ++models = types.ModuleType("styles.models") ++models.LegendItemName = LegendItemName ++models.__file__ = "acceptance fake styles.models" ++models.__spec__ = importlib.machinery.ModuleSpec("styles.models", loader=None) ++sys.modules["styles.models"] = models +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,174 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++( cd /workspace/repo && python - <<'PY' ++import django ++print(django.get_version()) ++PY ++) >/dev/null || { echo "FAIL: build/import django" >&2; exit 1; } ++ ++BIN=/workspace/repo/manage.py ++FIXTURES=/workspace/repo/usercase-test-coderl/fixtures ++TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++run_load_default_names() { ++ PYTHONPATH="$FIXTURES:/workspace/repo" \ ++ DJANGO_SETTINGS_MODULE=acceptance_settings \ ++ LEGEND_DB="$PWD/db.json" \ ++ python "$BIN" load_default_names >out 2>err ++} ++ ++ ++ ++ ++ ++ ++ ++ ++case1="$TMP/case1"; mkdir -p "$case1/styles/fixtures" "$case1/styles/locale/cs" ++cat > "$case1/styles/fixtures/default_names.csv" <<'CSV' ++slug,group,order,name_en ++existing-full,trails,2,Updated English ++existing-blank,,9, ++new-full,points,5,New English ++new-partial,,7, ++CSV ++cat > "$case1/styles/locale/cs/names.csv" <<'CSV' ++slug,name_en,name_cs ++existing-full,Updated English,Prelozeno ++existing-blank,Keep English, ++new-full,New English,Novy ++unknown-slug,Ghost,Neznamy ++CSV ++cat > "$case1/db.json" <<'JSON' ++[{"slug":"existing-full","group":"old-group","order":1,"name_en":"Old English","name_cs":"Stary"},{"slug":"existing-blank","group":"keep-group","order":3,"name_en":"Keep English","name_cs":"Keep CS"}] ++JSON ++cd "$case1" ++run_load_default_names; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++[ -f db.json ] || fail "F1 db.json was not written" ++ ++python - <<'PY' || fail "F1 db: $(cat db.json)" ++import json ++ ++with open("db.json", "r") as handle: ++ rows = json.load(handle) ++ ++by_slug = {} ++for row in rows: ++ slug = row.get("slug") ++ assert slug and slug not in by_slug, rows ++ by_slug[slug] = row ++ ++assert set(by_slug) == {"existing-full", "existing-blank", "new-full", "new-partial"}, rows ++ ++def order(row): ++ value = row.get("order") ++ return None if value is None else str(value) ++ ++assert by_slug["existing-full"].get("group") == "trails" ++assert order(by_slug["existing-full"]) == "2" ++assert by_slug["existing-full"].get("name_en") == "Updated English" ++assert by_slug["existing-full"].get("name_cs") == "Prelozeno" ++ ++assert by_slug["existing-blank"].get("group") == "keep-group" ++assert order(by_slug["existing-blank"]) == "9" ++assert by_slug["existing-blank"].get("name_en") == "Keep English" ++assert by_slug["existing-blank"].get("name_cs") == "Keep CS" ++ ++assert by_slug["new-full"].get("group") == "points" ++assert order(by_slug["new-full"]) == "5" ++assert by_slug["new-full"].get("name_en") == "New English" ++assert by_slug["new-full"].get("name_cs") == "Novy" ++ ++assert order(by_slug["new-partial"]) == "7" ++assert by_slug["new-partial"].get("group") in (None, "") ++assert by_slug["new-partial"].get("name_en") in (None, "") ++assert by_slug["new-partial"].get("name_cs") in (None, "") ++PY ++ ++grep -q 'unknown-slug' err || fail "F1 missing unknown-slug warning: $(cat err)" ++! grep -q '"unknown-slug"' db.json || fail "F1 unknown translation slug created a row" ++ ++ ++ ++ ++case2="$TMP/case2"; mkdir -p "$case2/styles/locale/cs" ++cat > "$case2/styles/locale/cs/names.csv" <<'CSV' ++slug,name_en,name_cs ++x,X,Y ++CSV ++printf '[]' > "$case2/db.json" ++cd "$case2" ++run_load_default_names; ec=$? ++[ "$ec" -ne 0 ] || fail "F2 expected non-zero exit" ++ ++[ -s err ] || fail "F2 expected diagnostic stderr" ++ ++grep -q "styles/fixtures/default_names.csv" err || fail "F2 stderr: $(cat err)" ++ ++ ++ ++ ++case3="$TMP/case3"; mkdir -p "$case3/styles/fixtures" "$case3/styles/locale" ++cat > "$case3/styles/fixtures/default_names.csv" <<'CSV' ++slug,group,order,name_en ++x,g,1,X ++CSV ++printf '[]' > "$case3/db.json" ++cd "$case3" ++run_load_default_names; ec=$? ++[ "$ec" -ne 0 ] || fail "F3 expected non-zero exit" ++ ++[ -s err ] || fail "F3 expected diagnostic stderr" ++ ++grep -q "styles/locale/cs/names.csv" err || fail "F3 stderr: $(cat err)" ++ ++ ++ ++ ++case4="$TMP/case4"; mkdir -p "$case4/styles/fixtures" "$case4/styles/locale/cs" ++cat > "$case4/styles/fixtures/default_names.csv" <<'CSV' ++group,order,name_en ++g,1,X ++CSV ++cat > "$case4/styles/locale/cs/names.csv" <<'CSV' ++slug,name_en,name_cs ++x,X,Y ++CSV ++printf '[]' > "$case4/db.json" ++cd "$case4" ++run_load_default_names; ec=$? ++[ "$ec" -ne 0 ] || fail "F4 expected non-zero exit" ++ ++[ -s err ] || fail "F4 expected diagnostic stderr" ++ ++grep -q "slug" err || fail "F4 stderr: $(cat err)" ++ ++ ++ ++ ++case5="$TMP/case5"; mkdir -p "$case5/styles/fixtures" "$case5/styles/locale/cs" ++cat > "$case5/styles/fixtures/default_names.csv" <<'CSV' ++slug,group,order,name_en ++x,g,1,X ++CSV ++cat > "$case5/styles/locale/cs/names.csv" <<'CSV' ++slug,name_en ++x,X ++CSV ++printf '[]' > "$case5/db.json" ++cd "$case5" ++run_load_default_names; ec=$? ++[ "$ec" -ne 0 ] || fail "F5 expected non-zero exit" ++ ++[ -s err ] || fail "F5 expected diagnostic stderr" ++ ++grep -q "name_cs" err || fail "F5 stderr: $(cat err)" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-001868/tests/test.sh b/tasks/format-code-task-001868/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5e8f7b6c7711a46b191b236354e98195bd9ea74d --- /dev/null +++ b/tasks/format-code-task-001868/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=/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/acceptance_settings.py +usercase-test-coderl/fixtures/acceptance_urls.py +usercase-test-coderl/fixtures/sitecustomize.py +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-001868/tests/test_command.sh b/tasks/format-code-task-001868/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001868/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-001895/environment/Dockerfile b/tasks/format-code-task-001895/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c3e3132a3fc2bfd0f525111c44971fd6d0e79df8 --- /dev/null +++ b/tasks/format-code-task-001895/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:61adda5faefde53a96d0811d25dbcc0a2ab2f282f17f3f22211209ed9514917c diff --git a/tasks/format-code-task-001895/environment/setup/files/blocklist b/tasks/format-code-task-001895/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001895/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-001895/environment/setup/setup.sh b/tasks/format-code-task-001895/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001895/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-001895/tests/test.patch b/tasks/format-code-task-001895/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1017cd4c28d5bb37e89b2ff9112faa4d47c3dd63 --- /dev/null +++ b/tasks/format-code-task-001895/tests/test.patch @@ -0,0 +1,76 @@ +diff --git a/controller/controller_test.go b/controller/controller_test.go +index c04b922ee60..0cd9a7ad953 100644 +--- a/controller/controller_test.go ++++ b/controller/controller_test.go +@@ -846,6 +846,51 @@ func TestControllerMutation(t *testing.T) { + Status: statusAssigned([]string{"1000::"}), + }, + }, ++ { ++ desc: "request IPs from dualstack pool with PreferDualStack policy but single stack clusterip", ++ in: &v1.Service{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Annotations: map[string]string{ ++ AnnotationAddressPool: "pool5", ++ }, ++ }, ++ Spec: v1.ServiceSpec{ ++ Type: "LoadBalancer", ++ ClusterIPs: []string{"1.2.3.4"}, ++ IPFamilyPolicy: &IPFamilyPolicyPreferDualStack, ++ }, ++ }, ++ want: &v1.Service{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Annotations: map[string]string{ ++ AnnotationAddressPool: "pool5", ++ }, ++ }, ++ Spec: v1.ServiceSpec{ ++ Type: "LoadBalancer", ++ ClusterIPs: []string{"1.2.3.4"}, ++ IPFamilyPolicy: &IPFamilyPolicyPreferDualStack, ++ }, ++ Status: statusAssigned([]string{"1.2.3.0"}), ++ }, ++ }, ++ { ++ desc: "request IPs from dualstack pool with RequireDualStack policy but single stack clusterip", ++ in: &v1.Service{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Annotations: map[string]string{ ++ AnnotationAddressPool: "pool5", ++ }, ++ }, ++ Spec: v1.ServiceSpec{ ++ Type: "LoadBalancer", ++ ClusterIPs: []string{"1.2.3.4"}, ++ IPFamilyPolicy: &IPFamilyPolicyRequireDualStack, ++ }, ++ }, ++ wantErr: true, ++ }, ++ + { + desc: "request specific loadbalancer IP with dual-stack", + in: &v1.Service{ +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+3RwQqCQBSF4Vn7FPcFUiedcdWzRI1SgTqgY8+fuagIyk0S0f9t7oW5MAdOvB9O ++dbmt2nOilpKOCmOmOXqe067NWusiS7N0vNPaFFaJWSzRg6EPu05Edd6Hd3dz7z8qvvcfqj5snW+a ++XVvG/fFzf8z2b+yt/3Vux/5zqwsl6ecivPbn/btSpuL3VRkdvFxXiRPn29D5uq66RFZnWTk/tGGj ++o2+nBQAAAAAAAAAAAAAAAPDoAo6inLMAKAAA +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-001895/tests/test.sh b/tasks/format-code-task-001895/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3942f78375fa3a57a5be9dcf0fbd3a4710d54661 --- /dev/null +++ b/tasks/format-code-task-001895/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' +controller/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-001895/tests/test_command.sh b/tasks/format-code-task-001895/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001895/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-001913/environment/Dockerfile b/tasks/format-code-task-001913/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ae78034e0fcdb046fed98799f5f42640ee7a5db8 --- /dev/null +++ b/tasks/format-code-task-001913/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:10d3fb48b9e7bafc00f47b4199406a1697d5e03a59815c08a3eb546f438001aa diff --git a/tasks/format-code-task-001913/environment/setup/files/blocklist b/tasks/format-code-task-001913/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001913/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-001913/environment/setup/setup.sh b/tasks/format-code-task-001913/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001913/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-001913/tests/test.patch b/tasks/format-code-task-001913/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cbe62758a7bf06426a279147bde6230bfa4ee9bd --- /dev/null +++ b/tasks/format-code-task-001913/tests/test.patch @@ -0,0 +1,108 @@ +diff --git a/cmd/sqlcmd/sqlcmd_test.go b/cmd/sqlcmd/sqlcmd_test.go +index 9d9574d0..8cff4213 100644 +--- a/cmd/sqlcmd/sqlcmd_test.go ++++ b/cmd/sqlcmd/sqlcmd_test.go +@@ -4,6 +4,7 @@ + package sqlcmd + + import ( ++ "bytes" + "os" + "path/filepath" + "runtime" +@@ -68,8 +69,8 @@ func TestValidCommandLineToArgsConversion(t *testing.T) { + {[]string{"-h", "2", "-?"}, func(args SQLCmdArguments) bool { + return args.Help && args.Headers == 2 + }}, +- {[]string{"-u"}, func(args SQLCmdArguments) bool { +- return args.UnicodeOutputFile ++ {[]string{"-u", "-A"}, func(args SQLCmdArguments) bool { ++ return args.UnicodeOutputFile && args.DedicatedAdminConnection + }}, + {[]string{"--version"}, func(args SQLCmdArguments) bool { + return args.Version +@@ -98,7 +99,10 @@ func TestValidCommandLineToArgsConversion(t *testing.T) { + Run: func(cmd *cobra.Command, argss []string) { + // Command logic goes here + }, ++ SilenceErrors: true, ++ SilenceUsage: true, + } ++ cmd.SetOut(new(bytes.Buffer)) + setFlags(cmd, arguments) + cmd.SetArgs(test.commandLine) + err := cmd.Execute() +@@ -136,6 +140,8 @@ func TestInvalidCommandLine(t *testing.T) { + }, + Run: func(cmd *cobra.Command, argss []string) { + }, ++ SilenceErrors: true, ++ SilenceUsage: true, + } + setFlags(cmd, arguments) + cmd.SetArgs(test.commandLine) +@@ -169,6 +175,8 @@ func TestValidateFlags(t *testing.T) { + }, + Run: func(cmd *cobra.Command, argss []string) { + }, ++ SilenceErrors: true, ++ SilenceUsage: true, + } + + setFlags(cmd, arguments) +diff --git a/pkg/sqlcmd/sqlcmd_test.go b/pkg/sqlcmd/sqlcmd_test.go +index 32d709e6..cc98bad8 100644 +--- a/pkg/sqlcmd/sqlcmd_test.go ++++ b/pkg/sqlcmd/sqlcmd_test.go +@@ -62,6 +62,18 @@ func TestConnectionStringFromSqlCmd(t *testing.T) { + &ConnectSettings{ServerName: `\\someserver\pipe\sql\query`}, + "sqlserver://someserver?pipe=sql%5Cquery&protocol=np", + }, ++ { ++ &ConnectSettings{DedicatedAdminConnection: true}, ++ "sqlserver://.?protocol=admin", ++ }, ++ { ++ &ConnectSettings{ServerName: `tcp:someserver`, DedicatedAdminConnection: true}, ++ "sqlserver://someserver?protocol=admin", ++ }, ++ { ++ &ConnectSettings{ServerName: `admin:someserver`, DedicatedAdminConnection: true}, ++ "sqlserver://someserver?protocol=admin", ++ }, + } + + for i, test := range commands { +@@ -633,7 +645,8 @@ func TestSqlcmdPrefersSharedMemoryProtocol(t *testing.T) { + t.Skip("Only valid on Windows amd64") + } + assert.EqualValuesf(t, "lpc", msdsn.ProtocolParsers[0].Protocol(), "lpc should be first protocol") +- assert.EqualValuesf(t, "tcp", msdsn.ProtocolParsers[1].Protocol(), "tcp should be second protocol") +- assert.EqualValuesf(t, "np", msdsn.ProtocolParsers[2].Protocol(), "np should be third protocol") ++ assert.Truef(t, msdsn.ProtocolParsers[1].Hidden(), "Protocol %s should be hidden", msdsn.ProtocolParsers[1].Protocol()) ++ assert.EqualValuesf(t, "tcp", msdsn.ProtocolParsers[2].Protocol(), "tcp should be second protocol") ++ assert.EqualValuesf(t, "np", msdsn.ProtocolParsers[3].Protocol(), "np should be third protocol") + + } +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+3SQUvDMBQH8J79FGF40MO6ZFu7kwcZDASFQYdHR9bErtgmW5JWhH140wpuDLQe ++NkT8/y4p7Xt5D/4NV1VeiKVU9SA4F+pNoqg9veOzfWbRkA4nbBjFo4AyFtNxQKKzbXSgso4bQgKj ++tfuuruv7HxXu83fSumWqy5IrEdr16WZ05T8esX3+lPn8xzGNA0JPt8LX/nn+qSBt8CspLjJNmkcS ++DtJSDOy2aA7Sr0k/1ZVyN4z0TaVI7+lq4cseeZGL6cfvcp8rudC3JrNTrWppbK7Vrim6U/VR2e6z ++lzs5K3hm2ze+T+TOt9mZNnNu7as2Ym50uXHXl72D1TYvWedq/jIl0+a2xJlcZTN/T7ItpqVoZyVt +++9zIZ79psuZGigdZavPm5zmd6qKZ+NvBAAAAAAAAAAAAAAAAAAAAAAD8wDuv79qMACgAAA== +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-001913/tests/test.sh b/tasks/format-code-task-001913/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fa682891b5b7589cf81e9e4ffd2a3ac3bda1db4d --- /dev/null +++ b/tasks/format-code-task-001913/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' +cmd/sqlcmd/sqlcmd_test.go +pkg/sqlcmd/sqlcmd_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-001913/tests/test_command.sh b/tasks/format-code-task-001913/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001913/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-001914/environment/Dockerfile b/tasks/format-code-task-001914/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2d204d150c96bcb030867438737cd59b73d5352b --- /dev/null +++ b/tasks/format-code-task-001914/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:bbfcff7e3fd1baf235a8550d79bc4448d3e8e034b5ab0fa823fa79c22424b047 diff --git a/tasks/format-code-task-001914/environment/setup/files/blocklist b/tasks/format-code-task-001914/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001914/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-001914/environment/setup/setup.sh b/tasks/format-code-task-001914/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001914/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-001914/tests/test.patch b/tasks/format-code-task-001914/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8808374222455748e7263f414f0ff1b53b2dcc46 --- /dev/null +++ b/tasks/format-code-task-001914/tests/test.patch @@ -0,0 +1,145 @@ +diff --git a/onnxscript/ir/_tape_test.py b/onnxscript/ir/_tape_test.py +index 46cbcc23..7b096777 100644 +--- a/onnxscript/ir/_tape_test.py ++++ b/onnxscript/ir/_tape_test.py +@@ -5,6 +5,7 @@ from __future__ import annotations + import unittest + + from onnxscript import ir ++from onnxscript.ir import _tape + + + class TestTape(unittest.TestCase): +@@ -72,5 +73,110 @@ class TestTape(unittest.TestCase): + self.assertEqual([n.op_type for n in tape.nodes], ["SomeOp", "SomeOtherOp"]) + + ++class TestBuilderName(unittest.TestCase): ++ """Tests that Builder extracts `_name` as the node name, not as an attribute.""" ++ ++ def _make_input(self): ++ return ir.Value( ++ name="x", type=ir.TensorType(ir.DataType.FLOAT), shape=ir.Shape((1, 2)) ++ ) ++ ++ def test_single_output_name_sets_node_name(self): ++ builder = _tape.Builder() ++ inp = self._make_input() ++ out = builder.Relu(inp, _name="my_relu_node") ++ node = out.producer() ++ self.assertEqual(node.name, "my_relu_node") ++ ++ def test_single_output_name_not_added_as_attribute(self): ++ builder = _tape.Builder() ++ inp = self._make_input() ++ out = builder.Relu(inp, _name="my_relu_node") ++ node = out.producer() ++ attr_names = list(dict(node.attributes).keys()) ++ self.assertNotIn("_name", attr_names) ++ self.assertNotIn("name", attr_names) ++ ++ def test_multi_output_name_sets_node_name(self): ++ builder = _tape.Builder() ++ inp = self._make_input() ++ outs = builder.Split(inp, _outputs=2, _name="split_node") ++ ++ self.assertEqual(outs[0].producer().name, "split_node") ++ self.assertEqual(outs[1].producer().name, "split_node") ++ ++ def test_multi_output_name_not_added_as_attribute(self): ++ builder = _tape.Builder() ++ inp = self._make_input() ++ outs = builder.Split(inp, _outputs=2, _name="split_node") ++ node = outs[0].producer() ++ attr_names = list(dict(node.attributes).keys()) ++ self.assertNotIn("_name", attr_names) ++ self.assertNotIn("name", attr_names) ++ ++ def test_name_coexists_with_other_attributes(self): ++ builder = _tape.Builder() ++ inp = self._make_input() ++ out = builder.SomeOp(inp, alpha=1.5, _name="custom_name") ++ node = out.producer() ++ self.assertEqual(node.name, "custom_name") ++ ++ attrs = dict(node.attributes) ++ self.assertIn("alpha", attrs) ++ self.assertNotIn("_name", attrs) ++ ++ def test_default_when_name_not_passed(self): ++ ++ builder = _tape.Builder() ++ inp = self._make_input() ++ out = builder.Add(inp, inp) ++ node = out.producer() ++ self.assertIsNone(node.name) ++ ++ attr_names = list(dict(node.attributes).keys()) ++ self.assertNotIn("_name", attr_names) ++ self.assertNotIn("name", attr_names) ++ ++ ++class TestRewriterNamePropagation(unittest.TestCase): ++ """End-to-end: the issue's reproduction — replacement op can carry a name.""" ++ ++ def test_replacement_pattern_can_set_node_name(self): ++ import onnx_ir as ir_top ++ from onnxscript.rewriter import pattern, rewrite ++ ++ def target_pattern(op, x): ++ return op.Relu(x, _outputs=["relu"]) ++ ++ def replacement_pattern(op, x, relu): ++ ir_node = relu.producer() ++ return op.Clip(x, _name=ir_node.name) ++ ++ rules = [pattern.RewriteRule(target_pattern, replacement_pattern)] ++ ++ ir_model = ir_top.from_onnx_text( ++ """ ++ < ir_version: 10, opset_import: ["" : 20] > ++ test_model (float[N, 16, 16] X) => (float [N, ?, ?] Y) ++ { ++ Y = Relu(X) ++ } ++ """ ++ ) ++ ++ ++ ++ ir_model.graph[0].name = "user_supplied_relu_name_xyz" ++ ++ ir_model = rewrite(ir_model, rules) ++ new_node = ir_model.graph[0] ++ self.assertEqual(new_node.op_type, "Clip") ++ self.assertEqual(new_node.name, "user_supplied_relu_name_xyz") ++ ++ attr_names = list(dict(new_node.attributes).keys()) ++ self.assertNotIn("_name", attr_names) ++ self.assertNotIn("name", attr_names) ++ ++ + if __name__ == "__main__": + unittest.main() +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..852bcdd1 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest onnxscript/ir/_tape_test.py -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest onnxscript/ir/_tape_test.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001914/tests/test.sh b/tasks/format-code-task-001914/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a1bd0bfb40d3e127d9ff49e3f847527e09e5c340 --- /dev/null +++ b/tasks/format-code-task-001914/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' +onnxscript/ir/_tape_test.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001914/tests/test_command.sh b/tasks/format-code-task-001914/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001914/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-001922/environment/Dockerfile b/tasks/format-code-task-001922/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..13a19c287e688ab9a38463ecfb05b2142f45a4a0 --- /dev/null +++ b/tasks/format-code-task-001922/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:a0e52396b6d43a87c7ffb6c9ca5addc2fa7b6d11ac3e129a2c27d920a5b6eff0 diff --git a/tasks/format-code-task-001922/environment/setup/files/blocklist b/tasks/format-code-task-001922/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001922/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-001922/environment/setup/setup.sh b/tasks/format-code-task-001922/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001922/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-001922/tests/test.patch b/tasks/format-code-task-001922/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0b35f5f4c14fd9f0ea7bdbb4c28e7d0832f7794d --- /dev/null +++ b/tasks/format-code-task-001922/tests/test.patch @@ -0,0 +1,262 @@ +diff --git a/core/src/test/scala/shapeless/hlist.scala b/core/src/test/scala/shapeless/hlist.scala +index ec772c84c..0caee3c24 100644 +--- a/core/src/test/scala/shapeless/hlist.scala ++++ b/core/src/test/scala/shapeless/hlist.scala +@@ -1822,31 +1822,31 @@ class HListTests { + val in4 = 1 :: "foo" :: 2.0 :: 'a' :: HNil + type S = String; type I = Int; type D = Double; type C = Char + +- // rotateLeft[_0] +- assertTypedSame[HNil](HNil, in0.rotateLeft[_0]) +- assertTypedSame[I :: HNil](in1, in1.rotateLeft[_0]) +- assertTypedSame[I :: S :: HNil](in2, in2.rotateLeft[_0]) +- assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateLeft[_0]) +- assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateLeft[_0]) +- +- // rotateLeft[N % Size == 0] +- assertTypedSame[I :: HNil](in1, in1.rotateLeft[_1]) +- assertTypedSame[I :: HNil](in1, in1.rotateLeft[_2]) +- assertTypedSame[I :: S :: HNil](in2, in2.rotateLeft[_2]) +- assertTypedSame[I :: S :: HNil](in2, in2.rotateLeft[_4]) +- assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateLeft[_3]) +- assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateLeft[_6]) +- assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateLeft[_4]) +- assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateLeft[_8]) ++ ++ assertTypedSame[HNil](HNil, in0.rotateLeft(0)) ++ assertTypedSame[I :: HNil](in1, in1.rotateLeft(0)) ++ assertTypedSame[I :: S :: HNil](in2, in2.rotateLeft(0)) ++ assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateLeft(0)) ++ assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateLeft(0)) ++ ++ ++ assertTypedSame[I :: HNil](in1, in1.rotateLeft(1)) ++ assertTypedSame[I :: HNil](in1, in1.rotateLeft(2)) ++ assertTypedSame[I :: S :: HNil](in2, in2.rotateLeft(2)) ++ assertTypedSame[I :: S :: HNil](in2, in2.rotateLeft(4)) ++ assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateLeft(3)) ++ assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateLeft(6)) ++ assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateLeft(4)) ++ assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateLeft(8)) + + // other +- assertTypedEquals[S :: I :: HNil]("foo" :: 1 :: HNil, in2.rotateLeft[_1]) +- assertTypedEquals[S :: D :: I :: HNil]("foo" :: 2.0 :: 1 :: HNil, in3.rotateLeft[_1]) +- assertTypedEquals[S :: D :: C :: I :: HNil]("foo" :: 2.0 :: 'a' :: 1 :: HNil, in4.rotateLeft[_1]) +- assertTypedEquals[D :: C :: I :: S :: HNil](2.0 :: 'a' :: 1 :: "foo" :: HNil, in4.rotateLeft[_2]) +- assertTypedEquals[C :: I :: S :: D :: HNil]('a' :: 1 :: "foo" :: 2.0 :: HNil, in4.rotateLeft[_3]) +- assertTypedEquals[S :: D :: C :: I :: HNil]("foo" :: 2.0 :: 'a' :: 1 :: HNil, in4.rotateLeft[_5]) +- assertTypedEquals[D :: C :: I :: S :: HNil](2.0 :: 'a' :: 1 :: "foo" :: HNil, in4.rotateLeft[_6]) ++ assertTypedEquals[S :: I :: HNil]("foo" :: 1 :: HNil, in2.rotateLeft(1)) ++ assertTypedEquals[S :: D :: I :: HNil]("foo" :: 2.0 :: 1 :: HNil, in3.rotateLeft(1)) ++ assertTypedEquals[S :: D :: C :: I :: HNil]("foo" :: 2.0 :: 'a' :: 1 :: HNil, in4.rotateLeft(1)) ++ assertTypedEquals[D :: C :: I :: S :: HNil](2.0 :: 'a' :: 1 :: "foo" :: HNil, in4.rotateLeft(2)) ++ assertTypedEquals[C :: I :: S :: D :: HNil]('a' :: 1 :: "foo" :: 2.0 :: HNil, in4.rotateLeft(3)) ++ assertTypedEquals[S :: D :: C :: I :: HNil]("foo" :: 2.0 :: 'a' :: 1 :: HNil, in4.rotateLeft(5)) ++ assertTypedEquals[D :: C :: I :: S :: HNil](2.0 :: 'a' :: 1 :: "foo" :: HNil, in4.rotateLeft(6)) + } + + @Test +@@ -1858,31 +1858,31 @@ class HListTests { + val in4 = 1 :: "foo" :: 2.0 :: 'a' :: HNil + type S = String; type I = Int; type D = Double; type C = Char + +- // rotateRight[_0] +- assertTypedSame[HNil](HNil, in0.rotateRight[_0]) +- assertTypedSame[I :: HNil](in1, in1.rotateRight[_0]) +- assertTypedSame[I :: S :: HNil](in2, in2.rotateRight[_0]) +- assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateRight[_0]) +- assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateRight[_0]) +- +- // rotateRight[N % Size == 0] +- assertTypedSame[I :: HNil](in1, in1.rotateRight[_1]) +- assertTypedSame[I :: HNil](in1, in1.rotateRight[_2]) +- assertTypedSame[I :: S :: HNil](in2, in2.rotateRight[_2]) +- assertTypedSame[I :: S :: HNil](in2, in2.rotateRight[_4]) +- assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateRight[_3]) +- assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateRight[_6]) +- assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateRight[_4]) +- assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateRight[_8]) ++ ++ assertTypedSame[HNil](HNil, in0.rotateRight(0)) ++ assertTypedSame[I :: HNil](in1, in1.rotateRight(0)) ++ assertTypedSame[I :: S :: HNil](in2, in2.rotateRight(0)) ++ assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateRight(0)) ++ assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateRight(0)) ++ ++ ++ assertTypedSame[I :: HNil](in1, in1.rotateRight(1)) ++ assertTypedSame[I :: HNil](in1, in1.rotateRight(2)) ++ assertTypedSame[I :: S :: HNil](in2, in2.rotateRight(2)) ++ assertTypedSame[I :: S :: HNil](in2, in2.rotateRight(4)) ++ assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateRight(3)) ++ assertTypedSame[I :: S :: D :: HNil](in3, in3.rotateRight(6)) ++ assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateRight(4)) ++ assertTypedSame[I :: S :: D :: C :: HNil](in4, in4.rotateRight(8)) + + // others +- assertTypedEquals[S :: I :: HNil]("foo" :: 1 :: HNil, in2.rotateRight[_1]) +- assertTypedEquals[D :: I :: S :: HNil](2.0 :: 1 :: "foo" :: HNil, in3.rotateRight[_1]) +- assertTypedEquals[C :: I :: S :: D :: HNil]('a' :: 1 :: "foo" :: 2.0 :: HNil, in4.rotateRight[_1]) +- assertTypedEquals[D :: C :: I :: S :: HNil](2.0 :: 'a' :: 1 :: "foo" :: HNil, in4.rotateRight[_2]) +- assertTypedEquals[S :: D :: C :: I :: HNil]("foo" :: 2.0 :: 'a' :: 1 :: HNil, in4.rotateRight[_3]) +- assertTypedEquals[C :: I :: S :: D :: HNil]('a' :: 1 :: "foo" :: 2.0 :: HNil, in4.rotateRight[_5]) +- assertTypedEquals[D :: C :: I :: S :: HNil](2.0 :: 'a' :: 1 :: "foo" :: HNil, in4.rotateRight[_6]) ++ assertTypedEquals[S :: I :: HNil]("foo" :: 1 :: HNil, in2.rotateRight(1)) ++ assertTypedEquals[D :: I :: S :: HNil](2.0 :: 1 :: "foo" :: HNil, in3.rotateRight(1)) ++ assertTypedEquals[C :: I :: S :: D :: HNil]('a' :: 1 :: "foo" :: 2.0 :: HNil, in4.rotateRight(1)) ++ assertTypedEquals[D :: C :: I :: S :: HNil](2.0 :: 'a' :: 1 :: "foo" :: HNil, in4.rotateRight(2)) ++ assertTypedEquals[S :: D :: C :: I :: HNil]("foo" :: 2.0 :: 'a' :: 1 :: HNil, in4.rotateRight(3)) ++ assertTypedEquals[C :: I :: S :: D :: HNil]('a' :: 1 :: "foo" :: 2.0 :: HNil, in4.rotateRight(5)) ++ assertTypedEquals[D :: C :: I :: S :: HNil](2.0 :: 'a' :: 1 :: "foo" :: HNil, in4.rotateRight(6)) + } + + object smear extends Poly { +diff --git a/core/src/test/scala/shapeless/tuples.scala b/core/src/test/scala/shapeless/tuples.scala +index 94ee45566..58db84dd2 100644 +--- a/core/src/test/scala/shapeless/tuples.scala ++++ b/core/src/test/scala/shapeless/tuples.scala +@@ -1421,27 +1421,27 @@ class TupleTests { + val in4 = (1, "foo", 2.0, 'a') + type S = String; type I = Int; type D = Double; type C = Char + +- // rotateLeft[_0] +- assertTypedEquals[(I, S)](in2, in2.rotateLeft[_0]) +- assertTypedEquals[(I, S, D)](in3, in3.rotateLeft[_0]) +- assertTypedEquals[(I, S, D, C)](in4, in4.rotateLeft[_0]) +- +- // rotateLeft[N % Size == 0] +- assertTypedEquals[(I, S)](in2, in2.rotateLeft[_2]) +- assertTypedEquals[(I, S)](in2, in2.rotateLeft[_4]) +- assertTypedEquals[(I, S, D)](in3, in3.rotateLeft[_3]) +- assertTypedEquals[(I, S, D)](in3, in3.rotateLeft[_6]) +- assertTypedEquals[(I, S, D, C)](in4, in4.rotateLeft[_4]) +- assertTypedEquals[(I, S, D, C)](in4, in4.rotateLeft[_8]) ++ ++ assertTypedEquals[(I, S)](in2, in2.rotateLeft(0)) ++ assertTypedEquals[(I, S, D)](in3, in3.rotateLeft(0)) ++ assertTypedEquals[(I, S, D, C)](in4, in4.rotateLeft(0)) ++ ++ ++ assertTypedEquals[(I, S)](in2, in2.rotateLeft(2)) ++ assertTypedEquals[(I, S)](in2, in2.rotateLeft(4)) ++ assertTypedEquals[(I, S, D)](in3, in3.rotateLeft(3)) ++ assertTypedEquals[(I, S, D)](in3, in3.rotateLeft(6)) ++ assertTypedEquals[(I, S, D, C)](in4, in4.rotateLeft(4)) ++ assertTypedEquals[(I, S, D, C)](in4, in4.rotateLeft(8)) + + // other +- assertTypedEquals[(S, I)](("foo", 1), in2.rotateLeft[_1]) +- assertTypedEquals[(S, D, I)](("foo", 2.0, 1), in3.rotateLeft[_1]) +- assertTypedEquals[(S, D, C, I)](("foo", 2.0, 'a', 1), in4.rotateLeft[_1]) +- assertTypedEquals[(D, C, I, S)]((2.0, 'a', 1, "foo"), in4.rotateLeft[_2]) +- assertTypedEquals[(C, I, S, D)](('a', 1, "foo", 2.0), in4.rotateLeft[_3]) +- assertTypedEquals[(S, D, C, I)](("foo", 2.0, 'a', 1), in4.rotateLeft[_5]) +- assertTypedEquals[(D, C, I, S)]((2.0, 'a', 1, "foo"), in4.rotateLeft[_6]) ++ assertTypedEquals[(S, I)](("foo", 1), in2.rotateLeft(1)) ++ assertTypedEquals[(S, D, I)](("foo", 2.0, 1), in3.rotateLeft(1)) ++ assertTypedEquals[(S, D, C, I)](("foo", 2.0, 'a', 1), in4.rotateLeft(1)) ++ assertTypedEquals[(D, C, I, S)]((2.0, 'a', 1, "foo"), in4.rotateLeft(2)) ++ assertTypedEquals[(C, I, S, D)](('a', 1, "foo", 2.0), in4.rotateLeft(3)) ++ assertTypedEquals[(S, D, C, I)](("foo", 2.0, 'a', 1), in4.rotateLeft(5)) ++ assertTypedEquals[(D, C, I, S)]((2.0, 'a', 1, "foo"), in4.rotateLeft(6)) + } + + @Test +@@ -1451,27 +1451,27 @@ class TupleTests { + val in4 = (1, "foo", 2.0, 'a') + type S = String; type I = Int; type D = Double; type C = Char + +- // rotateRight[_0] +- assertTypedEquals[(I, S)](in2, in2.rotateRight[_0]) +- assertTypedEquals[(I, S, D)](in3, in3.rotateRight[_0]) +- assertTypedEquals[(I, S, D, C)](in4, in4.rotateRight[_0]) ++ ++ assertTypedEquals[(I, S)](in2, in2.rotateRight(0)) ++ assertTypedEquals[(I, S, D)](in3, in3.rotateRight(0)) ++ assertTypedEquals[(I, S, D, C)](in4, in4.rotateRight(0)) + +- // rotateRight[N % Size == 0] +- assertTypedEquals[(I, S)](in2, in2.rotateRight[_2]) +- assertTypedEquals[(I, S)](in2, in2.rotateRight[_4]) +- assertTypedEquals[(I, S, D)](in3, in3.rotateRight[_3]) +- assertTypedEquals[(I, S, D)](in3, in3.rotateRight[_6]) +- assertTypedEquals[(I, S, D, C)](in4, in4.rotateRight[_4]) +- assertTypedEquals[(I, S, D, C)](in4, in4.rotateRight[_8]) ++ ++ assertTypedEquals[(I, S)](in2, in2.rotateRight(2)) ++ assertTypedEquals[(I, S)](in2, in2.rotateRight(4)) ++ assertTypedEquals[(I, S, D)](in3, in3.rotateRight(3)) ++ assertTypedEquals[(I, S, D)](in3, in3.rotateRight(6)) ++ assertTypedEquals[(I, S, D, C)](in4, in4.rotateRight(4)) ++ assertTypedEquals[(I, S, D, C)](in4, in4.rotateRight(8)) + + // others +- assertTypedEquals[(S, I)](("foo", 1), in2.rotateRight[_1]) +- assertTypedEquals[(D, I, S)]((2.0, 1, "foo"), in3.rotateRight[_1]) +- assertTypedEquals[(C, I, S, D)](('a', 1, "foo", 2.0), in4.rotateRight[_1]) +- assertTypedEquals[(D, C, I, S)]((2.0, 'a', 1, "foo"), in4.rotateRight[_2]) +- assertTypedEquals[(S, D, C, I)](("foo", 2.0, 'a', 1), in4.rotateRight[_3]) +- assertTypedEquals[(C, I, S, D)](('a', 1, "foo", 2.0), in4.rotateRight[_5]) +- assertTypedEquals[(D, C, I, S)]((2.0, 'a', 1, "foo"), in4.rotateRight[_6]) ++ assertTypedEquals[(S, I)](("foo", 1), in2.rotateRight(1)) ++ assertTypedEquals[(D, I, S)]((2.0, 1, "foo"), in3.rotateRight(1)) ++ assertTypedEquals[(C, I, S, D)](('a', 1, "foo", 2.0), in4.rotateRight(1)) ++ assertTypedEquals[(D, C, I, S)]((2.0, 'a', 1, "foo"), in4.rotateRight(2)) ++ assertTypedEquals[(S, D, C, I)](("foo", 2.0, 'a', 1), in4.rotateRight(3)) ++ assertTypedEquals[(C, I, S, D)](('a', 1, "foo", 2.0), in4.rotateRight(5)) ++ assertTypedEquals[(D, C, I, S)]((2.0, 'a', 1, "foo"), in4.rotateRight(6)) + } + + object smear extends Poly { +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,35 @@ ++H4sIAAAAAAAAA+1bzW/jxhVXNttmY6CXYlGgOQ2IAN1tw+E35QqSAyfdxTprZQ1bCQy4hkGJY2k2 ++FClwKK13gd5yyT/QS6899dpT7720DVoEKNBrLw16bXsv+mb0YclrrUTJ4ibo+wE2yZl5M0P+3pv3 ++3pCizT6PwjMWD4zSpmACyp6njoCrR3VuebZl+WXPdu2SCWemXyLexmY0hb7IgpSQUpok2avaLar/ ++loJe8h8lrSDSU9ZLblgVcvDvWjaUW47veMh/Ebie/1bSvUEdyM+/61oO8l8E5vPPWOgI/tN4fUXI ++z79vOrj+F4Il+BfNTFeteHyenNnUMs9MajnL60Vu/m2rDEXIfwFYg3+T2tRbRgvy8G/Dwm/atuOi ++/y8Ea/M/p1ZXtfRpkA759113Lv+e5V7avyv5LztuuUTMIh7A/zn/B4/fvH23dOfOndIX3//Dz6dr ++3i7dLtUfNHb1vY8fGv/9Y6n0JjR+646surVQ+C78TYTrux/vPXxw1KD1h/+pf/mn/cc6/ep7j/Uf ++//nLv/z20Pyr8/d/pPSj+nt79a/6v7n99vE/f/j7Xx2/c7/z+a+//uUP2Nf83+m/0jfU2D/64G9R ++BXquqLHfuHW3NDv6rampz2LmRq6KTnd7d0asNuc2Dh5/57vDAW+VfgHH363JwuvDhu2/l3QX23/Z ++v7r+lx0f7b8QVN+/6EZkwFLBk7imWdTUCItbCdDZrmmfNB7q29r7O1vVXpo8Za2MXAheEa0O6wb7 ++oC6ZEupkWa9iGN1gwGIa9AKopknaNg6e1A2XmtQk81pciHBYqKt2FK41AhOKxRK9alsEoFpXYFoT ++iWfPntFnjmprm6ZlHNf3j9SMdR4D2XGLaTsgWu0mIYs+Hd75juqxasyUyUbtNOn39sIdsAg6toiq ++MS6VLYI04+dBK4PLObZQNabaSBG4mc+CNjzhHfCPVePyUlaOuNhRBlQ1BlOTCZlopbwnn/rOUdZv ++kvMkJTODkl7Uh56qxnTTLRhiSN/O1lX+59t/m2edfvMmtgHy53+eX8b4rxAs5L8tGM9erKUG+fkv ++26aN/BeBZfmXq0zKIhYIlnsLIH/+b3uWhfwXgfX4N2mZWgu1IH/+71heGfkvAjfB/7V1uqpTGwAr ++5P++jfF/IcD8H/P/Tdq/3ABYnP9bV/N/3zPR/osA5v/L5/9Di6BDi3jlJsBL1rDqFgCY0JJbAKMh ++824AzLf/7HmPieCcvZb3v7aD7/8LwRL8g3atpwMr5P+QAiD/RWBJ/uUKA8vfKm//V3r/7+L+XzFY ++mX+T+tReTgvy5/+2TAOR/wKwJv8vleuqfPjef4z8+b9X9nyM/4sA5v+Y/2/A/tV7/zEW5v/e1fXf ++K0v/j/a/eWD+v3z+P7YIClr/yvR/xiJWTf3BjJZM/WG43O/9x8hh/4lo85USgBXif9/D+K8QrM6/ ++1FBzKS1YIf53LHz/VwjW5f/lChUBmNMZQP7433dMjP8LAcb/GP9vxP6nMoDF8b99Zf33HXz/Xwww ++/t9A/D9rEKsnAOaSCYAcb8UMIIf999q9wvb/Pfz9XzFYmX+Tbi/x6Z/CCvG/5WL8XwjW5P+lcl2V ++r7//72P8Xwgw/sf4fwP2v+b+vw+LAtp/EcD4fwPx/4xFrBr+by/96R8MdxP7/6or1Y3QExg45aG6 ++1bV1bKH/B58/sX/Xl9//ufL3P2j/m4dhkN0wJGrtJ3Vpa0R6AMGzJH1OWkmcBTwG5SRCatxHu4dC ++qV0ShVL1RmontqCbrBNkJEgZiRPoLm6zlASDgEdBM2LkPE260IJxEE05iMBok3E4E1T20Ohw6J1D ++c9FJ+jBCU37OGrRYSHgspclInQ0S8hSOcopZAuuVGiNlIon6UvNlZ8m5klDTHs1yMovR7V7eKN1S ++wtLayE9qRNtX9UcfNMiBEiWHk6YagduUk7ynXes7tfs0Sz453IP/R1kKT26u6X0jcMX+1SO56TEW ++2L9lWd7E/t2ytH/H9dD/F4KTaSs8BTejNHl8HPkDXVqRqCi1BwdrZExkTRYa1wePIDz06S0WZ2kQ ++VZT7FyAoqy069OjSPaszWwpc+p7xh+xiVowK6D/QoZ2SVFeTwHRW0HiPnECbIOYvVIByapyAW+9H ++7NS4p+TOTtRh5OZPjfv3oBcobGaXRfBcBnx4fiL9/qkwTsZ+/PSeftKC4QU/5yw9vU9P2EUmn904 ++QJh3D5MAYia+nsx7ugc+eJ6vl2mB1/UEXrcyI3JjyoSlVZ+BTnWDOKSic3NjLNr/85zJ7788VW65 ++PsZ/xaAVkvFyvsUuekmaQZD36e7Zoyf1BzWjL1Ij4k3j6QBWGtbtQzyjb+tPw8/0oBv67ljiYLfx ++qKa9OxE0mjyuvCtLtXETiKXOnhw0jmqaftwVtuludwmcXYzPjiv14OKApd0j/oLVPMseFh4ywdIB ++Cz+EvOxDmQKqatvzofpnyhmMExWlx1R5s1qW9tmofirGg2D2nLdr13mvSeijbcmoVhOdoAdrqRB6 ++K0mZkngSR8/JpJw+2ucia0C5mCps9HsRU4UaroUIBAKBQCAQCAQCgUAgEAgEAoFAIBAIBAKBKBL/ ++AxvsQ8YAeAAA +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-001922/tests/test.sh b/tasks/format-code-task-001922/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f61ef16efe362472f06b26a17585be87ba0ac79 --- /dev/null +++ b/tasks/format-code-task-001922/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +core/src/test/scala/shapeless/hlist.scala +core/src/test/scala/shapeless/tuples.scala +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001922/tests/test_command.sh b/tasks/format-code-task-001922/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001922/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-001925/environment/Dockerfile b/tasks/format-code-task-001925/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1f4ee2e6e6629d13afa2e7d82cd1c8fc5fea6b58 --- /dev/null +++ b/tasks/format-code-task-001925/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:f1f78ccdf37e9400bbb62443007c1012814aa8dc2f14e132b985e2ea81a45db8 diff --git a/tasks/format-code-task-001925/environment/setup/files/blocklist b/tasks/format-code-task-001925/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001925/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-001925/environment/setup/setup.sh b/tasks/format-code-task-001925/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001925/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-001925/tests/test.patch b/tasks/format-code-task-001925/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a161e75b2d3795e44f1cfabafdb3104e23ec0a15 --- /dev/null +++ b/tasks/format-code-task-001925/tests/test.patch @@ -0,0 +1,148 @@ +diff --git a/tests/test_decorators.py b/tests/test_decorators.py +index 9b5acf805..275121c2b 100644 +--- a/tests/test_decorators.py ++++ b/tests/test_decorators.py +@@ -3,6 +3,7 @@ + + from pymilvus.decorators import retry_on_rpc_failure, error_handler + from pymilvus.exceptions import MilvusUnavailableException, MilvusException ++from pymilvus.grpc_gen import common_pb2 + + + class TestDecorators: +@@ -11,8 +12,13 @@ def mock_failure(self, code: grpc.StatusCode): + raise MockUnavailableError() + if code == MockDeadlineExceededError().code(): + raise MockDeadlineExceededError() +- if code == MockResourceExhaustedError().code(): +- raise MockResourceExhaustedError() ++ ++ def mock_milvus_exception(self, code: common_pb2.ErrorCode): ++ if code == common_pb2.ForceDeny: ++ raise MockForceDenyError() ++ if code == common_pb2.RateLimit: ++ raise MockRateLimitError() ++ raise MilvusException(common_pb2.UNEXPECTED_ERROR, str("unexpected error")) + + @pytest.mark.parametrize("times", [0, 1, 2, 3]) + def test_retry_decorators_unavailable(self, times): +@@ -77,22 +83,55 @@ def test_api(self, code): + + assert self.test_retry_decorators_default_retry_times == 7 + 1 + ++ def test_retry_decorators_force_deny(self): ++ self.execute_times = 0 ++ ++ @retry_on_rpc_failure() ++ def test_api(self, code): ++ self.execute_times += 1 ++ self.mock_milvus_exception(code) ++ ++ with pytest.raises(MilvusException) as e: ++ test_api(self, common_pb2.ForceDeny) ++ print(e) ++ assert "force deny" in e.value.message ++ ++ ++ assert self.execute_times == 1 ++ + @pytest.mark.parametrize("times", [0, 1, 2, 3]) +- def test_retry_decorators_resource_exhausted(self, times): +- self.count_test_retry_decorators_resource_exhausted = 0 ++ def test_retry_decorators_rate_limit_without_retry(self, times): ++ self.count_test_retry_decorators_force_deny = 0 + + @retry_on_rpc_failure(retry_times=times) +- def test_api(self, code): +- self.count_test_retry_decorators_resource_exhausted += 1 +- self.mock_failure(code) ++ def test_api(self, code, retry_on_rate_limit): ++ self.count_test_retry_decorators_force_deny += 1 ++ self.mock_milvus_exception(code) + + with pytest.raises(MilvusException) as e: +- test_api(self, grpc.StatusCode.RESOURCE_EXHAUSTED) +- assert "resource exhausted" in e.reason() +- print(e) ++ test_api(self, common_pb2.RateLimit, retry_on_rate_limit=False) ++ print(e) ++ assert "rate limit" in e.value.message ++ ++ ++ assert self.count_test_retry_decorators_force_deny == 1 ++ ++ @pytest.mark.parametrize("times", [0, 1, 2, 3]) ++ def test_retry_decorators_rate_limit_with_retry(self, times): ++ self.count_test_retry_decorators_force_deny = 0 ++ ++ @retry_on_rpc_failure(retry_times=times) ++ def test_api(self, code, retry_on_rate_limit): ++ self.count_test_retry_decorators_force_deny += 1 ++ self.mock_milvus_exception(code) ++ ++ with pytest.raises(MilvusException) as e: ++ test_api(self, common_pb2.RateLimit, retry_on_rate_limit=True) ++ print(e) ++ assert "rate limit" in e.value.message + + # the first execute + retry times +- assert self.count_test_retry_decorators_resource_exhausted == times + 1 ++ assert self.count_test_retry_decorators_force_deny == times + 1 + + + class MockUnavailableError(grpc.RpcError): +@@ -110,9 +149,30 @@ def code(self): + def details(self): + return "details of deadline exceeded" + +-class MockResourceExhaustedError(grpc.RpcError): ++class MockForceDenyError(MilvusException): ++ def __init__(self, code=common_pb2.ForceDeny, message="force deny"): ++ super(MilvusException, self).__init__(message) ++ self._code = code ++ self._message = message ++ ++ @property + def code(self): +- return grpc.StatusCode.RESOURCE_EXHAUSTED ++ return self._code + +- def details(self): +- return "details of resource exhausted" ++ @property ++ def message(self): ++ return self._message ++ ++class MockRateLimitError(MilvusException): ++ def __init__(self, code=common_pb2.RateLimit, message="rate limit"): ++ super(MilvusException, self).__init__(message) ++ self._code = code ++ self._message = message ++ ++ @property ++ def code(self): ++ return self._code ++ ++ @property ++ def message(self): ++ return self._message +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+3S0QrCIBQGYK/3FOcFcnOb2+OEU6FBm6Fu0NtnCyqC6qaI6v8u9IgHVH55N/Vb ++s7bjnLN3KZJWymVObuelFrIUZVWIumpYIYRsG0bybTe6MoWoPBHzzsVHfc/2vxS/5B9tiGvthkGN ++hofN6854lr+o6nP+VZv6RN2IklHxuivc9+f5a0NL8J01WXCT1/a8zvl8/BZdP+ZKx35W0Wa7fdy4 ++kVYDpSq10XEIp69jrHZeRecD3+1pNWeffhsAAAAAAAAAAAAAAAAAAAAAwK87AAEHRgEAKAAA +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-001925/tests/test.sh b/tasks/format-code-task-001925/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d0f0c503dcf1426862d5ed09fed9024e69f51fe0 --- /dev/null +++ b/tasks/format-code-task-001925/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_decorators.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-001925/tests/test_command.sh b/tasks/format-code-task-001925/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001925/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-001940/environment/Dockerfile b/tasks/format-code-task-001940/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1142db065411e068c8398d6607ad17196144549e --- /dev/null +++ b/tasks/format-code-task-001940/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:76e0715e036052d409caf0082b544bbe281cae4ba5e428cdd436404080a04970 diff --git a/tasks/format-code-task-001940/environment/setup/files/blocklist b/tasks/format-code-task-001940/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001940/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-001940/environment/setup/setup.sh b/tasks/format-code-task-001940/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001940/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-001940/tests/test.patch b/tasks/format-code-task-001940/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e0032945e194d72de8a19af4772875334d752fee --- /dev/null +++ b/tasks/format-code-task-001940/tests/test.patch @@ -0,0 +1,136 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..acc585e +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest tests/test_finder.py -v"] ++} +diff --git a/tests/test_finder.py b/tests/test_finder.py +index d2d621b..08a476e 100644 +--- a/tests/test_finder.py ++++ b/tests/test_finder.py +@@ -58,3 +58,109 @@ def test_find_pkg_style_namespace_packages(statement): + assert package.name == "namespace" + assert package.is_namespace + assert package.path == [tmp_package1.path.parent, tmp_package2.path.parent] ++ ++ ++def test_pth_file_pywin32_like_does_not_raise(tmp_path): ++ """Regression test for the PyWin32 .pth file format breaking griffe. ++ ++ The .pth file contains comments, multiple directory lines, and an `import` ++ statement. The finder should not raise, and bogus content (multi-line text, ++ comment markers, import statements) should never appear in `search_paths`. ++ """ ++ pth_file = tmp_path / "pywin32.pth" ++ pth_content = ( ++ "# .pth file for the PyWin32 extensions\n" ++ "win32\n" ++ "win32\\lib\n" ++ "Pythonwin\n" ++ "# And some hackery to deal with environments where the post_install script\n" ++ "# isn't run.\n" ++ "import pywin32_bootstrap" ++ ) ++ pth_file.write_text(pth_content) ++ ++ ++ finder = ModuleFinder(search_paths=[tmp_path]) ++ ++ ++ ++ for sp in finder.search_paths: ++ sp_str = str(sp) ++ assert "\n" not in sp_str ++ assert "#" not in sp_str ++ assert "import pywin32_bootstrap" not in sp_str ++ ++ ++def test_pth_file_multiple_valid_directories_all_added(tmp_path): ++ """Multiple valid directories listed on separate lines must all be added.""" ++ dir1 = tmp_path / "dir_one" ++ dir2 = tmp_path / "dir_two" ++ dir1.mkdir() ++ dir2.mkdir() ++ ++ pth_file = tmp_path / "multi.pth" ++ pth_file.write_text(f"{dir1}\n{dir2}\n") ++ ++ finder = ModuleFinder(search_paths=[tmp_path]) ++ ++ assert dir1 in finder.search_paths ++ assert dir2 in finder.search_paths ++ ++ ++def test_pth_file_comment_lines_skipped(tmp_path): ++ """Comment lines (`#`) must be skipped; valid directories on other lines added.""" ++ valid_dir = tmp_path / "valid_after_comment" ++ valid_dir.mkdir() ++ ++ pth_file = tmp_path / "with_comment.pth" ++ pth_file.write_text(f"# this is a comment line\n{valid_dir}\n") ++ ++ finder = ModuleFinder(search_paths=[tmp_path]) ++ assert valid_dir in finder.search_paths ++ ++ ++ for sp in finder.search_paths: ++ assert "this is a comment" not in str(sp) ++ ++ ++def test_pth_file_import_lines_skipped(tmp_path): ++ """`import xxx` lines must be skipped (per Python .pth-file spec).""" ++ valid_dir = tmp_path / "valid_after_import" ++ valid_dir.mkdir() ++ ++ pth_file = tmp_path / "with_import.pth" ++ pth_file.write_text(f"import some_bootstrap_module\n{valid_dir}\n") ++ ++ ++ finder = ModuleFinder(search_paths=[tmp_path]) ++ ++ ++ assert valid_dir in finder.search_paths ++ ++ ++ for sp in finder.search_paths: ++ assert "import some_bootstrap_module" not in str(sp) ++ ++ ++def test_pth_file_nonexistent_directory_not_added(tmp_path): ++ """Non-existent directories from a .pth file must not be added to search_paths.""" ++ bogus = tmp_path / "this_directory_does_not_exist" ++ ++ pth_file = tmp_path / "bogus.pth" ++ pth_file.write_text(f"{bogus}\n") ++ ++ ++ finder = ModuleFinder(search_paths=[tmp_path]) ++ assert bogus not in finder.search_paths ++ ++ ++def test_pth_file_single_valid_directory_added(tmp_path): ++ """A .pth file with a single valid directory line still adds the directory.""" ++ only_dir = tmp_path / "only_dir" ++ only_dir.mkdir() ++ ++ pth_file = tmp_path / "single.pth" ++ pth_file.write_text(f"{only_dir}\n") ++ ++ finder = ModuleFinder(search_paths=[tmp_path]) ++ assert only_dir in finder.search_paths +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest -v -rA tests/test_finder.py::test_pth_file_pywin32_like_does_not_raise tests/test_finder.py::test_pth_file_multiple_valid_directories_all_added tests/test_finder.py::test_pth_file_comment_lines_skipped tests/test_finder.py::test_pth_file_import_lines_skipped tests/test_finder.py::test_pth_file_nonexistent_directory_not_added tests/test_finder.py::test_pth_file_single_valid_directory_added ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001940/tests/test.sh b/tasks/format-code-task-001940/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f6756d8a450f099cfcdbba2ef5992a0a072ac33 --- /dev/null +++ b/tasks/format-code-task-001940/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_finder.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-001940/tests/test_command.sh b/tasks/format-code-task-001940/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001940/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-001971/environment/Dockerfile b/tasks/format-code-task-001971/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..dd5ce12f49d56367160593e7376ed16cab4552ee --- /dev/null +++ b/tasks/format-code-task-001971/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:0017a76790a0318ce3b8ddd4a387166a174658b051ce2b9a7fbed16230e92557 diff --git a/tasks/format-code-task-001971/environment/setup/files/blocklist b/tasks/format-code-task-001971/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001971/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-001971/environment/setup/setup.sh b/tasks/format-code-task-001971/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001971/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-001971/tests/test.patch b/tasks/format-code-task-001971/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cd99651ea6e184f0d373b3322e07e2e90a31f120 --- /dev/null +++ b/tasks/format-code-task-001971/tests/test.patch @@ -0,0 +1,101 @@ +diff --git a/more_itertools/tests/test_more.py b/more_itertools/tests/test_more.py +index bdb1540..2dfcb4d 100644 +--- a/more_itertools/tests/test_more.py ++++ b/more_itertools/tests/test_more.py +@@ -2771,6 +2771,74 @@ class OnlyTests(TestCase): + ) + + ++class OnlyInformativeMessageTests(TestCase): ++ def test_only_empty_returns_none(self): ++ self.assertEqual(mi.only([]), None) ++ ++ def test_only_empty_with_default(self): ++ self.assertEqual(mi.only([], default='missing'), 'missing') ++ ++ def test_only_single_item(self): ++ self.assertEqual(mi.only([1]), 1) ++ ++ def test_only_too_long_raises_value_error(self): ++ self.assertRaises(ValueError, lambda: mi.only([1, 2])) ++ ++ def test_only_too_long_message_includes_first_and_second(self): ++ ++ try: ++ mi.only([42, 99]) ++ self.fail("Expected ValueError") ++ except ValueError as e: ++ msg = str(e) ++ self.assertIn('42', msg) ++ self.assertIn('99', msg) ++ ++ def test_only_too_long_message_uses_repr_for_strings(self): ++ ++ try: ++ mi.only(['foo', 'bar']) ++ self.fail("Expected ValueError") ++ except ValueError as e: ++ msg = str(e) ++ self.assertIn("'foo'", msg) ++ self.assertIn("'bar'", msg) ++ ++ def test_only_advances_iterator_only_twice(self): ++ ++ it = iter([1, 2, 3, 4, 5, 6]) ++ try: ++ mi.only(it) ++ except ValueError: ++ pass ++ self.assertEqual(next(it), 3) ++ ++ def test_only_custom_exception_class_still_raised(self): ++ self.assertRaises( ++ TypeError, lambda: mi.only([1, 2], too_long=TypeError) ++ ) ++ ++ ++class OneInformativeMessageTests(TestCase): ++ def test_one_basic_preserved(self): ++ self.assertEqual(mi.one(['item']), 'item') ++ ++ def test_one_too_short_preserved(self): ++ self.assertRaises(ValueError, lambda: mi.one([])) ++ self.assertRaises( ++ IndexError, lambda: mi.one([], too_short=IndexError) ++ ) ++ ++ def test_one_too_long_raises_value_error(self): ++ self.assertRaises(ValueError, lambda: mi.one([1, 2])) ++ ++ def test_one_custom_too_long_still_raised(self): ++ self.assertRaises( ++ OverflowError, ++ lambda: mi.one([1, 2], too_long=OverflowError), ++ ) ++ ++ + class IchunkedTests(TestCase): + def test_even(self): + iterable = (str(x) for x in range(10)) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..e4631e7 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m unittest more_itertools.tests.test_more.OnlyInformativeMessageTests more_itertools.tests.test_more.OneInformativeMessageTests -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m unittest more_itertools.tests.test_more.OnlyInformativeMessageTests more_itertools.tests.test_more.OneInformativeMessageTests -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001971/tests/test.sh b/tasks/format-code-task-001971/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..53a61c9d3ac2ba17bc748fc8b16023e16b4dfa58 --- /dev/null +++ b/tasks/format-code-task-001971/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' +more_itertools/tests/test_more.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001971/tests/test_command.sh b/tasks/format-code-task-001971/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001971/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-002045/environment/Dockerfile b/tasks/format-code-task-002045/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3dd03943255e44a5316fd8b276b44d4e9bf46627 --- /dev/null +++ b/tasks/format-code-task-002045/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:46f73326903fbdfa20e37813a360fbaa71cf6c69bb7f51a008164e351d6f5372 diff --git a/tasks/format-code-task-002045/environment/setup/files/blocklist b/tasks/format-code-task-002045/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002045/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-002045/environment/setup/setup.sh b/tasks/format-code-task-002045/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002045/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-002045/tests/test.patch b/tasks/format-code-task-002045/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f3d710c1f0245a434e3abe514e8db5ca67eb03da --- /dev/null +++ b/tasks/format-code-task-002045/tests/test.patch @@ -0,0 +1,160 @@ +diff --git a/src/datepicker/date-range.spec.ts b/src/datepicker/date-range.spec.ts +new file mode 100644 +index 00000000..1ebeac25 +--- /dev/null ++++ b/src/datepicker/date-range.spec.ts +@@ -0,0 +1,144 @@ ++import 'reflect-metadata'; ++import {NgbDate} from './ngb-date'; ++import {NgbCalendarGregorian} from './ngb-calendar'; ++import {NgbDatepickerService} from './datepicker-service'; ++ ++ ++ ++function rangeType(): any { return (require('./datepicker.module')).NgbDateRange; } ++ ++function makeRange(from: any, to: any): any { ++ const Range = rangeType(); ++ return typeof Range === 'function' ? new Range(from, to) : null; ++} ++ ++describe('NgbDateRange', () => { ++ it('is exported by both the datepicker module and the package entry point', () => { ++ expect(typeof rangeType()).toBe('function'); ++ expect(typeof (require('../index')).NgbDateRange).toBe('function'); ++ }); ++ ++ it('normalizes reversed endpoints without aliasing inputs', () => { ++ const Range = rangeType(); ++ expect(typeof Range).toBe('function'); ++ if (typeof Range !== 'function') { return; } ++ ++ const from = {year: 2017, month: 3, day: 20}; ++ const to = {year: 2017, month: 3, day: 10}; ++ const range = new Range(from, to); ++ ++ expect(range.from).toEqual(new NgbDate(2017, 3, 10)); ++ expect(range.to).toEqual(new NgbDate(2017, 3, 20)); ++ from.day = 1; ++ expect(range.from.day).toBe(10); ++ }); ++ ++ it('represents incomplete selections and reports completion separately', () => { ++ const range = makeRange({year: 2017, month: 3, day: 10}, null); ++ expect(range).not.toBeNull(); ++ if (!range) { return; } ++ expect(range.from).toEqual(new NgbDate(2017, 3, 10)); ++ expect(range.to).toBeNull(); ++ expect(range.isComplete()).toBeFalsy(); ++ expect(makeRange(null, null).isComplete()).toBeFalsy(); ++ expect(makeRange({year: 2017, month: 3, day: 10}, {year: 2017, month: 3, day: 10}).isComplete()) ++ .toBeTruthy(); ++ }); ++ ++ it('contains both endpoints and dates between them, but not dates outside', () => { ++ const range = makeRange({year: 2017, month: 3, day: 10}, {year: 2017, month: 3, day: 20}); ++ expect(range).not.toBeNull(); ++ if (!range) { return; } ++ expect(range.contains(new NgbDate(2017, 3, 10))).toBeTruthy(); ++ expect(range.contains(new NgbDate(2017, 3, 15))).toBeTruthy(); ++ expect(range.contains(new NgbDate(2017, 3, 20))).toBeTruthy(); ++ expect(range.contains(new NgbDate(2017, 3, 9))).toBeFalsy(); ++ expect(range.contains(null)).toBeFalsy(); ++ }); ++ ++ it('treats touching ranges as overlapping and rejects disjoint or incomplete ranges', () => { ++ const range = makeRange({year: 2017, month: 3, day: 10}, {year: 2017, month: 3, day: 20}); ++ expect(range).not.toBeNull(); ++ if (!range) { return; } ++ expect(range.overlaps(makeRange({year: 2017, month: 3, day: 20}, {year: 2017, month: 3, day: 25}))) ++ .toBeTruthy(); ++ expect(range.overlaps(makeRange({year: 2017, month: 3, day: 21}, {year: 2017, month: 3, day: 25}))) ++ .toBeFalsy(); ++ expect(range.overlaps(makeRange({year: 2017, month: 3, day: 15}, null))).toBeFalsy(); ++ }); ++ ++ it('returns a new normalized intersection or null without mutating either range', () => { ++ const left = makeRange({year: 2017, month: 3, day: 10}, {year: 2017, month: 3, day: 20}); ++ const right = makeRange({year: 2017, month: 3, day: 15}, {year: 2017, month: 3, day: 25}); ++ expect(left).not.toBeNull(); ++ expect(right).not.toBeNull(); ++ if (!left || !right) { return; } ++ const intersection = left.intersection(right); ++ expect(intersection).not.toBe(left); ++ expect(intersection).not.toBe(right); ++ expect(intersection.from).toEqual(new NgbDate(2017, 3, 15)); ++ expect(intersection.to).toEqual(new NgbDate(2017, 3, 20)); ++ expect(left.intersection(makeRange({year: 2017, month: 4, day: 1}, {year: 2017, month: 4, day: 2}))) ++ .toBeNull(); ++ expect(left.intersection(makeRange({year: 2017, month: 3, day: 15}, null))).toBeNull(); ++ }); ++ ++ it('compares ranges by endpoint values and does not equate partial ranges with complete ones', () => { ++ const range = makeRange({year: 2017, month: 3, day: 10}, {year: 2017, month: 3, day: 20}); ++ expect(range).not.toBeNull(); ++ if (!range) { return; } ++ expect(range.equals(makeRange({year: 2017, month: 3, day: 10}, {year: 2017, month: 3, day: 20}))).toBeTruthy(); ++ expect(range.equals(makeRange({year: 2017, month: 3, day: 11}, {year: 2017, month: 3, day: 20}))).toBeFalsy(); ++ expect(range.equals(makeRange({year: 2017, month: 3, day: 10}, null))).toBeFalsy(); ++ }); ++}); ++ ++describe('NgbDatepickerService range annotations', () => { ++ it('marks complete ranges inclusively, including both endpoints and interior dates', () => { ++ const calendar = new NgbCalendarGregorian(); ++ const service = new NgbDatepickerService(calendar); ++ const generate: any = (service).generateMonthViewModel; ++ expect(typeof generate).toBe('function'); ++ ++ const range = makeRange({year: 2017, month: 1, day: 10}, {year: 2017, month: 1, day: 12}); ++ const model: any = generate.call( ++ service, new NgbDate(2017, 1, 1), null, null, 1, null, range); ++ expect(model.weeks.some(week => week.days.some(day => day.date.day === 9 && day.inRange === false))).toBeTruthy(); ++ expect(model.weeks.some(week => week.days.some(day => day.date.day === 10 && day.inRange === true))).toBeTruthy(); ++ expect(model.weeks.some(week => week.days.some(day => day.date.day === 11 && day.inRange === true))).toBeTruthy(); ++ expect(model.weeks.some(week => week.days.some(day => day.date.day === 12 && day.inRange === true))).toBeTruthy(); ++ ++ }); ++ ++ it('does not annotate an incomplete range', () => { ++ const calendar = new NgbCalendarGregorian(); ++ const service = new NgbDatepickerService(calendar); ++ const range = makeRange({year: 2017, month: 1, day: 10}, null); ++ const model: any = (service).generateMonthViewModel( ++ new NgbDate(2017, 1, 1), null, null, 1, null, range); ++ const days = [].concat.apply([], model.weeks.map(week => week.days)); ++ expect(days.every(day => day.inRange === undefined)).toBeTruthy(); ++ }); ++ ++ it('preserves the legacy day shape when no range is provided', () => { ++ const calendar = new NgbCalendarGregorian(); ++ const service = new NgbDatepickerService(calendar); ++ const legacy: any = (service).generateMonthViewModel( ++ new NgbDate(2017, 1, 1), null, null, 1, null); ++ const days = [].concat.apply([], legacy.weeks.map(week => week.days)); ++ expect(days.every(day => day.inRange === undefined)).toBeTruthy(); ++ }); ++ ++ it('annotates visible cells across month boundaries, even when a day is disabled by bounds', () => { ++ const calendar = new NgbCalendarGregorian(); ++ const service = new NgbDatepickerService(calendar); ++ const range = makeRange({year: 2016, month: 12, day: 31}, {year: 2017, month: 2, day: 2}); ++ const model: any = (service).generateMonthViewModel( ++ new NgbDate(2017, 1, 1), new NgbDate(2017, 1, 15), null, 1, null, range); ++ const days = [].concat.apply([], model.weeks.map(week => week.days)); ++ expect(days.filter(day => day.date.month === 12 && day.date.day === 31)[0].inRange).toBeTruthy(); ++ expect(days.filter(day => day.date.month === 2 && day.date.day === 2)[0].inRange).toBeTruthy(); ++ expect(days.filter(day => day.date.day === 10 && day.date.month === 1)[0].inRange).toBeTruthy(); ++ expect(days.filter(day => day.date.day === 10 && day.date.month === 1)[0].disabled).toBeTruthy(); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++./node_modules/.bin/tsc ++./node_modules/.bin/jasmine-node temp/datepicker/date-range.spec.js diff --git a/tasks/format-code-task-002045/tests/test.sh b/tasks/format-code-task-002045/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ab6cbf2590b7e00e88a02f4c132fbc8f2f165842 --- /dev/null +++ b/tasks/format-code-task-002045/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/datepicker/date-range.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-002045/tests/test_command.sh b/tasks/format-code-task-002045/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002045/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-002073/environment/Dockerfile b/tasks/format-code-task-002073/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f72a10caa7bd37ae6cc0d50b84ca0871322df360 --- /dev/null +++ b/tasks/format-code-task-002073/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:c6a2a5b3a5b7bb0f2f8b905386441ca1b3d80032ff7d735ec2516c93f5cdd092 diff --git a/tasks/format-code-task-002073/environment/setup/files/blocklist b/tasks/format-code-task-002073/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002073/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-002073/environment/setup/setup.sh b/tasks/format-code-task-002073/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002073/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-002073/tests/test.patch b/tasks/format-code-task-002073/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..189034f646667021f48e791ba6c96b66d1ce436b --- /dev/null +++ b/tasks/format-code-task-002073/tests/test.patch @@ -0,0 +1,536 @@ +diff --git a/pkg/apis/numaflow/v1alpha1/serving_source_podspec_fixture_test.go b/pkg/apis/numaflow/v1alpha1/serving_source_podspec_fixture_test.go +new file mode 100644 +index 000000000..ff49f69ee +--- /dev/null ++++ b/pkg/apis/numaflow/v1alpha1/serving_source_podspec_fixture_test.go +@@ -0,0 +1,343 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package v1alpha1 ++ ++import ( ++ "encoding/base64" ++ "encoding/json" ++ "strconv" ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++ corev1 "k8s.io/api/core/v1" ++ resource "k8s.io/apimachinery/pkg/api/resource" ++ "k8s.io/apimachinery/pkg/util/intstr" ++) ++ ++func fixtureEnvByName(c corev1.Container, name string) (corev1.EnvVar, bool) { ++ for _, env := range c.Env { ++ if env.Name == name { ++ return env, true ++ } ++ } ++ return corev1.EnvVar{}, false ++} ++ ++func fixtureContainerByName(containers []corev1.Container, name string) (corev1.Container, bool) { ++ for _, c := range containers { ++ if c.Name == name { ++ return c, true ++ } ++ } ++ return corev1.Container{}, false ++} ++ ++func fixtureHasServingProbe(c corev1.Container) bool { ++ probes := []*corev1.Probe{c.LivenessProbe, c.ReadinessProbe, c.StartupProbe} ++ for _, p := range probes { ++ if p == nil || p.HTTPGet == nil { ++ continue ++ } ++ if (p.HTTPGet.Path == "/readyz" || p.HTTPGet.Path == "/livez") && ++ p.HTTPGet.Scheme == corev1.URISchemeHTTPS && ++ p.HTTPGet.Port == intstr.FromInt32(VertexHTTPSPort) { ++ return true ++ } ++ } ++ return false ++} ++ ++func fixtureServingSource() *ServingSource { ++ url := "redis://redis:6379" ++ return &ServingSource{ ++ Store: &ServingStore{URL: &url}, ++ } ++} ++ ++func fixtureVertexPodSpecReq() *GetVertexPodSpecReq { ++ return &GetVertexPodSpecReq{ ++ ISBSvcType: ISBSvcTypeRedis, ++ Image: testFlowImage, ++ PullPolicy: corev1.PullIfNotPresent, ++ Env: []corev1.EnvVar{{Name: "fixture-env", Value: "fixture-val"}}, ++ DefaultResources: corev1.ResourceRequirements{ ++ Requests: corev1.ResourceList{ ++ corev1.ResourceCPU: resource.MustParse("100m"), ++ corev1.ResourceMemory: resource.MustParse("100Mi"), ++ }, ++ Limits: corev1.ResourceList{}, ++ }, ++ } ++} ++ ++func fixtureServingPodSpec(t *testing.T, vertexName string, req *GetVertexPodSpecReq, vertices []AbstractVertex, edges []Edge) *corev1.PodSpec { ++ t.Helper() ++ ++ vtx := testVertex.DeepCopy() ++ vtx.Spec.Name = vertexName ++ vtx.Spec.Source = &Source{Serving: fixtureServingSource()} ++ vtx.Spec.UDF = nil ++ vtx.Spec.Sink = nil ++ ++ reqCopy := req.DeepCopy() ++ reqCopy.PipelineSpec.Vertices = vertices ++ reqCopy.PipelineSpec.Edges = edges ++ ++ spec, err := vtx.GetPodSpec(*reqCopy) ++ require.NoError(t, err) ++ require.NotNil(t, spec) ++ return spec ++} ++ ++func TestServingSourcePodSpecUsesMainContainerOnlyForServing(t *testing.T) { ++ spec := fixtureServingPodSpec( ++ t, ++ "serving-main-only", ++ fixtureVertexPodSpecReq(), ++ []AbstractVertex{ ++ {Name: "serving-main-only", Source: &Source{Serving: fixtureServingSource()}}, ++ {Name: "log-sink", Sink: &Sink{}}, ++ }, ++ []Edge{{From: "serving-main-only", To: "log-sink"}}, ++ ) ++ ++ main, ok := fixtureContainerByName(spec.Containers, CtrMain) ++ require.True(t, ok, "main Numaflow container should be present") ++ assert.NotEmpty(t, main.Env) ++ ++ _, hasNamedServingSidecar := fixtureContainerByName(spec.Containers, ServingSourceContainer) ++ assert.False(t, hasNamedServingSidecar, "serving source should not create a separate serving sidecar") ++ ++ for _, c := range spec.Containers { ++ if c.Name == CtrMain { ++ continue ++ } ++ assert.NotContains(t, c.Args, "--serving", "non-main container must not run serving mode") ++ assert.False(t, fixtureHasServingProbe(c), "non-main container must not expose serving health probes") ++ } ++} ++ ++func TestServingSourcePodSpecRejectsSidecarForAlternateServingInputs(t *testing.T) { ++ req := fixtureVertexPodSpecReq() ++ req.Env = []corev1.EnvVar{{Name: "controller-env", Value: "controller-val"}} ++ ++ spec := fixtureServingPodSpec( ++ t, ++ "alternate-serving-main", ++ req, ++ []AbstractVertex{ ++ {Name: "alternate-serving-main", Source: &Source{Serving: fixtureServingSource()}}, ++ {Name: "alternate-sink", Sink: &Sink{}}, ++ }, ++ []Edge{{From: "alternate-serving-main", To: "alternate-sink"}}, ++ ) ++ ++ require.Len(t, spec.Containers, 1, "a simple serving source pod should only have the main container") ++ assert.Equal(t, CtrMain, spec.Containers[0].Name) ++ assert.NotContains(t, spec.Containers[0].Args, "--serving") ++ assert.False(t, fixtureHasServingProbe(spec.Containers[0]), "main container should not be configured as the removed serving sidecar") ++} ++ ++func TestServingSourceMainContainerHasServingRuntimeEnv(t *testing.T) { ++ spec := fixtureServingPodSpec( ++ t, ++ "edge-http-in", ++ fixtureVertexPodSpecReq(), ++ []AbstractVertex{ ++ {Name: "edge-http-in", Source: &Source{Serving: fixtureServingSource()}}, ++ {Name: "map-a", UDF: &UDF{}}, ++ {Name: "sink-a", Sink: &Sink{}}, ++ }, ++ []Edge{ ++ {From: "edge-http-in", To: "map-a"}, ++ {From: "map-a", To: "sink-a"}, ++ }, ++ ) ++ ++ main, ok := fixtureContainerByName(spec.Containers, CtrMain) ++ require.True(t, ok) ++ ++ minSpecEnv, ok := fixtureEnvByName(main, EnvServingMinPipelineSpec) ++ require.True(t, ok, "main container should receive minimal pipeline spec") ++ require.NotEmpty(t, minSpecEnv.Value) ++ decoded, err := base64.StdEncoding.DecodeString(minSpecEnv.Value) ++ require.NoError(t, err) ++ var decodedSpec PipelineSpec ++ require.NoError(t, json.Unmarshal(decoded, &decodedSpec)) ++ require.Len(t, decodedSpec.Vertices, 3) ++ assert.Equal(t, "edge-http-in", decodedSpec.Vertices[0].Name) ++ assert.Equal(t, "map-a", decodedSpec.Vertices[1].Name) ++ require.Len(t, decodedSpec.Edges, 2) ++ assert.Equal(t, "edge-http-in", decodedSpec.Edges[0].From) ++ assert.Equal(t, "map-a", decodedSpec.Edges[0].To) ++ assert.Equal(t, "map-a", decodedSpec.Edges[1].From) ++ assert.Equal(t, "sink-a", decodedSpec.Edges[1].To) ++ ++ portEnv, ok := fixtureEnvByName(main, EnvServingPort) ++ require.True(t, ok, "main container should receive serving listen port") ++ assert.Equal(t, strconv.Itoa(VertexHTTPSPort), portEnv.Value) ++ assert.Nil(t, portEnv.ValueFrom) ++ ++ hostIPEnv, ok := fixtureEnvByName(main, EnvServingHostIP) ++ require.True(t, ok, "main container should receive pod IP source") ++ require.NotNil(t, hostIPEnv.ValueFrom) ++ require.NotNil(t, hostIPEnv.ValueFrom.FieldRef) ++ assert.Equal(t, "status.podIP", hostIPEnv.ValueFrom.FieldRef.FieldPath) ++} ++ ++func TestServingSourceMainContainerRuntimeEnvForSingleEdgePipeline(t *testing.T) { ++ spec := fixtureServingPodSpec( ++ t, ++ "single-edge-serving", ++ fixtureVertexPodSpecReq(), ++ []AbstractVertex{ ++ {Name: "single-edge-serving", Source: &Source{Serving: fixtureServingSource()}}, ++ {Name: "single-edge-sink", Sink: &Sink{}}, ++ }, ++ []Edge{{From: "single-edge-serving", To: "single-edge-sink"}}, ++ ) ++ ++ main, ok := fixtureContainerByName(spec.Containers, CtrMain) ++ require.True(t, ok) ++ ++ minSpecEnv, ok := fixtureEnvByName(main, EnvServingMinPipelineSpec) ++ require.True(t, ok, "main container should receive minimal pipeline spec for every serving source shape") ++ decoded, err := base64.StdEncoding.DecodeString(minSpecEnv.Value) ++ require.NoError(t, err) ++ var decodedSpec PipelineSpec ++ require.NoError(t, json.Unmarshal(decoded, &decodedSpec)) ++ require.Len(t, decodedSpec.Vertices, 2) ++ assert.Equal(t, "single-edge-serving", decodedSpec.Vertices[0].Name) ++ assert.Equal(t, "single-edge-sink", decodedSpec.Vertices[1].Name) ++ require.Len(t, decodedSpec.Edges, 1) ++ assert.Equal(t, "single-edge-serving", decodedSpec.Edges[0].From) ++ assert.Equal(t, "single-edge-sink", decodedSpec.Edges[0].To) ++ ++ portEnv, ok := fixtureEnvByName(main, EnvServingPort) ++ require.True(t, ok) ++ assert.Equal(t, strconv.Itoa(VertexHTTPSPort), portEnv.Value) ++ assert.Nil(t, portEnv.ValueFrom) ++ ++ hostIPEnv, ok := fixtureEnvByName(main, EnvServingHostIP) ++ require.True(t, ok) ++ require.NotNil(t, hostIPEnv.ValueFrom) ++ require.NotNil(t, hostIPEnv.ValueFrom.FieldRef) ++ assert.Equal(t, "status.podIP", hostIPEnv.ValueFrom.FieldRef.FieldPath) ++} ++ ++func TestCallbackEnvOnlyForPipelinesWithServingSource(t *testing.T) { ++ servingPipelineReq := fixtureVertexPodSpecReq() ++ servingPipelineReq.PipelineSpec.Vertices = []AbstractVertex{ ++ {Name: "callback-serving-in", Source: &Source{Serving: fixtureServingSource()}}, ++ {Name: "callback-map", UDF: &UDF{}}, ++ {Name: "callback-sink", Sink: &Sink{}}, ++ } ++ servingPipelineReq.PipelineSpec.Edges = []Edge{ ++ {From: "callback-serving-in", To: "callback-map"}, ++ {From: "callback-map", To: "callback-sink"}, ++ } ++ ++ for _, vtx := range []Vertex{ ++ func() Vertex { ++ v := *testVertex.DeepCopy() ++ v.Spec.Name = "callback-serving-in" ++ v.Spec.Source = &Source{Serving: fixtureServingSource()} ++ v.Spec.UDF = nil ++ v.Spec.Sink = nil ++ return v ++ }(), ++ func() Vertex { ++ v := *testVertex.DeepCopy() ++ v.Spec.Name = "callback-map" ++ v.Spec.Source = nil ++ v.Spec.UDF = &UDF{Builtin: &Function{Name: "cat"}} ++ v.Spec.Sink = nil ++ return v ++ }(), ++ } { ++ spec, err := vtx.GetPodSpec(*servingPipelineReq) ++ require.NoError(t, err) ++ main, ok := fixtureContainerByName(spec.Containers, CtrMain) ++ require.True(t, ok) ++ ++ callbackEnabled, ok := fixtureEnvByName(main, EnvCallbackEnabled) ++ require.True(t, ok, "all vertices in a serving-source pipeline should have callback enabled") ++ enabled, err := strconv.ParseBool(callbackEnabled.Value) ++ require.NoError(t, err) ++ assert.True(t, enabled) ++ assert.Nil(t, callbackEnabled.ValueFrom, "callback enabled should not be annotation-sourced") ++ ++ _, hasCallbackURL := fixtureEnvByName(main, EnvCallbackURL) ++ assert.False(t, hasCallbackURL, "callback URL env should not be injected") ++ } ++ ++ nonServingVtx := testVertex.DeepCopy() ++ nonServingVtx.Spec.Name = "plain-source" ++ nonServingVtx.Spec.Source = &Source{} ++ nonServingVtx.Spec.UDF = nil ++ nonServingVtx.Spec.Sink = nil ++ nonServingReq := fixtureVertexPodSpecReq() ++ nonServingReq.PipelineSpec.Vertices = []AbstractVertex{ ++ {Name: "plain-source", Source: &Source{}}, ++ {Name: "plain-sink", Sink: &Sink{}}, ++ } ++ nonServingReq.PipelineSpec.Edges = []Edge{{From: "plain-source", To: "plain-sink"}} ++ ++ spec, err := nonServingVtx.GetPodSpec(*nonServingReq) ++ require.NoError(t, err) ++ main, ok := fixtureContainerByName(spec.Containers, CtrMain) ++ require.True(t, ok) ++ _, hasCallbackEnabled := fixtureEnvByName(main, EnvCallbackEnabled) ++ assert.False(t, hasCallbackEnabled, "pipelines without a serving source should not receive callback enabled env") ++ _, hasCallbackURL := fixtureEnvByName(main, EnvCallbackURL) ++ assert.False(t, hasCallbackURL, "pipelines without a serving source should not receive callback URL env") ++} ++ ++func TestCallbackEnvEnabledForSinkInServingPipeline(t *testing.T) { ++ servingPipelineReq := fixtureVertexPodSpecReq() ++ servingPipelineReq.PipelineSpec.Vertices = []AbstractVertex{ ++ {Name: "orders-http", Source: &Source{Serving: fixtureServingSource()}}, ++ {Name: "orders-map", UDF: &UDF{Builtin: &Function{Name: "cat"}}}, ++ {Name: "orders-sink", Sink: &Sink{}}, ++ } ++ servingPipelineReq.PipelineSpec.Edges = []Edge{ ++ {From: "orders-http", To: "orders-map"}, ++ {From: "orders-map", To: "orders-sink"}, ++ } ++ ++ sinkVtx := testVertex.DeepCopy() ++ sinkVtx.Spec.Name = "orders-sink" ++ sinkVtx.Spec.Source = nil ++ sinkVtx.Spec.UDF = nil ++ sinkVtx.Spec.Sink = &Sink{} ++ ++ spec, err := sinkVtx.GetPodSpec(*servingPipelineReq) ++ require.NoError(t, err) ++ main, ok := fixtureContainerByName(spec.Containers, CtrMain) ++ require.True(t, ok) ++ ++ callbackEnabled, ok := fixtureEnvByName(main, EnvCallbackEnabled) ++ require.True(t, ok, "sink vertices in a serving-source pipeline should have callback enabled") ++ enabled, err := strconv.ParseBool(callbackEnabled.Value) ++ require.NoError(t, err) ++ assert.True(t, enabled) ++ assert.Nil(t, callbackEnabled.ValueFrom, "callback enabled should not be annotation-sourced") ++ ++ _, hasCallbackURL := fixtureEnvByName(main, EnvCallbackURL) ++ assert.False(t, hasCallbackURL, "callback URL env should not be injected") ++} +diff --git a/pkg/reconciler/validator/serving_source_reduce_fixture_test.go b/pkg/reconciler/validator/serving_source_reduce_fixture_test.go +new file mode 100644 +index 000000000..5bc0572d9 +--- /dev/null ++++ b/pkg/reconciler/validator/serving_source_reduce_fixture_test.go +@@ -0,0 +1,156 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package validator ++ ++import ( ++ "testing" ++ "time" ++ ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++ corev1 "k8s.io/api/core/v1" ++ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ++ ++ dfv1 "github.com/numaproj/numaflow/pkg/apis/numaflow/v1alpha1" ++) ++ ++func fixturePipelineWithVertices(vertices []dfv1.AbstractVertex, edges []dfv1.Edge) *dfv1.Pipeline { ++ pl := testPipeline.DeepCopy() ++ pl.Spec.Vertices = vertices ++ pl.Spec.Edges = edges ++ return pl ++} ++ ++func fixtureReduceUDF() *dfv1.UDF { ++ return &dfv1.UDF{ ++ Container: &dfv1.Container{Image: "my-image"}, ++ GroupBy: &dfv1.GroupBy{ ++ Window: dfv1.Window{ ++ Fixed: &dfv1.FixedWindow{ ++ Length: &metav1.Duration{Duration: time.Minute}, ++ }, ++ }, ++ Keyed: true, ++ Storage: &dfv1.PBQStorage{ ++ EmptyDir: &corev1.EmptyDirVolumeSource{}, ++ }, ++ }, ++ } ++} ++ ++func fixtureServingSource() *dfv1.ServingSource { ++ url := "redis://redis:6379" ++ return &dfv1.ServingSource{ ++ Store: &dfv1.ServingStore{URL: &url}, ++ } ++} ++ ++func TestValidatePipelineRejectsServingSourceWithReduce(t *testing.T) { ++ cases := []struct { ++ name string ++ serving string ++ reduce string ++ throughMap string ++ }{ ++ { ++ name: "direct names", ++ serving: "serving-in", ++ reduce: "reduce-vtx", ++ throughMap: "map-before-reduce", ++ }, ++ { ++ name: "different names to prevent hardcoding", ++ serving: "http-in", ++ reduce: "aggregate", ++ throughMap: "normalize", ++ }, ++ } ++ ++ for _, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ pl := fixturePipelineWithVertices( ++ []dfv1.AbstractVertex{ ++ {Name: tc.serving, Source: &dfv1.Source{Serving: fixtureServingSource()}}, ++ {Name: tc.throughMap, UDF: &dfv1.UDF{Builtin: &dfv1.Function{Name: "cat"}}}, ++ {Name: tc.reduce, UDF: fixtureReduceUDF()}, ++ {Name: "out", Sink: &dfv1.Sink{}}, ++ }, ++ []dfv1.Edge{ ++ {From: tc.serving, To: tc.throughMap}, ++ {From: tc.throughMap, To: tc.reduce}, ++ {From: tc.reduce, To: "out"}, ++ }, ++ ) ++ ++ err := ValidatePipeline(pl) ++ require.Error(t, err) ++ }) ++ } ++} ++ ++func TestValidatePipelineRejectsServingReduceWhenServingSourceIsNotFirstOrTwoHop(t *testing.T) { ++ pl := fixturePipelineWithVertices( ++ []dfv1.AbstractVertex{ ++ {Name: "plain-source", Source: &dfv1.Source{}}, ++ {Name: "late-source", Source: &dfv1.Source{Serving: fixtureServingSource()}}, ++ {Name: "direct-reduce", UDF: fixtureReduceUDF()}, ++ {Name: "joined-sink", Sink: &dfv1.Sink{}}, ++ }, ++ []dfv1.Edge{ ++ {From: "plain-source", To: "direct-reduce"}, ++ {From: "late-source", To: "direct-reduce"}, ++ {From: "direct-reduce", To: "joined-sink"}, ++ }, ++ ) ++ ++ err := ValidatePipeline(pl) ++ require.Error(t, err) ++} ++ ++func TestValidatePipelineAllowsServingWithoutReduceAndReduceWithoutServing(t *testing.T) { ++ t.Run("serving source without reduce remains valid", func(t *testing.T) { ++ pl := fixturePipelineWithVertices( ++ []dfv1.AbstractVertex{ ++ {Name: "serving-ok", Source: &dfv1.Source{Serving: fixtureServingSource()}}, ++ {Name: "map-ok", UDF: &dfv1.UDF{Builtin: &dfv1.Function{Name: "cat"}}}, ++ {Name: "sink-ok", Sink: &dfv1.Sink{}}, ++ }, ++ []dfv1.Edge{ ++ {From: "serving-ok", To: "map-ok"}, ++ {From: "map-ok", To: "sink-ok"}, ++ }, ++ ) ++ ++ assert.NoError(t, ValidatePipeline(pl)) ++ }) ++ ++ t.Run("reduce without serving source remains valid", func(t *testing.T) { ++ pl := fixturePipelineWithVertices( ++ []dfv1.AbstractVertex{ ++ {Name: "input-ok", Source: &dfv1.Source{}}, ++ {Name: "reduce-ok", UDF: fixtureReduceUDF()}, ++ {Name: "sink-ok", Sink: &dfv1.Sink{}}, ++ }, ++ []dfv1.Edge{ ++ {From: "input-ok", To: "reduce-ok"}, ++ {From: "reduce-ok", To: "sink-ok"}, ++ }, ++ ) ++ ++ assert.NoError(t, ValidatePipeline(pl)) ++ }) ++} +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 @@ ++#!/bin/bash ++set -uo pipefail ++ ++cd /testbed ++set -e ++ ++case "${1:-}" in ++ base) ++ go test ./pkg/reconciler/validator/ -count=1 -run 'TestValidateInterStepBuffer|TestValidateMonoVertex|TestValidatePipeline|TestValidateReducePipeline|TestValidateVertex|TestValidateUDF|Test_validateSideInputs|Test_getCyclesFromVertex|Test_validateCycles|Test_validateIdleSource|TestValidateSink|TestIsValidSinkRetryStrategy' -v ++ go test ./pkg/apis/numaflow/v1alpha1/ -count=1 -run 'TestOwnedBuffers|TestOwnedBuffersSource|TestGetFromBuckets|TestGetToBuffers|TestGetToBuffersSink|TestWithoutReplicas|TestGetVertexReplicas|TestGetHeadlessSvcSpec|TestGetServiceObjs|TestGetHeadlessServiceName|Test_getType|TestVertexMarkPhase|TestVertexMarkPhaseRunning|TestVertexMarkPhaseFailed|Test_VertexMarkPodNotHealthy|Test_VertexMarkPodHealthy|Test_VertexMarkDeployed|Test_VertexMarkDeployFailed|TestGetPipelineSpec|TestUpdateVertexCondition' -v ++ ;; ++ new) ++ go test ./pkg/apis/numaflow/v1alpha1/ -count=1 -run 'TestServingSourcePodSpecUsesMainContainerOnlyForServing|TestServingSourcePodSpecRejectsSidecarForAlternateServingInputs|TestServingSourceMainContainerHasServingRuntimeEnv|TestServingSourceMainContainerRuntimeEnvForSingleEdgePipeline|TestCallbackEnvOnlyForPipelinesWithServingSource|TestCallbackEnvEnabledForSinkInServingPipeline' -v ++ go test ./pkg/reconciler/validator/ -count=1 -run 'TestValidatePipelineRejectsServingSourceWithReduce|TestValidatePipelineRejectsServingReduceWhenServingSourceIsNotFirstOrTwoHop|TestValidatePipelineAllowsServingWithoutReduceAndReduceWithoutServing' -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002073/tests/test.sh b/tasks/format-code-task-002073/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d3c40715976d22ce21e25a4b175a82c26e8985e2 --- /dev/null +++ b/tasks/format-code-task-002073/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/apis/numaflow/v1alpha1/serving_source_podspec_fixture_test.go +pkg/reconciler/validator/serving_source_reduce_fixture_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-002073/tests/test_command.sh b/tasks/format-code-task-002073/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002073/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-002080/tests/test.patch b/tasks/format-code-task-002080/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fefcdee181a3d811c533a64a3223b316f21959ca --- /dev/null +++ b/tasks/format-code-task-002080/tests/test.patch @@ -0,0 +1,93 @@ +diff --git a/test/preconnect.test.js b/test/preconnect.test.js +new file mode 100644 +index 0000000..25dca2f +--- /dev/null ++++ b/test/preconnect.test.js +@@ -0,0 +1,65 @@ ++const path = require('path') ++const googleFontsModule = require(path.resolve(__dirname, '../lib/module')) ++ ++function createMockContext () { ++ let hookFn ++ const ctx = { ++ nuxt: { ++ hook: (event, fn) => { hookFn = fn }, ++ resolver: { resolveAlias: a => a } ++ }, ++ options: { ++ dir: { assets: 'assets' }, ++ head: { link: [] }, ++ googleFonts: { families: { Roboto: true } }, ++ css: [] ++ }, ++ _getHook: () => hookFn ++ } ++ return ctx ++} ++ ++async function runModule (moduleOptions = {}) { ++ const ctx = createMockContext() ++ googleFontsModule.call(ctx, moduleOptions) ++ await ctx._getHook()() ++ return ctx ++} ++ ++describe('preconnect crossorigin', () => { ++ test('preconnect link has empty-string crossorigin (renders as bare attribute)', async () => { ++ const ctx = await runModule() ++ const preconnect = ctx.options.head.link.find(l => l.hid === 'gf-preconnect') ++ expect(preconnect).toBeDefined() ++ expect(preconnect.crossorigin).toBe('') ++ }) ++ ++ test('preconnect crossorigin is not the buggy boolean true', async () => { ++ const ctx = await runModule() ++ const preconnect = ctx.options.head.link.find(l => l.hid === 'gf-preconnect') ++ expect(preconnect.crossorigin).not.toBe(true) ++ }) ++ ++ test('preconnect crossorigin is not a non-empty string value', async () => { ++ const ctx = await runModule() ++ const preconnect = ctx.options.head.link.find(l => l.hid === 'gf-preconnect') ++ expect(typeof preconnect.crossorigin).toBe('string') ++ expect(preconnect.crossorigin.length).toBe(0) ++ }) ++ ++ test('preconnect link retains hid, rel, and href', async () => { ++ const ctx = await runModule() ++ const preconnect = ctx.options.head.link.find(l => l.hid === 'gf-preconnect') ++ expect(preconnect.hid).toBe('gf-preconnect') ++ expect(preconnect.rel).toBe('preconnect') ++ expect(preconnect.href).toBe('https://fonts.gstatic.com/') ++ }) ++ ++ test('preconnect link is not pushed when preconnect option is false', async () => { ++ const ctx = createMockContext() ++ googleFontsModule.call(ctx, { preconnect: false }) ++ await ctx._getHook()() ++ const preconnect = ctx.options.head.link.find(l => l.hid === 'gf-preconnect') ++ expect(preconnect).toBeUndefined() ++ }) ++}) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..d06e32d +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["node_modules/.bin/jest test/preconnect.test.js --coverage=false"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++node_modules/.bin/jest test/preconnect.test.js --coverage=false ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002080/tests/test_command.sh b/tasks/format-code-task-002080/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002080/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-002087/environment/Dockerfile b/tasks/format-code-task-002087/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7a16edcc3385cbe3887096333766d7b06e712543 --- /dev/null +++ b/tasks/format-code-task-002087/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:cdd157f634fd23998f29620103932cf879bb0e9e0950fa99e0fbf2a8a5196ab0 diff --git a/tasks/format-code-task-002087/environment/setup/files/blocklist b/tasks/format-code-task-002087/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002087/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-002087/environment/setup/setup.sh b/tasks/format-code-task-002087/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002087/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-002087/tests/test.patch b/tasks/format-code-task-002087/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..278e0132b818fddfc4659a12623bbc009e6bab85 --- /dev/null +++ b/tasks/format-code-task-002087/tests/test.patch @@ -0,0 +1,137 @@ +diff --git a/obspy/core/tests/test_stats.py b/obspy/core/tests/test_stats.py +index 950072fcd..cb547166d 100644 +--- a/obspy/core/tests/test_stats.py ++++ b/obspy/core/tests/test_stats.py +@@ -5,6 +5,8 @@ import pickle + import unittest + import warnings + ++import numpy as np ++ + from obspy import Stream, Trace, UTCDateTime, read + from obspy.core import Stats + from obspy.core.util import AttribDict +@@ -345,6 +347,101 @@ class StatsTestCase(unittest.TestCase): + self.assertEqual(stats.channel, 'HHZ') + + ++ def test_trace_copy_preserves_high_sampling_rate(self): ++ """ ++ Regression test: Trace.copy() should preserve the original ++ sampling_rate exactly, even at large values where floating point ++ round-tripping through delta loses precision. ++ """ ++ tr = Trace(data=np.ones(100000), ++ header={'sampling_rate': 100000.}) ++ self.assertEqual(tr.stats.sampling_rate, 100000.0) ++ tr2 = tr.copy() ++ self.assertEqual(tr2.stats.sampling_rate, 100000.0) ++ ++ def test_stats_deepcopy_preserves_high_sampling_rate(self): ++ """ ++ Regression test: copy.deepcopy(stats) preserves the original ++ sampling_rate exactly. ++ """ ++ stats = Stats({'sampling_rate': 100000.0}) ++ self.assertEqual(stats.sampling_rate, 100000.0) ++ stats2 = copy.deepcopy(stats) ++ self.assertEqual(stats2.sampling_rate, 100000.0) ++ ++ def test_trace_deepcopy_preserves_high_sampling_rate(self): ++ """ ++ Regression test: copy.deepcopy(trace) preserves the original ++ sampling_rate exactly. ++ """ ++ tr = Trace(data=np.ones(100000), ++ header={'sampling_rate': 100000.}) ++ tr2 = copy.deepcopy(tr) ++ self.assertEqual(tr2.stats.sampling_rate, 100000.0) ++ ++ def test_stats_pickle_preserves_high_sampling_rate(self): ++ """ ++ Regression test: pickling/unpickling a Stats object preserves ++ the original sampling_rate exactly. ++ """ ++ stats = Stats({'sampling_rate': 100000.0, ++ 'starttime': UTCDateTime(2020, 1, 1), ++ 'npts': 100000}) ++ for protocol in (0, 1, 2): ++ stats2 = pickle.loads(pickle.dumps(stats, protocol=protocol)) ++ self.assertEqual(stats2.sampling_rate, 100000.0) ++ ++ def test_stats_copy_preserves_derived_endtime(self): ++ """ ++ After copying a high-sampling-rate Stats, the derived endtime ++ must match the original endtime (since sampling_rate is preserved). ++ """ ++ stats = Stats({'sampling_rate': 100000.0, ++ 'starttime': UTCDateTime(2020, 1, 1), ++ 'npts': 100000}) ++ original_endtime = stats.endtime ++ stats2 = copy.deepcopy(stats) ++ self.assertEqual(stats2.endtime, original_endtime) ++ self.assertEqual(stats2.delta, stats.delta) ++ ++ def test_trace_copy_equals_original_high_sr(self): ++ """ ++ Regression test: a copy of a high-sampling-rate Trace must compare ++ equal to the original (both data and stats). ++ """ ++ tr = Trace(data=np.ones(100000), ++ header={'sampling_rate': 100000.}) ++ tr2 = tr.copy() ++ self.assertEqual(tr, tr2) ++ ++ def test_stats_normal_sampling_rate_copy_preservation(self): ++ """ ++ Preservation: ordinary sampling_rate values must still round-trip ++ through copy/deepcopy correctly. ++ """ ++ stats = Stats({'sampling_rate': 200.0, ++ 'starttime': UTCDateTime(2020, 1, 1), ++ 'npts': 1000, ++ 'network': 'BW', ++ 'station': 'ROTZ'}) ++ stats2 = copy.deepcopy(stats) ++ self.assertEqual(stats2.sampling_rate, 200.0) ++ self.assertEqual(stats2.delta, 1.0 / 200.0) ++ self.assertEqual(stats2.network, 'BW') ++ self.assertEqual(stats2.station, 'ROTZ') ++ self.assertEqual(stats2.npts, 1000) ++ ++ def test_stats_high_sampling_rate_copy_preserves_sampling_rate(self): ++ """ ++ Another high-rate value whose reciprocal isn't exactly representable ++ must still survive copying. ++ """ ++ stats = Stats({'sampling_rate': 250000.0}) ++ self.assertEqual(stats.sampling_rate, 250000.0) ++ stats2 = copy.deepcopy(stats) ++ self.assertEqual(stats2.sampling_rate, 250000.0) ++ ++ + def suite(): + return unittest.makeSuite(StatsTestCase, 'test') + +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..b690f369a +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest obspy/core/tests/test_stats.py -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest obspy/core/tests/test_stats.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002087/tests/test.sh b/tasks/format-code-task-002087/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bcfe55d77749b460120e730fceb90785fae6b494 --- /dev/null +++ b/tasks/format-code-task-002087/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' +obspy/core/tests/test_stats.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002087/tests/test_command.sh b/tasks/format-code-task-002087/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002087/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-002101/environment/Dockerfile b/tasks/format-code-task-002101/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..22806e251499c931488eae31453afaaa639ce43d --- /dev/null +++ b/tasks/format-code-task-002101/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:fdf3802103037a0ad5b3543a7086fb805aa614e92f41227d56f3b29c693b4c30 diff --git a/tasks/format-code-task-002101/environment/setup/files/blocklist b/tasks/format-code-task-002101/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002101/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-002101/environment/setup/setup.sh b/tasks/format-code-task-002101/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002101/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-002101/tests/test.patch b/tasks/format-code-task-002101/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..526f016faf38b8d1d35d787575d9083133c702fa --- /dev/null +++ b/tasks/format-code-task-002101/tests/test.patch @@ -0,0 +1,506 @@ +diff --git a/usercase-test-coderl/msearch_stateful_test.go b/usercase-test-coderl/msearch_stateful_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/msearch_stateful_test.go +@@ -0,0 +1,477 @@ ++package usercase_test_coderl ++ ++import ( ++ "context" ++ "encoding/json" ++ "fmt" ++ "io" ++ "net/http" ++ "net/http/httptest" ++ "net/url" ++ "reflect" ++ "strings" ++ "testing" ++ ++ elastic "github.com/olivere/elastic/v7" ++) ++ ++func newClient(t *testing.T, serverURL string) *elastic.Client { ++ t.Helper() ++ ++ client, err := elastic.NewSimpleClient(elastic.SetURL(serverURL)) ++ if err != nil { ++ t.Fatalf("NewSimpleClient() error = %v", err) ++ } ++ return client ++} ++ ++func oneResponseBody(took int64, total int64, status int, timedOut bool) string { ++ return fmt.Sprintf(`{"took":%d,"responses":[{"took":5,"timed_out":%t,"hits":{"total":{"value":%d,"relation":"eq"},"hits":[]},"status":%d}]}`, ++ took, timedOut, total, status) ++} ++ ++func TestMultiSearchBuildsTwoRequestBatchWithDefaultIndexAndQueryOptions(t *testing.T) { ++ ++ ++ var gotMethod, gotPath, gotBody string ++ var gotQuery url.Values ++ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ gotMethod = r.Method ++ gotPath = r.URL.Path ++ gotQuery = r.URL.Query() ++ b, err := io.ReadAll(r.Body) ++ if err != nil { ++ t.Fatalf("ReadAll(request body) error = %v", err) ++ } ++ gotBody = string(b) ++ w.Header().Set("Content-Type", "application/json") ++ _, _ = io.WriteString(w, `{"took":17,"responses":[{"took":5,"timed_out":false,"hits":{"total":{"value":2,"relation":"eq"},"hits":[]},"status":200},{"took":7,"timed_out":true,"hits":{"total":{"value":4,"relation":"gte"},"hits":[]},"status":206}]}`) ++ })) ++ defer ts.Close() ++ ++ client := newClient(t, ts.URL) ++ req1 := elastic.NewSearchRequest().Source(`{"query":{"match_all":{}},"size":1}`) ++ req2 := elastic.NewSearchRequest(). ++ Index("explicit-a", "explicit-b"). ++ Routing("r-9"). ++ RequestCache(true). ++ Source(`{"query":{"term":{"level":"error"}}}`) ++ ++ result, err := client.MultiSearch(). ++ Add(req1, req2). ++ Index("logs"). ++ Pretty(true). ++ Human(false). ++ ErrorTrace(true). ++ FilterPath("responses.hits", "took"). ++ MaxConcurrentSearches(3). ++ PreFilterShardSize(11). ++ Do(context.Background()) ++ if err != nil { ++ t.Fatalf("MultiSearch Do() error = %v", err) ++ } ++ ++ if gotMethod != "GET" { ++ t.Fatalf("request method = %q, want %q", gotMethod, "GET") ++ } ++ if gotPath != "/_msearch" { ++ t.Fatalf("request path = %q, want %q", gotPath, "/_msearch") ++ } ++ if gotQuery.Get("pretty") != "true" { ++ t.Fatalf("query pretty = %q, want %q", gotQuery.Get("pretty"), "true") ++ } ++ if gotQuery.Get("human") != "false" { ++ t.Fatalf("query human = %q, want %q", gotQuery.Get("human"), "false") ++ } ++ if gotQuery.Get("error_trace") != "true" { ++ t.Fatalf("query error_trace = %q, want %q", gotQuery.Get("error_trace"), "true") ++ } ++ if gotQuery.Get("filter_path") != "responses.hits,took" { ++ t.Fatalf("query filter_path = %q, want %q", gotQuery.Get("filter_path"), "responses.hits,took") ++ } ++ if gotQuery.Get("max_concurrent_searches") != "3" { ++ t.Fatalf("query max_concurrent_searches = %q, want %q", gotQuery.Get("max_concurrent_searches"), "3") ++ } ++ if gotQuery.Get("pre_filter_shard_size") != "11" { ++ t.Fatalf("query pre_filter_shard_size = %q, want %q", gotQuery.Get("pre_filter_shard_size"), "11") ++ } ++ ++ ++ bodyLines := splitNDJSONLines(t, gotBody, 4) ++ assertHeaderIndices(t, bodyLines[0], []string{"logs"}) ++ assertJSONLineEqual(t, bodyLines[1], `{"query":{"match_all":{}},"size":1}`) ++ assertHeaderIndices(t, bodyLines[2], []string{"explicit-a", "explicit-b"}) ++ assertJSONLineEqual(t, bodyLines[3], `{"query":{"term":{"level":"error"}}}`) ++ if result.TookInMillis != 17 { ++ t.Fatalf("result TookInMillis = %d, want %d", result.TookInMillis, int64(17)) ++ } ++ if len(result.Responses) != 2 { ++ t.Fatalf("len(result.Responses) = %d, want %d", len(result.Responses), 2) ++ } ++ if result.Responses[0].TookInMillis != 5 { ++ t.Fatalf("response[0] TookInMillis = %d, want %d", result.Responses[0].TookInMillis, int64(5)) ++ } ++ if result.Responses[0].TotalHits() != 2 { ++ t.Fatalf("response[0] TotalHits() = %d, want %d", result.Responses[0].TotalHits(), int64(2)) ++ } ++ if result.Responses[0].Status != 200 { ++ t.Fatalf("response[0] Status = %d, want %d", result.Responses[0].Status, 200) ++ } ++ if result.Responses[1].TookInMillis != 7 { ++ t.Fatalf("response[1] TookInMillis = %d, want %d", result.Responses[1].TookInMillis, int64(7)) ++ } ++ if result.Responses[1].TotalHits() != 4 { ++ t.Fatalf("response[1] TotalHits() = %d, want %d", result.Responses[1].TotalHits(), int64(4)) ++ } ++ if result.Responses[1].Status != 206 { ++ t.Fatalf("response[1] Status = %d, want %d", result.Responses[1].Status, 206) ++ } ++ if result.Responses[1].TimedOut != true { ++ t.Fatalf("response[1] TimedOut = %t, want %t", result.Responses[1].TimedOut, true) ++ } ++} ++ ++func TestMultiSearchHeaderAddsCustomHeader(t *testing.T) { ++ ++ ++ var gotHeader string ++ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ gotHeader = r.Header.Get("X-Trace") ++ w.Header().Set("Content-Type", "application/json") ++ _, _ = io.WriteString(w, oneResponseBody(3, 1, 200, false)) ++ })) ++ defer ts.Close() ++ ++ result, err := newClient(t, ts.URL).MultiSearch(). ++ Add(elastic.NewSearchRequest().Source(`{"query":{"match_all":{}}}`)). ++ Header("X-Trace", "trace-1"). ++ Do(context.Background()) ++ if err != nil { ++ t.Fatalf("MultiSearch Do() error = %v", err) ++ } ++ ++ if gotHeader != "trace-1" { ++ t.Fatalf("X-Trace header = %q, want %q", gotHeader, "trace-1") ++ } ++ if result.TookInMillis != 3 { ++ t.Fatalf("result TookInMillis = %d, want %d", result.TookInMillis, int64(3)) ++ } ++ if len(result.Responses) != 1 { ++ t.Fatalf("len(result.Responses) = %d, want %d", len(result.Responses), 1) ++ } ++} ++ ++func TestNewMultiSearchServiceHeadersSetsCustomHeaders(t *testing.T) { ++ ++ ++ var gotHeader string ++ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ gotHeader = r.Header.Get("X-Bulk") ++ w.Header().Set("Content-Type", "application/json") ++ _, _ = io.WriteString(w, oneResponseBody(4, 8, 201, false)) ++ })) ++ defer ts.Close() ++ ++ result, err := elastic.NewMultiSearchService(newClient(t, ts.URL)). ++ Add(elastic.NewSearchRequest().Source(`{"query":{"match_all":{}}}`)). ++ Headers(http.Header{"X-Bulk": []string{"bulk-1"}}). ++ Do(context.Background()) ++ if err != nil { ++ t.Fatalf("MultiSearch Do() error = %v", err) ++ } ++ ++ if gotHeader != "bulk-1" { ++ t.Fatalf("X-Bulk header = %q, want %q", gotHeader, "bulk-1") ++ } ++ if result.Responses[0].TotalHits() != 8 { ++ t.Fatalf("response[0] TotalHits() = %d, want %d", result.Responses[0].TotalHits(), int64(8)) ++ } ++ if result.Responses[0].Status != 201 { ++ t.Fatalf("response[0] Status = %d, want %d", result.Responses[0].Status, 201) ++ } ++} ++ ++func TestMultiSearchAddRetainsStateAcrossSeparateCallsAndRepeatedDo(t *testing.T) { ++ ++ ++ var bodies []string ++ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ b, err := io.ReadAll(r.Body) ++ if err != nil { ++ t.Fatalf("ReadAll(request body) error = %v", err) ++ } ++ bodies = append(bodies, string(b)) ++ w.Header().Set("Content-Type", "application/json") ++ _, _ = io.WriteString(w, `{"took":9,"responses":[{"took":1,"hits":{"total":{"value":1,"relation":"eq"},"hits":[]},"status":200},{"took":2,"hits":{"total":{"value":2,"relation":"eq"},"hits":[]},"status":200}]}`) ++ })) ++ defer ts.Close() ++ ++ service := newClient(t, ts.URL).MultiSearch() ++ service.Add(elastic.NewSearchRequest().Source(`{"query":{"match_all":{}}}`)) ++ service.Add(elastic.NewSearchRequest().Source(`{"query":{"term":{"user":"olivere"}}}`)) ++ ++ first, err := service.Do(context.Background()) ++ if err != nil { ++ t.Fatalf("first Do() error = %v", err) ++ } ++ second, err := service.Do(context.Background()) ++ if err != nil { ++ t.Fatalf("second Do() error = %v", err) ++ } ++ ++ if len(bodies) != 2 { ++ t.Fatalf("captured request bodies = %d, want %d", len(bodies), 2) ++ } ++ ++ wantLines := []string{ ++ `{}`, ++ `{"query":{"match_all":{}}}`, ++ `{}`, ++ `{"query":{"term":{"user":"olivere"}}}`, ++ } ++ assertNDJSONLinesEqual(t, bodies[0], wantLines) ++ assertNDJSONLinesEqual(t, bodies[1], wantLines) ++ if first.TookInMillis != 9 { ++ t.Fatalf("first TookInMillis = %d, want %d", first.TookInMillis, int64(9)) ++ } ++ if second.TookInMillis != 9 { ++ t.Fatalf("second TookInMillis = %d, want %d", second.TookInMillis, int64(9)) ++ } ++ if len(second.Responses) != 2 { ++ t.Fatalf("len(second.Responses) = %d, want %d", len(second.Responses), 2) ++ } ++} ++ ++func TestMultiSearchServicesKeepIndependentBuilderState(t *testing.T) { ++ ++ ++ var bodies []string ++ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ b, err := io.ReadAll(r.Body) ++ if err != nil { ++ t.Fatalf("ReadAll(request body) error = %v", err) ++ } ++ bodies = append(bodies, string(b)) ++ w.Header().Set("Content-Type", "application/json") ++ _, _ = io.WriteString(w, oneResponseBody(6, 1, 200, false)) ++ })) ++ defer ts.Close() ++ ++ client := newClient(t, ts.URL) ++ a := client.MultiSearch().Index("logs-a").Add(elastic.NewSearchRequest().Source(`{"query":{"match_all":{}}}`)) ++ b := client.MultiSearch().Add(elastic.NewSearchRequest().Source(`{"query":{"term":{"level":"warn"}}}`)) ++ ++ resultA, err := a.Do(context.Background()) ++ if err != nil { ++ t.Fatalf("service a Do() error = %v", err) ++ } ++ resultB, err := b.Do(context.Background()) ++ if err != nil { ++ t.Fatalf("service b Do() error = %v", err) ++ } ++ ++ if len(bodies) != 2 { ++ t.Fatalf("captured request bodies = %d, want %d", len(bodies), 2) ++ } ++ ++ bodyLinesA := splitNDJSONLines(t, bodies[0], 2) ++ assertHeaderIndices(t, bodyLinesA[0], []string{"logs-a"}) ++ assertJSONLineEqual(t, bodyLinesA[1], `{"query":{"match_all":{}}}`) ++ assertNDJSONLinesEqual(t, bodies[1], []string{ ++ `{}`, ++ `{"query":{"term":{"level":"warn"}}}`, ++ }) ++ if resultA.TookInMillis != 6 { ++ t.Fatalf("service a TookInMillis = %d, want %d", resultA.TookInMillis, int64(6)) ++ } ++ if resultB.TookInMillis != 6 { ++ t.Fatalf("service b TookInMillis = %d, want %d", resultB.TookInMillis, int64(6)) ++ } ++} ++ ++func TestMultiSearchDoReturnsTypedBodyBuildError(t *testing.T) { ++ ++ ++ called := false ++ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ called = true ++ w.WriteHeader(http.StatusInternalServerError) ++ })) ++ defer ts.Close() ++ ++ result, err := newClient(t, ts.URL).MultiSearch(). ++ Add(elastic.NewSearchRequest().Source(map[string]interface{}{"bad": func() {}})). ++ Do(context.Background()) ++ ++ ++ if err == nil { ++ t.Fatalf("Do() error = nil, want non-nil") ++ } ++ if result != nil { ++ t.Fatalf("Do() result = %#v, want nil", result) ++ } ++ if called != false { ++ t.Fatalf("server called after body build failure = %t, want %t", called, false) ++ } ++} ++ ++func TestMultiSearchDoReturnsElasticErrorOnHTTPError(t *testing.T) { ++ ++ ++ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ w.Header().Set("Content-Type", "application/json") ++ w.WriteHeader(http.StatusServiceUnavailable) ++ _, _ = io.WriteString(w, `{"error":{"type":"unavailable","reason":"planned outage"},"status":503}`) ++ })) ++ defer ts.Close() ++ ++ result, err := newClient(t, ts.URL).MultiSearch(). ++ Add(elastic.NewSearchRequest().Source(`{"query":{"match_all":{}}}`)). ++ Do(context.Background()) ++ ++ ++ if err == nil { ++ t.Fatalf("Do() error = nil, want non-nil") ++ } ++ if result != nil { ++ t.Fatalf("Do() result = %#v, want nil", result) ++ } ++} ++ ++func TestMultiSearchDoReturnsTypedDecodeError(t *testing.T) { ++ ++ ++ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ w.Header().Set("Content-Type", "application/json") ++ _, _ = io.WriteString(w, `{"took":`) ++ })) ++ defer ts.Close() ++ ++ result, err := newClient(t, ts.URL).MultiSearch(). ++ Add(elastic.NewSearchRequest().Source(`{"query":{"match_all":{}}}`)). ++ Do(context.Background()) ++ ++ ++ if err == nil { ++ t.Fatalf("Do() error = nil, want non-nil") ++ } ++ if result != nil { ++ t.Fatalf("Do() result = %#v, want nil", result) ++ } ++} ++ ++func TestMultiSearchDoSucceedsAcrossManyCycles(t *testing.T) { ++ ++ ++ requests := 0 ++ ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ requests++ ++ w.Header().Set("Content-Type", "application/json") ++ _, _ = io.WriteString(w, oneResponseBody(1, 1, 200, false)) ++ })) ++ defer ts.Close() ++ ++ ++ for i := 0; i < 10; i++ { ++ result, err := newClient(t, ts.URL).MultiSearch(). ++ Add(elastic.NewSearchRequest().Source(`{"query":{"match_all":{}}}`)). ++ Do(context.Background()) ++ if err != nil { ++ t.Fatalf("cycle %d Do() error = %v", i, err) ++ } ++ if result.TookInMillis != 1 { ++ t.Fatalf("cycle %d TookInMillis = %d, want %d", i, result.TookInMillis, int64(1)) ++ } ++ if len(result.Responses) != 1 { ++ t.Fatalf("cycle %d len(result.Responses) = %d, want %d", i, len(result.Responses), 1) ++ } ++ } ++ ++ if requests != 10 { ++ t.Fatalf("server requests = %d, want %d", requests, 10) ++ } ++} ++ ++func assertNDJSONLinesEqual(t *testing.T, got string, wantLines []string) { ++ t.Helper() ++ ++ gotLines := splitNDJSONLines(t, got, len(wantLines)) ++ for i := range wantLines { ++ assertJSONLineEqual(t, gotLines[i], wantLines[i]) ++ } ++} ++ ++func splitNDJSONLines(t *testing.T, got string, wantCount int) []string { ++ t.Helper() ++ ++ if !strings.HasSuffix(got, "\n") { ++ t.Fatalf("request body %q does not have required trailing newline", got) ++ } ++ gotLines := strings.Split(strings.TrimSuffix(got, "\n"), "\n") ++ if len(gotLines) != wantCount { ++ t.Fatalf("request body line count = %d, want %d; body = %q", len(gotLines), wantCount, got) ++ } ++ return gotLines ++} ++ ++func assertJSONLineEqual(t *testing.T, got string, want string) { ++ t.Helper() ++ ++ gotJSON := decodeJSONLine(t, got, "got") ++ wantJSON := decodeJSONLine(t, want, "want") ++ if !reflect.DeepEqual(gotJSON, wantJSON) { ++ t.Fatalf("request body line = %s, want JSON-equivalent to %s", got, want) ++ } ++} ++ ++func assertHeaderIndices(t *testing.T, line string, want []string) { ++ t.Helper() ++ ++ raw := decodeJSONLine(t, line, "header") ++ header, ok := raw.(map[string]interface{}) ++ if !ok { ++ t.Fatalf("request header line = %s, want JSON object", line) ++ } ++ ++ var got []string ++ if v, ok := header["index"]; ok { ++ got = appendIndexValues(t, got, v, "index") ++ } ++ if v, ok := header["indices"]; ok { ++ got = appendIndexValues(t, got, v, "indices") ++ } ++ if !reflect.DeepEqual(got, want) { ++ t.Fatalf("request header indices = %#v, want %#v; line = %s", got, want, line) ++ } ++} ++ ++func appendIndexValues(t *testing.T, got []string, value interface{}, field string) []string { ++ t.Helper() ++ ++ switch v := value.(type) { ++ case string: ++ return append(got, v) ++ case []interface{}: ++ for _, item := range v { ++ s, ok := item.(string) ++ if !ok { ++ t.Fatalf("request header %s item = %#v, want string", field, item) ++ } ++ got = append(got, s) ++ } ++ return got ++ default: ++ t.Fatalf("request header %s = %#v, want string or string array", field, value) ++ return got ++ } ++} ++ ++func decodeJSONLine(t *testing.T, line string, label string) interface{} { ++ t.Helper() ++ ++ var v interface{} ++ if err := json.Unmarshal([]byte(line), &v); err != nil { ++ t.Fatalf("%s request body line is invalid JSON: %v; line = %q", label, err, line) ++ } ++ return v ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++export GOWORK=off ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++exec go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-002101/tests/test.sh b/tasks/format-code-task-002101/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d2c6bb24a6f913f05478827b6d98c58a6f2fa3d8 --- /dev/null +++ b/tasks/format-code-task-002101/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/msearch_stateful_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-002101/tests/test_command.sh b/tasks/format-code-task-002101/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002101/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-002106/environment/Dockerfile b/tasks/format-code-task-002106/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..02055934b31f755ec935c23e73b0956dd9e13187 --- /dev/null +++ b/tasks/format-code-task-002106/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:98c980029d831e51e3eac0762fb3014a6be9e8b37d88f20ae3235f385cd9a820 diff --git a/tasks/format-code-task-002106/environment/setup/files/blocklist b/tasks/format-code-task-002106/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002106/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-002106/environment/setup/setup.sh b/tasks/format-code-task-002106/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002106/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-002106/tests/test.patch b/tasks/format-code-task-002106/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6f2a08e4197718fc26dca5dd614623c283fe982c --- /dev/null +++ b/tasks/format-code-task-002106/tests/test.patch @@ -0,0 +1,354 @@ +diff --git a/usercase-test-coderl/test_pending_messages_sdk.py b/usercase-test-coderl/test_pending_messages_sdk.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_pending_messages_sdk.py +@@ -0,0 +1,324 @@ ++ ++ ++from __future__ import annotations ++ ++import asyncio ++import json ++import threading ++import uuid ++from collections import deque ++from dataclasses import dataclass ++from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer ++from urllib.parse import parse_qs, urlparse ++ ++import pytest ++ ++from omnara.sdk import AsyncOmnaraClient, OmnaraClient ++ ++ ++AGENT_ONE = "11111111-1111-1111-1111-111111111111" ++AGENT_TWO = "22222222-2222-2222-2222-222222222222" ++ ++ ++def ok_response(agent_instance_id: str = AGENT_ONE) -> dict: ++ return { ++ "agent_instance_id": agent_instance_id, ++ "status": "ok", ++ "messages": [ ++ { ++ "id": "m1", ++ "content": "ship it", ++ "sender_type": "user", ++ "created_at": "2026-01-02T03:04:05Z", ++ "requires_user_input": False, ++ } ++ ], ++ } ++ ++ ++def stale_response(agent_instance_id: str = AGENT_TWO) -> dict: ++ return { ++ "agent_instance_id": agent_instance_id, ++ "status": "stale", ++ "messages": [], ++ } ++ ++ ++@dataclass ++class RecordedRequest: ++ path: str ++ query: dict[str, list[str]] ++ ++ ++class PendingAPIServer: ++ def __init__(self, responses: list[dict]): ++ self._responses = deque(responses) ++ self.requests: list[RecordedRequest] = [] ++ owner = self ++ ++ class Handler(BaseHTTPRequestHandler): ++ def do_GET(self): # noqa: N802 - required by BaseHTTPRequestHandler ++ parsed = urlparse(self.path) ++ owner.requests.append( ++ RecordedRequest(parsed.path, parse_qs(parsed.query)) ++ ) ++ ++ if parsed.path != "/api/v1/messages/pending": ++ body = b'{"detail":"not found"}' ++ self.send_response(404) ++ else: ++ payload = owner._responses.popleft() ++ body = json.dumps(payload).encode("utf-8") ++ self.send_response(200) ++ ++ self.send_header("Content-Type", "application/json") ++ self.send_header("Content-Length", str(len(body))) ++ self.send_header("Connection", "close") ++ self.end_headers() ++ self.wfile.write(body) ++ ++ def log_message(self, *args): ++ return ++ ++ self._server = ThreadingHTTPServer(("127.0.0.1", 0), Handler) ++ self._thread = threading.Thread(target=self._server.serve_forever, daemon=True) ++ self.base_url = f"http://127.0.0.1:{self._server.server_port}" ++ ++ def __enter__(self) -> "PendingAPIServer": ++ self._thread.start() ++ return self ++ ++ def __exit__(self, exc_type, exc, tb): ++ self._server.shutdown() ++ self._server.server_close() ++ ++ ++def test_sync_pending_messages_accepts_uuid_object_and_returns_message_dataclass(): ++ ++ ++ ++ with PendingAPIServer([ok_response()]) as server: ++ client = OmnaraClient("test-key", base_url=server.base_url, timeout=5, max_retries=1) ++ try: ++ response = client.get_pending_messages(uuid.UUID(AGENT_ONE)) ++ ++ assert type(response).__name__ == "PendingMessagesResponse" ++ assert response.agent_instance_id == "11111111-1111-1111-1111-111111111111" ++ assert response.status == "ok" ++ assert len(response.messages) == 1 ++ ++ message = response.messages[0] ++ assert type(message).__name__ == "Message" ++ assert message.id == "m1" ++ assert message.content == "ship it" ++ assert message.sender_type == "user" ++ assert message.created_at == "2026-01-02T03:04:05Z" ++ assert message.requires_user_input is False ++ ++ assert len(server.requests) == 1 ++ assert server.requests[0].path == "/api/v1/messages/pending" ++ assert server.requests[0].query == { ++ "agent_instance_id": ["11111111-1111-1111-1111-111111111111"] ++ } ++ finally: ++ client.close() ++ ++ ++def test_async_pending_messages_accepts_string_includes_last_read_and_preserves_stale(): ++ ++ ++ ++ ++ async def run_session(): ++ with PendingAPIServer([stale_response()]) as server: ++ client = AsyncOmnaraClient( ++ "test-key", base_url=server.base_url, timeout=5, max_retries=1 ++ ) ++ try: ++ response = await client.get_pending_messages( ++ AGENT_TWO, last_read_message_id="m1" ++ ) ++ ++ assert type(response).__name__ == "PendingMessagesResponse" ++ assert response.agent_instance_id == "22222222-2222-2222-2222-222222222222" ++ assert response.status == "stale" ++ assert response.messages == [] ++ ++ assert len(server.requests) == 1 ++ assert server.requests[0].path == "/api/v1/messages/pending" ++ assert server.requests[0].query == { ++ "agent_instance_id": ["22222222-2222-2222-2222-222222222222"], ++ "last_read_message_id": ["m1"], ++ } ++ finally: ++ await client.close() ++ ++ asyncio.run(run_session()) ++ ++ ++def test_invalid_agent_instance_id_raises_value_error_before_http_request(): ++ ++ ++ ++ with PendingAPIServer([ok_response(), ok_response()]) as server: ++ sync_client = OmnaraClient( ++ "test-key", base_url=server.base_url, timeout=5, max_retries=1 ++ ) ++ try: ++ with pytest.raises(ValueError) as sync_error: ++ sync_client.get_pending_messages("not-a-uuid") ++ ++ assert isinstance(sync_error.value, ValueError) ++ assert len(server.requests) == 0 ++ finally: ++ sync_client.close() ++ ++ async def run_invalid_async(): ++ async_client = AsyncOmnaraClient( ++ "test-key", base_url=server.base_url, timeout=5, max_retries=1 ++ ) ++ try: ++ with pytest.raises(ValueError) as async_error: ++ await async_client.get_pending_messages("not-a-uuid") ++ ++ assert isinstance(async_error.value, ValueError) ++ ++ assert len(server.requests) == 0 ++ finally: ++ await async_client.close() ++ ++ asyncio.run(run_invalid_async()) ++ ++ ++def test_two_clients_keep_pending_message_sessions_independent(): ++ ++ ++ ++ with PendingAPIServer([ok_response(AGENT_ONE)]) as server_a: ++ with PendingAPIServer([stale_response(AGENT_TWO)]) as server_b: ++ client_a = OmnaraClient( ++ "test-key-a", base_url=server_a.base_url, timeout=5, max_retries=1 ++ ) ++ client_b = OmnaraClient( ++ "test-key-b", base_url=server_b.base_url, timeout=5, max_retries=1 ++ ) ++ try: ++ response_a = client_a.get_pending_messages(AGENT_ONE) ++ assert response_a.agent_instance_id == "11111111-1111-1111-1111-111111111111" ++ assert response_a.status == "ok" ++ assert len(server_a.requests) == 1 ++ assert len(server_b.requests) == 0 ++ ++ response_b = client_b.get_pending_messages(AGENT_TWO) ++ assert response_b.agent_instance_id == "22222222-2222-2222-2222-222222222222" ++ assert response_b.status == "stale" ++ assert response_b.messages == [] ++ assert len(server_a.requests) == 1 ++ assert len(server_b.requests) == 1 ++ assert server_a.requests[0].query == { ++ "agent_instance_id": ["11111111-1111-1111-1111-111111111111"] ++ } ++ assert server_b.requests[0].query == { ++ "agent_instance_id": ["22222222-2222-2222-2222-222222222222"] ++ } ++ finally: ++ client_a.close() ++ client_b.close() ++ ++ ++def test_sync_and_async_clients_can_poll_after_prior_pending_message_requests(): ++ ++ ++ ++ with PendingAPIServer([stale_response(AGENT_ONE), stale_response(AGENT_TWO)]) as server: ++ sync_client = OmnaraClient( ++ "test-key", base_url=server.base_url, timeout=5, max_retries=1 ++ ) ++ ++ sync_response = sync_client.get_pending_messages(AGENT_ONE) ++ assert sync_response.agent_instance_id == "11111111-1111-1111-1111-111111111111" ++ assert sync_response.status == "stale" ++ assert sync_response.messages == [] ++ assert len(server.requests) == 1 ++ assert server.requests[0].query == { ++ "agent_instance_id": ["11111111-1111-1111-1111-111111111111"] ++ } ++ ++ async def run_async_close(): ++ async_client = AsyncOmnaraClient( ++ "test-key", base_url=server.base_url, timeout=5, max_retries=1 ++ ) ++ ++ async_response = await async_client.get_pending_messages(AGENT_TWO) ++ assert async_response.agent_instance_id == "22222222-2222-2222-2222-222222222222" ++ assert async_response.status == "stale" ++ assert async_response.messages == [] ++ assert len(server.requests) == 2 ++ assert server.requests[1].query == { ++ "agent_instance_id": ["22222222-2222-2222-2222-222222222222"] ++ } ++ await async_client.close() ++ ++ asyncio.run(run_async_close()) ++ sync_client.close() ++ ++ ++def test_repeated_pending_message_polls_preserve_request_parameters(): ++ ++ ++ ++ responses = [ ++ ok_response(AGENT_ONE), ++ stale_response(AGENT_TWO), ++ ok_response(AGENT_ONE), ++ stale_response(AGENT_TWO), ++ ] ++ ++ with PendingAPIServer(responses) as server: ++ sync_client = OmnaraClient( ++ "test-key", base_url=server.base_url, timeout=5, max_retries=1 ++ ) ++ ++ first_sync = sync_client.get_pending_messages(AGENT_ONE) ++ second_sync = sync_client.get_pending_messages( ++ AGENT_TWO, last_read_message_id="m1" ++ ) ++ assert first_sync.status == "ok" ++ assert len(first_sync.messages) == 1 ++ assert second_sync.status == "stale" ++ assert second_sync.messages == [] ++ assert len(server.requests) == 2 ++ assert server.requests[0].query == { ++ "agent_instance_id": ["11111111-1111-1111-1111-111111111111"] ++ } ++ assert server.requests[1].query == { ++ "agent_instance_id": ["22222222-2222-2222-2222-222222222222"], ++ "last_read_message_id": ["m1"], ++ } ++ sync_client.close() ++ ++ async def run_async_cycles(): ++ async_client = AsyncOmnaraClient( ++ "test-key", base_url=server.base_url, timeout=5, max_retries=1 ++ ) ++ ++ first_async = await async_client.get_pending_messages(AGENT_ONE) ++ second_async = await async_client.get_pending_messages( ++ AGENT_TWO, last_read_message_id="m1" ++ ) ++ assert first_async.status == "ok" ++ assert len(first_async.messages) == 1 ++ assert second_async.status == "stale" ++ assert second_async.messages == [] ++ assert len(server.requests) == 4 ++ assert server.requests[2].query == { ++ "agent_instance_id": ["11111111-1111-1111-1111-111111111111"] ++ } ++ assert server.requests[3].query == { ++ "agent_instance_id": ["22222222-2222-2222-2222-222222222222"], ++ "last_read_message_id": ["m1"], ++ } ++ await async_client.close() ++ ++ asyncio.run(run_async_cycles()) ++ assert len(server.requests) == 4 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++ ++ ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++PYTHONPATH=/workspace/repo/src exec python -m pytest /workspace/repo/usercase-test-coderl/test_pending_messages_sdk.py -v diff --git a/tasks/format-code-task-002106/tests/test.sh b/tasks/format-code-task-002106/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..55b7092f5774370dd2f628d52e064688025cd1a3 --- /dev/null +++ b/tasks/format-code-task-002106/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_pending_messages_sdk.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-002106/tests/test_command.sh b/tasks/format-code-task-002106/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002106/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-002108/environment/Dockerfile b/tasks/format-code-task-002108/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eb7c793aa4242121ca8e966ded8d662c06cd6578 --- /dev/null +++ b/tasks/format-code-task-002108/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:853d745cb3826493c8aea6464b875c75b87e47c999c67c9eba03d350afc92717 diff --git a/tasks/format-code-task-002108/environment/setup/files/blocklist b/tasks/format-code-task-002108/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002108/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-002108/environment/setup/setup.sh b/tasks/format-code-task-002108/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002108/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-002108/tests/test.patch b/tasks/format-code-task-002108/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e6de15edaa591e581f6311b78b28b629d3435242 --- /dev/null +++ b/tasks/format-code-task-002108/tests/test.patch @@ -0,0 +1,250 @@ +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,225 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++ ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++ ++SRC="$TMP/src" ++VENV="$TMP/venv" ++cp -a /workspace/repo/python "$SRC" || fail "copy python package" ++ ++ ++ ++ ++mkdir -p "$SRC/oneflow/include/mock" ++: > "$SRC/oneflow/include/mock/dummy.h" ++cat > "$SRC/oneflow/version.py" <<'PY' ++__version__ = '0.0.0' ++__git_commit__ = 'fixture' ++PY ++suffix=$(python3 - <<'PY' ++import importlib.machinery ++print(importlib.machinery.EXTENSION_SUFFIXES[0]) ++PY ++) || fail "detect extension suffix" ++: > "$SRC/oneflow/_oneflow_internal${suffix}" ++cat > "$SRC/oneflow/__init__.py" <<'PY' ++ ++PY ++ ++python3 -m venv --system-site-packages "$VENV" || fail "create virtualenv" ++( cd "$SRC" && "$VENV/bin/python" -m pip install --no-index --no-deps --no-build-isolation . >/dev/null ) \ ++ || fail "build/install test package" ++ ++PYTHON="$VENV/bin/python" ++BIN="$VENV/bin/oneflow-mock-torch" ++[ -n "$BIN" ] || fail "installed oneflow-mock-torch command not found" ++PYLIB=$("$PYTHON" - <<'PY' ++import site ++print(site.getsitepackages()[0]) ++PY ++) || fail "detect venv site-packages" ++[ -n "$PYLIB" ] || fail "installed python package path not found" ++MOCK_DIR="$PYLIB/oneflow/mock_torch" ++[ -d "$MOCK_DIR" ] || fail "mock_torch package directory not installed" ++ ++mkdir -p "$PYLIB/packaging" ++: > "$PYLIB/packaging/__init__.py" ++cat > "$PYLIB/packaging/requirements.py" <<'PY' ++class Requirement: ++ def __init__(self, requirement): ++ self.name = str(requirement).split(';', 1)[0].strip().split()[0] ++PY ++cat > "$PYLIB/importlib_metadata.py" <<'PY' ++def requires(_package): ++ return [] ++PY ++ ++run_module() { ++ env -u PYTHONPATH "$PYTHON" -m oneflow.mock_torch "$@" >out 2>err ++ ec=$? ++} ++ ++run_bin() { ++ env -u PYTHONPATH "$BIN" "$@" >out 2>err ++ ec=$? ++} ++ ++assert_stdout_eq() { ++ expected=$1 ++ actual=$(cat out) ++ [ "$actual" = "$expected" ] || fail "$2 stdout: [$actual]" ++} ++ ++assert_empty_stderr() { ++ [ ! -s err ] || fail "$1 stderr: $(cat err)" ++} ++ ++cd "$TMP" ++ ++ ++ ++ ++ ++run_module ++EXPECTED="export ONEFLOW_MOCK_TORCH_LAZY=False; export ONEFLOW_MOCK_TORCH_VERBOSE=False; export PYTHONPATH=${MOCK_DIR}:\$PYTHONPATH" ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_stdout_eq "$EXPECTED" "F1" ++assert_empty_stderr "F1" ++ ++ ++ ++ ++ ++run_bin enable ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++assert_stdout_eq "$EXPECTED" "F2" ++assert_empty_stderr "F2" ++ ++ ++ ++ ++run_module enable --lazy ++EXPECTED="export ONEFLOW_MOCK_TORCH_LAZY=True; export ONEFLOW_MOCK_TORCH_VERBOSE=False; export PYTHONPATH=${MOCK_DIR}:\$PYTHONPATH" ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++assert_stdout_eq "$EXPECTED" "F3" ++assert_empty_stderr "F3" ++ ++ ++ ++ ++run_module --verbose enable ++EXPECTED="export ONEFLOW_MOCK_TORCH_LAZY=False; export ONEFLOW_MOCK_TORCH_VERBOSE=True; export PYTHONPATH=${MOCK_DIR}:\$PYTHONPATH" ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++assert_stdout_eq "$EXPECTED" "F4" ++assert_empty_stderr "F4" ++ ++ ++ ++ ++run_module --lazy --verbose enable ++EXPECTED="export ONEFLOW_MOCK_TORCH_LAZY=True; export ONEFLOW_MOCK_TORCH_VERBOSE=True; export PYTHONPATH=${MOCK_DIR}:\$PYTHONPATH" ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++assert_stdout_eq "$EXPECTED" "F5" ++assert_empty_stderr "F5" ++ ++ ++ ++ ++ ++PYTHONPATH="/alpha:/tmp/x/oneflow/mock_torch:/beta:/opt/oneflow/mock_torch" \ ++ "$PYTHON" -m oneflow.mock_torch disable >out 2>err ++ec=$? ++EXPECTED="export PYTHONPATH=/alpha:/beta; unset ONEFLOW_MOCK_TORCH_LAZY; unset ONEFLOW_MOCK_TORCH_VERBOSE" ++[ "$ec" -eq 0 ] || fail "F6 exit $ec; want 0" ++assert_stdout_eq "$EXPECTED" "F6" ++assert_empty_stderr "F6" ++ ++ ++ ++ ++PYTHONPATH="/tmp/x/oneflow/mock_torch:/opt/oneflow/mock_torch:" \ ++ "$BIN" disable >out 2>err ++ec=$? ++EXPECTED="unset PYTHONPATH; unset ONEFLOW_MOCK_TORCH_LAZY; unset ONEFLOW_MOCK_TORCH_VERBOSE" ++[ "$ec" -eq 0 ] || fail "F7 exit $ec; want 0" ++assert_stdout_eq "$EXPECTED" "F7" ++assert_empty_stderr "F7" ++ ++ ++ ++ ++env -u PYTHONPATH "$BIN" disable >out 2>err ++ec=$? ++[ "$ec" -eq 0 ] || fail "F8 exit $ec; want 0" ++[ ! -s out ] || fail "F8 stdout should be empty: $(cat out)" ++assert_empty_stderr "F8" ++ ++ ++ ++ ++run_module --help ++[ "$ec" -eq 0 ] || fail "F9 exit $ec; want 0" ++ ++[ -s out ] || fail "F9 stdout should contain help text" ++grep -q '^usage:' out || fail "F9 help should include argparse usage: $(cat out)" ++grep -q 'enable' out || fail "F9 help should show enable action: $(cat out)" ++grep -q 'disable' out || fail "F9 help should show disable action: $(cat out)" ++grep -q -- '--lazy' out || fail "F9 help should show --lazy flag: $(cat out)" ++grep -q -- '--verbose' out || fail "F9 help should show --verbose flag: $(cat out)" ++assert_empty_stderr "F9" ++ ++ ++ ++ ++run_bin --help ++[ "$ec" -eq 0 ] || fail "F10 exit $ec; want 0" ++ ++[ -s out ] || fail "F10 stdout should contain help text" ++grep -q '^usage:' out || fail "F10 help should include argparse usage: $(cat out)" ++grep -q 'enable' out || fail "F10 help should show enable action: $(cat out)" ++grep -q 'disable' out || fail "F10 help should show disable action: $(cat out)" ++grep -q -- '--lazy' out || fail "F10 help should show --lazy flag: $(cat out)" ++grep -q -- '--verbose' out || fail "F10 help should show --verbose flag: $(cat out)" ++assert_empty_stderr "F10" ++ ++ ++ ++ ++set +e ++env -u PYTHONPATH "$PYTHON" -m oneflow.mock_torch maybe >out 2>err ++ec=$? ++set -e ++[ "$ec" -ne 0 ] || fail "F11 exit $ec; want non-zero" ++[ ! -s out ] || fail "F11 stdout should be empty: $(cat out)" ++ ++[ -s err ] || fail "F11 stderr should contain argparse usage error" ++grep -q '^usage:' err || fail "F11 stderr should include usage: $(cat err)" ++grep -q 'error:' err || fail "F11 stderr should include argparse error: $(cat err)" ++grep -q 'maybe' err || fail "F11 stderr should mention invalid action: $(cat err)" ++ ++ ++ ++ ++set +e ++env -u PYTHONPATH "$BIN" maybe >out 2>err ++ec=$? ++set -e ++[ "$ec" -ne 0 ] || fail "F12 exit $ec; want non-zero" ++[ ! -s out ] || fail "F12 stdout should be empty: $(cat out)" ++ ++[ -s err ] || fail "F12 stderr should contain argparse usage error" ++grep -q '^usage:' err || fail "F12 stderr should include usage: $(cat err)" ++grep -q 'error:' err || fail "F12 stderr should include argparse error: $(cat err)" ++grep -q 'maybe' err || fail "F12 stderr should mention invalid action: $(cat err)" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,15 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++ ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-002108/tests/test.sh b/tasks/format-code-task-002108/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-002108/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-002108/tests/test_command.sh b/tasks/format-code-task-002108/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002108/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-002130/environment/Dockerfile b/tasks/format-code-task-002130/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0a0574e82738449f1bc189c99672134d77eb61b0 --- /dev/null +++ b/tasks/format-code-task-002130/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:060ca0fd213026d1cfcad4bec04b67c04fa30df85812e01b7f88310e58538b8f diff --git a/tasks/format-code-task-002130/environment/setup/files/blocklist b/tasks/format-code-task-002130/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002130/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-002130/environment/setup/setup.sh b/tasks/format-code-task-002130/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002130/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-002130/tests/test.patch b/tasks/format-code-task-002130/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b663516f35d800b462cc1fcb599bc8e5f6786d22 --- /dev/null +++ b/tasks/format-code-task-002130/tests/test.patch @@ -0,0 +1,249 @@ +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,227 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC NO_COLOR=1 COLUMNS=160 ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++ ++PYTHON=/opt/openapi-python-client-coderl/bin/python ++[ -x "$PYTHON" ] || fail "offline Python environment missing: $PYTHON" ++ ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:$PYTHONPATH}" ++BIN=("$PYTHON" -m openapi_python_client) ++ ++RUN_ROOT=/tmp/openapi-python-client-coderl-fixture ++rm -rf "$RUN_ROOT" ++mkdir -p "$RUN_ROOT" ++trap 'rm -rf "$RUN_ROOT"' EXIT ++ ++assert_file_contains() { ++ local file=$1 ++ local pattern=$2 ++ local label=$3 ++ grep -Eq "$pattern" "$file" || fail "$label missing pattern $pattern in $file" ++} ++ ++assert_file_not_contains() { ++ local file=$1 ++ local pattern=$2 ++ local label=$3 ++ ! grep -Eq "$pattern" "$file" || fail "$label unexpected pattern $pattern in $file" ++} ++ ++assert_no_config_specific_stream() { ++ local label=$1 ++ local stream_file=$2 ++ local stream_name=$3 ++ local config_file=$4 ++ ++ ! grep -Eqi 'config|Unable to parse config' "$stream_file" || fail "$label $stream_name included config-specific text: $(cat "$stream_file")" ++ ! grep -Fq "$config_file" "$stream_file" || fail "$label $stream_name mentioned config file $config_file: $(cat "$stream_file")" ++} ++ ++assert_no_config_specific_output() { ++ local label=$1 ++ local config_file=$2 ++ assert_no_config_specific_stream "$label" out stdout "$config_file" ++ assert_no_config_specific_stream "$label" err stderr "$config_file" ++} ++ ++assert_unable_to_parse_config() { ++ local label=$1 ++ local out_dir=$2 ++ local ec=$3 ++ [ "$ec" -eq 2 ] || fail "$label exit $ec; want 2" ++ ++ ! grep -q 'Generating ' out || fail "$label stdout suggests generation started: $(cat out)" ++ grep -q 'Unable to parse config' err || fail "$label stderr missing Unable to parse config: $(cat err)" ++ [ ! -e "$out_dir" ] || fail "$label generated $out_dir before rejecting config" ++} ++ ++ ++ ++ ++cd "$RUN_ROOT" ++"${BIN[@]}" generate --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F0 exit $ec; want 0" ++grep -q -- '--config' out || fail "F0 help did not include --config" ++ ++! grep -q 'No such option' err || fail "F0 help rejected --config-capable CLI: $(cat err)" ++ ++ ++ ++ ++cat > spec_full.yml <<'EOF' ++openapi: '3.1.0' ++info: ++ title: Fixture API ++ version: '9.8.7' ++paths: ++ /items: ++ get: ++ operationId: get_item ++ tags: [items] ++ responses: ++ '200': ++ description: ok ++ content: ++ application/json: ++ schema: ++ $ref: '#/components/schemas/Item' ++components: ++ schemas: ++ Item: ++ type: object ++ required: [_secret, status] ++ properties: ++ _secret: ++ type: string ++ status: ++ $ref: '#/components/schemas/Status' ++ Status: ++ type: string ++ enum: [available, sold] ++EOF ++cat > client.yml <<'EOF' ++package_name_override: cfg_pkg ++project_name_override: cfg-project ++field_prefix: cfg_ ++class_overrides: ++ Item: ++ class_name: InventoryItem ++ module_name: inventory_item ++post_hooks: ++ - python -c "from pathlib import Path; Path('hook.txt').write_text('yaml-hook')" ++literal_enums: true ++EOF ++"${BIN[@]}" generate --path spec_full.yml --config client.yml >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0; stderr: $(cat err)" ++assert_no_config_specific_output F1 client.yml ++[ -d cfg-project/cfg_pkg ] || fail "F1 cfg_pkg package directory missing" ++ ++assert_file_contains cfg-project/pyproject.toml '^name = "cfg-project"$' F1 ++assert_file_contains cfg-project/pyproject.toml 'include = "cfg_pkg"' F1 ++[ -f cfg-project/cfg_pkg/models/inventory_item.py ] || fail "F1 class_overrides module inventory_item.py missing" ++assert_file_contains cfg-project/cfg_pkg/models/inventory_item.py '^class InventoryItem:' F1 ++assert_file_contains cfg-project/cfg_pkg/models/inventory_item.py 'cfg_secret' F1 ++assert_file_contains cfg-project/cfg_pkg/models/inventory_item.py '"_secret"' F1 ++assert_file_not_contains cfg-project/cfg_pkg/models/inventory_item.py 'field_secret' F1 ++assert_file_contains cfg-project/cfg_pkg/models/__init__.py 'InventoryItem' F1 ++assert_file_contains cfg-project/cfg_pkg/models/status.py 'Literal' F1 ++assert_file_contains cfg-project/cfg_pkg/models/status.py 'available' F1 ++assert_file_contains cfg-project/cfg_pkg/models/status.py 'sold' F1 ++[ "$(cat cfg-project/hook.txt)" = "yaml-hook" ] || fail "F1 post hook did not run from config" ++ ++ ++ ++ ++mkdir f2 ++cd f2 ++cat > spec_min.yml <<'EOF' ++openapi: '3.1.0' ++info: ++ title: JSON API ++ version: '1.2.3' ++paths: {} ++EOF ++cat > client.json <<'EOF' ++{"package_name_override":"json_pkg","project_name_override":"json-project","post_hooks":[]} ++EOF ++"${BIN[@]}" generate --path spec_min.yml --config client.json >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0; stderr: $(cat err)" ++assert_no_config_specific_output F2 client.json ++[ -f json-project/json_pkg/__init__.py ] || fail "F2 json_pkg package missing" ++ ++assert_file_contains json-project/pyproject.toml '^name = "json-project"$' F2 ++assert_file_contains json-project/pyproject.toml 'include = "json_pkg"' F2 ++cd "$RUN_ROOT" ++ ++ ++ ++ ++mkdir f3 ++cd f3 ++cat > spec_min.yml <<'EOF' ++openapi: '3.1.0' ++info: ++ title: YAML Extension API ++ version: '4.5.6' ++paths: {} ++EOF ++cat > client.yaml <<'EOF' ++package_name_override: yaml_ext_pkg ++post_hooks: [] ++EOF ++"${BIN[@]}" generate --path spec_min.yml --config client.yaml --meta none >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0; stderr: $(cat err)" ++assert_no_config_specific_output F3 client.yaml ++[ -f yaml_ext_pkg/__init__.py ] || fail "F3 yaml_ext_pkg package missing" ++ ++[ -f yaml_ext_pkg/types.py ] || fail "F3 generated package types.py missing" ++cd "$RUN_ROOT" ++ ++ ++mkdir f_err ++cd f_err ++cat > spec_min.yml <<'EOF' ++openapi: '3.1.0' ++info: {title: Error API, version: '1.0'} ++paths: {} ++EOF ++ ++ ++ ++ ++"${BIN[@]}" generate --path spec_min.yml --config missing.yml --output-path should-not-exist >out 2>err; ec=$? ++assert_unable_to_parse_config F4 should-not-exist "$ec" ++ ++ ++ ++ ++cat > malformed.yml <<'EOF' ++package_name_override: [unterminated ++EOF ++"${BIN[@]}" generate --path spec_min.yml --config malformed.yml --output-path should-not-exist-yaml >out 2>err; ec=$? ++assert_unable_to_parse_config F5 should-not-exist-yaml "$ec" ++ ++ ++ ++ ++cat > invalid.yml <<'EOF' ++literal_enums: definitely ++EOF ++"${BIN[@]}" generate --path spec_min.yml --config invalid.yml --output-path should-not-exist-invalid >out 2>err; ec=$? ++assert_unable_to_parse_config F6 should-not-exist-invalid "$ec" ++ ++ ++ ++ ++cat > yaml_syntax.json <<'EOF' ++package_name_override: yaml_not_json ++EOF ++"${BIN[@]}" generate --path spec_min.yml --config yaml_syntax.json --output-path should-not-exist-json >out 2>err; ec=$? ++assert_unable_to_parse_config F7 should-not-exist-json "$ec" ++ ++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-002130/tests/test.sh b/tasks/format-code-task-002130/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-002130/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-002130/tests/test_command.sh b/tasks/format-code-task-002130/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002130/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-002137/environment/Dockerfile b/tasks/format-code-task-002137/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..82d0ba8da577693e1044c23bd466009a9c43f2c7 --- /dev/null +++ b/tasks/format-code-task-002137/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:668437521d9f2a11b60fde8adde403236d7a7d37f51f39586615904f24a045e0 diff --git a/tasks/format-code-task-002137/environment/setup/files/blocklist b/tasks/format-code-task-002137/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002137/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-002137/environment/setup/setup.sh b/tasks/format-code-task-002137/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002137/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-002137/tests/test.patch b/tasks/format-code-task-002137/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c25e5b0f1dad0fb3a5fe6652befbe28c910a6844 --- /dev/null +++ b/tasks/format-code-task-002137/tests/test.patch @@ -0,0 +1,80 @@ +diff --git a/udata/tests/dataset/test_dataset_events.py b/udata/tests/dataset/test_dataset_events.py +index cd25314eea..cd0d9e6eef 100644 +--- a/udata/tests/dataset/test_dataset_events.py ++++ b/udata/tests/dataset/test_dataset_events.py +@@ -31,7 +31,7 @@ def test_publish_message_resource_created_no_api_key(self, mock_req): + } + + mock_req.assert_called_with( +- f"{current_app.config['RESOURCES_ANALYSER_URI']}/api/resource/created/", ++ f"{current_app.config['RESOURCES_ANALYSER_URI']}/api/resources/", + json=expected_value, + headers={}, # No RESOURCES_ANALYSER_API_KEY, no headers. + ) +@@ -53,12 +53,12 @@ def test_publish_message_resource_created(self, mock_req): + dataset.add_resource(resource) + + mock_req.assert_called_with( +- f"{current_app.config['RESOURCES_ANALYSER_URI']}/api/resource/created/", ++ f"{current_app.config['RESOURCES_ANALYSER_URI']}/api/resources/", + json=expected_value, + headers={"Authorization": "Bearer foobar-api-key"}, + ) + +- @patch("requests.post") ++ @patch("requests.put") + @pytest.mark.options(RESOURCES_ANALYSER_API_KEY="foobar-api-key") + def test_publish_message_resource_modified(self, mock_req): + resource = ResourceFactory(schema=Schema(url="http://localhost/my-schema")) +@@ -77,7 +77,7 @@ def test_publish_message_resource_modified(self, mock_req): + dataset.update_resource(resource) + + mock_req.assert_called_with( +- f"{current_app.config['RESOURCES_ANALYSER_URI']}/api/resource/updated/", ++ f"{current_app.config['RESOURCES_ANALYSER_URI']}/api/resources/", + json=expected_value, + headers={"Authorization": "Bearer foobar-api-key"}, + ) +@@ -87,7 +87,7 @@ def test_publish_message_resource_modified(self, mock_req): + # (for example, encoding Embeds fails) + complexjson.dumps(expected_value) + +- @patch("requests.post") ++ @patch("requests.delete") + @pytest.mark.options(RESOURCES_ANALYSER_API_KEY="foobar-api-key") + def test_publish_message_resource_removed(self, mock_req): + resource = ResourceFactory() +@@ -104,7 +104,7 @@ def test_publish_message_resource_removed(self, mock_req): + dataset.remove_resource(resource) + + mock_req.assert_called_with( +- f"{current_app.config['RESOURCES_ANALYSER_URI']}/api/resource/deleted/", ++ f"{current_app.config['RESOURCES_ANALYSER_URI']}/api/resources/", + json=expected_value, + headers={"Authorization": "Bearer foobar-api-key"}, + ) +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+3TzY7TMBAA4JzzFIOQUPeQ3262B6QeEByREC9QJfE0MZvYxnayVNqHZ+rQbUFa ++VkK7Qoj5Lo5je8bOOGkzyUHsUM1Z9FJysqmq0JJf2/BcVGW+zou82FxHeVFUmzKC6sV2dGFyvrYA ++kdXa/27eU+P/qPRcf4/O71o9jrUSqeufL8cT9S9o9Fz/8obqf32TFxHkz7eFx/3n9W8FhMI3KOL4 ++NXxQbrIIH7Xq9Pt3IB3YSSmpOlgpRIEC9trCcQGI2tdN7fAqlnt4BaazaCD5BuNxrYAtZALnTE3D ++AOX2TfEWfI8qBjLeCmkhMTSDYmSiWd4u65JENKb2/cMgvaGct9QMultG5tpm1MmWJSk9hhQhjBuQ ++9lHGe3lxnk8H32sF67QojmeqWy9nhJWx+gu2Hu5qB1LRRRgGOuGdpBzSX8W0/8RRr+3BhADrJUK5 ++PR/t/h68nfAi1ymovIy5kgJHoz0qinsKloxgpDnNggQfSkGH/TpJ9I+l+jwpoGvb0YzjCvdTyEMo ++zxQ+XxgNX9KhX/7wH50dzrQZl5oDJHP8t68hY4wxxhhjjDHGGGOMMcYYY4wxxhj7Q98BqngvNgAo ++AAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002137/tests/test.sh b/tasks/format-code-task-002137/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4d0dcdd32c1d14d1534006d39c3466b872620f80 --- /dev/null +++ b/tasks/format-code-task-002137/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' +udata/tests/dataset/test_dataset_events.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-002137/tests/test_command.sh b/tasks/format-code-task-002137/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002137/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-002139/environment/Dockerfile b/tasks/format-code-task-002139/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..212f3947ba51ea3f5913b16e606d5ab48018e65b --- /dev/null +++ b/tasks/format-code-task-002139/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:5ec95334aa32aeeb0d78a1b8ccd734c03f423a13466df71eeaaf39119d324039 diff --git a/tasks/format-code-task-002139/environment/setup/files/blocklist b/tasks/format-code-task-002139/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002139/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-002139/environment/setup/setup.sh b/tasks/format-code-task-002139/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002139/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-002139/tests/test.patch b/tasks/format-code-task-002139/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1d8167d8ce8a2bdc261f17f32c315477f830429d --- /dev/null +++ b/tasks/format-code-task-002139/tests/test.patch @@ -0,0 +1,410 @@ +diff --git a/usercase-test-coderl/test_gcp_fetch.py b/usercase-test-coderl/test_gcp_fetch.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_gcp_fetch.py +@@ -0,0 +1,380 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import os ++import sys ++import types ++ ++import pytest ++ ++ ++CONTENT = b"bitbake-gcs-fetcher-content\n" ++CURRENT_STATE = None ++ ++ ++class FakeNotFound(Exception): ++ pass ++ ++ ++class FakeGCSState: ++ def __init__(self, scenario="success"): ++ self.scenario = scenario ++ self.calls = [] ++ ++ ++class FakeBlob: ++ def __init__(self, bucket_name, blob_name): ++ self.bucket_name = bucket_name ++ self.blob_name = blob_name ++ ++ def download_to_filename(self, filename): ++ CURRENT_STATE.calls.append( ++ ("download_to_filename", self.bucket_name, self.blob_name, os.path.basename(filename)) ++ ) ++ if CURRENT_STATE.scenario == "notfound": ++ raise FakeNotFound("missing") ++ if CURRENT_STATE.scenario == "missingfile": ++ return None ++ with open(filename, "wb") as target: ++ if CURRENT_STATE.scenario == "zero": ++ target.write(b"") ++ else: ++ target.write(CONTENT) ++ return None ++ ++ ++ def download_to_file(self, file_obj): ++ CURRENT_STATE.calls.append(("download_to_file", self.bucket_name, self.blob_name)) ++ if CURRENT_STATE.scenario == "notfound": ++ raise FakeNotFound("missing") ++ if CURRENT_STATE.scenario == "missingfile": ++ return None ++ if CURRENT_STATE.scenario == "zero": ++ file_obj.write(b"") ++ else: ++ file_obj.write(CONTENT) ++ return None ++ ++ def download_as_bytes(self): ++ CURRENT_STATE.calls.append(("download_as_bytes", self.bucket_name, self.blob_name)) ++ if CURRENT_STATE.scenario == "notfound": ++ raise FakeNotFound("missing") ++ if CURRENT_STATE.scenario == "missingfile": ++ return None ++ if CURRENT_STATE.scenario == "zero": ++ return b"" ++ return CONTENT ++ ++ def exists(self): ++ CURRENT_STATE.calls.append(("exists", self.bucket_name, self.blob_name)) ++ return CURRENT_STATE.scenario != "notfound" ++ ++ ++class FakeBucket: ++ def __init__(self, bucket_name): ++ self.bucket_name = bucket_name ++ ++ def blob(self, blob_name): ++ CURRENT_STATE.calls.append(("blob", self.bucket_name, blob_name)) ++ return FakeBlob(self.bucket_name, blob_name) ++ ++ ++class FakeStorageClient: ++ def __init__(self, project=None): ++ if CURRENT_STATE is not None: ++ CURRENT_STATE.calls.append(("Client", project)) ++ ++ def bucket(self, bucket_name): ++ CURRENT_STATE.calls.append(("bucket", bucket_name)) ++ return FakeBucket(bucket_name) ++ ++ ++def install_fake_google_modules(): ++ google = types.ModuleType("google") ++ cloud = types.ModuleType("google.cloud") ++ storage = types.ModuleType("google.cloud.storage") ++ api_core = types.ModuleType("google.api_core") ++ exceptions = types.ModuleType("google.api_core.exceptions") ++ ++ storage.Client = FakeStorageClient ++ exceptions.NotFound = FakeNotFound ++ cloud.storage = storage ++ api_core.exceptions = exceptions ++ google.cloud = cloud ++ google.api_core = api_core ++ ++ sys.modules["google"] = google ++ sys.modules["google.cloud"] = cloud ++ sys.modules["google.cloud.storage"] = storage ++ sys.modules["google.api_core"] = api_core ++ sys.modules["google.api_core.exceptions"] = exceptions ++ ++ ++install_fake_google_modules() ++ ++import bb.data # noqa: E402 ++import bb.fetch2 # noqa: E402 ++ ++ ++@pytest.fixture(autouse=True) ++def fake_gcs_success(): ++ global CURRENT_STATE ++ CURRENT_STATE = FakeGCSState("success") ++ yield CURRENT_STATE ++ ++ ++@pytest.fixture ++def datastore(tmp_path): ++ dldir = tmp_path / "download" ++ dldir.mkdir() ++ d = bb.data.init() ++ d.setVar("DL_DIR", str(dldir)) ++ d.setVar("PREMIRRORS", "") ++ d.setVar("MIRRORS", "") ++ d.setVar("BB_STRICT_CHECKSUM", "ignore") ++ d.setVar("PN", "gcp-fetch-acceptance") ++ return d ++ ++ ++def fetcher(url, datastore): ++ return bb.fetch2.Fetch([url], datastore) ++ ++ ++def target_path(fetch, url): ++ return fetch.localpath(url) ++ ++ ++def assert_download_attempted_for(calls, bucket, blob_name): ++ ++ assert any( ++ call[0] in {"download_to_filename", "download_to_file", "download_as_bytes"} ++ and call[1] == bucket ++ and call[2] == blob_name ++ for call in calls ++ ) ++ ++ ++def assert_target_has_fake_object(path): ++ ++ assert os.path.getsize(path) > 0 ++ assert open(path, "rb").read() == CONTENT ++ ++ ++def test_gs_url_default_filename_downloads_and_checkstatus_uses_stripped_object_path(datastore, fake_gcs_success): ++ ++ ++ ++ ++ url = "gs://example-bucket/releases/pkg-1.0.tar.gz" ++ f = fetcher(url, datastore) ++ ++ ++ assert target_path(f, url) ++ assert os.path.basename(target_path(f, url)) == "pkg-1.0.tar.gz" ++ ++ ++ f.download() ++ assert os.path.exists(target_path(f, url)) is True ++ assert_target_has_fake_object(target_path(f, url)) ++ assert ("bucket", "example-bucket") in fake_gcs_success.calls ++ assert ("blob", "example-bucket", "releases/pkg-1.0.tar.gz") in fake_gcs_success.calls ++ assert_download_attempted_for(fake_gcs_success.calls, "example-bucket", "releases/pkg-1.0.tar.gz") ++ ++ ++ f.checkstatus() ++ assert ("exists", "example-bucket", "releases/pkg-1.0.tar.gz") in fake_gcs_success.calls ++ ++ ++def test_gs_url_downloadfilename_overrides_local_filename_and_keeps_object_path(datastore, fake_gcs_success): ++ ++ ++ ++ ++ url = "gs://example-bucket/releases/pkg;downloadfilename=source.tar.gz" ++ f = fetcher(url, datastore) ++ ++ ++ assert target_path(f, url) ++ assert os.path.basename(target_path(f, url)) == "source.tar.gz" ++ ++ ++ f.download() ++ assert os.path.exists(target_path(f, url)) is True ++ assert_target_has_fake_object(target_path(f, url)) ++ assert ("blob", "example-bucket", "releases/pkg") in fake_gcs_success.calls ++ assert_download_attempted_for(fake_gcs_success.calls, "example-bucket", "releases/pkg") ++ ++ ++def test_storage_notfound_during_download_raises_fetcherror(datastore, fake_gcs_success): ++ ++ ++ ++ ++ fake_gcs_success.scenario = "notfound" ++ url = "gs://example-bucket/releases/pkg-1.0.tar.gz" ++ f = fetcher(url, datastore) ++ ++ with pytest.raises(bb.fetch2.FetchError) as excinfo: ++ f.download() ++ ++ ++ assert isinstance(excinfo.value, bb.fetch2.FetchError) ++ assert os.path.exists(target_path(f, url)) is False ++ assert_download_attempted_for(fake_gcs_success.calls, "example-bucket", "releases/pkg-1.0.tar.gz") ++ ++ ++def test_download_success_but_missing_target_raises_fetcherror(datastore, fake_gcs_success): ++ ++ ++ ++ ++ fake_gcs_success.scenario = "missingfile" ++ url = "gs://example-bucket/releases/pkg-1.0.tar.gz" ++ f = fetcher(url, datastore) ++ ++ with pytest.raises(bb.fetch2.FetchError) as excinfo: ++ f.download() ++ ++ ++ assert isinstance(excinfo.value, bb.fetch2.FetchError) ++ assert os.path.exists(target_path(f, url)) is False ++ ++ ++def test_download_zero_byte_target_raises_fetcherror_and_removes_file(datastore, fake_gcs_success): ++ ++ ++ ++ ++ fake_gcs_success.scenario = "zero" ++ url = "gs://example-bucket/releases/pkg-1.0.tar.gz" ++ f = fetcher(url, datastore) ++ ++ with pytest.raises(bb.fetch2.FetchError) as excinfo: ++ f.download() ++ ++ ++ assert isinstance(excinfo.value, bb.fetch2.FetchError) ++ assert os.path.exists(target_path(f, url)) is False ++ ++ ++def test_checkstatus_missing_blob_raises_fetcherror(datastore, fake_gcs_success): ++ ++ ++ ++ ++ fake_gcs_success.scenario = "notfound" ++ url = "gs://example-bucket/releases/pkg-1.0.tar.gz" ++ f = fetcher(url, datastore) ++ ++ with pytest.raises(bb.fetch2.FetchError) as excinfo: ++ f.checkstatus() ++ ++ ++ assert isinstance(excinfo.value, bb.fetch2.FetchError) ++ assert ("exists", "example-bucket", "releases/pkg-1.0.tar.gz") in fake_gcs_success.calls ++ ++ ++def test_network_disabled_blocks_download_before_blob_download(datastore, fake_gcs_success): ++ ++ ++ ++ ++ datastore.setVar("BB_NO_NETWORK", "1") ++ url = "gs://example-bucket/releases/pkg-1.0.tar.gz" ++ f = fetcher(url, datastore) ++ ++ with pytest.raises(bb.fetch2.NetworkAccess) as excinfo: ++ f.download() ++ ++ ++ assert excinfo.value.url == url ++ assert [ ++ call for call in fake_gcs_success.calls if call[0] == "download_to_filename" ++ ] == [] ++ assert [ ++ call ++ for call in fake_gcs_success.calls ++ if call[0] in {"download_to_file", "download_as_bytes"} ++ ] == [] ++ ++ ++def test_network_disabled_blocks_checkstatus_before_existence_check(datastore, fake_gcs_success): ++ ++ ++ ++ ++ datastore.setVar("BB_NO_NETWORK", "1") ++ url = "gs://example-bucket/releases/pkg-1.0.tar.gz" ++ f = fetcher(url, datastore) ++ ++ with pytest.raises(bb.fetch2.NetworkAccess) as excinfo: ++ f.checkstatus() ++ ++ ++ assert excinfo.value.url == url ++ assert [call for call in fake_gcs_success.calls if call[0] == "exists"] == [] ++ ++ ++def test_two_fetch_instances_keep_independent_url_state(datastore, fake_gcs_success): ++ ++ ++ ++ ++ url_a = "gs://example-bucket/releases/pkg-1.0.tar.gz" ++ url_b = "gs://another-bucket/assets/other.bin" ++ a = fetcher(url_a, datastore) ++ b = fetcher(url_b, datastore) ++ ++ assert os.path.basename(target_path(a, url_a)) == "pkg-1.0.tar.gz" ++ assert os.path.basename(target_path(b, url_b)) == "other.bin" ++ ++ ++ a.download() ++ assert os.path.exists(target_path(a, url_a)) is True ++ assert_target_has_fake_object(target_path(a, url_a)) ++ assert os.path.exists(target_path(b, url_b)) is False ++ ++ ++ b.checkstatus() ++ assert ("exists", "another-bucket", "assets/other.bin") in fake_gcs_success.calls ++ ++ ++def test_download_writes_target_file(datastore): ++ ++ ++ ++ ++ url = "gs://example-bucket/releases/pkg-1.0.tar.gz" ++ f = fetcher(url, datastore) ++ ++ f.download() ++ assert os.path.exists(target_path(f, url)) is True ++ assert_target_has_fake_object(target_path(f, url)) ++ ++ ++def test_zero_byte_cleanup_leak_floor_over_many_fetch_sessions(datastore, fake_gcs_success): ++ ++ ++ ++ ++ fake_gcs_success.scenario = "zero" ++ url = "gs://example-bucket/releases/pkg-1.0.tar.gz" ++ ++ for _ in range(100): ++ f = fetcher(url, datastore) ++ with pytest.raises(bb.fetch2.FetchError): ++ f.download() ++ ++ assert os.path.exists(target_path(f, url)) is False ++ ++ dldir_entries = sorted(os.listdir(datastore.getVar("DL_DIR"))) ++ ++ assert "pkg-1.0.tar.gz" not in dldir_entries +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/lib${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTHONDONTWRITEBYTECODE=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++unset PYTEST_ADDOPTS ++ ++exec python -m pytest --rootdir=/workspace/repo -c /dev/null -p no:cacheprovider /workspace/repo/usercase-test-coderl/test_gcp_fetch.py -v diff --git a/tasks/format-code-task-002139/tests/test.sh b/tasks/format-code-task-002139/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8fe96b0f67358b39cafe4df9a1109cdbafbd3f1a --- /dev/null +++ b/tasks/format-code-task-002139/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_gcp_fetch.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-002139/tests/test_command.sh b/tasks/format-code-task-002139/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002139/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-002155/environment/Dockerfile b/tasks/format-code-task-002155/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..603f0ad110441ad4cb4efe42782545420d95243a --- /dev/null +++ b/tasks/format-code-task-002155/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:6325d55e7d13ff47928a0a7f99c37faf0cded01ef74386c43f606732bc97c28e diff --git a/tasks/format-code-task-002155/environment/setup/files/blocklist b/tasks/format-code-task-002155/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002155/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-002155/environment/setup/setup.sh b/tasks/format-code-task-002155/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002155/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-002155/tests/test.patch b/tasks/format-code-task-002155/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3c0ddf3ba2f606ff37f5c9707f2e1ec3378849b7 --- /dev/null +++ b/tasks/format-code-task-002155/tests/test.patch @@ -0,0 +1,40 @@ +diff --git a/pkg/synthetictests/duplicated_events_test.go b/pkg/synthetictests/duplicated_events_test.go +index eb720b9e58ac..eaa2419dfacd 100644 +--- a/pkg/synthetictests/duplicated_events_test.go ++++ b/pkg/synthetictests/duplicated_events_test.go +@@ -112,6 +112,14 @@ func TestUpgradeEventRegexExcluder(t *testing.T) { + name: "etcd-member", + message: `ns/openshift-etcd-operator deployment/etcd-operator - reason/UnhealthyEtcdMember unhealthy members: ip-10-0-198-128.ec2.internal`, + }, ++ { ++ name: "readiness-notready", ++ message: `ns/openshift-machine-api pod/machine-api-controllers-6665d45fd-blbbp node/ip-1-2-3-4.ec2.internal - reason/ProbeError Readiness probe error: Get "http://1.2.3.4:9441/healthz": dial tcp 1.2.3.4:9441: connect: connection refused`, ++ }, ++ { ++ name: "readiness-timeout", ++ message: `ns/openshift-monitoring pod/thanos-querier-d89745c9-xttvz node/ip-1-2-3-4.us-west-2.compute.internal - reason/ProbeError Readiness probe error: Get "https://1.2.3.4:9091/-/ready": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)`, ++ }, + } + + for _, test := range tests { +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+3RT2vDIBgGcM/9FN56aqJB0/tGTruN7VxSFVvWavFPlsE+/JIM1jHoemkZZc/v ++or6v4ItPsc7bnV4Z15XkWthgKeW0Dn6u057LivOlEKwWhHFeM0movNpE3+SY2kApCd6n3+6d69+o ++4ph/MjGtlN/vW6eLuLncG+fyrypxzJ+P+YuaV4Syy41w2j/PX2k6Bb82emY9Hbd00dGiPLzYMr65 ++tDFpq8ZyLOkiZEfnT8Oh6YxL9z671PQptCr58P5VfzTW9E2vdlmbz/LzwYZWmxPdB+df3V22UzvO ++Z3/9JwAAAAAAAAAAAAAAAAAAAAAAt+IDWXdxhAAoAAA= +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-002155/tests/test.sh b/tasks/format-code-task-002155/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..865fac67bd2edf363179f0c1cae5bdde3a7cd8df --- /dev/null +++ b/tasks/format-code-task-002155/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/synthetictests/duplicated_events_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-002155/tests/test_command.sh b/tasks/format-code-task-002155/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002155/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-002164/environment/Dockerfile b/tasks/format-code-task-002164/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5bf5241f843fcf3b9646a6935a81806641f43bd6 --- /dev/null +++ b/tasks/format-code-task-002164/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:06375acea7ad9e19f0a9ed4cf94f59c5acea5badb5d027d43819413183a47904 diff --git a/tasks/format-code-task-002164/environment/setup/files/blocklist b/tasks/format-code-task-002164/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002164/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-002164/environment/setup/setup.sh b/tasks/format-code-task-002164/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002164/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-002164/tests/test.patch b/tasks/format-code-task-002164/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..201cff930e4f4a26c66a4f2464fdc656316681b7 --- /dev/null +++ b/tasks/format-code-task-002164/tests/test.patch @@ -0,0 +1,43 @@ +diff --git a/pkg/generator/generator_test.go b/pkg/generator/generator_test.go +index c67550ad31a..75a283b8aba 100644 +--- a/pkg/generator/generator_test.go ++++ b/pkg/generator/generator_test.go +@@ -262,10 +262,10 @@ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ${BIN_DIR}/${PROJECT_NAME} $BU + + const dockerFileExp = `FROM alpine:3.6 + +-ADD tmp/_output/bin/app-operator /usr/local/bin/app-operator +- + RUN adduser -D app-operator + USER app-operator ++ ++ADD tmp/_output/bin/app-operator /usr/local/bin/app-operator + ` + + func TestGenBuild(t *testing.T) { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,10 @@ ++H4sIAAAAAAAAA+2TW2/TMBTH8+xPcdbxAEKJk6ztHtAQSKCBBCoa8ITQlIuTmia28SWj0j48Tjra ++ES4d0iaEOL8XRz4n5/Y/jnLHm/KciY4Gd0XsOZ7NhtMzPofvZJYmaRynR/E0iJNkNp8HMLuziq7h ++jM00QKCltL/z22f/R4l2+ltm7Hkh2zYTZWSWt5djj/7JdJ5s9U+PjoPhJgkgvr0Sfs1/rv/hAc25 ++oHlmlsQwCyFzEhRXrMp4Q0hRwrAXOSsJOYS33sMpOF28efruBRirXWGdZlBJDXbJDSjNwlaWrmEG ++Tn0gLT+xwhL2RUltr/47of0saS1Juyq5hlDB5N7GRI0uaM3t0uWR30QqFdOZlTqsdNayC6lXE9II ++CE0ltnX9wc+7K1P6SL6hl8LL3zRQS7WqIz+IddY2UZdCyRQTJRPFGriwEnYp4L5mnx3XPnO+hpoJ ++/2ZExeuolg8Ir+ADHEA4rmoUfgIfH/mBMUHAsx0Dta0aXMIuHSzD+Ed3tQQ/YV8Vt2BZqyB9TEvW ++UeF8H5eX4EVh3xxrr9c495MujaZR/H3mn1Y72dSgINQ7B2+iPv8PLV2FnexpfBNy2XcQnoF7eHEj ++/2tbWPFetzMn+vmBf7t9j73RkNNFkiSvF8/ev3p+IqtqvG79QHpHCDu4+ZoMDXuVNzeU/O0HiyAI ++giAIgiAIgiAIgiAIgiAIgiAIgiAIMuIrcSX87QAoAAA= +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-002164/tests/test.sh b/tasks/format-code-task-002164/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..79441270b1e461fc9755f74cc7309386b488fa04 --- /dev/null +++ b/tasks/format-code-task-002164/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/generator/generator_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-002164/tests/test_command.sh b/tasks/format-code-task-002164/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002164/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-002190/environment/Dockerfile b/tasks/format-code-task-002190/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b9c872ffb8a4047b63a0d7932accca06c9ef9630 --- /dev/null +++ b/tasks/format-code-task-002190/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:ba6995f48c1c15997c830d5615ec9227b3153d15b71950e0fdb201eec402e55a diff --git a/tasks/format-code-task-002190/environment/setup/files/blocklist b/tasks/format-code-task-002190/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002190/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-002190/environment/setup/setup.sh b/tasks/format-code-task-002190/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002190/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-002190/tests/test.patch b/tasks/format-code-task-002190/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..983ec7f9b3cbefd307952e0bd9a07020c1b98d06 --- /dev/null +++ b/tasks/format-code-task-002190/tests/test.patch @@ -0,0 +1,44 @@ +diff --git a/tests/test_arguments.py b/tests/test_arguments.py +index 825bcc487..5dc56a468 100644 +--- a/tests/test_arguments.py ++++ b/tests/test_arguments.py +@@ -198,6 +198,19 @@ def cmd(arg): + assert result.return_value == expect + + ++def test_envvar_flag_value(runner): ++ @click.command() ++ ++ @click.option("--upper", flag_value="upper", envvar="UPPER") ++ def cmd(upper): ++ click.echo(upper) ++ return upper ++ ++ ++ result = runner.invoke(cmd, env={"UPPER": "whatever"}) ++ assert result.output.strip() == "upper" ++ ++ + def test_nargs_envvar_only_if_values_empty(runner): + @click.command() + @click.argument("arg", envvar="X", nargs=-1) +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+3S0QqCMBTGca97ivMCmlOnjxOmkkFquCn09i2DiqC6USL6/y62w9lgB74F22F/ ++KDdVO669pYROpvW0O8/7VCsdhVGmVRK7vlKpa4lebKIHg7F5L+L1XWff3ft0/qOCe/62MnZTdE2T ++t2Vg6vne+Jh/pm75x2nq8k/SKPIknG+E1/48/6KUKfhtVa6OJ1t3bSx+I650Tbks5vox8n43NFVr ++TXA8iT+uvj04AAAAAAAAAAAAAAAAAO8MNv/L9AAoAAA= +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-002190/tests/test.sh b/tasks/format-code-task-002190/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c42d5f80b1ed47b9738aab50d921cbde81faf278 --- /dev/null +++ b/tasks/format-code-task-002190/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_arguments.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-002190/tests/test_command.sh b/tasks/format-code-task-002190/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002190/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-002248/environment/Dockerfile b/tasks/format-code-task-002248/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0310c10bb9514987fe0a396102f6fc5aa8df2985 --- /dev/null +++ b/tasks/format-code-task-002248/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:13b25282d93720a9bdf912e57c0e14b10ca7d309ed72ca31962894887a050bbf diff --git a/tasks/format-code-task-002248/environment/setup/files/blocklist b/tasks/format-code-task-002248/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002248/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-002248/environment/setup/setup.sh b/tasks/format-code-task-002248/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002248/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-002248/tests/test.patch b/tasks/format-code-task-002248/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0e9715be5da7340be849bca08442c1f4e1537c65 --- /dev/null +++ b/tasks/format-code-task-002248/tests/test.patch @@ -0,0 +1,93 @@ +diff --git a/tests/test_metrics.py b/tests/test_metrics.py +new file mode 100644 +index 0000000..b1d03c6 +--- /dev/null ++++ b/tests/test_metrics.py +@@ -0,0 +1,62 @@ ++import unittest ++ ++import numpy as np ++ ++from fastTSNE.tsne import TSNE ++ ++ ++class TestDistanceMetrics(unittest.TestCase): ++ @classmethod ++ def setUpClass(cls): ++ cls.x = np.random.RandomState(42).randn(50, 4) ++ ++ def _embed_exact(self, metric, metric_params=None): ++ tsne = TSNE(metric=metric, metric_params=metric_params, neighbors='exact') ++ embedding = tsne.prepare_initial(self.x) ++ return np.asarray(embedding) ++ ++ def test_common_metrics_produce_embedding_with_exact(self): ++ ++ for metric in ['euclidean', 'manhattan', 'chebyshev']: ++ embedding = self._embed_exact(metric) ++ self.assertEqual(embedding.shape, (self.x.shape[0], 2)) ++ self.assertTrue(np.all(np.isfinite(embedding))) ++ ++ def test_exact_supports_metrics_beyond_kdtree(self): ++ ++ for metric in ['braycurtis', 'canberra']: ++ embedding = self._embed_exact(metric) ++ self.assertEqual(embedding.shape, (self.x.shape[0], 2)) ++ self.assertTrue(np.all(np.isfinite(embedding))) ++ ++ def test_metric_params_are_honored(self): ++ ++ cov = np.cov(self.x.T) ++ embedding = self._embed_exact('mahalanobis', metric_params={'V': cov}) ++ self.assertEqual(embedding.shape, (self.x.shape[0], 2)) ++ self.assertTrue(np.all(np.isfinite(embedding))) ++ ++ def test_unrecognized_metric_raises_value_error(self): ++ ++ for method in ['exact', 'approx']: ++ tsne = TSNE(metric='this_is_not_a_metric', neighbors=method) ++ with self.assertRaises(ValueError): ++ tsne.prepare_initial(self.x) ++ ++ def test_metric_supported_by_only_one_backend_is_rejected(self): ++ ++ ++ ++ ++ ++ ++ ++ for metric in ['cosine', 'cityblock']: ++ for method in ['exact', 'approx']: ++ tsne = TSNE(metric=metric, neighbors=method) ++ with self.assertRaises(ValueError): ++ tsne.prepare_initial(self.x) ++ ++ ++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,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++python -m pytest tests/test_tsne.py -q ++ ++ ++python -m pytest tests/test_metrics.py -q diff --git a/tasks/format-code-task-002248/tests/test.sh b/tasks/format-code-task-002248/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..45a5d008e8fdf463e4f70888458638e6761f675d --- /dev/null +++ b/tasks/format-code-task-002248/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_metrics.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-002248/tests/test_command.sh b/tasks/format-code-task-002248/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002248/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-002277/environment/Dockerfile b/tasks/format-code-task-002277/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c198db0840103ca1ceb6aa501647939619f0d706 --- /dev/null +++ b/tasks/format-code-task-002277/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:5fc6a41a8b16db3e1c953eee95c09d7f045cd98a8f993937492ae4ce88420af8 diff --git a/tasks/format-code-task-002277/environment/setup/files/blocklist b/tasks/format-code-task-002277/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002277/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-002277/environment/setup/setup.sh b/tasks/format-code-task-002277/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002277/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-002277/tests/test.patch b/tasks/format-code-task-002277/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cd9312dfb4975a1c661761ceae47fe1162410357 --- /dev/null +++ b/tasks/format-code-task-002277/tests/test.patch @@ -0,0 +1,47 @@ +diff --git a/sync_diff_inspector/utils/utils_test.go b/sync_diff_inspector/utils/utils_test.go +index a247a0eca..9a95a03fe 100644 +--- a/sync_diff_inspector/utils/utils_test.go ++++ b/sync_diff_inspector/utils/utils_test.go +@@ -548,7 +548,7 @@ func TestCompareStruct(t *testing.T) { + require.NoError(t, err) + + isEqual, isPanic = CompareStruct([]*model.TableInfo{tableInfo, tableInfo2}, tableInfo) +- require.True(t, isEqual) ++ require.False(t, isEqual) + require.False(t, isPanic) + require.Equal(t, len(tableInfo.Indices), 1) + require.Equal(t, tableInfo.Indices[0].Name.O, "PRIMARY") +@@ -563,7 +563,7 @@ func TestCompareStruct(t *testing.T) { + require.NoError(t, err) + + isEqual, isPanic = CompareStruct([]*model.TableInfo{tableInfo, tableInfo2}, tableInfo) +- require.True(t, isEqual) ++ require.False(t, isEqual) + require.False(t, isPanic) + require.Equal(t, len(tableInfo.Indices), 1) + require.Equal(t, tableInfo.Indices[0].Name.O, "c") +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+3SUW/TMBAA4D7nVxwbD+yhcVxIJ5D2gBgaD6BO08Zr5cSXxiLxBdsp7N9jp0Cn ++CtjLJoS478WNfbq72pdXo+n0Gu1WzB5LEZ2W5bRGh+v0W5aLYrFcyMVSzgopy9PlDMpH6+iO0Qfl ++AGaOKPwp7r7zf1S+f/+APqxr6ntlde7bh6txz/vLoty/vyyfx/d/sSzi+xcP18Lv/efvf/xEVMaK ++Svk2qzVMQ1ChzrJjuHQ4KIewobwnLeLixx4aRz2kDSnSt4RnMYxg9OghtMbDoEJAZ0+yeviZTuxy ++yMONw5gp4cFGauXGI1wQyFy+TPU+j8alcgRqS0bDNMMf0XlDFjpjP1nVIxgbhzl2YyrTmXB7kuHX ++gVyAy9fX786OBA0hVpinnOkKXj1N+0c/gi5WV6vV9dndqP2RlPLD6vzm/dszsqm9Nx3GGZq6gFrV ++Le5bi9PVISgXTKPq4HfXR6FFl/7Qdtezz1wPc9eASFMm8ilHKjulTBXO6YvtSGnQOKDVaGuDPtsQ ++xEsE/f0wBV6NFuJAbzBAukZoTIcpbvqYb2FjQjtWebwZMRi7qdUggtHVPBB1XvhbW6+1aZq1sX7A ++OpATYzCdz/72nDLGGGOMMcYYY4wxxhhjjDHGGGOMsV/7BjkM7i0AKAAA +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-002277/tests/test.sh b/tasks/format-code-task-002277/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..82bd192882f40d0f83f23e68b8f44dea12d523b1 --- /dev/null +++ b/tasks/format-code-task-002277/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' +sync_diff_inspector/utils/utils_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-002277/tests/test_command.sh b/tasks/format-code-task-002277/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002277/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-002283/environment/Dockerfile b/tasks/format-code-task-002283/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..35b34efbf9c1f4977a459014ffbcdad65e4cb5fc --- /dev/null +++ b/tasks/format-code-task-002283/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:a6a2eaafb5cb3e503e25051f77b1afb581284cdbba6d8b2a8e92e2869281bc11 diff --git a/tasks/format-code-task-002283/environment/setup/files/blocklist b/tasks/format-code-task-002283/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002283/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-002283/environment/setup/setup.sh b/tasks/format-code-task-002283/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002283/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-002283/tests/test.patch b/tasks/format-code-task-002283/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..64c4c703cded1cb7d76f675bc27cad0ea91a4b62 --- /dev/null +++ b/tasks/format-code-task-002283/tests/test.patch @@ -0,0 +1,114 @@ +diff --git a/smart_open/tests/test_s3.py b/smart_open/tests/test_s3.py +index 4e5ca5b..9406e0a 100644 +--- a/smart_open/tests/test_s3.py ++++ b/smart_open/tests/test_s3.py +@@ -877,6 +877,87 @@ class DownloadKeyTest(unittest.TestCase): + KEY_NAME, bucket_name=BUCKET_NAME) + + ++def _make_404_client_error(): ++ return botocore.client.ClientError( ++ error_response={'Error': {'Code': '404', 'Message': 'Not Found'}}, ++ operation_name='HeadObject', ++ ) ++ ++ ++def _make_500_client_error(): ++ return botocore.client.ClientError( ++ error_response={'Error': {'Code': '500', 'Message': 'Internal Server Error'}}, ++ operation_name='HeadObject', ++ ) ++ ++ ++@moto.mock_s3 ++class IterBucketRaceConditionTest(unittest.TestCase): ++ """Tests that iter_bucket survives keys that vanish between list and download.""" ++ ++ def setUp(self): ++ self.old_flag_multi = smart_open.concurrency._MULTIPROCESSING ++ self.old_flag_concurrent = smart_open.concurrency._CONCURRENT_FUTURES ++ smart_open.concurrency._MULTIPROCESSING = False ++ smart_open.concurrency._CONCURRENT_FUTURES = False ++ ignore_resource_warnings() ++ _resource('s3').create_bucket(Bucket=BUCKET_NAME).wait_until_exists() ++ populate_bucket(num_keys=5) ++ ++ def tearDown(self): ++ smart_open.concurrency._MULTIPROCESSING = self.old_flag_multi ++ smart_open.concurrency._CONCURRENT_FUTURES = self.old_flag_concurrent ++ ++ def test_iter_bucket_skips_404(self): ++ """A single key 404 during download must be silently skipped, others yielded.""" ++ missing = 'key_2' ++ ++ def fake_download(bucket, key_name): ++ if key_name == missing: ++ raise _make_404_client_error() ++ return b'content-' + key_name.encode('ascii') ++ ++ with mock.patch('smart_open.s3._download_fileobj', side_effect=fake_download): ++ results = list(smart_open.s3.iter_bucket(BUCKET_NAME, retries=0)) ++ ++ returned_keys = [k for k, _ in results] ++ self.assertNotIn(missing, returned_keys) ++ self.assertEqual(sorted(returned_keys), ++ sorted(['key_0', 'key_1', 'key_3', 'key_4'])) ++ ++ def test_iter_bucket_skips_multiple_404s(self): ++ """Multiple 404s must all be skipped; remaining keys still yielded.""" ++ missing = {'key_0', 'key_3'} ++ ++ def fake_download(bucket, key_name): ++ if key_name in missing: ++ raise _make_404_client_error() ++ return b'content-' + key_name.encode('ascii') ++ ++ with mock.patch('smart_open.s3._download_fileobj', side_effect=fake_download): ++ results = list(smart_open.s3.iter_bucket(BUCKET_NAME, retries=0)) ++ ++ returned_keys = [k for k, _ in results] ++ for m in missing: ++ self.assertNotIn(m, returned_keys) ++ self.assertEqual(sorted(returned_keys), sorted(['key_1', 'key_2', 'key_4'])) ++ ++ def test_iter_bucket_propagates_non_404_clienterror(self): ++ """Non-404 ClientErrors must still propagate to the caller.""" ++ def fake_download(bucket, key_name): ++ raise _make_500_client_error() ++ ++ with mock.patch('smart_open.s3._download_fileobj', side_effect=fake_download): ++ with self.assertRaises(botocore.client.ClientError): ++ list(smart_open.s3.iter_bucket(BUCKET_NAME, retries=0)) ++ ++ def test_iter_bucket_no_errors_preservation(self): ++ """With no errors, iter_bucket still yields every key (preservation).""" ++ results = list(smart_open.s3.iter_bucket(BUCKET_NAME)) ++ returned_keys = sorted(k for k, _ in results) ++ self.assertEqual(returned_keys, ['key_0', 'key_1', 'key_2', 'key_3', 'key_4']) ++ ++ + @moto.mock_s3 + class OpenTest(unittest.TestCase): + def setUp(self): +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..c779a37 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest smart_open/tests/test_s3.py::IterBucketRaceConditionTest -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -v -rA smart_open/tests/test_s3.py::IterBucketRaceConditionTest::test_iter_bucket_skips_404 smart_open/tests/test_s3.py::IterBucketRaceConditionTest::test_iter_bucket_skips_multiple_404s smart_open/tests/test_s3.py::IterBucketRaceConditionTest::test_iter_bucket_propagates_non_404_clienterror smart_open/tests/test_s3.py::IterBucketRaceConditionTest::test_iter_bucket_no_errors_preservation ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002283/tests/test.sh b/tasks/format-code-task-002283/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c82a4e91849fdb4c861cac8e5601de23bdce7925 --- /dev/null +++ b/tasks/format-code-task-002283/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' +smart_open/tests/test_s3.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002283/tests/test_command.sh b/tasks/format-code-task-002283/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002283/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-002302/environment/Dockerfile b/tasks/format-code-task-002302/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3571717ede92919999b251e62cee237f8cc37e36 --- /dev/null +++ b/tasks/format-code-task-002302/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:ca9f21f3497778911bdd3fab85b5ac7a3006ff53e9466456554b2ff37221c688 diff --git a/tasks/format-code-task-002302/environment/setup/files/blocklist b/tasks/format-code-task-002302/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002302/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-002302/environment/setup/setup.sh b/tasks/format-code-task-002302/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002302/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-002302/tests/test.patch b/tasks/format-code-task-002302/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f72643a3450a0e6d753e1efaf7a4dae4a2a9e27f --- /dev/null +++ b/tasks/format-code-task-002302/tests/test.patch @@ -0,0 +1,257 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..e6a28341 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=. python tests/test_python/test_i3wm_ipc_v2.py --verbose"] ++} +diff --git a/tests/test_python/test_i3wm_ipc_v2.py b/tests/test_python/test_i3wm_ipc_v2.py +new file mode 100644 +index 00000000..1fb275cf +--- /dev/null ++++ b/tests/test_python/test_i3wm_ipc_v2.py +@@ -0,0 +1,229 @@ ++# vim:fileencoding=utf-8:noet ++from __future__ import (unicode_literals, division, absolute_import, print_function) ++ ++import powerline.segments.i3wm as segments_i3wm ++import powerline.listers.i3wm as listers_i3wm ++ ++from tests.modules.lib import Args, replace_attr, Pl ++from tests.modules import TestCase ++ ++ ++class FakeWS(object): ++ ++ def __init__(self, name, output, focused=False, urgent=False, visible=False): ++ self.name = name ++ self.output = output ++ self.focused = focused ++ self.urgent = urgent ++ self.visible = visible ++ ++ ++def make_workspaces(): ++ return iter([ ++ FakeWS('1: w1', 'LVDS1'), ++ FakeWS('2: w2', 'LVDS1', visible=True), ++ FakeWS('3: w3', 'HDMI1', urgent=True, visible=True), ++ FakeWS('4: w4', 'DVI01', focused=True, urgent=True, visible=True), ++ ]) ++ ++ ++def make_conn(): ++ return Args(get_workspaces=make_workspaces) ++ ++ ++class TestI3WMSegmentsAttrAccess(TestCase): ++ def test_workspaces_lists_all(self): ++ pl = Pl() ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = segments_i3wm.workspaces(pl=pl, segment_info={}) ++ self.assertEqual(result, [ ++ {'contents': '1: w1', 'highlight_groups': ['workspace']}, ++ {'contents': '2: w2', 'highlight_groups': ['w_visible', 'workspace']}, ++ {'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']}, ++ {'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']}, ++ ]) ++ ++ def test_workspaces_only_show_focused_urgent(self): ++ pl = Pl() ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = segments_i3wm.workspaces( ++ pl=pl, segment_info={}, only_show=['focused', 'urgent']) ++ self.assertEqual(result, [ ++ {'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']}, ++ {'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']}, ++ ]) ++ ++ def test_workspaces_only_show_visible(self): ++ pl = Pl() ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = segments_i3wm.workspaces( ++ pl=pl, segment_info={}, only_show=['visible']) ++ self.assertEqual(result, [ ++ {'contents': '2: w2', 'highlight_groups': ['w_visible', 'workspace']}, ++ {'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']}, ++ {'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']}, ++ ]) ++ ++ def test_workspaces_output_filter(self): ++ pl = Pl() ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = segments_i3wm.workspaces( ++ pl=pl, segment_info={}, output='LVDS1') ++ self.assertEqual(result, [ ++ {'contents': '1: w1', 'highlight_groups': ['workspace']}, ++ {'contents': '2: w2', 'highlight_groups': ['w_visible', 'workspace']}, ++ ]) ++ ++ def test_workspaces_strip(self): ++ pl = Pl() ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = segments_i3wm.workspaces( ++ pl=pl, segment_info={}, only_show=['visible'], strip=3) ++ self.assertEqual(result, [ ++ {'contents': 'w2', 'highlight_groups': ['w_visible', 'workspace']}, ++ {'contents': 'w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']}, ++ {'contents': 'w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']}, ++ ]) ++ ++ def test_workspaces_segment_info_output(self): ++ pl = Pl() ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = segments_i3wm.workspaces( ++ pl=pl, segment_info={'output': 'HDMI1'}) ++ self.assertEqual(result, [ ++ {'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']}, ++ ]) ++ ++ def test_workspace_by_name(self): ++ pl = Pl() ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = segments_i3wm.workspace( ++ pl=pl, segment_info={}, workspace='3: w3') ++ self.assertEqual(result, [ ++ {'contents': '3: w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']}, ++ ]) ++ ++ def test_workspace_by_name_strip(self): ++ pl = Pl() ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = segments_i3wm.workspace( ++ pl=pl, segment_info={}, workspace='3: w3', strip=True) ++ self.assertEqual(result, [ ++ {'contents': 'w3', 'highlight_groups': ['w_urgent', 'w_visible', 'workspace']}, ++ ]) ++ ++ def test_workspace_not_found(self): ++ pl = Pl() ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = segments_i3wm.workspace( ++ pl=pl, segment_info={}, workspace='999: nope') ++ self.assertIsNone(result) ++ ++ def test_workspace_default_returns_focused(self): ++ pl = Pl() ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = segments_i3wm.workspace(pl=pl, segment_info={}) ++ self.assertEqual(result, [ ++ {'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']}, ++ ]) ++ ++ ++class TestI3WMListerAttrAccess(TestCase): ++ def test_lister_lists_all(self): ++ pl = Pl() ++ with replace_attr(listers_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = list(listers_i3wm.workspace_lister(pl=pl, segment_info={'a': 1})) ++ self.assertEqual(len(result), 4) ++ outputs = [info['output'] for (info, _) in result] ++ self.assertEqual(outputs, ['LVDS1', 'LVDS1', 'HDMI1', 'DVI01']) ++ for (info, opts) in result: ++ self.assertEqual(opts, {'draw_inner_divider': None}) ++ self.assertEqual(info['a'], 1) ++ self.assertIn('workspace', info) ++ ++ def test_lister_output_filter(self): ++ pl = Pl() ++ with replace_attr(listers_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = list(listers_i3wm.workspace_lister( ++ pl=pl, segment_info={'a': 1}, output='LVDS1')) ++ self.assertEqual(len(result), 2) ++ self.assertEqual([info['output'] for (info, _) in result], ['LVDS1', 'LVDS1']) ++ ++ def test_lister_only_show(self): ++ pl = Pl() ++ with replace_attr(listers_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = list(listers_i3wm.workspace_lister( ++ pl=pl, segment_info={'a': 1}, only_show=['focused', 'urgent'])) ++ self.assertEqual(len(result), 2) ++ self.assertEqual([info['output'] for (info, _) in result], ['HDMI1', 'DVI01']) ++ ++ def test_lister_segment_info_output(self): ++ pl = Pl() ++ with replace_attr(listers_i3wm, 'get_i3_connection', lambda: make_conn()): ++ result = list(listers_i3wm.workspace_lister( ++ pl=pl, segment_info={'a': 1, 'output': 'HDMI1'})) ++ self.assertEqual(len(result), 1) ++ self.assertEqual(result[0][0]['output'], 'HDMI1') ++ ++ def test_lister_workspace_carries_to_workspace_segment(self): ++ ++ ++ ++ pl = Pl() ++ with replace_attr(listers_i3wm, 'get_i3_connection', lambda: make_conn()): ++ tuples = list(listers_i3wm.workspace_lister(pl=pl, segment_info={'a': 1})) ++ info_for_focused = tuples[3][0] ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: make_conn()): ++ out = segments_i3wm.workspace(pl=pl, segment_info=info_for_focused) ++ self.assertEqual(out, [ ++ {'contents': '4: w4', 'highlight_groups': ['w_focused', 'w_urgent', 'w_visible', 'workspace']}, ++ ]) ++ ++ ++class TestI3WMScratchpadDescendants(TestCase): ++ def test_scratchpad_returns_correct_output(self): ++ ++ ++ ++ ++ ++ ++ ++ nodes_focused = [Args(focused=True)] ++ nodes_unfocused = [Args(focused=False)] ++ ws_scratch = lambda: Args(name='__i3_scratch') ++ ws_other = lambda: Args(name='2: www') ++ ++ def make_descendants(): ++ return [ ++ Args(scratchpad_state='fresh', urgent=False, ++ workspace=ws_scratch, nodes=nodes_unfocused), ++ Args(scratchpad_state='changed', urgent=True, ++ workspace=ws_other, nodes=nodes_focused), ++ ] ++ ++ class Tree(object): ++ def descendants(self): ++ return make_descendants() ++ ++ def descendents(self): ++ return make_descendants() ++ ++ class Conn(object): ++ def get_tree(self): ++ return Tree() ++ ++ pl = Pl() ++ with replace_attr(segments_i3wm, 'get_i3_connection', lambda: Conn()): ++ out = segments_i3wm.scratchpad(pl=pl) ++ ++ self.assertEqual(out, [ ++ {'contents': 'O', 'highlight_groups': ['scratchpad']}, ++ {'contents': 'X', 'highlight_groups': [ ++ 'scratchpad:urgent', 'scratchpad:focused', 'scratchpad:visible', 'scratchpad']}, ++ ]) ++ ++ ++if __name__ == '__main__': ++ from tests.modules import main ++ main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=. python tests/test_python/test_i3wm_ipc_v2.py --verbose ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002302/tests/test.sh b/tasks/format-code-task-002302/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b9ca7bcfa1cb903c3736eb405a1999cbad320630 --- /dev/null +++ b/tasks/format-code-task-002302/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_python/test_i3wm_ipc_v2.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-002302/tests/test_command.sh b/tasks/format-code-task-002302/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002302/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-002305/environment/Dockerfile b/tasks/format-code-task-002305/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..76f177d5c0906a6df1d96d8e0333812e29c12070 --- /dev/null +++ b/tasks/format-code-task-002305/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:3cc9de5fb85cd7a171f7de0f72202e0fb692d4f84516487bef586e14b296197e diff --git a/tasks/format-code-task-002305/environment/setup/files/blocklist b/tasks/format-code-task-002305/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002305/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-002305/environment/setup/setup.sh b/tasks/format-code-task-002305/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002305/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-002305/tests/test.patch b/tasks/format-code-task-002305/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e18feb834aca78eac571dd556a1e7eb4d6ff6d90 --- /dev/null +++ b/tasks/format-code-task-002305/tests/test.patch @@ -0,0 +1,381 @@ +diff --git a/usercase-test-coderl/fixtures/sync_ignore_harness.go b/usercase-test-coderl/fixtures/sync_ignore_harness.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/sync_ignore_harness.go +@@ -0,0 +1,250 @@ ++package main ++ ++import ( ++ "crypto/md5" ++ "crypto/rand" ++ "crypto/rsa" ++ "crypto/tls" ++ "crypto/x509" ++ "crypto/x509/pkix" ++ "encoding/hex" ++ "encoding/json" ++ "encoding/pem" ++ "fmt" ++ "math/big" ++ "net" ++ "net/http" ++ "os" ++ "os/exec" ++ "path/filepath" ++ "strings" ++ "time" ++) ++ ++const dirMime = "application/vnd.google-apps.folder" ++ ++func main() { ++ if len(os.Args) < 4 { ++ fmt.Fprintln(os.Stderr, "usage: sync_ignore_harness ") ++ os.Exit(2) ++ } ++ ++ scenario := os.Args[1] ++ bin := os.Args[2] ++ args := os.Args[3:] ++ ++ certPath, cert, key, err := makeCert() ++ if err != nil { ++ fmt.Fprintln(os.Stderr, err) ++ os.Exit(1) ++ } ++ defer os.Remove(certPath) ++ ++ proxy, err := startProxy(scenario, cert, key) ++ if err != nil { ++ fmt.Fprintln(os.Stderr, err) ++ os.Exit(1) ++ } ++ defer proxy.Close() ++ ++ cmd := exec.Command(bin, args...) ++ cmd.Stdout = os.Stdout ++ cmd.Stderr = os.Stderr ++ cmd.Env = append(os.Environ(), ++ "HTTPS_PROXY=http://"+proxy.Addr().String(), ++ "https_proxy=http://"+proxy.Addr().String(), ++ "SSL_CERT_FILE="+certPath, ++ ) ++ ++ if err := cmd.Run(); err != nil { ++ if exitErr, ok := err.(*exec.ExitError); ok { ++ os.Exit(exitErr.ExitCode()) ++ } ++ fmt.Fprintln(os.Stderr, err) ++ os.Exit(1) ++ } ++} ++ ++func startProxy(scenario string, certPEM, keyPEM []byte) (net.Listener, error) { ++ cert, err := tls.X509KeyPair(certPEM, keyPEM) ++ if err != nil { ++ return nil, err ++ } ++ ++ ln, err := net.Listen("tcp", "127.0.0.1:0") ++ if err != nil { ++ return nil, err ++ } ++ ++ server := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ if r.Method != http.MethodConnect { ++ http.Error(w, "proxy only supports CONNECT", http.StatusMethodNotAllowed) ++ return ++ } ++ ++ hijacker, ok := w.(http.Hijacker) ++ if !ok { ++ http.Error(w, "hijacking not supported", http.StatusInternalServerError) ++ return ++ } ++ ++ conn, _, err := hijacker.Hijack() ++ if err != nil { ++ return ++ } ++ fmt.Fprint(conn, "HTTP/1.1 200 Connection Established\r\n\r\n") ++ ++ tlsConn := tls.Server(conn, &tls.Config{Certificates: []tls.Certificate{cert}}) ++ go func() { ++ defer tlsConn.Close() ++ _ = http.Serve(&oneConnListener{conn: tlsConn}, fakeDriveHandler(scenario)) ++ }() ++ })} ++ ++ go server.Serve(ln) ++ return ln, nil ++} ++ ++func fakeDriveHandler(scenario string) http.Handler { ++ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ w.Header().Set("Content-Type", "application/json") ++ path := strings.TrimPrefix(r.URL.Path, "/drive/v3") ++ ++ switch { ++ case r.Method == "GET" && path == "/files/root": ++ writeJSON(w, file("root", "RemoteRoot", dirMime, []string{}, map[string]string{"sync": "true", "syncRoot": "true"}, 0, "")) ++ case r.Method == "GET" && path == "/files": ++ writeJSON(w, map[string]interface{}{"files": remoteFiles(scenario)}) ++ case r.Method == "GET" && path == "/about": ++ writeJSON(w, map[string]interface{}{"storageQuota": map[string]string{"limit": "0", "usage": "0"}}) ++ default: ++ http.Error(w, "unexpected fake drive request: "+r.Method+" "+r.URL.String(), http.StatusNotFound) ++ } ++ }) ++} ++ ++func remoteFiles(scenario string) []*driveFile { ++ files := []*driveFile{ ++ file("remote-build-dir", "build", dirMime, []string{"root"}, nil, 0, ""), ++ file("remote-src-dir", "src", dirMime, []string{"root"}, nil, 0, ""), ++ file("remote-src-main", "main.go", "text/plain", []string{"remote-src-dir"}, nil, 14, md5Hex("package main\n")), ++ file("remote-readme", "README.md", "text/plain", []string{"root"}, nil, 7, md5Hex("remote\n")), ++ } ++ ++ if scenario == "upload_no_ignore" { ++ files = append(files, ++ file("remote-build-app", "app.bin", "application/octet-stream", []string{"remote-build-dir"}, nil, 7, md5Hex("binary\n")), ++ file("remote-debug-log", "debug.log", "text/plain", []string{"root"}, nil, 4, md5Hex("log\n")), ++ ) ++ } ++ ++ return files ++} ++ ++type driveFile struct { ++ Id string `json:"id,omitempty"` ++ Name string `json:"name,omitempty"` ++ MimeType string `json:"mimeType,omitempty"` ++ Parents []string `json:"parents,omitempty"` ++ AppProperties map[string]string `json:"appProperties,omitempty"` ++ Size string `json:"size,omitempty"` ++ Md5Checksum string `json:"md5Checksum,omitempty"` ++ ModifiedTime string `json:"modifiedTime,omitempty"` ++} ++ ++func file(id, name, mime string, parents []string, props map[string]string, size int64, md5sum string) *driveFile { ++ if props == nil { ++ props = map[string]string{"sync": "true", "syncRootId": "root"} ++ } ++ return &driveFile{ ++ Id: id, ++ Name: name, ++ MimeType: mime, ++ Parents: parents, ++ AppProperties: props, ++ Size: fmt.Sprint(size), ++ Md5Checksum: md5sum, ++ ModifiedTime: "2020-01-02T03:04:05.000Z", ++ } ++} ++ ++func md5Hex(s string) string { ++ sum := md5.Sum([]byte(s)) ++ return hex.EncodeToString(sum[:]) ++} ++ ++func writeJSON(w http.ResponseWriter, v interface{}) { ++ if err := json.NewEncoder(w).Encode(v); err != nil { ++ http.Error(w, err.Error(), http.StatusInternalServerError) ++ } ++} ++ ++type oneConnListener struct { ++ conn net.Conn ++ used bool ++} ++ ++func (l *oneConnListener) Accept() (net.Conn, error) { ++ if l.used { ++ select {} ++ } ++ l.used = true ++ return l.conn, nil ++} ++ ++func (l *oneConnListener) Close() error { ++ return nil ++} ++ ++func (l *oneConnListener) Addr() net.Addr { ++ return l.conn.LocalAddr() ++} ++ ++func makeCert() (string, []byte, []byte, error) { ++ caKey, err := rsa.GenerateKey(rand.Reader, 2048) ++ if err != nil { ++ return "", nil, nil, err ++ } ++ caTemplate := &x509.Certificate{ ++ SerialNumber: big.NewInt(1), ++ Subject: pkix.Name{CommonName: "fixture fake drive CA"}, ++ NotBefore: time.Now().Add(-time.Hour), ++ NotAfter: time.Now().Add(time.Hour), ++ KeyUsage: x509.KeyUsageCertSign | x509.KeyUsageDigitalSignature, ++ BasicConstraintsValid: true, ++ IsCA: true, ++ } ++ caDER, err := x509.CreateCertificate(rand.Reader, caTemplate, caTemplate, &caKey.PublicKey, caKey) ++ if err != nil { ++ return "", nil, nil, err ++ } ++ ++ leafKey, err := rsa.GenerateKey(rand.Reader, 2048) ++ if err != nil { ++ return "", nil, nil, err ++ } ++ leafTemplate := &x509.Certificate{ ++ SerialNumber: big.NewInt(2), ++ Subject: pkix.Name{CommonName: "www.googleapis.com"}, ++ DNSNames: []string{"www.googleapis.com"}, ++ NotBefore: time.Now().Add(-time.Hour), ++ NotAfter: time.Now().Add(time.Hour), ++ KeyUsage: x509.KeyUsageDigitalSignature, ++ ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, ++ } ++ leafDER, err := x509.CreateCertificate(rand.Reader, leafTemplate, caTemplate, &leafKey.PublicKey, caKey) ++ if err != nil { ++ return "", nil, nil, err ++ } ++ ++ caPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: caDER}) ++ certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: leafDER}) ++ keyPEM := pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(leafKey)}) ++ ++ certPath := filepath.Join(os.TempDir(), fmt.Sprintf("fixture-fake-drive-ca-%d.pem", os.Getpid())) ++ if err := os.WriteFile(certPath, caPEM, 0600); err != nil { ++ return "", nil, nil, err ++ } ++ ++ return certPath, certPEM, keyPEM, nil ++} +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,104 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++export GO111MODULE=off GOPATH=/root/go GOPROXY=off GOSUMDB=off ++ ++( cd /workspace/repo && go build -o /tmp/gdrive-fixture-coderl . ) \ ++ || { echo "FAIL: build gdrive" >&2; exit 1; } ++ ++mkdir -p /tmp/gdrive-fixture-coderl-harness ++cp /workspace/repo/usercase-test-coderl/fixtures/sync_ignore_harness.go /tmp/gdrive-fixture-coderl-harness/main.go ++( cd /tmp/gdrive-fixture-coderl-harness && go build -o /tmp/sync-ignore-harness-coderl . ) \ ++ || { echo "FAIL: build sync ignore harness" >&2; exit 1; } ++ ++BIN=/tmp/gdrive-fixture-coderl ++HARNESS=/tmp/sync-ignore-harness-coderl ++TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT ++fail() { echo "FAIL: $*" >&2; exit 1; } ++local_count() { ++ sed -n 's/^Found \([0-9][0-9]*\) local files.*/\1/p' "$1" | head -n 1 ++} ++ ++make_tree() { ++ root="$1" ++ mkdir -p "$root/build" "$root/src" "$root/docs" "$root/nested" ++ printf 'binary\n' > "$root/build/app.bin" ++ printf 'log\n' > "$root/debug.log" ++ printf 'package main\n' > "$root/src/main.go" ++ printf 'notes\n' > "$root/docs/notes.txt" ++ printf 'secret\n' > "$root/nested/secret.tmp" ++ printf '*.tmp\n' > "$root/nested/.gdriveignore" ++} ++ ++ ++ ++ ++"$BIN" help sync upload >"$TMP/help.out" 2>"$TMP/help.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F_help exit $ec; want 0" ++ ++grep -q -- '--dry-run' "$TMP/help.out" || fail "F_help stdout missing --dry-run" ++ ++ ++ ++ ++LOCAL="$TMP/upload-no-ignore/local-dir" ++make_tree "$LOCAL" ++"$HARNESS" upload_no_ignore "$BIN" --access-token fake sync upload --dry-run --no-progress "$LOCAL" root >"$TMP/f1.out" 2>"$TMP/f1.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++F1_COUNT=$(local_count "$TMP/f1.out") ++[ -n "$F1_COUNT" ] || fail "F1 missing local count: $(cat "$TMP/f1.out")" ++grep -q 'Uploading nested/secret\.tmp' "$TMP/f1.out" || fail "F1 nested .gdriveignore affected planning" ++ ++ ++ ++ ++LOCAL="$TMP/upload-root-ignore/local-dir" ++make_tree "$LOCAL" ++printf 'build/\n*.log\n' > "$LOCAL/.gdriveignore" ++"$HARNESS" upload_root_ignore "$BIN" --access-token fake sync upload --dry-run --no-progress "$LOCAL" root >"$TMP/f2.out" 2>"$TMP/f2.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++ ++F2_COUNT=$(local_count "$TMP/f2.out") ++[ -n "$F2_COUNT" ] || fail "F2 missing local count: $(cat "$TMP/f2.out")" ++ ++[ "$F2_COUNT" -lt "$F1_COUNT" ] || fail "F2 ignored paths counted as local files" ++! grep -qE 'Uploading .*build/app\.bin|Uploading .*debug\.log|Creating directory .*build|Updating .*build/app\.bin|Updating .*debug\.log' "$TMP/f2.out" \ ++ || fail "F2 ignored path appeared in upload action lines" ++grep -q 'nested/secret.tmp' "$TMP/f2.out" || fail "F2 subdirectory .gdriveignore affected planning" ++ ++ ++ ++ ++LOCAL="$TMP/download-root-ignore/local-dir" ++make_tree "$LOCAL" ++printf 'build/\n*.log\n' > "$LOCAL/.gdriveignore" ++"$HARNESS" download_root_ignore "$BIN" --access-token fake sync download --dry-run --delete-extraneous --keep-remote --no-progress root "$LOCAL" >"$TMP/f3.out" 2>"$TMP/f3.err"; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++ ++F3_COUNT=$(local_count "$TMP/f3.out") ++[ -n "$F3_COUNT" ] || fail "F3 missing local count: $(cat "$TMP/f3.out")" ++ ++[ "$F3_COUNT" -lt "$F1_COUNT" ] || fail "F3 ignored paths counted in download comparison" ++ ++! grep -qE 'Deleting .*build/app\.bin|Deleting .*debug\.log|Conflict detected' "$TMP/f3.out" \ ++ || fail "F3 ignored local path became conflict or extraneous action" ++grep -q 'nested/secret.tmp' "$TMP/f3.out" || fail "F3 subdirectory .gdriveignore affected download planning" ++ ++ ++ ++ ++LOCAL="$TMP/upload-bad-ignore/local-dir" ++make_tree "$LOCAL" ++rm -f "$LOCAL/.gdriveignore" ++mkdir "$LOCAL/.gdriveignore" ++"$HARNESS" upload_root_ignore "$BIN" --access-token fake sync upload --dry-run --no-progress "$LOCAL" root >"$TMP/f4.out" 2>"$TMP/f4.err"; ec=$? ++[ "$ec" -ne 0 ] || fail "F4 exit $ec; want non-zero" ++cat "$TMP/f4.out" "$TMP/f4.err" > "$TMP/f4.combined" ++ ++grep -q '^Failed to prepare ignorer:' "$TMP/f4.combined" || fail "F4 output missing prefix: $(cat "$TMP/f4.combined")" ++ ++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-002305/tests/test.sh b/tasks/format-code-task-002305/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c8ac3d97c5395aaddd19c9c96e9c010db9e00541 --- /dev/null +++ b/tasks/format-code-task-002305/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/sync_ignore_harness.go +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-002305/tests/test_command.sh b/tasks/format-code-task-002305/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002305/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-002333/environment/Dockerfile b/tasks/format-code-task-002333/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eb499fc32aa9356f08c0eb21a781609efae10d0e --- /dev/null +++ b/tasks/format-code-task-002333/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:8ffaae413e0ad66a786a62f660d3d106a28bbdb91709983543f447343536ad9f diff --git a/tasks/format-code-task-002333/environment/setup/files/blocklist b/tasks/format-code-task-002333/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002333/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-002333/environment/setup/setup.sh b/tasks/format-code-task-002333/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002333/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-002333/tests/test.patch b/tasks/format-code-task-002333/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..388a0802eccf14ac53880dfc84ab6d1b70c884eb --- /dev/null +++ b/tasks/format-code-task-002333/tests/test.patch @@ -0,0 +1,363 @@ +diff --git a/usercase-test-coderl/fixtures/make_bad_shm b/usercase-test-coderl/fixtures/make_bad_shm +new file mode 100644 +index 0000000000000000000000000000000000000000..3e9487a505de12b1e86beb49107a9900980c2776 +GIT binary patch +literal 16376 +zcmeHOYiu0V6~4PpzzK=%5YjwolPM6CwDrVJoYV;otQ|WUqXg0l*TVtNQ@Ni?Nk636YXL? +z+*gR@;u4T&NlfWuih)+qsc0pyC%g_g`Ypji75-@j3+CKHezUPi +za*%(U+QFRlUVR!m18MT^@l|L5#N6+PxhXbFwJ2_`%2|N07IG4vBftFF}4m-lg0GbF2et_ghZ<5Y%aEMXx`AK=d=1+*#vBt1{e0J +zZ8zN_Aj||}ltvL9Rx-y!-4&!q`^$H~{q)G0pPo7W-rnWWce`$UF|Yp$ZLrhWX9%SmRzJCW{lQUZfwH{Bq%ZSU#aVy@NK +z>1|$lt-jtXuWJ)#&z>D7RB8_-^NyX{vtvsto3Zy;y(z3NtntyJV~r42ScY<)_!`MS{`%w4y`$p0AS3bjC+Bx~p~8ph +z`;qY&;q@`4XPo6zHz*v(4)!so(>|QXFzU)aT>gHL!&x6bkAnc8_Te}tnYe#o3>>FS +zhsYksQ~#(@bZ>Ygx0Uap^%jd$1I +z0kFIBF1RBndu+4qC1m^Dl`rU(@(%*?GXeR@fc$tsek>qA +z9FX@1Md7@qbe +zoF|uu0W3`(m}nfuS+cS%-wB{mI&O?iyNwUYmN%Rk?#{3BWI?KQq)*|!6-dA +z-6+HZ$1vQnsk#r0=Z(_u%jJtu^TeH#6!8Lx?>uab&2NHMA6*7jy@VgAad7jWVMbS; +z3l+-$QrtONeiBT_+RKZv4P%>6!~ZB=!q3_`xafCaYLt$(PL$sUn@&*#3^1@i +z?6d!&XMYrwvL$bnvrv3zvR`jp@euf9hm)UY>tB0HC+{{&ZyFMm9fPP>n`#}j_Se9ea8+`zV6lNgIK$w9r17QZj41^g7 +zGZ1DV%s`ldPbdQsc*vxtr%l?*yewOeD#9w} +z%DU_D-4`z1%YSoS{GY(+S=T)T{0ZRC0bg~_btix)-gn)dz>)BM98zT8E)gjf`ohIkmf1oZJ3)+@}soBZ7IpT +zFYZc`@zp32zQ#l1{c*e@l=c6(=w?xWm^Qod-nQGQz!l24-*f@ +z{ckewkKDFp%O-8rExm<|Q_x!1!RFDH<_!fYuHC=3O>b$_TUV3fqhexSXNhz8TC;-i +zbBloHQA(^vTI|-<>~V2l4TqPt@Slq&aU!r;cMai!#tDd$I^mA?Jl+Tvw?QESqh(c0 +zA>1G0691Gpew0>-F(_ah9>0u#OWH5;_Ng*ntNkxX`zypXpJmG#UhR2bmiCK9u;2Vf +zx-Inf(Q}m3(te3I{un)DP$HYUI4ra`a?^M +z0Alw7emQ8ysgi36f0699fc-?p(@C3sxJNw?j`6HHkjnO2DKqY5b9vJ$6h&V)J(#i`JFd4> +zx4@0{Nz=;ZtRd6RIJqIwpR>}o884*ML*U|*Ot5q+Oigp^u8tkuX7^29CTxlCy8Wh( +z9X(sX3yy1;-3Domu3f_1w*BVLj_u~nTet4+-ed0R=-l279>G2TF>jMTY{n1l==XHE +zY5${k>dQk0mDYCLax5XA72=|xHu8f|v8!L5OsMoVpw2xS>b60nT)Du5%{o# +zXD)MBaiF47gyr@tJJwKFotX|-7cti38m*5D8of{N-ChOSxK&GG%=CXr!&KdGS +zy@e#49ZJRt>geog#y&316IMPU^!QK)s!-g?Db0O$E{|t9q!|e&=yG<-LI)}hrW~Qm +zmg`W|2eKeyA#e8y-LZ=xVlM~ltn3H6ouGc5h(k1%R1DR@l?RuhDl46YV9FgnZ=u7; +zO2dGuGWI_Xg!5JSYJ=ZWMZt4`JYOZXwB<7LtKq^qBKy}m?}oNWJTFv|5F4Q2_YaQJj^k<{X7q6zKZ;4I{F{&w?L0`aQ5eUI`d&n +zE)cd6i~RgNUrqvsQ!w`Dc|UWW=YxqP3df?j7fLvXW`CYHGuOzH+s}5)_k$kiK>~z?|0!Tz~NSalVHBop2!yV?{ph_s5(C{htC1bHeex-#z;M +zQ`XGel<3`q +z{(l6G-+xe3rp%9co~pq8hvB!N&;S>&FL@o$=Tw9CEHgg`zKuSAUgr-t0|>-+N}7=w +z{}2?|ce#FESMa%GK3`13!i&eB|MTFB&(Hq6&M)Eu3}{p_@6PoyzXY89{vt-EEsAqJ +z9Dw~;o(Il|as66MX_{*IYfA0i7f}6V?&0iDY4mVxE0Ujc-%%QMk5RyO>M)-H7?%v( +me*7*$!gVmWT>^9~QpXz)1m}9$c0mpQC0|q)%K{DoQT!Wu>Qd ++#include ++#include ++#include ++#include ++#include ++ ++int main(int argc, char **argv) { ++ key_t key; ++ int old_id; ++ int id; ++ void *ptr; ++ ++ if (argc != 2) { ++ fprintf(stderr, "usage: make_bad_shm \n"); ++ return 2; ++ } ++ ++ key = (key_t) strtol(argv[1], NULL, 10); ++ old_id = shmget(key, 0, 0); ++ if (old_id >= 0) ++ shmctl(old_id, IPC_RMID, NULL); ++ ++ id = shmget(key, 4096, IPC_CREAT | IPC_EXCL | 0600); ++ if (id < 0) { ++ fprintf(stderr, "shmget: %s\n", strerror(errno)); ++ return 1; ++ } ++ ++ ptr = shmat(id, NULL, 0); ++ if (ptr == (void *) -1) { ++ fprintf(stderr, "shmat: %s\n", strerror(errno)); ++ shmctl(id, IPC_RMID, NULL); ++ return 1; ++ } ++ ++ memset(ptr, 0xa5, 4096); ++ shmdt(ptr); ++ return 0; ++} +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,227 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++ ++( cd /workspace/repo && ./compile.sh ) \ ++ || { echo "FAIL: build wgdb" >&2; exit 1; } ++cc -O2 -Wall \ ++ -o /workspace/repo/usercase-test-coderl/fixtures/make_bad_shm \ ++ /workspace/repo/usercase-test-coderl/fixtures/make_bad_shm.c \ ++ || { echo "FAIL: build make_bad_shm fixture" >&2; exit 1; } ++ ++BIN=/workspace/repo/Main/wgdb ++BAD_SHM=/workspace/repo/usercase-test-coderl/fixtures/make_bad_shm ++ ++TMP=$(mktemp -d) ++BASE=$((330000 + ($$ % 10000) * 10)) ++KEYS="" ++trap 'for key in $KEYS; do "$BIN" "$key" free >/dev/null 2>/dev/null || true; ipcrm -M "$key" >/dev/null 2>/dev/null || true; done; "$BIN" free >/dev/null 2>/dev/null || true; rm -rf "$TMP"' EXIT ++cd "$TMP" || exit 1 ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++add_key() { KEYS="$KEYS $1"; "$BIN" "$1" free >/dev/null 2>/dev/null || true; ipcrm -M "$1" >/dev/null 2>/dev/null || true; } ++ ++expect_file() { ++ local label=$1 file=$2 expected=$3 ++ ++ printf '%s\n' "$expected" | cmp -s - "$file" \ ++ || fail "$label: got [$(cat "$file")], want [$expected]" ++} ++ ++expect_empty() { ++ local label=$1 file=$2 ++ [ ! -s "$file" ] || fail "$label: got [$(cat "$file")]" ++} ++ ++expect_help_entry() { ++ local label=$1 command=$2 token_regex=$3 ++ ++ awk -v command="$command" -v token_regex="$token_regex" ' ++ BEGIN { found = 0 } ++ { ++ lower = tolower($0) ++ if (index(lower, command) && lower ~ token_regex && $0 ~ / - .+/) ++ found = 1 ++ } ++ END { exit(found ? 0 : 1) } ++ ' out || fail "$label" ++} ++ ++expect_index_table_shape() { ++ local label=$1 file=$2 expected_count=$3 header count ++ ++ IFS= read -r header <"$file" || fail "$label missing header" ++ [ "$header" = $'col\ttype\tmulti\tid\tmask' ] \ ++ || fail "$label header: got [$header]" ++ count=$(awk 'BEGIN { FS = "\t" } NR > 1 { c++ } END { print c + 0 }' "$file") ++ [ "$count" -eq "$expected_count" ] \ ++ || fail "$label row count: got $count, want $expected_count; output: $(cat "$file")" ++ awk ' ++ BEGIN { FS = "\t" } ++ NR == 1 { next } ++ NF != 5 || $1 !~ /^[0-9]+$/ || $2 !~ /^(T|TJ|#|#J)$/ || ++ $3 !~ /^[0-9]+$/ || $4 !~ /^[0-9]+$/ || $5 !~ /^[-N]$/ { exit 1 } ++ ' "$file" || fail "$label row shape: $(cat "$file")" ++} ++ ++expect_index_entry() { ++ local label=$1 file=$2 col=$3 type=$4 multi=$5 id ++ id=$(awk -v col="$col" -v type="$type" -v multi="$multi" ' ++ BEGIN { FS = "\t"; matches = 0; id = "" } ++ NR > 1 && $1 == col && $2 == type && $3 == multi { ++ matches++ ++ id = $4 ++ } ++ END { ++ if (matches == 1) ++ print id ++ else ++ exit 1 ++ } ++ ' "$file") || fail "$label missing unique row col=$col type=$type multi=$multi; output: $(cat "$file")" ++ printf '%s' "$id" ++} ++ ++ ++ ++ ++"$BIN" help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++expect_help_entry "F1 missing createindex help" "createindex" "" ++expect_help_entry "F1 missing createhash help" "createhash" "column" ++expect_help_entry "F1 missing dropindex help" "dropindex" "id" ++expect_help_entry "F1 missing listindex help" "listindex" "." ++expect_empty "F1 stderr" err ++ ++ ++ ++ ++"$BIN" free >/dev/null 2>/dev/null || true ++"$BIN" listindex >out 2>err; ec=$? ++EXPECTED=$'No indexes in the database.' ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++expect_file "F2 stdout" out "$EXPECTED" ++expect_empty "F2 stderr" err ++"$BIN" free >/dev/null 2>/dev/null || true ++ ++ ++ ++ ++KEY=$((BASE + 1)); add_key "$KEY" ++"$BIN" "$KEY" createindex 0 >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 createindex exit $ec; want 0" ++expect_empty "F3 createindex stdout" out ++"$BIN" "$KEY" listindex >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 listindex exit $ec; want 0" ++ ++expect_index_table_shape "F3 listindex stdout" out 1 ++IDX=$(expect_index_entry "F3 listindex stdout" out 0 T 1) ++[ "$IDX" -gt 0 ] || fail "F3 index id should be positive decimal, got $IDX" ++expect_empty "F3 listindex stderr" err ++ ++ ++ ++ ++KEY=$((BASE + 2)); add_key "$KEY" ++"$BIN" "$KEY" createhash 9 >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 createhash exit $ec; want 0" ++expect_empty "F4 createhash stdout" out ++"$BIN" "$KEY" listindex >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 listindex exit $ec; want 0" ++ ++expect_index_table_shape "F4 listindex stdout" out 1 ++IDX=$(expect_index_entry "F4 listindex stdout" out 9 '#J' 1) ++[ "$IDX" -gt 0 ] || fail "F4 index id should be positive decimal, got $IDX" ++expect_empty "F4 listindex stderr" err ++ ++ ++ ++ ++KEY=$((BASE + 3)); add_key "$KEY" ++"$BIN" "$KEY" createhash 0 2 5 >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F5 createhash exit $ec; want 0" ++expect_empty "F5 createhash stdout" out ++"$BIN" "$KEY" listindex >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F5 listindex exit $ec; want 0" ++ ++expect_index_table_shape "F5 listindex stdout" out 3 ++IDX0=$(expect_index_entry "F5 listindex stdout" out 0 '#J' 3) ++IDX2=$(expect_index_entry "F5 listindex stdout" out 2 '#J' 3) ++IDX5=$(expect_index_entry "F5 listindex stdout" out 5 '#J' 3) ++[ "$IDX0" = "$IDX2" ] && [ "$IDX0" = "$IDX5" ] \ ++ || fail "F5 multi-column hash entries should share one index id: $IDX0 $IDX2 $IDX5" ++expect_empty "F5 listindex stderr" err ++ ++ ++ ++ ++KEY=$((BASE + 4)); add_key "$KEY" ++"$BIN" "$KEY" createindex 7 >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F6 createindex exit $ec; want 0" ++expect_empty "F6 createindex stdout" out ++"$BIN" "$KEY" createhash 4 8 >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F6 createhash exit $ec; want 0" ++expect_empty "F6 createhash stdout" out ++"$BIN" "$KEY" listindex >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F6 listindex exit $ec; want 0" ++ ++expect_index_table_shape "F6 stdout" out 3 ++IDX_HASH_4=$(expect_index_entry "F6 stdout" out 4 '#J' 2) ++IDX_T=$(expect_index_entry "F6 stdout" out 7 T 1) ++IDX_HASH_8=$(expect_index_entry "F6 stdout" out 8 '#J' 2) ++[ "$IDX_HASH_4" = "$IDX_HASH_8" ] \ ++ || fail "F6 hash entries should share one index id: $IDX_HASH_4 $IDX_HASH_8" ++[ "$IDX_T" != "$IDX_HASH_4" ] \ ++ || fail "F6 T-tree and hash indexes should have distinct ids: $IDX_T" ++expect_empty "F6 stderr" err ++ ++ ++ ++ ++KEY=$((BASE + 5)); add_key "$KEY" ++"$BIN" "$KEY" createindex 2 >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F7 createindex exit $ec; want 0" ++expect_empty "F7 createindex stdout" out ++ ++"$BIN" "$KEY" listindex >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F7 pre-drop listindex exit $ec; want 0" ++expect_index_table_shape "F7 pre-drop listindex stdout" out 1 ++IDX=$(expect_index_entry "F7 pre-drop listindex stdout" out 2 T 1) ++expect_empty "F7 pre-drop listindex stderr" err ++"$BIN" "$KEY" dropindex "$IDX" >out 2>err; ec=$? ++EXPECTED=$'Index dropped.' ++[ "$ec" -eq 0 ] || fail "F7 dropindex exit $ec; want 0" ++expect_file "F7 stdout" out "$EXPECTED" ++expect_empty "F7 stderr" err ++"$BIN" "$KEY" listindex >out 2>err; ec=$? ++EXPECTED=$'No indexes in the database.' ++[ "$ec" -eq 0 ] || fail "F7 listindex exit $ec; want 0" ++expect_file "F7 listindex stdout" out "$EXPECTED" ++expect_empty "F7 listindex stderr" err ++ ++ ++ ++ ++KEY=$((BASE + 6)); add_key "$KEY" ++"$BIN" "$KEY" dropindex 12345 >out 2>err; ec=$? ++ ++expect_empty "F8 stdout" out ++ ++grep -Fqx 'Failed to drop index.' err || fail "F8 stderr missing required line: $(cat err)" ++ ++ ++ ++ ++KEY=$((BASE + 7)); add_key "$KEY" ++"$BAD_SHM" "$KEY" >helper.out 2>helper.err || fail "F9 make_bad_shm: $(cat helper.err)" ++"$BIN" "$KEY" listindex >out 2>err; ec=$? ++[ "$ec" -eq 1 ] || fail "F9 listindex exit $ec; want 1" ++expect_empty "F9 stdout" out ++ ++grep -Fqx 'Failed to attach to database.' err || fail "F9 stderr missing required line: $(cat err)" ++ipcrm -M "$KEY" >/dev/null 2>/dev/null || true ++ ++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-002333/tests/test.sh b/tasks/format-code-task-002333/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..028384dcf63ccc9baee693c6b7e683de90191500 --- /dev/null +++ b/tasks/format-code-task-002333/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/make_bad_shm +usercase-test-coderl/fixtures/make_bad_shm.c +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-002333/tests/test_command.sh b/tasks/format-code-task-002333/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002333/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-002334/environment/Dockerfile b/tasks/format-code-task-002334/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6f8c4b8cef9e27ca08b399e1236d9abeee214b8e --- /dev/null +++ b/tasks/format-code-task-002334/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:76e94f2a74c7e3c82f16a2033925f94ecfe0bcbebb93e8cd3f6796e1f04f3d3a diff --git a/tasks/format-code-task-002334/environment/setup/files/blocklist b/tasks/format-code-task-002334/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002334/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-002334/environment/setup/setup.sh b/tasks/format-code-task-002334/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002334/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-002334/tests/test.patch b/tasks/format-code-task-002334/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..20a68fe5bdc704d997fa157e42b030d449e25c1d --- /dev/null +++ b/tasks/format-code-task-002334/tests/test.patch @@ -0,0 +1,128 @@ +diff --git a/packages/react/src/SegmentedControl/SegmentedControl.test.tsx b/packages/react/src/SegmentedControl/SegmentedControl.test.tsx +index d389f17f76a..f7e4746e2ce 100644 +--- a/packages/react/src/SegmentedControl/SegmentedControl.test.tsx ++++ b/packages/react/src/SegmentedControl/SegmentedControl.test.tsx +@@ -9,11 +9,30 @@ import theme from '../theme' + import {BaseStyles, ThemeProvider} from '..' + import {act} from 'react-test-renderer' + import {viewportRanges} from '../hooks/useResponsiveValue' ++import {FeatureFlags} from '../FeatureFlags' + + const segmentData = [ +- {label: 'Preview', id: 'preview', iconLabel: 'EyeIcon', icon: () => }, +- {label: 'Raw', id: 'raw', iconLabel: 'FileCodeIcon', icon: () => }, +- {label: 'Blame', id: 'blame', iconLabel: 'PeopleIcon', icon: () => }, ++ { ++ label: 'Preview', ++ description: 'This preview does blah.', ++ id: 'preview', ++ iconLabel: 'EyeIcon', ++ icon: () => , ++ }, ++ { ++ label: 'Raw', ++ description: 'This shows the raw content.', ++ id: 'raw', ++ iconLabel: 'FileCodeIcon', ++ icon: () => , ++ }, ++ { ++ label: 'Blame', ++ description: 'This shows the blame.', ++ id: 'blame', ++ iconLabel: 'PeopleIcon', ++ icon: () => , ++ }, + ] + + let matchMedia: MatchMediaMock +@@ -164,6 +183,68 @@ describe('SegmentedControl', () => { + } + }) + ++ it('renders icon button with tooltip as label when feature flag is enabled', () => { ++ const {getByRole, getByText} = render( ++ ++ ++ {segmentData.map(({label, icon}) => ( ++ ++ ))} ++ ++ , ++ ) ++ ++ for (const datum of segmentData) { ++ const labelledButton = getByRole('button', {name: datum.label}) ++ const tooltipElement = getByText(datum.label) ++ expect(labelledButton).toHaveAttribute('aria-labelledby', tooltipElement.id) ++ expect(labelledButton).not.toHaveAttribute('aria-label') ++ } ++ }) ++ ++ it('renders icon button with tooltip description when feature flag is enabled', () => { ++ const {getByRole, getByText} = render( ++ ++ ++ {segmentData.map(({label, icon, description}) => ( ++ ++ ))} ++ ++ , ++ ) ++ ++ for (const datum of segmentData) { ++ const labelledButton = getByRole('button', {name: datum.label}) ++ const tooltipElement = getByText(datum.description) ++ expect(labelledButton).toHaveAttribute('aria-describedby', tooltipElement.id) ++ expect(labelledButton).toHaveAccessibleName(datum.label) ++ expect(labelledButton).toHaveAttribute('aria-label', datum.label) ++ } ++ }) ++ ++ it('renders icon button with aria-label and no tooltip', () => { ++ const {getByRole} = render( ++ ++ {segmentData.map(({label, icon}) => ( ++ ++ ))} ++ , ++ ) ++ ++ for (const datum of segmentData) { ++ const labelledButton = getByRole('button', {name: datum.label}) ++ expect(labelledButton).toHaveAttribute('aria-label', datum.label) ++ } ++ }) ++ + it('calls onChange with index of clicked segment button', async () => { + const user = userEvent.setup() + const handleChange = jest.fn() +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+3RTQ7CIBAF4K49BReQQi3tATyCBzAIWP8KDaDx+GJN1GjUjcYY37eBMJPMkEdn ++2+VGT43d5dmnsKQWoj+T27O/c1GwohJVyVMf5xWrMyI+ttGVbYjSE5J55+Kzvlf1H0Uv+UcT4lS5 ++tpVW07B434xX+fO6OOc/KtM7L6uCZYS9b4XH/jx/pUkf/Mzoge32ZJXuZDhUzs6XDemkWsvGhNwb ++qWJ+LNJTia7CbTV4lU9M0xobjR47G73b3D3Q4zAaw37w7Z8DAAAAAAAAAAAAAAAAAAAAAPy+AxvU ++7yIAKAAA +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-002334/tests/test.sh b/tasks/format-code-task-002334/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..862483fd94a2275c74b61a5932bc6d5ee4da6f1f --- /dev/null +++ b/tasks/format-code-task-002334/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/react/src/SegmentedControl/SegmentedControl.test.tsx +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-002334/tests/test_command.sh b/tasks/format-code-task-002334/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002334/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-002367/environment/Dockerfile b/tasks/format-code-task-002367/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8047cde1a06164084193f0928f8c23f118af57a6 --- /dev/null +++ b/tasks/format-code-task-002367/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:d6113c45ed053b18f1e2f090456831defdb36c0280e36e952072165c01462dc3 diff --git a/tasks/format-code-task-002367/environment/setup/files/blocklist b/tasks/format-code-task-002367/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002367/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-002367/environment/setup/setup.sh b/tasks/format-code-task-002367/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002367/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-002367/tests/test.patch b/tasks/format-code-task-002367/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..460284f7678b5d6987194040d9716532342d17ad --- /dev/null +++ b/tasks/format-code-task-002367/tests/test.patch @@ -0,0 +1,151 @@ +diff --git a/tests/test_merge_writer_over.py b/tests/test_merge_writer_over.py +new file mode 100644 +index 00000000..82c8f15e +--- /dev/null ++++ b/tests/test_merge_writer_over.py +@@ -0,0 +1,118 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++from io import BytesIO ++from pathlib import Path ++ ++import pytest ++ ++from pypdf import PdfReader, PdfWriter, Transformation ++ ++TESTS_ROOT = Path(__file__).parent.resolve() ++PROJECT_ROOT = TESTS_ROOT.parent ++RESOURCE_ROOT = PROJECT_ROOT / "resources" ++ ++ ++BASE_PDF = RESOURCE_ROOT / "crazyones.pdf" ++ ++OVERLAY_PDF = RESOURCE_ROOT / "AutoCad_Simple.pdf" ++ ++BASE_MARKER = "Crazy" ++OVERLAY_MARKER = "EXAMPLE" ++ ++ ++def _write_read_text(writer: PdfWriter) -> str: ++ ++ buf = BytesIO() ++ writer.write(buf) ++ buf.seek(0) ++ return PdfReader(buf).pages[0].extract_text() ++ ++ ++def test_merge_into_writer_blank_page_keeps_content(): ++ ++ ++ reader = PdfReader(BASE_PDF) ++ src = reader.pages[0] ++ ++ writer = PdfWriter() ++ page = writer.add_blank_page(src.mediabox.width, src.mediabox.height) ++ page.merge_page(src) ++ ++ text = _write_read_text(writer) ++ assert BASE_MARKER in text ++ ++ ++def test_merge_transformed_page_is_not_deprecated(): ++ ++ ++ base = PdfReader(BASE_PDF).pages[0] ++ overlay = PdfReader(OVERLAY_PDF).pages[0] ++ ++ writer = PdfWriter() ++ page = writer.add_page(base) ++ ++ page.merge_transformed_page(overlay, Transformation()) ++ ++ text = _write_read_text(writer) ++ assert BASE_MARKER in text ++ assert OVERLAY_MARKER in text ++ ++ ++def test_merge_transformed_page_over_true_default(): ++ ++ ++ base = PdfReader(BASE_PDF).pages[0] ++ overlay = PdfReader(OVERLAY_PDF).pages[0] ++ ++ writer = PdfWriter() ++ page = writer.add_page(base) ++ page.merge_transformed_page(overlay, Transformation()) ++ ++ text = _write_read_text(writer) ++ assert text.index(BASE_MARKER) < text.index(OVERLAY_MARKER) ++ ++ ++def test_merge_transformed_page_over_false_places_under(): ++ ++ ++ base = PdfReader(BASE_PDF).pages[0] ++ overlay = PdfReader(OVERLAY_PDF).pages[0] ++ ++ writer = PdfWriter() ++ page = writer.add_page(base) ++ page.merge_transformed_page(overlay, Transformation(), over=False) ++ ++ text = _write_read_text(writer) ++ assert text.index(OVERLAY_MARKER) < text.index(BASE_MARKER) ++ ++ ++def test_over_parameter_flips_layer_order(): ++ ++ ++ base = PdfReader(BASE_PDF).pages[0] ++ overlay = PdfReader(OVERLAY_PDF).pages[0] ++ ++ w_over = PdfWriter() ++ p_over = w_over.add_page(base) ++ p_over.merge_transformed_page(overlay, Transformation(), over=True) ++ t_over = _write_read_text(w_over) ++ ++ w_under = PdfWriter() ++ p_under = w_under.add_page(base) ++ p_under.merge_transformed_page(overlay, Transformation(), over=False) ++ t_under = _write_read_text(w_under) ++ ++ ++ for t in (t_over, t_under): ++ assert BASE_MARKER in t ++ assert OVERLAY_MARKER in t ++ ++ ++ assert t_over.index(BASE_MARKER) < t_over.index(OVERLAY_MARKER) ++ assert t_under.index(OVERLAY_MARKER) < t_under.index(BASE_MARKER) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,22 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++python -m pytest -p no:cacheprovider -q \ ++ "tests/test_page.py::test_transformation_equivalence" \ ++ "tests/test_page.py::test_merge_page_reproducible_with_proc_set" \ ++ "tests/test_page.py::test_merge_page_resources_smoke_test" \ ++ "tests/test_writer.py::test_writer_clone" \ ++ "tests/test_writer.py::test_pdf_header" \ ++ "tests/test_writer.py::test_write_dict_stream_object" ++ ++ ++python -m pytest -p no:cacheprovider -q tests/test_merge_writer_over.py diff --git a/tasks/format-code-task-002367/tests/test.sh b/tasks/format-code-task-002367/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0d388cf686f4e082e19fd670db4565827e0815c2 --- /dev/null +++ b/tasks/format-code-task-002367/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_merge_writer_over.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-002367/tests/test_command.sh b/tasks/format-code-task-002367/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002367/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-002393/environment/Dockerfile b/tasks/format-code-task-002393/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5dac2791b3618f04e69da3489dc4beb31d81032a --- /dev/null +++ b/tasks/format-code-task-002393/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:d0c1ec9d738a55a467363fabcb4b74dd1dccbc7592d1abb04f391cf99979f8b7 diff --git a/tasks/format-code-task-002393/environment/setup/files/blocklist b/tasks/format-code-task-002393/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002393/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-002393/environment/setup/setup.sh b/tasks/format-code-task-002393/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002393/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-002393/tests/test.patch b/tasks/format-code-task-002393/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ce9b9a6f592b83b302fb2f2af824c95348ae2bd7 --- /dev/null +++ b/tasks/format-code-task-002393/tests/test.patch @@ -0,0 +1,157 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..d6f0605 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest tests/cli/test_convert.py -k convert_pkg_info -v"] ++} +diff --git a/tests/cli/test_convert.py b/tests/cli/test_convert.py +index 62884c2..6381045 100644 +--- a/tests/cli/test_convert.py ++++ b/tests/cli/test_convert.py +@@ -10,7 +10,9 @@ from _pytest.fixtures import SubRequest + from pytest import CaptureFixture, TempPathFactory + + import wheel +-from wheel.cli.convert import convert, egg_filename_re ++from email.message import Message ++ ++from wheel.cli.convert import convert, convert_pkg_info, egg_filename_re + from wheel.wheelfile import WheelFile + + PKG_INFO = """\ +@@ -262,3 +264,119 @@ def test_convert_bdist_wininst( + assert wf.read("sampledist-1.0.0.dist-info/entry_points.txt") == b"" + + assert capsys.readouterr().out == f"{bdist_wininst_path}...OK\n" ++ ++ ++def test_convert_pkg_info_empty_description_does_not_raise() -> None: ++ """Empty Description field must not raise IndexError (the reported bug).""" ++ metadata = Message() ++ pkginfo = "Metadata-Version: 2.1\nName: test\nVersion: 1.0\nDescription:\n" ++ convert_pkg_info(pkginfo, metadata) ++ ++ ++def test_convert_pkg_info_empty_description_issue_repro() -> None: ++ """Exact reproduction style from the bug report: description with no body.""" ++ from email.parser import Parser ++ ++ parsed = Parser().parsestr("description:\n") ++ assert parsed["description"] == "" ++ ++ metadata = Message() ++ ++ convert_pkg_info("Metadata-Version: 2.1\ndescription:\n", metadata) ++ ++ ++def test_convert_pkg_info_empty_description_payload() -> None: ++ """When description is empty, payload must be empty/blank. ++ ++ Any of None, "", or "\\n" is acceptable — these all serialize to an ++ equivalent METADATA file. What is NOT acceptable is junk content ++ (e.g. a stray "Description" written into the payload body). ++ """ ++ metadata = Message() ++ pkginfo = "Metadata-Version: 2.1\nName: test\nVersion: 1.0\nDescription:\n" ++ convert_pkg_info(pkginfo, metadata) ++ payload = metadata.get_payload() ++ assert payload in (None, "", "\n") ++ ++ ++def test_convert_pkg_info_empty_description_not_added_as_header() -> None: ++ """Empty description must not be added as a 'Description' header. ++ ++ The description belongs in the payload (body), never as a header. ++ """ ++ metadata = Message() ++ pkginfo = "Metadata-Version: 2.1\nName: test\nVersion: 1.0\nDescription:\n" ++ convert_pkg_info(pkginfo, metadata) ++ assert metadata.get("Description") is None ++ assert metadata.get("description") is None ++ ++ ++def test_convert_pkg_info_empty_description_preserves_other_headers() -> None: ++ """Empty description must not prevent processing of other headers.""" ++ metadata = Message() ++ pkginfo = ( ++ "Metadata-Version: 2.1\n" ++ "Name: testpkg\n" ++ "Version: 9.8.7\n" ++ "Author: Somebody\n" ++ "Description:\n" ++ ) ++ convert_pkg_info(pkginfo, metadata) ++ assert metadata.get("Name") == "testpkg" ++ assert metadata.get("Version") == "9.8.7" ++ assert metadata.get("Author") == "Somebody" ++ assert metadata.get("Metadata-Version") == "2.4" ++ ++ ++def test_convert_pkg_info_empty_non_description_header_preserved() -> None: ++ """A non-description header with an empty value must still be added. ++ ++ The fix is scoped to the description handling; it must not strip ++ other empty-valued headers. ++ """ ++ metadata = Message() ++ pkginfo = ( ++ "Metadata-Version: 2.1\n" ++ "Name: test\n" ++ "Version: 1.0\n" ++ "Author:\n" ++ "Description: Hello\n" ++ ) ++ convert_pkg_info(pkginfo, metadata) ++ ++ assert metadata.get("Author") is not None ++ ++ ++def test_convert_pkg_info_non_empty_description_preserved() -> None: ++ """Non-empty descriptions still produce the expected dedented payload.""" ++ metadata = Message() ++ pkginfo = ( ++ "Metadata-Version: 2.1\n" ++ "Name: test\n" ++ "Version: 1.0\n" ++ "Description: First line\n" ++ " Second line\n" ++ " Third line\n" ++ ) ++ convert_pkg_info(pkginfo, metadata) ++ payload = metadata.get_payload() ++ assert payload is not None ++ assert "First line" in payload ++ assert "Second line" in payload ++ assert "Third line" in payload ++ ++ assert "\n Second line" not in payload ++ ++ ++def test_convert_pkg_info_unknown_value_still_skipped() -> None: ++ """The pre-existing UNKNOWN-skip behavior must be preserved.""" ++ metadata = Message() ++ pkginfo = ( ++ "Metadata-Version: 2.1\n" ++ "Name: test\n" ++ "Version: 1.0\n" ++ "Author: UNKNOWN\n" ++ "Description:\n" ++ ) ++ convert_pkg_info(pkginfo, metadata) ++ assert metadata.get("Author") is None +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest -v -rA tests/cli/test_convert.py::test_convert_pkg_info_empty_description_does_not_raise tests/cli/test_convert.py::test_convert_pkg_info_empty_description_issue_repro tests/cli/test_convert.py::test_convert_pkg_info_empty_description_payload tests/cli/test_convert.py::test_convert_pkg_info_empty_description_not_added_as_header tests/cli/test_convert.py::test_convert_pkg_info_empty_description_preserves_other_headers tests/cli/test_convert.py::test_convert_pkg_info_empty_non_description_header_preserved tests/cli/test_convert.py::test_convert_pkg_info_non_empty_description_preserved tests/cli/test_convert.py::test_convert_pkg_info_unknown_value_still_skipped ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002393/tests/test.sh b/tasks/format-code-task-002393/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7bc8c18b51f70351b58af379d482f77e2c27a985 --- /dev/null +++ b/tasks/format-code-task-002393/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/cli/test_convert.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-002393/tests/test_command.sh b/tasks/format-code-task-002393/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002393/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-002421/environment/Dockerfile b/tasks/format-code-task-002421/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5bf28e15f7a1008d0744e542644e60953b4ec789 --- /dev/null +++ b/tasks/format-code-task-002421/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:9d36493dd377b6170bdf9e380054e344a9f13e4d8559f42ce6e57868feb50ac7 diff --git a/tasks/format-code-task-002421/environment/setup/files/blocklist b/tasks/format-code-task-002421/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002421/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-002421/environment/setup/setup.sh b/tasks/format-code-task-002421/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002421/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-002421/tests/test.patch b/tasks/format-code-task-002421/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e27090e06c2d0d5e2ae3e1011e06c838d683a0ce --- /dev/null +++ b/tasks/format-code-task-002421/tests/test.patch @@ -0,0 +1,190 @@ +diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py +index 51dd66bea0c..762f656b112 100644 +--- a/Lib/test/test_enum.py ++++ b/Lib/test/test_enum.py +@@ -2962,34 +2962,40 @@ def test_bool(self): + self.assertEqual(bool(f.value), bool(f)) + + def test_boundary(self): +- self.assertIs(enum.Flag._boundary_, CONFORM) +- class Iron(Flag, boundary=STRICT): ++ class DefaultFlag(Flag): + ONE = 1 + TWO = 2 + EIGHT = 8 +- self.assertIs(Iron._boundary_, STRICT) ++ with self.assertRaises(ValueError): ++ DefaultFlag(7) ++ with self.assertRaises(ValueError): ++ DefaultFlag(16) + # +- class Water(Flag, boundary=CONFORM): ++ class Iron(Flag, boundary=CONFORM): ++ ONE = 1 ++ TWO = 2 ++ EIGHT = 8 ++ ++ class Water(Flag, boundary=STRICT): + ONE = 1 + TWO = 2 + EIGHT = 8 +- self.assertIs(Water._boundary_, CONFORM) + # + class Space(Flag, boundary=EJECT): + ONE = 1 + TWO = 2 + EIGHT = 8 +- self.assertIs(Space._boundary_, EJECT) + # + class Bizarre(Flag, boundary=KEEP): + b = 3 + c = 4 + d = 6 + # +- self.assertRaisesRegex(ValueError, 'invalid value 7', Iron, 7) ++ with self.assertRaises(ValueError): ++ Water(7) + # +- self.assertIs(Water(7), Water.ONE|Water.TWO) +- self.assertIs(Water(~9), Water.TWO) ++ self.assertIs(Iron(7), Iron.ONE|Iron.TWO) ++ self.assertIs(Iron(~9), Iron.TWO) + # + self.assertEqual(Space(7), 7) + self.assertTrue(type(Space(7)) is int) +@@ -2997,6 +3003,98 @@ class Bizarre(Flag, boundary=KEEP): + self.assertEqual(list(Bizarre), [Bizarre.c]) + self.assertIs(Bizarre(3), Bizarre.b) + self.assertIs(Bizarre(6), Bizarre.d) ++ ++ class CompositeFlag(enum.Flag): ++ A = 1 ++ B = 2 ++ C = 4 | B ++ combo = CompositeFlag.A | CompositeFlag.C ++ self.assertEqual(combo.value, 7) ++ self.assertTrue(CompositeFlag.C in combo) ++ with self.assertRaises(ValueError): ++ CompositeFlag(15) ++ ++ class CompositeIntFlag(enum.IntFlag): ++ A = 1 ++ B = 2 ++ C = 4 | B ++ self.assertTrue(CompositeIntFlag.C in (CompositeIntFlag.A|CompositeIntFlag.C)) ++ self.assertEqual(CompositeIntFlag(15).value, 15) ++ ++ def test_flag_default_boundary_rejects_unknown_bits(self): ++ class Color(Flag): ++ RED = 1 ++ BLUE = 2 ++ with self.assertRaises(ValueError): ++ Color(4) ++ with self.assertRaises(ValueError): ++ Color(5) ++ ++ class Sparse(Flag): ++ A = 1 ++ C = 4 ++ with self.assertRaises(ValueError): ++ Sparse(2) ++ with self.assertRaises(ValueError): ++ Sparse(8) ++ ++ class ConformingColor(Flag, boundary=CONFORM): ++ RED = 1 ++ BLUE = 2 ++ self.assertEqual(ConformingColor(4).value, 0) ++ self.assertIs(ConformingColor(5), ConformingColor.RED) ++ ++ def test_named_multi_bit_alias_is_used_for_exact_results(self): ++ class Perm(Flag): ++ R = 1 ++ W = 2 ++ X = 4 ++ RW = R | W ++ RWX = R | W | X ++ self.assertIs(Perm.R | Perm.W, Perm.RW) ++ self.assertIs(Perm.R | Perm.W | Perm.X, Perm.RWX) ++ self.assertIs(Perm(3), Perm.RW) ++ self.assertIs(Perm(7), Perm.RWX) ++ ++ def test_named_multi_bit_aliases_participate_in_combinations(self): ++ class CompositeFlag(Flag): ++ A = 1 ++ B = 2 ++ C = 4 | B ++ combo = CompositeFlag.A | CompositeFlag.C ++ self.assertEqual(combo.value, 7) ++ self.assertTrue(CompositeFlag.A in combo) ++ self.assertTrue(CompositeFlag.C in combo) ++ with self.assertRaises(ValueError): ++ CompositeFlag(15) ++ ++ class MethodHint(Flag): ++ HIDDEN = 0x10 ++ DIGITS = 0x01 ++ LETTERS = 0x02 ++ MASK = 0x0f ++ hint = MethodHint.HIDDEN | MethodHint.MASK ++ self.assertEqual(hint.value, 0x1f) ++ self.assertTrue(MethodHint.HIDDEN in hint) ++ self.assertTrue(MethodHint.MASK in hint) ++ ++ def test_flag_boundary_documentation_defaults(self): ++ enum_doc = os.path.join( ++ os.path.dirname(__file__), ++ '..', '..', 'Doc', 'library', 'enum.rst', ++ ) ++ with open(enum_doc, encoding='utf-8') as f: ++ text = f.read() ++ strict_start = text.index('.. attribute:: STRICT') ++ conform_start = text.index('.. attribute:: CONFORM') ++ eject_start = text.index('.. attribute:: EJECT') ++ strict_section = text[strict_start:conform_start].lower() ++ conform_section = text[conform_start:eject_start].lower() ++ self.assertIn('flag', strict_section) ++ self.assertIn('default', strict_section) ++ self.assertIn('out-of-range', conform_section) ++ self.assertFalse('default' in conform_section and 'flag' in conform_section) ++ self.assertIs(enum.Flag._boundary_, STRICT) + + def test_iter(self): + Color = self.Color +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,32 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++set -euo pipefail ++if [ ! -x ./python ] || [ ! -f pybuilddir.txt ]; then ++ if [ ! -f Makefile ]; then ++ ./configure --without-ensurepip ++ fi ++ make -j2 ++fi ++set +e ++ ++ ++case "${1:-}" in ++ base) ++ ./python -m test test_enum -v --match 'test_or' ++ ;; ++ new) ++ ./python -m test test_enum -v \ ++ --match 'test_boundary' \ ++ --match 'test_flag_default_boundary_rejects_unknown_bits' \ ++ --match 'test_named_multi_bit_alias_is_used_for_exact_results' \ ++ --match 'test_named_multi_bit_aliases_participate_in_combinations' \ ++ --match 'test_flag_boundary_documentation_defaults' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002421/tests/test.sh b/tasks/format-code-task-002421/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4ce5deddc6d5f82abbc5f7f87e8bbaf18a1023bf --- /dev/null +++ b/tasks/format-code-task-002421/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' +Lib/test/test_enum.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-002421/tests/test_command.sh b/tasks/format-code-task-002421/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002421/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-002428/environment/Dockerfile b/tasks/format-code-task-002428/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..94761ad701d70f772b945e09dcb58c94e717b2f1 --- /dev/null +++ b/tasks/format-code-task-002428/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:405cd5769bb2318d64d51e5e0857c5dd12da3127530a1c4b5454aa67896f04d8 diff --git a/tasks/format-code-task-002428/environment/setup/files/blocklist b/tasks/format-code-task-002428/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002428/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-002428/environment/setup/setup.sh b/tasks/format-code-task-002428/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002428/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-002428/tests/test.patch b/tasks/format-code-task-002428/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..74cfc3cfe23b35c727d25045dc4b64f75550a650 --- /dev/null +++ b/tasks/format-code-task-002428/tests/test.patch @@ -0,0 +1,74 @@ +diff --git a/test-data/unit/check-statements.test b/test-data/unit/check-statements.test +index 33e106504..180665301 100644 +--- a/test-data/unit/check-statements.test ++++ b/test-data/unit/check-statements.test +@@ -1795,3 +1795,47 @@ def foo2(): + bar2 = [] # type: List[str] + bar2 + [builtins fixtures/list.pyi] ++ ++[case testImplicitInstantiationOfRaiseClassWithRequiredArg] ++class SomeException(Exception): ++ def __init__(self, thing: str) -> None: ... ++def a() -> None: ++ raise SomeException # E: Too few arguments for "SomeException" ++def b() -> None: ++ raise SomeException() # E: Missing positional argument "thing" in call to "SomeException" ++def c() -> None: ++ raise SomeException(thing="snake") ++[builtins fixtures/exception.pyi] ++ ++[case testImplicitInstantiationOfRaiseClassNoRequiredArgs] ++class NoArgError(Exception): pass ++class OptionalArgError(Exception): ++ def __init__(self, x: int = 0) -> None: ... ++def f1() -> None: ++ raise NoArgError ++def f2() -> None: ++ raise OptionalArgError ++def f3() -> None: ++ raise BaseException ++[builtins fixtures/exception.pyi] ++ ++[case testImplicitInstantiationOfRaiseClassMultipleRequiredArgs] ++class MultiArg(Exception): ++ def __init__(self, a: str, b: int) -> None: ... ++def f() -> None: ++ raise MultiArg # E: Too few arguments for "MultiArg" ++[builtins fixtures/exception.pyi] ++ ++[case testImplicitInstantiationOfRaiseClassKeywordOnlyArg] ++class OnlyKw(Exception): ++ def __init__(self, *, name: str) -> None: ... ++def f() -> None: ++ raise OnlyKw # E: Missing named argument "name" for "OnlyKw" ++[builtins fixtures/exception.pyi] ++ ++[case testImplicitInstantiationOfRaiseFromClassWithRequiredArg] ++class SomeException(Exception): ++ def __init__(self, thing: str) -> None: ... ++def f() -> None: ++ raise BaseException from SomeException # E: Too few arguments for "SomeException" ++[builtins fixtures/exception.pyi] +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..212363fd3 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest mypy/test/testcheck.py -k testImplicitInstantiation -p no:cacheprovider"] ++} +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 mypy/test/testcheck.py -k testImplicitInstantiation -p no:cacheprovider ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002428/tests/test.sh b/tasks/format-code-task-002428/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fe61e67a1335229001d32ca6d53dd6290335aad4 --- /dev/null +++ b/tasks/format-code-task-002428/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-data/unit/check-statements.test +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-002428/tests/test_command.sh b/tasks/format-code-task-002428/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002428/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-002531/environment/Dockerfile b/tasks/format-code-task-002531/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..eea657694f0c4e32cd1bc4828b5f1d8d9897d5e6 --- /dev/null +++ b/tasks/format-code-task-002531/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:a2ab46bef923d93d860318c7863d51e74998d83a390c283cd75e63297a35171a diff --git a/tasks/format-code-task-002531/environment/setup/files/blocklist b/tasks/format-code-task-002531/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002531/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-002531/environment/setup/setup.sh b/tasks/format-code-task-002531/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002531/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-002531/tests/test.patch b/tasks/format-code-task-002531/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9720a6df9fb2cb2b03675a416f0e0e101cd3eba7 --- /dev/null +++ b/tasks/format-code-task-002531/tests/test.patch @@ -0,0 +1,32 @@ +diff --git a/pkg/operator/ceph/cluster/nodedaemon/crash_test.go b/pkg/operator/ceph/cluster/nodedaemon/crash_test.go +index ba7e470efcfa..c13343af30a2 100644 +--- a/pkg/operator/ceph/cluster/nodedaemon/crash_test.go ++++ b/pkg/operator/ceph/cluster/nodedaemon/crash_test.go +@@ -102,4 +102,6 @@ func TestCreateOrUpdateCephCrash(t *testing.T) { + assert.Equal(t, tolerations, podSpec.Spec.Tolerations) + assert.Equal(t, true, podSpec.Spec.HostNetwork) + assert.Equal(t, "test-priority-class", podSpec.Spec.PriorityClassName) ++ assert.NotEqual(t, "", deploy.ObjectMeta.Labels["rook-version"]) ++ assert.Equal(t, "", podSpec.ObjectMeta.Labels["rook-version"]) + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3Ru07DMBQG4Mx9iqPuiS/F7cRUIUYWYK3c+KhBNHbkOJl4eJwsRUjQpRWq+L/l ++WPbxRf6r/fB2dDv2oyiuRWYbY+aafa/zWBmttFoZuVaFVMpsTEHmai/6YuiTjURFDCH91ndu/UZV ++p/wT92lXh7a13lV9c7k7zuWv5eqUv9Y5/7u1VAXJyz3hZ/88/9rRHPye3eIQaBpSOVJZh8Gne0WV ++6N4PInQcbQpR1Nw1oj7mT+MofHDsLLfBCyrj4Gn5nLc/sp+aeRtt3zz48dXGj2l+GznPPsWXzk2r +++aC5Y7n46y8AAAAAAAAAAAAAAAAAAAAAALhZn349J9oAKAAA +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-002531/tests/test.sh b/tasks/format-code-task-002531/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5db34f8900bbde5145878711e729fc20d6e70ad1 --- /dev/null +++ b/tasks/format-code-task-002531/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/operator/ceph/cluster/nodedaemon/crash_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-002531/tests/test_command.sh b/tasks/format-code-task-002531/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002531/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-002554/environment/Dockerfile b/tasks/format-code-task-002554/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..76fc75d45a2d88c3ba82019e24c4ad51785535f8 --- /dev/null +++ b/tasks/format-code-task-002554/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:3025244c9939cdabac1fc4b9c0fb79b1e67cf359c287a16069e348db82aa0491 diff --git a/tasks/format-code-task-002554/environment/setup/files/blocklist b/tasks/format-code-task-002554/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002554/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-002554/environment/setup/setup.sh b/tasks/format-code-task-002554/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002554/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-002554/tests/test.patch b/tasks/format-code-task-002554/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6794520622c1923685bdb7801b8a761657e5b05e --- /dev/null +++ b/tasks/format-code-task-002554/tests/test.patch @@ -0,0 +1,164 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..04a44bab2 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_api_and_interface.py::TestHistory -v"] ++} +diff --git a/tests/test_api_and_interface.py b/tests/test_api_and_interface.py +index 3e4256370..cbda0466c 100644 +--- a/tests/test_api_and_interface.py ++++ b/tests/test_api_and_interface.py +@@ -229,6 +229,29 @@ class TestSecuredExpose: + assert cherrypy.response.status == 403 + + ++def _make_pp_nzo(nzo_id, final_name=None): ++ """Build a mock NZO suitable for add_active_history().""" ++ nzo = mock.Mock() ++ nzo.nzo_id = nzo_id ++ nzo.final_name = final_name or ("pp_" + nzo_id) ++ nzo.filename = nzo.final_name + ".nzb" ++ nzo.cat = "*" ++ nzo.repair, nzo.unpack, nzo.delete = pp_to_opts(0) ++ nzo.script = "None" ++ nzo.url = "" ++ nzo.status = "Extracting" ++ nzo.download_path = "/incomplete/" + nzo_id ++ nzo.nzo_info = {"download_time": 1} ++ nzo.bytes_downloaded = 1024 ++ nzo.fail_msg = "" ++ nzo.duplicate_key = "" ++ nzo.correct_password = "" ++ nzo.action_line = "" ++ nzo.pp_active = False ++ nzo.unpack_info = {} ++ return nzo ++ ++ + class TestHistory: + @pytest.mark.usefixtures("run_sabnzbd") + def test_add_active_history_consistency(self): +@@ -259,3 +282,107 @@ class TestHistory: + history_keys = list(history_job.keys()) + history_keys.sort() + assert pp_keys == history_keys ++ ++ def test_add_active_history_skips_duplicate_nzo_id(self): ++ """Race window: when a postproc NZO shares its nzo_id with an item ++ already in the list (from history DB), it must NOT be appended again. ++ The kept entry must be the DB one with its storage path filled.""" ++ shared_id = "SABnzbd_nzo_h4h4kvnz" ++ ++ db_storage = "/media/downloads/usenet/comics/foo.cbr" ++ items = [ ++ { ++ "nzo_id": shared_id, ++ "storage": db_storage, ++ "name": "from_db", ++ "status": "Completed", ++ } ++ ] ++ ++ nzo = _make_pp_nzo(shared_id, final_name="from_pp") ++ ++ api.add_active_history([nzo], items) ++ ++ ++ nzo_ids = [item["nzo_id"] for item in items] ++ assert nzo_ids.count(shared_id) == 1 ++ assert len(items) == 1 ++ ++ ++ ++ assert items[0]["storage"] == db_storage ++ assert items[0]["name"] == "from_db" ++ ++ def test_add_active_history_appends_when_no_duplicate(self): ++ """Normal path: postproc nzo_id not in items - append it (preservation).""" ++ items = [ ++ { ++ "nzo_id": "db_only_id", ++ "storage": "/db/path", ++ "name": "from_db", ++ "status": "Completed", ++ } ++ ] ++ nzo = _make_pp_nzo("pp_only_id", final_name="from_pp") ++ ++ api.add_active_history([nzo], items) ++ ++ assert len(items) == 2 ++ nzo_ids = [item["nzo_id"] for item in items] ++ assert "db_only_id" in nzo_ids ++ assert "pp_only_id" in nzo_ids ++ ++ def test_add_active_history_empty_items_appends_all(self): ++ """Empty items + non-empty postproc: all postproc items appended.""" ++ items = [] ++ nzo = _make_pp_nzo("solo_pp") ++ ++ api.add_active_history([nzo], items) ++ ++ assert len(items) == 1 ++ assert items[0]["nzo_id"] == "solo_pp" ++ ++ assert items[0]["storage"] == "" ++ ++ def test_add_active_history_empty_postproc_unchanged(self): ++ """Empty postproc: items unchanged.""" ++ items = [ ++ {"nzo_id": "A", "storage": "/a", "name": "n_a"}, ++ {"nzo_id": "B", "storage": "/b", "name": "n_b"}, ++ ] ++ snapshot = [dict(item) for item in items] ++ ++ api.add_active_history([], items) ++ ++ assert items == snapshot ++ ++ def test_add_active_history_mixed_duplicates(self): ++ """Realistic mix: some postproc nzo_ids duplicate, some not. ++ Only the non-duplicate ones get appended, and the DB items keep their ++ original storage/name fields.""" ++ items = [ ++ {"nzo_id": "shared_1", "storage": "/db/1", "name": "db1", "status": "Completed"}, ++ {"nzo_id": "shared_2", "storage": "/db/2", "name": "db2", "status": "Completed"}, ++ {"nzo_id": "db_only", "storage": "/db/3", "name": "db3", "status": "Completed"}, ++ ] ++ nzo_dup_1 = _make_pp_nzo("shared_1", final_name="pp_shared_1") ++ nzo_new = _make_pp_nzo("pp_only", final_name="pp_only_name") ++ nzo_dup_2 = _make_pp_nzo("shared_2", final_name="pp_shared_2") ++ ++ api.add_active_history([nzo_dup_1, nzo_new, nzo_dup_2], items) ++ ++ ++ assert len(items) == 4 ++ nzo_ids = [item["nzo_id"] for item in items] ++ assert sorted(nzo_ids) == ["db_only", "pp_only", "shared_1", "shared_2"] ++ ++ by_id = {item["nzo_id"]: item for item in items} ++ ++ assert by_id["shared_1"]["storage"] == "/db/1" ++ assert by_id["shared_1"]["name"] == "db1" ++ assert by_id["shared_2"]["storage"] == "/db/2" ++ assert by_id["shared_2"]["name"] == "db2" ++ assert by_id["db_only"]["storage"] == "/db/3" ++ ++ assert by_id["pp_only"]["storage"] == "" ++ assert by_id["pp_only"]["name"] == "pp_only_name" +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_api_and_interface.py::TestHistory -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002554/tests/test.sh b/tasks/format-code-task-002554/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..edab1319581bb964725d37977c2c4e59a5d72ffd --- /dev/null +++ b/tasks/format-code-task-002554/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_api_and_interface.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-002554/tests/test_command.sh b/tasks/format-code-task-002554/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002554/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-002562/environment/Dockerfile b/tasks/format-code-task-002562/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6ae83a7f3d2b5893bf78ee1e7524885fa08e068e --- /dev/null +++ b/tasks/format-code-task-002562/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:274ce8d36736100c0051bb786b852198016375a6dc9915ca091b7e98dca3c370 diff --git a/tasks/format-code-task-002562/environment/setup/files/blocklist b/tasks/format-code-task-002562/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002562/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-002562/environment/setup/setup.sh b/tasks/format-code-task-002562/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002562/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-002562/tests/test.patch b/tasks/format-code-task-002562/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..79035a2cf27f7dda4a429c337a271b16256ef8e2 --- /dev/null +++ b/tasks/format-code-task-002562/tests/test.patch @@ -0,0 +1,263 @@ +diff --git a/tests/unit/modules/dig_test.py b/tests/unit/modules/dig_test.py +index 82faf07c0e46..21e89c0ce9e9 100644 +--- a/tests/unit/modules/dig_test.py ++++ b/tests/unit/modules/dig_test.py +@@ -13,6 +13,42 @@ + from salt.modules import dig + + ++_SPF_VALUES = { ++ 'dig +short xmission.com TXT': { ++ 'pid': 27282, ++ 'retcode': 0, ++ 'stderr': '', ++ 'stdout': '"v=spf1 a mx include:_spf.xmission.com ?all"' ++ }, ++ 'dig +short _spf.xmission.com TXT': { ++ 'pid': 27282, ++ 'retcode': 0, ++ 'stderr': '', ++ 'stdout': '"v=spf1 a mx ip4:198.60.22.0/24 ' ++ 'ip4:166.70.13.0/24 ~all"' ++ }, ++ 'dig +short xmission-redirect.com TXT': { ++ 'pid': 27282, ++ 'retcode': 0, ++ 'stderr': '', ++ 'stdout': 'v=spf1 redirect=_spf.xmission.com' ++ }, ++ 'dig +short foo.com TXT': { ++ 'pid': 27282, ++ 'retcode': 0, ++ 'stderr': '', ++ 'stdout': 'v=spf1 ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all' ++ }, ++} ++ ++ ++def _spf_side_effect(key, output_loglevel='info'): ++ return _SPF_VALUES.get(key, {'pid': 27310, ++ 'retcode': 0, ++ 'stderr': '', ++ 'stdout': ''}) ++ ++ + @skipIf(NO_MOCK, NO_MOCK_REASON) + @skipIf(dig.__virtual__() is False, 'Dig must be installed') + class DigTestCase(TestCase): +@@ -21,94 +57,137 @@ def test_check_ip(self): + self.assertTrue(dig.check_ip('127.0.0.1'), msg='Not a valid ip address') + + def test_check_ip_ipv6(self): +- self.assertTrue(dig.check_ip('1111:2222:3333:4444:5555:6666:7777:8888'), msg='Not a valid ip address') ++ self.assertTrue( ++ dig.check_ip('1111:2222:3333:4444:5555:6666:7777:8888'), ++ msg='Not a valid ip address' ++ ) + +- @skipIf(True, 'Waiting for 2014.1 release') + def test_check_ip_ipv6_valid(self): + self.assertTrue(dig.check_ip('2607:fa18:0:3::4')) + + def test_check_ip_neg(self): +- self.assertFalse(dig.check_ip('-127.0.0.1'), msg="Did not detect negative value as invalid") ++ self.assertFalse( ++ dig.check_ip('-127.0.0.1'), ++ msg="Did not detect negative value as invalid" ++ ) + + def test_check_ip_empty(self): +- self.assertFalse(dig.check_ip(''), msg="Did not detect empty value as invalid") ++ self.assertFalse( ++ dig.check_ip(''), ++ msg="Did not detect empty value as invalid" ++ ) + + def test_a(self): + dig.__salt__ = {} +- dig_mock = MagicMock(return_value={ +- 'pid': 3656, 'retcode': 0, 'stderr': '', 'stdout': '74.125.193.104\n' +- '74.125.193.105\n' +- '74.125.193.99\n' +- '74.125.193.106\n' +- '74.125.193.103\n' +- '74.125.193.147' +- }) ++ dig_mock = MagicMock( ++ return_value={ ++ 'pid': 3656, ++ 'retcode': 0, ++ 'stderr': '', ++ 'stdout': '74.125.193.104\n' ++ '74.125.193.105\n' ++ '74.125.193.99\n' ++ '74.125.193.106\n' ++ '74.125.193.103\n' ++ '74.125.193.147' ++ } ++ ) + with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}): +- self.assertEqual(dig.A('www.google.com'), ['74.125.193.104', +- '74.125.193.105', +- '74.125.193.99', +- '74.125.193.106', +- '74.125.193.103', +- '74.125.193.147']) +- +- @skipIf(True, 'Waiting for 2014.1 release') ++ self.assertEqual( ++ dig.A('www.google.com'), ++ ['74.125.193.104', ++ '74.125.193.105', ++ '74.125.193.99', ++ '74.125.193.106', ++ '74.125.193.103', ++ '74.125.193.147'] ++ ) ++ + def test_aaaa(self): + dig.__salt__ = {} +- dig_mock = MagicMock(return_value={ +- 'pid': 25451, 'retcode': 0, 'stderr': '', 'stdout': '2607:f8b0:400f:801::1014' +- }) ++ dig_mock = MagicMock( ++ return_value={ ++ 'pid': 25451, ++ 'retcode': 0, ++ 'stderr': '', ++ 'stdout': '2607:f8b0:400f:801::1014' ++ } ++ ) + with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}): +- self.assertEqual(dig.AAAA('www.google.com'), ['2607:f8b0:400f:801::1014']) ++ self.assertEqual( ++ dig.AAAA('www.google.com'), ++ ['2607:f8b0:400f:801::1014'] ++ ) + + @patch('salt.modules.dig.A', MagicMock(return_value=['ns4.google.com.'])) + def test_ns(self): + dig.__salt__ = {} +- dig_mock = MagicMock(return_value={ +- 'pid': 26136, 'retcode': 0, 'stderr': '', 'stdout': 'ns4.google.com.' +- }) ++ dig_mock = MagicMock( ++ return_value={ ++ 'pid': 26136, ++ 'retcode': 0, ++ 'stderr': '', ++ 'stdout': 'ns4.google.com.' ++ } ++ ) + with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}): + self.assertEqual(dig.NS('google.com'), ['ns4.google.com.']) + + def test_spf(self): + dig.__salt__ = {} +- dig_mock = MagicMock(return_value={'pid': 26795, +- 'retcode': 0, +- 'stderr': '', +- 'stdout': 'v=spf1' +- ' include:_spf.google.com ' +- 'ip4:216.73.93.70/31 ' +- 'ip4:216.73.93.72/31 ~all'}) ++ dig_mock = MagicMock(side_effect=_spf_side_effect) + with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}): +- self.assertEqual(dig.SPF('google.com'), +- ['216.73.93.70/31', '216.73.93.72/31']) ++ self.assertEqual( ++ dig.SPF('foo.com'), ++ ['216.73.93.70/31', '216.73.93.72/31'] ++ ) + +- @skipIf(True, 'Waiting for 2014.1 release') + def test_spf_redir(self): + ''' +- Test was written after a bug was found when a domain is redirecting the SPF ipv4 range ++ Test for SPF records which use the 'redirect' SPF mechanism ++ https://en.wikipedia.org/wiki/Sender_Policy_Framework#Mechanisms ++ ''' ++ dig.__salt__ = {} ++ dig_mock = MagicMock(side_effect=_spf_side_effect) ++ with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}): ++ self.assertEqual( ++ dig.SPF('xmission-redirect.com'), ++ ['198.60.22.0/24', '166.70.13.0/24'] ++ ) ++ ++ def test_spf_include(self): ++ ''' ++ Test for SPF records which use the 'include' SPF mechanism ++ https://en.wikipedia.org/wiki/Sender_Policy_Framework#Mechanisms + ''' + dig.__salt__ = {} +- dig_mock = MagicMock(return_value={'pid': 27282, +- 'retcode': 0, +- 'stderr': '', +- 'stdout': 'v=spf1 a mx ' +- 'include:_spf.xmission.com ?all'}) ++ dig_mock = MagicMock(side_effect=_spf_side_effect) + with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}): +- self.assertEqual(dig.SPF('xmission.com'), ['198.60.22.0/24', '166.70.13.0/24']) ++ self.assertEqual( ++ dig.SPF('xmission.com'), ++ ['198.60.22.0/24', '166.70.13.0/24'] ++ ) + + def test_mx(self): + dig.__salt__ = {} +- dig_mock = MagicMock(return_value={'pid': 27780, +- 'retcode': 0, +- 'stderr': '', +- 'stdout': '10 aspmx.l.google.com.\n' +- '20 alt1.aspmx.l.google.com.\n' +- '40 alt3.aspmx.l.google.com.\n' +- '50 alt4.aspmx.l.google.com.\n' +- '30 alt2.aspmx.l.google.com.'}) ++ dig_mock = MagicMock( ++ return_value={ ++ 'pid': 27780, ++ 'retcode': 0, ++ 'stderr': '', ++ 'stdout': '10 aspmx.l.google.com.\n' ++ '20 alt1.aspmx.l.google.com.\n' ++ '40 alt3.aspmx.l.google.com.\n' ++ '50 alt4.aspmx.l.google.com.\n' ++ '30 alt2.aspmx.l.google.com.' ++ } ++ ) + with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}): +- self.assertEqual(dig.MX('google.com'), [['10', 'aspmx.l.google.com.'], +- ['20', 'alt1.aspmx.l.google.com.'], +- ['40', 'alt3.aspmx.l.google.com.'], +- ['50', 'alt4.aspmx.l.google.com.'], +- ['30', 'alt2.aspmx.l.google.com.']]) ++ self.assertEqual( ++ dig.MX('google.com'), ++ [['10', 'aspmx.l.google.com.'], ++ ['20', 'alt1.aspmx.l.google.com.'], ++ ['40', 'alt3.aspmx.l.google.com.'], ++ ['50', 'alt4.aspmx.l.google.com.'], ++ ['30', 'alt2.aspmx.l.google.com.']] ++ ) +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+3ST2uDMBgG8Jz9FC/iYTtoTLZUGOzQQ6GXsR12F21CK6gRjbJ++0UvHYOtl5ZR ++9vwOScgb8ocnSTlWtc5NO3F2LamXKbX03vd+GQslhUyVkJlkqRAqWzFSV7vRF+Pgip6I9da639ad ++q9+o5JS/M4PLd7ZpilYnw+FyZ5zLX2QPp/ylXyceV0IwSi93hZ/98/x3mpbgS6MD89HZ3tHb+n37 ++HEbb15cNT7rj/DXKqn2K5vkwMFNRUxjdLQWq2spRfB8G3dEdbEtxQ37k96O5Gfjo67yxeqzNwHW1 ++z+dpvynFU/DXTwcAAAAAAAAAAAAAAAAAAAAAuHmfS/OG1gAoAAA= +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-002562/tests/test.sh b/tasks/format-code-task-002562/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f8965fbe5cebb1ac4fa09808edf5b1ffc2d58d70 --- /dev/null +++ b/tasks/format-code-task-002562/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/unit/modules/dig_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002562/tests/test_command.sh b/tasks/format-code-task-002562/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002562/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-002591/environment/Dockerfile b/tasks/format-code-task-002591/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d4eac6caad6c76a0304da601880fa03b608528d1 --- /dev/null +++ b/tasks/format-code-task-002591/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:28083122eb2a49482efd5a104c634b10af139b70e1e8d38a222a9e64cab3916c diff --git a/tasks/format-code-task-002591/environment/setup/files/blocklist b/tasks/format-code-task-002591/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002591/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-002591/environment/setup/setup.sh b/tasks/format-code-task-002591/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002591/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-002591/tests/test.patch b/tasks/format-code-task-002591/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0356324aef2c8ec3a15d390d46eb13b559ded992 --- /dev/null +++ b/tasks/format-code-task-002591/tests/test.patch @@ -0,0 +1,85 @@ +diff --git a/test/cliques.jl b/test/cliques.jl +new file mode 100644 +index 000000000..a4e0e9bac +--- /dev/null ++++ b/test/cliques.jl +@@ -0,0 +1,46 @@ ++ ++ ++ ++ ++ ++ ++ ++function setofsets(array_of_arrays) ++ Set(map(Set, array_of_arrays)) ++end ++ ++function test_cliques(graph, expected) ++ ++ setofsets(maximal_cliques(graph)) == setofsets(expected) ++end ++ ++g = Graph(3) ++add_edge!(g, 1, 2) ++@test test_cliques(g, Array[[1,2], [3]]) ++add_edge!(g, 2, 3) ++@test test_cliques(g, Array[[1,2], [2,3]]) ++ ++ ++h = Graph(6) ++add_edge!(h, 1, 2) ++add_edge!(h, 1, 3) ++add_edge!(h, 1, 4) ++add_edge!(h, 2, 5) ++add_edge!(h, 2, 6) ++add_edge!(h, 3, 4) ++add_edge!(h, 3, 6) ++add_edge!(h, 5, 6) ++ ++@test maximal_cliques(h) != [] ++ ++ ++ ++h = Graph(7) ++add_edge!(h,1,3) ++add_edge!(h,2,6) ++add_edge!(h,3,5) ++add_edge!(h,3,6) ++add_edge!(h,4,5) ++add_edge!(h,4,7) ++add_edge!(h,5,7) ++@test test_cliques(h, Array[[7,4,5], [2,6], [3,5], [3,6], [3,1]]) +diff --git a/test/runtests.jl b/test/runtests.jl +index ce2d02433..4e58b8652 100644 +--- a/test/runtests.jl ++++ b/test/runtests.jl +@@ -60,6 +60,7 @@ tests = [ + "traversals/maxadjvisit", + "traversals/graphvisit", + "connectivity", ++ "cliques", + "centrality/betweenness", + "centrality/closeness", + "centrality/degree", +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+3RTwuCMBgG8J39FEOC6pBu0ykEHTrVoUOH7qE50v440Rl9/EyIIqguRUTP7/KO ++dxt7x+PEdbZLlio/uORTWCOUsq2N+9quuRRMhFyGnkcY5wELCJUfm+hGXZmopJSUWptn517t/yjn ++mr9RlVmu9H4f5YlTpe9741X+XIhL/kwIv8nfD5hHKHvfCI/9ef6rhLbBxyqx1LHQpaHz8WI6sl1d ++GHdT77LIjbN82Dl3batt0IGi3fl27Zwv9uxZtk7NpIyKtLL7XevbPwIAAAAAAAAAAAAAAAAAAAAA +++B8nB8u1sgAoAAA= +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-002591/tests/test.sh b/tasks/format-code-task-002591/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..21fc180ac39c2c1af42108a0ac63f19179ecddaa --- /dev/null +++ b/tasks/format-code-task-002591/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/cliques.jl +test/runtests.jl +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-002591/tests/test_command.sh b/tasks/format-code-task-002591/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002591/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-002596/environment/Dockerfile b/tasks/format-code-task-002596/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..38d8b9316a0ecc7af87ff8694718d80e3b366901 --- /dev/null +++ b/tasks/format-code-task-002596/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:4100c7c2dc67d6666a7254e2d37f8bf93f1669d29d779d68c058ceee28a13eca diff --git a/tasks/format-code-task-002596/environment/setup/files/blocklist b/tasks/format-code-task-002596/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002596/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-002596/environment/setup/setup.sh b/tasks/format-code-task-002596/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002596/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-002596/tests/test.patch b/tasks/format-code-task-002596/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..54af68957a00c8c363841fbfaa56c4fb36407de7 --- /dev/null +++ b/tasks/format-code-task-002596/tests/test.patch @@ -0,0 +1,118 @@ +diff --git a/Tests/Fixtures/ObjectWithEmptyHash.php b/Tests/Fixtures/ObjectWithEmptyHash.php +new file mode 100644 +index 00000000..7d7535a3 +--- /dev/null ++++ b/Tests/Fixtures/ObjectWithEmptyHash.php +@@ -0,0 +1,29 @@ ++") ++ */ ++ private $hash = array(); ++} +diff --git a/Tests/Serializer/BaseSerializationTest.php b/Tests/Serializer/BaseSerializationTest.php +index e1d741a0..539c323c 100644 +--- a/Tests/Serializer/BaseSerializationTest.php ++++ b/Tests/Serializer/BaseSerializationTest.php +@@ -70,6 +70,7 @@ + use JMS\SerializerBundle\Tests\Fixtures\SimpleObjectProxy; + use JMS\SerializerBundle\Tests\Serializer\Fixture\Article; + use JMS\SerializerBundle\Tests\Fixtures\Input; ++use JMS\SerializerBundle\Tests\Fixtures\ObjectWithEmptyHash; + use Metadata\MetadataFactory; + use Symfony\Component\Form\Form; + use Symfony\Component\Form\FormError; +@@ -500,6 +501,11 @@ public function testInput() + $this->assertEquals($this->getContent('input'), $this->serializer->serialize(new Input(), $this->getFormat())); + } + ++ public function testObjectWithEmptyHash() ++ { ++ $this->assertEquals($this->getContent('hash_empty'), $this->serializer->serialize(new ObjectWithEmptyHash(), $this->getFormat())); ++ } ++ + abstract protected function getContent($key); + abstract protected function getFormat(); + +diff --git a/Tests/Serializer/JsonSerializationTest.php b/Tests/Serializer/JsonSerializationTest.php +index 7554c962..ba77edab 100644 +--- a/Tests/Serializer/JsonSerializationTest.php ++++ b/Tests/Serializer/JsonSerializationTest.php +@@ -81,6 +81,7 @@ protected function getContent($key) + $outputs['virtual_properties_high'] = '{"high":8}'; + $outputs['virtual_properties_all'] = '{"low":1,"high":8}'; + $outputs['input'] = '{"attributes":{"type":"text","name":"firstname","value":"Adrien"}}'; ++ $outputs['hash_empty'] = '{"hash":{}}'; + } + + if (!isset($outputs[$key])) { +diff --git a/Tests/Serializer/xml/hash_empty.xml b/Tests/Serializer/xml/hash_empty.xml +new file mode 100644 +index 00000000..0ea94e97 +--- /dev/null ++++ b/Tests/Serializer/xml/hash_empty.xml +@@ -0,0 +1,4 @@ ++ ++ ++ ++ +diff --git a/Tests/Serializer/yml/hash_empty.yml b/Tests/Serializer/yml/hash_empty.yml +new file mode 100644 +index 00000000..6ec4ff79 +--- /dev/null ++++ b/Tests/Serializer/yml/hash_empty.yml +@@ -0,0 +1 @@ ++hash: {} +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,14 @@ ++H4sIAAAAAAAAA+2W62/TMBDA+zl/xU2b+pDapOn6QBsFCYG08YVpTAIEKHKT62JInWA7VQva/845 ++fW60TEJdGcK/SHnc2eezz3eOO8h5EgUoxl7poWgSvU6neBJ3n8W732n5dHWOjdz3O71mCToP5tEa ++udJMApRkmurftbtP/4/iruI/oBkqLVnmZnG2yzFMgLvt9tb495q9ZfybrRbFv33cOi5Bc5dObOM/ ++j//T5xRsx/E8uEiT6ZAnCQxTCcjCuFoDiaN0jBFwARdnF/DEbTp8CNWDYS5CzVMR4IQrraoV075S ++q8EPB4iFemamfMSkZNOF0nD0FafQB7pX58rTpc4MMNP3+yDyJFnvaJCocylgyBKFq243K+NjluRI ++5sNcShT61yGOMsYlNSjk1Sb0nxUe1aFC98rq0y9eC3OkK56VlWjNoMDJhmHmjhajzaQ3zk2x1uci ++TPIIQccIqeTXXLAElvnnSPyWc4lBKkKEIHh5fhkE4ELFc13vCmnBb+dq5dT54/iv5b8JVpDNd8Eu ++a8B9+d/p+qv875n636F3m//7YJb/Nv33lv5/O+B3WMt/TZUlCNPRiInIVfHuxrjn/89v91b532p1 ++zfnf9bs2//fB4YE34MIbMBU7YQTFJhhg5DiHdEjR0lBBiDBDEaEIOSqTniLVkElUlFumHHyEA2hE ++MKY2VDk+n5pDTRTbnfZSliqUVD9mlhqNCMd059cildjIEqap2owadN4pEou0wYVGyWbVo/Ws7DtD ++bly5zEVxVlKorlGDcfKkuL8ZfMFQv+M6fjXK9PSMpgEslKlSYAbUsUQEcoGzhH9nhVkzItOKrF7F ++XJGTY5TqBF4whW/XG5qD1pyCUI1wyAXNvfCApLU6vFap2Ni6TnY3ODUzNOQTKglI/SejxItJHqBp ++4dJnHaa3ZfTpUK+e256vbREokuSCa1qt5S8AbPglID0Vc1rLras067SYA0pv65SgXIZPe3Xl/Sh5 ++JJ58YFtceWx13GKxWCwWi8VisVgsFovFYrFYLBaLZcFPjiubggAoAAA= +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-002596/tests/test.sh b/tasks/format-code-task-002596/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..92cb37fa20aa615fe1fcd2d80ecdfe7b08a220b2 --- /dev/null +++ b/tasks/format-code-task-002596/tests/test.sh @@ -0,0 +1,43 @@ +#!/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/Fixtures/ObjectWithEmptyHash.php +Tests/Serializer/BaseSerializationTest.php +Tests/Serializer/JsonSerializationTest.php +Tests/Serializer/xml/hash_empty.xml +Tests/Serializer/yml/hash_empty.yml +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-002596/tests/test_command.sh b/tasks/format-code-task-002596/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002596/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-002598/environment/Dockerfile b/tasks/format-code-task-002598/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..24128bb8b5e074bf7cc6a7bfc7813bba741c5881 --- /dev/null +++ b/tasks/format-code-task-002598/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:1dcdfc716ab2c6a6f8d41b2be9942bdf9d9af085952530c7326da94b81f92498 diff --git a/tasks/format-code-task-002598/environment/setup/files/blocklist b/tasks/format-code-task-002598/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002598/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-002598/environment/setup/setup.sh b/tasks/format-code-task-002598/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002598/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-002598/tests/test.patch b/tasks/format-code-task-002598/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4d43a06eedd207eb0ada0c81047cb742a6194873 --- /dev/null +++ b/tasks/format-code-task-002598/tests/test.patch @@ -0,0 +1,168 @@ +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,140 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++( cd /workspace/repo && go build -o /tmp/collidertracker-usecase ./ ) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN=/tmp/collidertracker-usecase ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || exit 1 ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++assert_file_has() { ++ local file=$1 ++ local expected=$2 ++ grep -Fq -- "$expected" "$file" || fail "$file missing: $expected" ++} ++ ++assert_file_lacks() { ++ local file=$1 ++ local unexpected=$2 ++ if grep -Fq -- "$unexpected" "$file"; then ++ fail "$file unexpectedly contains: $unexpected" ++ fi ++} ++ ++assert_file_matches() { ++ local file=$1 ++ local expected_regex=$2 ++ grep -Eq -- "$expected_regex" "$file" || fail "$file missing regex: $expected_regex" ++} ++ ++make_sc_extension_markers() { ++ local home_dir=$1 ++ local ext_dir="$home_dir/.local/share/SuperCollider/Extensions" ++ mkdir -p "$ext_dir" ++ : > "$ext_dir/Fverb.sc" ++ : > "$ext_dir/AnalogTape.sc" ++ : > "$ext_dir/MiBraids.sc" ++ : > "$ext_dir/Open303.sc" ++ : > "$ext_dir/Juno60.sc" ++ : > "$ext_dir/MoogLadder.schelp" ++} ++ ++make_probe_path() { ++ local probe_dir=$1 ++ mkdir -p "$probe_dir" ++ cat > "$probe_dir/pgrep" <<'PROBE' ++#!/usr/bin/env bash ++if [ "${1:-}" = "-x" ] && [ "${2:-}" = "sclang" ]; then ++ echo "sclang process detection was invoked" >> "${PROBE_LOG:?}" ++ exit 7 ++fi ++exec /usr/bin/pgrep "$@" ++PROBE ++ cat > "$probe_dir/sclang" <<'PROBE' ++#!/usr/bin/env bash ++echo "sclang executable was started" >> "${PROBE_LOG:?}" ++exit 23 ++PROBE ++ chmod +x "$probe_dir/pgrep" "$probe_dir/sclang" ++} ++ ++run_tracker_in_pty() { ++ local flag=$1 ++ local run_dir=$2 ++ mkdir -p "$run_dir/home" "$run_dir/project" "$run_dir/probe-bin" ++ make_sc_extension_markers "$run_dir/home" ++ make_probe_path "$run_dir/probe-bin" ++ ++ ++ ++ ( ++ sleep 0.2 ++ printf '\033]11;rgb:0000/0000/0000\033\\' ++ printf '\033[24;80R' ++ sleep 1 ++ printf 'q' ++ sleep 0.3 ++ printf '\021' ++ ) | env \ ++ HOME="$run_dir/home" \ ++ PATH="$run_dir/probe-bin:$PATH" \ ++ PROBE_LOG="$run_dir/probe.log" \ ++ TERM=xterm-256color \ ++ timeout 8s script -q -e -c "$BIN $flag --project '$run_dir/project' --log '$run_dir/debug.log'" "$run_dir/typescript" \ ++ >"$run_dir/out" 2>"$run_dir/err" ++ return $? ++} ++ ++ ++ ++ ++"$BIN" --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++[ ! -s err ] || fail "F1 unexpected stderr: $(cat err)" ++ ++assert_file_matches out '(^|[[:space:]])-s,[[:space:]]+--skip-sc[[:space:]]+Skip SuperCollider detection and management entirely' ++ ++assert_file_matches out '(^|[[:space:]])-p,[[:space:]]+--project([[:space:]]|$)' ++assert_file_matches out '(^|[[:space:]])--port([[:space:]]|$)' ++assert_file_matches out '(^|[[:space:]])-r,[[:space:]]+--record([[:space:]]|$)' ++assert_file_matches out '(^|[[:space:]])-l,[[:space:]]+--log([[:space:]]|$)' ++ ++ ++ ++ ++RUN_LONG="$TMP/run-long" ++run_tracker_in_pty "--skip-sc" "$RUN_LONG"; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0; err=$(cat "$RUN_LONG/err")" ++ ++[ ! -s "$RUN_LONG/probe.log" ] || fail "F2 SuperCollider lifecycle probe was touched: $(cat "$RUN_LONG/probe.log")" ++ ++assert_file_matches "$RUN_LONG/out" 'T1[[:space:]]+T2[[:space:]]+T3[[:space:]]+T4[[:space:]]+T5[[:space:]]+T6[[:space:]]+T7[[:space:]]+T8[[:space:]]+Song' ++ ++ ++ ++ ++RUN_SHORT="$TMP/run-short" ++run_tracker_in_pty "-s" "$RUN_SHORT"; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0; err=$(cat "$RUN_SHORT/err")" ++ ++[ ! -s "$RUN_SHORT/probe.log" ] || fail "F3 SuperCollider lifecycle probe was touched: $(cat "$RUN_SHORT/probe.log")" ++ ++assert_file_matches "$RUN_SHORT/out" 'T1[[:space:]]+T2[[:space:]]+T3[[:space:]]+T4[[:space:]]+T5[[:space:]]+T6[[:space:]]+T7[[:space:]]+T8[[:space:]]+Song' ++ ++ ++ ++ ++ ++README=/workspace/repo/README.md ++assert_file_has "$README" "-s, --skip-sc" ++assert_file_has "$README" "SuperCollider" ++assert_file_matches "$README" '[Mm]anual' ++assert_file_has "$README" "Skip SuperCollider detection and management entirely" ++ ++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,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 GOPATH="${GOPATH:-/root/go}" ++export GOMODCACHE="${GOMODCACHE:-/root/go/pkg/mod}" ++export GOCACHE="${GOCACHE:-/workspace/repo/.gocache}" ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-002598/tests/test.sh b/tasks/format-code-task-002598/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-002598/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-002598/tests/test_command.sh b/tasks/format-code-task-002598/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002598/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-002613/environment/Dockerfile b/tasks/format-code-task-002613/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c1ec79dc3f561862e47dbbff68b815f7d1b88b52 --- /dev/null +++ b/tasks/format-code-task-002613/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:b966167e8171f099e0fe228185d313e03f6d20dec7f3d576706b742ddc85d4c7 diff --git a/tasks/format-code-task-002613/environment/setup/files/blocklist b/tasks/format-code-task-002613/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002613/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-002613/environment/setup/setup.sh b/tasks/format-code-task-002613/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002613/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-002613/tests/test.patch b/tasks/format-code-task-002613/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..794eb1de67361d3eb926b515afdce496c6867d95 --- /dev/null +++ b/tasks/format-code-task-002613/tests/test.patch @@ -0,0 +1,197 @@ +diff --git a/src/Sculpin/Core/Tests/Source/CompositeDataSourceTest.php b/src/Sculpin/Core/Tests/Source/CompositeDataSourceTest.php +index 9ecf884f..f26546fd 100644 +--- a/src/Sculpin/Core/Tests/Source/CompositeDataSourceTest.php ++++ b/src/Sculpin/Core/Tests/Source/CompositeDataSourceTest.php +@@ -62,9 +62,9 @@ public function testDataSourceId() + + $dataSource = new CompositeDataSource([$ds000, $ds001, $ds002]); + +- $this->assertContains('TestDataSource:000', $dataSource->dataSourceId()); +- $this->assertContains('TestDataSource:001', $dataSource->dataSourceId()); +- $this->assertContains('TestDataSource:002', $dataSource->dataSourceId()); ++ $this->assertStringContainsString('TestDataSource:000', $dataSource->dataSourceId()); ++ $this->assertStringContainsString('TestDataSource:001', $dataSource->dataSourceId()); ++ $this->assertStringContainsString('TestDataSource:002', $dataSource->dataSourceId()); + } + + public function testRefresh() +diff --git a/src/Sculpin/Core/Tests/Source/Map/CalculatedDateFromFilenameMapTest.php b/src/Sculpin/Core/Tests/Source/Map/CalculatedDateFromFilenameMapTest.php +index dc7b8da0..0b8bd393 100644 +--- a/src/Sculpin/Core/Tests/Source/Map/CalculatedDateFromFilenameMapTest.php ++++ b/src/Sculpin/Core/Tests/Source/Map/CalculatedDateFromFilenameMapTest.php +@@ -25,7 +25,7 @@ class CalculatedDateFromFilenameMapTest extends TestCase + */ + private $map; + +- protected function setUp() ++ protected function setUp(): void + { + $this->map = new CalculatedDateFromFilenameMap(); + } +diff --git a/src/Sculpin/Tests/Functional/FunctionalTestCase.php b/src/Sculpin/Tests/Functional/FunctionalTestCase.php +index 3935f921..90b2a35e 100644 +--- a/src/Sculpin/Tests/Functional/FunctionalTestCase.php ++++ b/src/Sculpin/Tests/Functional/FunctionalTestCase.php +@@ -25,6 +25,9 @@ class FunctionalTestCase extends TestCase + /** @var string */ + protected $executeOutput; + ++ /** @var string */ ++ protected $errorOutput; ++ + public static function setUpBeforeClass(): void + { + static::$fs = new Filesystem(); +@@ -73,9 +76,15 @@ protected function tearDownTestProject(): void + */ + protected function executeSculpin($command): void + { +- $binPath = __DIR__ . '/../../../../bin'; +- $projectDir = static::projectDir(); +- exec("$binPath/sculpin $command --project-dir $projectDir --env=test", $this->executeOutput); ++ $process = $this->executeSculpinAsync($command, false); ++ $process->run(); ++ $this->executeOutput = $process->getOutput(); ++ $this->errorOutput = $process->getErrorOutput(); ++ ++ // This is a temporary assertion for diagnostic purposes. ++ // When adding tests that analyze error output, ++ // you are welcome to move this to its own specific test. ++ self::assertSame('', $this->errorOutput, 'Execution output should not contain errors'); + } + + /** +@@ -215,7 +224,7 @@ protected function assertGeneratedFileHasContent(string $filePath, string $expec + $this->assertTrue($fileExists, $msg . ' (File Not Found!)'); + + $contents = file_get_contents($fullPath); +- $this->assertContains($expected, $contents, $msg); ++ $this->assertStringContainsString($expected, $contents, $msg); + } + + /** +diff --git a/src/Sculpin/Tests/Functional/GenerateCommandTest.php b/src/Sculpin/Tests/Functional/GenerateCommandTest.php +index 6e7dcef5..618e4664 100644 +--- a/src/Sculpin/Tests/Functional/GenerateCommandTest.php ++++ b/src/Sculpin/Tests/Functional/GenerateCommandTest.php +@@ -10,7 +10,7 @@ class GenerateCommandTest extends FunctionalTestCase + . DIRECTORY_SEPARATOR . 'config' + . DIRECTORY_SEPARATOR . 'sculpin_kernel.yml'; + +- public function tearDown() ++ public function tearDown(): void + { + parent::tearDown(); + +diff --git a/src/Sculpin/Tests/Functional/GenerateFromMarkdownTest.php b/src/Sculpin/Tests/Functional/GenerateFromMarkdownTest.php +index eebccbf9..c59f6833 100644 +--- a/src/Sculpin/Tests/Functional/GenerateFromMarkdownTest.php ++++ b/src/Sculpin/Tests/Functional/GenerateFromMarkdownTest.php +@@ -25,7 +25,7 @@ public function shouldGenerateHtmlContentFromMarkdown(): void + + $crawler = $this->crawlGeneratedProjectFile('/hello_world/index.html'); + +- $this->assertContains('Hello World', $crawler->filter('h1')->text()); ++ $this->assertStringContainsString('Hello World', $crawler->filter('h1')->text()); + } + + /** @test */ +@@ -66,7 +66,7 @@ public function shouldGenerateHtmlUsingALayout() + $pageContentEl->count(), + "Expected generated file to have a single .page-content element." + ); +- $this->assertContains('Hello World', $pageContentEl->text()); ++ $this->assertStringContainsString('Hello World', $pageContentEl->text()); + } + + /** @test */ +@@ -116,8 +116,8 @@ public function shouldRefreshGeneratedHtmlAfterFilesystemChange(): void + "Expected generated file to have a single .header element." + ); + +- $this->assertContains($expectedHeader, $pageHeaderEl->text()); +- $this->assertContains($expectedContent, $pageContentEl->text()); ++ $this->assertStringContainsString($expectedHeader, $pageHeaderEl->text()); ++ $this->assertStringContainsString($expectedContent, $pageContentEl->text()); + + // update the content + $originalHeader = $expectedHeader; +@@ -142,7 +142,7 @@ public function shouldRefreshGeneratedHtmlAfterFilesystemChange(): void + "Expected generated file to have a single .page-content element." + ); + +- $this->assertContains($expectedContent, $pageContentEl->text()); ++ $this->assertStringContainsString($expectedContent, $pageContentEl->text()); + + // test that layouts/views refresh properly + $this->addProjectFile($layoutFile, $layoutContent); +@@ -157,7 +157,10 @@ public function shouldRefreshGeneratedHtmlAfterFilesystemChange(): void + "Expected generated file to have a single .header element." + ); + +- $this->assertContains($expectedHeader, $pageHeaderEl->text()); // I don't get it. This should be failing. ++ $this->assertStringContainsString( ++ $expectedHeader, ++ $pageHeaderEl->text() ++ ); + + $process->stop(0); + } +@@ -196,10 +199,13 @@ public function shouldSkipContentTypeFilesWithNoExtension(): void + + $this->executeSculpin('generate'); + +- $actualOutput = implode("\n", $this->executeOutput); +- $this->assertContains('Skipping empty or unknown file: _posts/hello_world' . PHP_EOL, $actualOutput); +- $this->assertContains('Skipping empty or unknown file: _posts/hello_world2', $actualOutput); +- $this->assertNotContains('Skipping empty or unknown file: _posts/hello_world3.md', $actualOutput); ++ $actualOutput = $this->executeOutput; ++ $this->assertStringContainsString( ++ 'Skipping empty or unknown file: _posts/hello_world' . PHP_EOL, ++ $actualOutput ++ ); ++ $this->assertStringContainsString('Skipping empty or unknown file: _posts/hello_world2', $actualOutput); ++ $this->assertStringNotContainsString('Skipping empty or unknown file: _posts/hello_world3.md', $actualOutput); + + $this->assertProjectLacksFile('/output_test/_posts/hello_world'); + $this->assertProjectLacksFile('/output_test/_posts/hello_world2'); +@@ -230,10 +236,10 @@ public function shouldSkipHiddenFilesSilently(): void + + $this->executeSculpin('generate'); + +- $actualOutput = implode("\n", $this->executeOutput); +- $this->assertNotContains('.DS_Store', $actualOutput); +- $this->assertNotContains('.hello_world2.swp', $actualOutput); +- $this->assertNotContains('Skipping empty or unknown file:', $actualOutput); ++ $actualOutput = $this->executeOutput; ++ $this->assertStringNotContainsString('.DS_Store', $actualOutput); ++ $this->assertStringNotContainsString('.hello_world2.swp', $actualOutput); ++ $this->assertStringNotContainsString('Skipping empty or unknown file:', $actualOutput); + + $this->assertProjectLacksFile('/output_test/_posts/.DS_Store'); + $this->assertProjectLacksFile('/output_test/_posts/.hello_world2.swp'); +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+3U3UvcQBAA8HvOXzEgSPuQT81Z8PHKtX0QpPooyN7u3GUxmU13Nx6++Ld3kmux ++LaggJyKd30M+dpPZyUySbDXY1lwj3eaz11Kwk7qe9uzf/XRc1lVRzavqqD6aFWU5L8oZ1K+W0R+G ++EJUHmHnn4lPXPTf/TmUP/Y8Y4rV2XafIZKHZ3xrP9L+sipOH/h/zeHk8L7n/xf5SeNx/3n9tYGr8 ++Ck2SHMA34nK0LRjskQySthhg7V0HsUFonb6BtW0RPmwbqxuwAXoVdYMGooNuPJwu1M7wplG0wfAx ++47iXf93NFd9gDHD+9RzuP2XFKWwRhoCQpnZDzmPatyqune9Sjz8CBEsap8B+oGg75KXuYIVAuEWf ++JfzS9i6gB/sr/TQll1qK6JWO1tEjgccn/j7QFHmXE4y1mJIMSd/0cMtVcD5fWcr5dCAb4SoBCF7n ++F3poex5fcNj8km8L+YUbvEYeGdOxET+rqHZj43w2BrxKDg/hxZHPVJ8vVMvzKqLh8Ljk3iw5XVId ++8uyL1tktsRxoqpVq8y9IXLmIi93PYL9Bx4zPlL8xbku/Iydv/RkIIYQQQgghhBBCCCGEEEIIIYQQ ++QrxbPwHF6pX3ACgAAA== +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-002613/tests/test.sh b/tasks/format-code-task-002613/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..691e61f5c578680b66d567d088bb7349b1f6ce9d --- /dev/null +++ b/tasks/format-code-task-002613/tests/test.sh @@ -0,0 +1,43 @@ +#!/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/Sculpin/Core/Tests/Source/CompositeDataSourceTest.php +src/Sculpin/Core/Tests/Source/Map/CalculatedDateFromFilenameMapTest.php +src/Sculpin/Tests/Functional/FunctionalTestCase.php +src/Sculpin/Tests/Functional/GenerateCommandTest.php +src/Sculpin/Tests/Functional/GenerateFromMarkdownTest.php +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-002613/tests/test_command.sh b/tasks/format-code-task-002613/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002613/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-002703/environment/Dockerfile b/tasks/format-code-task-002703/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..48620953006f1a8a29cf919e37549b21be4f2f9a --- /dev/null +++ b/tasks/format-code-task-002703/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:1cfc3c8c690b3f67873d17ff7c442d784b8a31524edcc9686c0e19658ba5b536 diff --git a/tasks/format-code-task-002703/environment/setup/files/blocklist b/tasks/format-code-task-002703/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002703/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-002703/environment/setup/setup.sh b/tasks/format-code-task-002703/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002703/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-002703/tests/test.patch b/tasks/format-code-task-002703/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c40e215f2788564d22c88115410c61e36187b616 --- /dev/null +++ b/tasks/format-code-task-002703/tests/test.patch @@ -0,0 +1,307 @@ +diff --git a/usercase-test-coderl/stringer_error_methods_test.go b/usercase-test-coderl/stringer_error_methods_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/stringer_error_methods_test.go +@@ -0,0 +1,279 @@ ++package usercase_test_coderl ++ ++import ( ++ "bytes" ++ "fmt" ++ "reflect" ++ "strings" ++ "testing" ++ ++ spew "github.com/spewerspew/spew" ++) ++ ++ ++ ++ ++type ID string ++ ++func (v ID) String() string { return "id=" + string(v) } ++ ++type Code int ++ ++func (c Code) Error() string { return fmt.Sprintf("code %d", c) } ++ ++type PointerOnly struct { ++ S string ++} ++ ++func (p *PointerOnly) String() string { return "ptr=" + p.S } ++ ++type Box struct { ++ N int ++} ++ ++func (b Box) String() string { return fmt.Sprintf("box:%d", b.N) } ++ ++type Bad int ++ ++func (b Bad) String() string { panic("boom") } ++ ++type Key struct { ++ Name string ++} ++ ++func (k Key) String() string { return k.Name } ++ ++type ByteName uint8 ++ ++func (b ByteName) String() string { return fmt.Sprintf("B%02d", b) } ++ ++func TestTopLevelStringerAndErrorRendering(t *testing.T) { ++ ++ ++ if got := spew.Sprintf("%v", ID("a7")); got != "id=a7" { ++ t.Fatalf("Sprintf %%v ID = %q", got) ++ } ++ if got := spew.Sprintf("%#v", ID("a7")); got != "(usercase_test_coderl.ID)id=a7" { ++ t.Fatalf("Sprintf %%#v ID = %q", got) ++ } ++ if got := spew.Sdump(ID("a7")); got != "(usercase_test_coderl.ID) (len=2) id=a7\n" { ++ t.Fatalf("Sdump ID = %q", got) ++ } ++ if got := spew.Sprintf("%v", Code(5)); got != "code 5" { ++ t.Fatalf("Sprintf Code = %q", got) ++ } ++ if got := spew.Sdump(Code(5)); got != "(usercase_test_coderl.Code) code 5\n" { ++ t.Fatalf("Sdump Code = %q", got) ++ } ++} ++ ++func TestDirectFormatterAndConvenienceWrappersRenderMethodText(t *testing.T) { ++ ++ ++ if got := fmt.Sprintf("%v", spew.NewFormatter(ID("a7"))); got != "id=a7" { ++ t.Fatalf("NewFormatter ID = %q", got) ++ } ++ if got := fmt.Sprintf("%#v", (&spew.ConfigState{}).NewFormatter(ID("a7"))); got != "(usercase_test_coderl.ID)id=a7" { ++ t.Fatalf("ConfigState.NewFormatter ID = %q", got) ++ } ++ if got := spew.Sprint(ID("a7")); got != "id=a7" { ++ t.Fatalf("Sprint ID = %q", got) ++ } ++ if got := spew.Sprintln(ID("a7")); got != "id=a7\n" { ++ t.Fatalf("Sprintln ID = %q", got) ++ } ++ if got := (&spew.ConfigState{}).Sprint(ID("a7")); got != "id=a7" { ++ t.Fatalf("ConfigState.Sprint ID = %q", got) ++ } ++ if got := (&spew.ConfigState{}).Sprintln(ID("a7")); got != "id=a7\n" { ++ t.Fatalf("ConfigState.Sprintln ID = %q", got) ++ } ++ if got := spew.Errorf("wrapped %v", ID("a7")).Error(); got != "wrapped id=a7" { ++ t.Fatalf("Errorf ID = %q", got) ++ } ++ ++ var buf bytes.Buffer ++ n, err := spew.Fprint(&buf, ID("a7")) ++ if n != 5 || err != nil || buf.String() != "id=a7" { ++ t.Fatalf("Fprint ID = n:%d err:%v text:%q", n, err, buf.String()) ++ } ++ buf.Reset() ++ n, err = spew.Fprintf(&buf, "got %v", Code(5)) ++ if n != 10 || err != nil || buf.String() != "got code 5" { ++ t.Fatalf("Fprintf Code = n:%d err:%v text:%q", n, err, buf.String()) ++ } ++ buf.Reset() ++ cfg := &spew.ConfigState{} ++ n, err = cfg.Fprint(&buf, ID("a7")) ++ if n != 5 || err != nil || buf.String() != "id=a7" { ++ t.Fatalf("ConfigState.Fprint ID = n:%d err:%v text:%q", n, err, buf.String()) ++ } ++ buf.Reset() ++ n, err = cfg.Fprintf(&buf, "got %v", Code(5)) ++ if n != 10 || err != nil || buf.String() != "got code 5" { ++ t.Fatalf("ConfigState.Fprintf Code = n:%d err:%v text:%q", n, err, buf.String()) ++ } ++ buf.Reset() ++ spew.Fdump(&buf, ID("a7")) ++ if got := buf.String(); got != "(usercase_test_coderl.ID) (len=2) id=a7\n" { ++ t.Fatalf("Fdump ID = %q", got) ++ } ++ buf.Reset() ++ cfg.Fdump(&buf, Code(5)) ++ if got := buf.String(); got != "(usercase_test_coderl.Code) code 5\n" { ++ t.Fatalf("ConfigState.Fdump Code = %q", got) ++ } ++} ++ ++func TestConfigDisablesMethodInvocation(t *testing.T) { ++ ++ ++ cfg := &spew.ConfigState{DisableMethods: true} ++ if got := cfg.Sprintf("%v", ID("a7")); got != "a7" { ++ t.Fatalf("DisableMethods Sprintf ID = %q", got) ++ } ++} ++ ++func TestPointerReceiverMethodsCanBeEnabledAndDisabled(t *testing.T) { ++ ++ ++ if spew.UnsafeDisabled { ++ t.Fatal("unsafe reflection is unavailable in this build") ++ } ++ value := PointerOnly{S: "z"} ++ if got := spew.Sprintf("%v", value); got != "ptr=z" { ++ t.Fatalf("default pointer receiver Sprintf = %q", got) ++ } ++ cfg := &spew.ConfigState{DisablePointerMethods: true} ++ ++ if got := cfg.Sprintf("%v", value); strings.Contains(got, "ptr=") || !strings.Contains(got, "z") { ++ t.Fatalf("DisablePointerMethods Sprintf = %q", got) ++ } ++ if !reflect.DeepEqual(value, PointerOnly{S: "z"}) { ++ t.Fatalf("pointer receiver formatting mutated input: %#v", value) ++ } ++} ++ ++func TestContinueOnMethodIncludesMethodTextAndStructInternals(t *testing.T) { ++ ++ ++ cfg := &spew.ConfigState{Indent: " ", ContinueOnMethod: true} ++ if got := cfg.Sdump(Box{N: 2}); got != "(usercase_test_coderl.Box) (box:2) {\n N: (int) 2\n}\n" { ++ t.Fatalf("ContinueOnMethod Sdump Box = %q", got) ++ } ++} ++ ++func TestPanickingStringerIsRenderedInline(t *testing.T) { ++ ++ ++ if got := spew.Sprintf("%v", Bad(9)); got != "(PANIC=boom)9" { ++ t.Fatalf("panicking Stringer Sprintf = %q", got) ++ } ++} ++ ++func TestSortKeysUsesMethodTextForMapKeys(t *testing.T) { ++ ++ ++ cfg := &spew.ConfigState{SortKeys: true} ++ input := map[Key]int{Key{"b"}: 2, Key{"a"}: 1} ++ if got := cfg.Sprintf("%v", input); got != "map[a:1 b:2]" { ++ t.Fatalf("SortKeys map Sprintf = %q", got) ++ } ++} ++ ++func TestByteLikeCollectionsUseMethodsInsteadOfHexdumpWhenEnabled(t *testing.T) { ++ ++ ++ ++ if got := spew.Sdump([]ByteName{1, 2, 15}); !dumpUsesByteNameMethods(got) { ++ t.Fatalf("Sdump []ByteName methods enabled = %q", got) ++ } ++ ++ if got := spew.Sdump([3]ByteName{1, 2, 15}); !dumpUsesByteNameMethods(got) { ++ t.Fatalf("Sdump [3]ByteName methods enabled = %q", got) ++ } ++} ++ ++func TestByteLikeSliceCanFallBackToHexdumpWhenMethodsDisabled(t *testing.T) { ++ ++ ++ cfg := &spew.ConfigState{Indent: " ", DisableMethods: true} ++ ++ if got := cfg.Sdump([]ByteName{1, 2, 15}); dumpContainsByteNameText(got) || !dumpShowsDisabledByteValues(got) { ++ t.Fatalf("Sdump []ByteName DisableMethods = %q", got) ++ } ++} ++ ++func TestReferentialTransparencyForSameInput(t *testing.T) { ++ first := spew.Sprintf("%#v", ID("a7")) ++ second := spew.Sprintf("%#v", ID("a7")) ++ if first != "(usercase_test_coderl.ID)id=a7" { ++ t.Fatalf("first call = %q", first) ++ } ++ if second != "(usercase_test_coderl.ID)id=a7" { ++ t.Fatalf("second call = %q", second) ++ } ++} ++ ++func TestFormattingDoesNotMutateCallerInputs(t *testing.T) { ++ input := map[Key][]ID{ ++ Key{"b"}: {ID("b1"), ID("b2")}, ++ Key{"a"}: {ID("a1")}, ++ } ++ original := map[Key][]ID{ ++ Key{"b"}: append([]ID(nil), input[Key{"b"}]...), ++ Key{"a"}: append([]ID(nil), input[Key{"a"}]...), ++ } ++ cfg := &spew.ConfigState{SortKeys: true} ++ ++ if got := cfg.Sprintf("%v", input); !strings.Contains(got, "id=a1") || !strings.Contains(got, "id=b1") || !strings.Contains(got, "id=b2") || strings.Index(got, "a:") < 0 || strings.Index(got, "b:") < 0 || strings.Index(got, "a:") > strings.Index(got, "b:") { ++ t.Fatalf("map formatting = %q", got) ++ } ++ if !reflect.DeepEqual(input, original) { ++ t.Fatalf("formatting mutated input: got %#v want %#v", input, original) ++ } ++} ++ ++func TestNoGlobalStateAcrossDifferentInputs(t *testing.T) { ++ first := spew.Sprintf("%v", ID("a7")) ++ if first != "id=a7" { ++ t.Fatalf("first ID call = %q", first) ++ } ++ if got := spew.Sprintf("%v", Code(5)); got != "code 5" { ++ t.Fatalf("noise Code call = %q", got) ++ } ++ if got := (&spew.ConfigState{SortKeys: true}).Sprintf("%v", map[Key]int{Key{"b"}: 2, Key{"a"}: 1}); got != "map[a:1 b:2]" { ++ t.Fatalf("noise map call = %q", got) ++ } ++ second := spew.Sprintf("%v", ID("a7")) ++ if second != "id=a7" { ++ t.Fatalf("second ID call after noise = %q", second) ++ } ++} ++ ++func TestCombinedFormattingUsesMethodText(t *testing.T) { ++ ++ if got := spew.Sprintf("%v %#v %v", ID("a7"), Box{N: 2}, []ByteName{1, 2, 15}); !strings.Contains(got, "id=a7") || !strings.Contains(got, "box:2") || !strings.Contains(got, "B01") || !strings.Contains(got, "B02") || !strings.Contains(got, "B15") { ++ t.Fatalf("combined method formatting = %q", got) ++ } ++} ++ ++func dumpUsesByteNameMethods(got string) bool { ++ return strings.Contains(got, "B01") && ++ strings.Contains(got, "B02") && ++ strings.Contains(got, "B15") && ++ !strings.Contains(got, "00000000") ++} ++ ++func dumpContainsByteNameText(got string) bool { ++ return strings.Contains(got, "B01") || ++ strings.Contains(got, "B02") || ++ strings.Contains(got, "B15") ++} ++ ++func dumpShowsDisabledByteValues(got string) bool { ++ lower := strings.ToLower(got) ++ hexdumpValues := strings.Contains(lower, "01") && strings.Contains(lower, "02") && strings.Contains(lower, "0f") ++ decimalValues := strings.Contains(got, "1") && strings.Contains(got, "2") && strings.Contains(got, "15") ++ return hexdumpValues || decimalValues ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export GOPROXY=off ++export GOSUMDB=off ++export GOVCS='*:off' ++export GOWORK=off ++exec go test -mod=readonly -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-002703/tests/test.sh b/tasks/format-code-task-002703/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4dc975a6c4dff5298eef03ea9e9d132789391964 --- /dev/null +++ b/tasks/format-code-task-002703/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/stringer_error_methods_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-002703/tests/test_command.sh b/tasks/format-code-task-002703/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002703/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-002750/environment/Dockerfile b/tasks/format-code-task-002750/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..dbef7df8281d7829e2b7b67c0a9b3a76dd7a4f2f --- /dev/null +++ b/tasks/format-code-task-002750/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:74bc026f505f8e8e4263c4fc3b244fa0de926719cfd672985725a85bcaf81403 diff --git a/tasks/format-code-task-002750/environment/setup/files/blocklist b/tasks/format-code-task-002750/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002750/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-002750/environment/setup/setup.sh b/tasks/format-code-task-002750/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002750/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-002750/tests/test.patch b/tasks/format-code-task-002750/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6ba4e8124e72d679213275d9db4e33abdf0048f5 --- /dev/null +++ b/tasks/format-code-task-002750/tests/test.patch @@ -0,0 +1,73 @@ +diff --git a/redfish/manager_test.go b/redfish/manager_test.go +index d0a4db28..bbcc9638 100644 +--- a/redfish/manager_test.go ++++ b/redfish/manager_test.go +@@ -379,3 +379,48 @@ func TestManagerUpdate(t *testing.T) { + t.Errorf("Unexpected DateTimeLocalOffset update payload: %s", calls[0].Payload) + } + } ++ ++func TestManagerReset(t *testing.T) { ++ var result Manager ++ err := json.NewDecoder(strings.NewReader(managerBody)).Decode(&result) ++ ++ if err != nil { ++ t.Errorf("Error decoding JSON: %s", err) ++ } ++ ++ testClient := &common.TestClient{} ++ result.SetClient(testClient) ++ ++ ++ result.SupportedResetTypes = []ResetType{GracefulRestartResetType} ++ err = result.Reset(GracefulRestartResetType) ++ if err != nil { ++ t.Errorf("Error making Reset call: %s", err) ++ } ++ ++ calls := testClient.CapturedCalls() ++ ++ if !strings.Contains(calls[0].Payload, "ResetType:GracefulRestart") { ++ t.Errorf("Unexpected ResetType in payload: %s", calls[0].Payload) ++ } ++ ++ ++ result.SupportedResetTypes = []ResetType{GracefulRestartResetType} ++ err = result.Reset(ForceRestartResetType) ++ if err == nil { ++ t.Errorf("No error when expected on Reset call: %s", err) ++ } ++ ++ ++ result.SupportedResetTypes = []ResetType{} ++ err = result.Reset(GracefulRestartResetType) ++ if err != nil { ++ t.Errorf("Error making Reset call: %s", err) ++ } ++ ++ calls = testClient.CapturedCalls() ++ ++ if calls[1].Payload != "map[]" { ++ t.Errorf("Unexpected payload: %s", calls[1].Payload) ++ } ++} +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+3RTarCMBSG4YxdxdmAbVJMs4o7uTiXauIPaAtJ6vqtnSiCOlFEfJ/JOSSBfPAV ++y36394vQHkv1LnrgrB3n4HaOu7GVrpy2zhmljam1U2LfluhKn3ITRVTsuvzo3bP7L1Vc+s8h5cWq ++Oxya1hdp+7o/nvbvrvqfVUP/s9rUSvTrItz34/2vvIzFL4OfbDo5r1KUMfj1Lm1Lmca+lflw+Ne0 ++zSbE/5BClulx8uncAAAAAAAAAAAAAAAAAJQ6AbkuOtUAKAAA +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-002750/tests/test.sh b/tasks/format-code-task-002750/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..64156614c059b6f615da4b744f0416dfbf5142ee --- /dev/null +++ b/tasks/format-code-task-002750/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' +redfish/manager_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-002750/tests/test_command.sh b/tasks/format-code-task-002750/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002750/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-002757/environment/Dockerfile b/tasks/format-code-task-002757/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e2bb1ac38ab1986e36e53f22726b46479a2e70b2 --- /dev/null +++ b/tasks/format-code-task-002757/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:f52203508c2088fa1d0b104aae7b71f1b648b707e941cd2fa4551a4d606b1970 diff --git a/tasks/format-code-task-002757/environment/setup/files/blocklist b/tasks/format-code-task-002757/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002757/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-002757/environment/setup/setup.sh b/tasks/format-code-task-002757/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002757/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-002757/tests/test.patch b/tasks/format-code-task-002757/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..46f09b7ede1858ab6e6653dea55c669f9afd4978 --- /dev/null +++ b/tasks/format-code-task-002757/tests/test.patch @@ -0,0 +1,201 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..b4530be3 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest tests/stream/dash/test_manifest.py -k segment_list"] ++} +diff --git a/tests/resources/dash/test_segment_list_p1.mpd b/tests/resources/dash/test_segment_list_p1.mpd +new file mode 100644 +index 00000000..22400021 +--- /dev/null ++++ b/tests/resources/dash/test_segment_list_p1.mpd +@@ -0,0 +1,38 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/resources/dash/test_segment_list_p2.mpd b/tests/resources/dash/test_segment_list_p2.mpd +new file mode 100644 +index 00000000..b0a88c53 +--- /dev/null ++++ b/tests/resources/dash/test_segment_list_p2.mpd +@@ -0,0 +1,38 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/stream/dash/test_manifest.py b/tests/stream/dash/test_manifest.py +index 4d6ede52..8e3671ad 100644 +--- a/tests/stream/dash/test_manifest.py ++++ b/tests/stream/dash/test_manifest.py +@@ -494,3 +494,86 @@ class TestMPDParser: + assert getattr(mpd.get_representation(("period-0", "0", "audio2")), "mimeType", None) == "audio/mp4" + assert getattr(mpd.get_representation(("period-0", None, "video1")), "mimeType", None) == "video/mp4" + assert getattr(mpd.get_representation(("period-0", None, "video2")), "mimeType", None) == "video/mp4" ++ ++ def test_segment_list_dynamic_reload_yields_only_new_segments(self): ++ """ ++ https://github.com/streamlink/streamlink/issues/5478 ++ After a manifest reload of a dynamic SegmentList, only new SegmentURLs ++ should be yielded - not the already-downloaded ones from the top. ++ """ ++ with xml("dash/test_segment_list_p1.mpd") as mpd_xml_p1: ++ mpd_p1 = MPD(mpd_xml_p1, base_url="http://test/", url="http://test/manifest.mpd") ++ rep_p1 = mpd_p1.periods[0].adaptationSets[0].representations[0] ++ iter_p1 = rep_p1.segments() ++ segments_p1 = [(seg.uri, seg.num, seg.init, seg.content) for seg in iter_p1] ++ ++ ++ assert segments_p1 == [ ++ ("http://test/init-video-p1.mp4", -1, True, False), ++ ("http://test/seg-2.mp4", 2, False, True), ++ ("http://test/seg-3.mp4", 3, False, True), ++ ("http://test/seg-4.mp4", 4, False, True), ++ ("http://test/seg-5.mp4", 5, False, True), ++ ("http://test/seg-6.mp4", 6, False, True), ++ ("http://test/seg-7.mp4", 7, False, True), ++ ("http://test/seg-8.mp4", 8, False, True), ++ ("http://test/seg-9.mp4", 9, False, True), ++ ("http://test/seg-10.mp4", 10, False, True), ++ ("http://test/seg-11.mp4", 11, False, True), ++ ("http://test/seg-12.mp4", 12, False, True), ++ ("http://test/seg-13.mp4", 13, False, True), ++ ("http://test/seg-14.mp4", 14, False, True), ++ ("http://test/seg-15.mp4", 15, False, True), ++ ("http://test/seg-16.mp4", 16, False, True), ++ ("http://test/seg-17.mp4", 17, False, True), ++ ] ++ ++ ++ with xml("dash/test_segment_list_p2.mpd") as mpd_xml_p2: ++ mpd_p2 = MPD(mpd_xml_p2, base_url=mpd_p1.base_url, url=mpd_p1.url, timelines=mpd_p1.timelines) ++ rep_p2 = mpd_p2.periods[0].adaptationSets[0].representations[0] ++ iter_p2 = rep_p2.segments(init=False) ++ segments_p2 = [(seg.uri, seg.num, seg.init, seg.content) for seg in iter_p2] ++ ++ ++ assert segments_p2 == [ ++ ("http://test/seg-18.mp4", 18, False, True), ++ ("http://test/seg-19.mp4", 19, False, True), ++ ] ++ ++ def test_segment_list_reload_no_new_segments(self): ++ """When the manifest is reloaded with no new SegmentURLs, no segments should be yielded.""" ++ with xml("dash/test_segment_list_p1.mpd") as mpd_xml_p1: ++ mpd_p1 = MPD(mpd_xml_p1, base_url="http://test/", url="http://test/manifest.mpd") ++ rep_p1 = mpd_p1.periods[0].adaptationSets[0].representations[0] ++ ++ list(rep_p1.segments()) ++ ++ ++ with xml("dash/test_segment_list_p1.mpd") as mpd_xml_p1b: ++ mpd_p1b = MPD(mpd_xml_p1b, base_url=mpd_p1.base_url, url=mpd_p1.url, timelines=mpd_p1.timelines) ++ rep_p1b = mpd_p1b.periods[0].adaptationSets[0].representations[0] ++ segments_after_reload = list(rep_p1b.segments(init=False)) ++ ++ assert segments_after_reload == [] ++ ++ def test_segment_list_static_unchanged(self): ++ """Preservation: static SegmentList default invocation still yields init + all segments.""" ++ with xml("dash/test_segment_list.mpd") as mpd_xml: ++ mpd = MPD(mpd_xml, base_url="http://test/", url="http://test/manifest.mpd") ++ ++ segments = list(mpd.periods[0].adaptationSets[0].representations[0].segments()) ++ uris = [seg.uri for seg in segments] ++ ++ assert uris == [ ++ "http://test/chunk_ctvideo_ridp0va0br4332748_cinit_mpd.m4s", ++ "http://test/chunk_ctvideo_ridp0va0br4332748_cn1_mpd.m4s", ++ "http://test/chunk_ctvideo_ridp0va0br4332748_cn2_mpd.m4s", ++ "http://test/chunk_ctvideo_ridp0va0br4332748_cn3_mpd.m4s", ++ "http://test/chunk_ctvideo_ridp0va0br4332748_cn4_mpd.m4s", ++ "http://test/chunk_ctvideo_ridp0va0br4332748_cn5_mpd.m4s", ++ "http://test/chunk_ctvideo_ridp0va0br4332748_cn6_mpd.m4s", ++ "http://test/chunk_ctvideo_ridp0va0br4332748_cn7_mpd.m4s", ++ "http://test/chunk_ctvideo_ridp0va0br4332748_cn8_mpd.m4s", ++ "http://test/chunk_ctvideo_ridp0va0br4332748_cn9_mpd.m4s", ++ ] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest -rA tests/stream/dash/test_manifest.py::TestMPDParser::test_segment_list_dynamic_reload_yields_only_new_segments tests/stream/dash/test_manifest.py::TestMPDParser::test_segment_list_reload_no_new_segments tests/stream/dash/test_manifest.py::TestMPDParser::test_segment_list_static_unchanged ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002757/tests/test.sh b/tasks/format-code-task-002757/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b238407adbe23427dfccc97da1ebfcd48bbbe094 --- /dev/null +++ b/tasks/format-code-task-002757/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/resources/dash/test_segment_list_p1.mpd +tests/resources/dash/test_segment_list_p2.mpd +tests/stream/dash/test_manifest.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-002757/tests/test_command.sh b/tasks/format-code-task-002757/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002757/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-002766/environment/Dockerfile b/tasks/format-code-task-002766/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..552b1a1bea0aa499358264e42d9ce2db9eb9cd2f --- /dev/null +++ b/tasks/format-code-task-002766/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:9fc82f659f790ad51e251620aa8ced16776e777f0349a06d2d90226dfa1ffb3a diff --git a/tasks/format-code-task-002766/environment/setup/files/blocklist b/tasks/format-code-task-002766/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002766/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-002766/environment/setup/setup.sh b/tasks/format-code-task-002766/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002766/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-002766/tests/test.patch b/tasks/format-code-task-002766/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b0c35ccfd8b3cbc801ebe19076e0e34066962dee --- /dev/null +++ b/tasks/format-code-task-002766/tests/test.patch @@ -0,0 +1,75 @@ +diff --git a/lib/rules/property-no-vendor-prefix/__tests__/index.js b/lib/rules/property-no-vendor-prefix/__tests__/index.js +index b375f1b4a3..15d8d6dcba 100644 +--- a/lib/rules/property-no-vendor-prefix/__tests__/index.js ++++ b/lib/rules/property-no-vendor-prefix/__tests__/index.js +@@ -100,3 +100,49 @@ testRule(rule, { + } + ] + }); ++ ++testRule(rule, { ++ ruleName, ++ config: [ ++ true, ++ { ignoreProperties: ["transform", "columns", "/^animation-/i"] } ++ ], ++ ++ accept: [ ++ { ++ code: "a { -webkit-transform: scale(1); }" ++ }, ++ { ++ code: "a { -moz-columns: 2; }" ++ }, ++ { ++ code: "a { -webkit-animation-delay: 0.5s; }" ++ }, ++ { ++ code: "a { -webkit-ANIMATION-DeLaY: 0.5s; }" ++ }, ++ { ++ code: "a { width: 320px; }" ++ } ++ ], ++ reject: [ ++ { ++ code: "a { -webkit-border-radius: 10px; }", ++ message: messages.rejected("-webkit-border-radius"), ++ line: 1, ++ column: 5 ++ }, ++ { ++ code: "a { -moz-background-size: cover; }", ++ message: messages.rejected("-moz-background-size"), ++ line: 1, ++ column: 5 ++ }, ++ { ++ code: "a { -WEBKIT-tranSFoRM: translateY(-50%); }", ++ message: messages.rejected("-WEBKIT-tranSFoRM"), ++ line: 1, ++ column: 5 ++ } ++ ] ++}); +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+3RsW7DIBAGYM95ipu62eacON76KsgOVCXCYAGOXKkPX+qhrSq1WRJFaf9vAelO ++cPBXw2ysktqd6uJaRNa17bpm39d1z23D3ImuEbmPeS+4oPZqE30xx9QHoiJ4n37rO1e/U9Vn/knH ++JA9+HHunqvh8uTvO5c+77iN/Fk3Of7fnbUHiciP87J/nf1C0Bj9otXHTSMbl/7CWmscHpldKvbFU ++bnNpoWNuI2uGOsxWx3oKftIhvZTOlyftlA/lFPSTWWop30+MUtbGKb1Ux7i59TMBAAAAAAAAAAAA ++AAAAAAAAAP6kN98i9DAAKAAA +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-002766/tests/test.sh b/tasks/format-code-task-002766/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..40fee903f9de9985d10ba080a7ce2cbe7fbfdaed --- /dev/null +++ b/tasks/format-code-task-002766/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' +lib/rules/property-no-vendor-prefix/__tests__/index.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-002766/tests/test_command.sh b/tasks/format-code-task-002766/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002766/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-002768/environment/Dockerfile b/tasks/format-code-task-002768/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8e9316262ccf0306b8fb3a4995cd4c43e15810f5 --- /dev/null +++ b/tasks/format-code-task-002768/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:3f99b1136d83a0c56be5bcea22419aecffc446ff8ddae2ec70a9eefb5d22f64d diff --git a/tasks/format-code-task-002768/environment/setup/files/blocklist b/tasks/format-code-task-002768/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002768/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-002768/environment/setup/setup.sh b/tasks/format-code-task-002768/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002768/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-002768/tests/test.patch b/tasks/format-code-task-002768/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1b9df8e9ebb2abf8ea7afbb99430112e5680b42e --- /dev/null +++ b/tasks/format-code-task-002768/tests/test.patch @@ -0,0 +1,74 @@ +diff --git a/lib/rules/max-line-length/__tests__/index.js b/lib/rules/max-line-length/__tests__/index.js +index 88de79635..c5ee7a502 100644 +--- a/lib/rules/max-line-length/__tests__/index.js ++++ b/lib/rules/max-line-length/__tests__/index.js +@@ -499,3 +499,47 @@ testRule(rule, { + } + ] + }); ++ ++testRule(rule, { ++ ruleName, ++ config: [20], ++ ++ accept: [ ++ { ++ code: ++ "a {\n background: url(\n 'something something something'\n );\n}", ++ description: ++ "multi-line url() with quoted content containing spaces (issue case)" ++ }, ++ { ++ code: ++ "a {\n background-image: url(\n \"data:image/svg+xml;utf8,\"\n );\n}", ++ description: "multi-line url() with svg data URI (issue case)" ++ }, ++ { ++ code: ++ "a {\n background: URL(\n 'something something something'\n );\n}", ++ description: "multi-line URL() uppercase should be recognised" ++ } ++ ], ++ ++ reject: [ ++ { ++ code: ++ "a {\n background: url(\n 'short'\n );\n color: aaaaaaaaa bbbbbbbbb cccccccc;\n}", ++ message: messages.expected(20), ++ description: ++ "long non-url line after a multi-line url() should still be flagged", ++ line: 5, ++ column: 38 ++ }, ++ { ++ code: "/* url( */\na { color: aaa bbbb cccc ddddd; }", ++ message: messages.expected(20), ++ description: ++ "literal text 'url(' inside a comment must not silence long-line warnings on later lines", ++ line: 2, ++ column: 33 ++ } ++ ] ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..71f4b6312 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest lib/rules/max-line-length"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx jest lib/rules/max-line-length ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002768/tests/test.sh b/tasks/format-code-task-002768/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3734508b5c086053c74d26372673d4f54c3e5f43 --- /dev/null +++ b/tasks/format-code-task-002768/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' +lib/rules/max-line-length/__tests__/index.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-002768/tests/test_command.sh b/tasks/format-code-task-002768/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002768/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-002792/environment/Dockerfile b/tasks/format-code-task-002792/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..de2d58c2bb0a86fa2afb111b401ff2ce1cfd075c --- /dev/null +++ b/tasks/format-code-task-002792/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:256791984a181fa850a3834bf4e9966495c54cc6dfcad529ee27183bd8bb2c6a diff --git a/tasks/format-code-task-002792/environment/setup/files/blocklist b/tasks/format-code-task-002792/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002792/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-002792/environment/setup/setup.sh b/tasks/format-code-task-002792/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002792/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-002792/tests/test.patch b/tasks/format-code-task-002792/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..68479bb6d6013ed6daec739279313e69325459f0 --- /dev/null +++ b/tasks/format-code-task-002792/tests/test.patch @@ -0,0 +1,643 @@ +diff --git a/usercase-test-coderl/fixtures/nested_input.js b/usercase-test-coderl/fixtures/nested_input.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/nested_input.js +@@ -0,0 +1,1 @@ ++function outer(a){ var y = a; return function inner(b){ return y + b; }; } +diff --git a/usercase-test-coderl/parser_entries.test.js b/usercase-test-coderl/parser_entries.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/parser_entries.test.js +@@ -0,0 +1,613 @@ ++ ++ ++ ++ ++ ++const assert = require('assert'); ++const childProcess = require('child_process'); ++const fs = require('fs'); ++const net = require('net'); ++const os = require('os'); ++const path = require('path'); ++const vm = require('vm'); ++ ++const REPO = '/workspace/repo'; ++const FIXTURES = '/workspace/repo/usercase-test-coderl/fixtures'; ++ ++const deepStrictEqual = assert.deepStrictEqual.bind(assert); ++function jsonValue(value) { ++ return JSON.parse(JSON.stringify(value)); ++} ++assert.deepStrictEqual = function (actual, expected, message) { ++ return deepStrictEqual(jsonValue(actual), jsonValue(expected), message); ++}; ++ ++function loadTachyonParser() { ++ const context = { ++ Error: Error, ++ config: { verbosity: 0 }, ++ }; ++ ++ context.print = function (value) { ++ process.stdout.write(String(value) + '\n'); ++ }; ++ context.readFile = function (fileName) { ++ return fs.readFileSync(fileName, 'utf8'); ++ }; ++ context.global = context; ++ ++ vm.createContext(context); ++ ++ [ ++ 'source/utility/debug.js', ++ 'source/utility/strings.js', ++ 'source/utility/iterators.js', ++ 'source/utility/arrays.js', ++ 'source/utility/hashmap.js', ++ 'source/utility/num.js', ++ 'source/utility/log.js', ++ 'source/parser/scanner.js', ++ 'source/parser/parser.js', ++ ++ 'source/parser/ast-passes.js', ++ 'source/parser/pp.js', ++ 'source/compiler/params.js', ++ 'source/parser/misc.js', ++ ].forEach((relPath) => { ++ vm.runInContext( ++ fs.readFileSync(path.join(REPO, relPath), 'utf8'), ++ context, ++ { filename: relPath } ++ ); ++ }); ++ ++ return context; ++} ++ ++const tachyon = loadTachyonParser(); ++ ++function makeParams(options) { ++ options = options || {}; ++ const params = Object.create(tachyon.CompParams.prototype); ++ params.parserWarnings = options.parserWarnings === true; ++ params.debugTrace = options.debugTrace === true; ++ params.printAST = options.printAST === true; ++ return params; ++} ++ ++function locOf(node) { ++ return node && node.loc ? node.loc.to_string() : null; ++} ++ ++function idName(id) { ++ if (id === null || id === undefined) ++ return null; ++ ++ if (id.id !== undefined) ++ return idName(id.id); ++ ++ if (id.value !== undefined) ++ return id.value; ++ ++ return String(id); ++} ++ ++function varMapSummary(vars) { ++ if (!vars) ++ return {}; ++ ++ const out = {}; ++ Object.keys(vars).sort().forEach((name) => { ++ const variable = vars[name]; ++ out[name] = { ++ id: idName(variable), ++ isParam: variable.is_param, ++ scope: variable.scope && variable.scope.constructor ++ ? variable.scope.constructor.name ++ : null, ++ loc: variable.id && variable.id.loc ? variable.id.loc.to_string() : null, ++ }; ++ }); ++ return out; ++} ++ ++function scopeKeys(vars) { ++ return vars ? Object.keys(vars).sort() : []; ++} ++ ++function functionHead(node) { ++ if (node instanceof tachyon.FunctionDeclaration) { ++ return { ++ type: 'FunctionDeclaration', ++ loc: locOf(node), ++ id: idName(node.id), ++ }; ++ } ++ ++ if (node instanceof tachyon.FunctionExpr) { ++ return { ++ type: 'FunctionExpr', ++ loc: locOf(node), ++ id: idName(node.id), ++ params: node.params.map((param) => idName(param)), ++ }; ++ } ++ ++ return { ++ type: node && node.constructor && node.constructor.name ++ ? node.constructor.name ++ : typeof node, ++ loc: locOf(node), ++ }; ++} ++ ++function summarizeAst(node) { ++ if (node === null || node === undefined) ++ return null; ++ ++ if (node instanceof tachyon.Program) { ++ return { ++ type: 'Program', ++ loc: locOf(node), ++ vars: varMapSummary(node.vars), ++ freeVars: varMapSummary(node.free_vars), ++ funcs: (node.funcs || []).map((fn) => functionHead(fn)), ++ usesArguments: node.usesArguments, ++ usesEval: node.usesEval, ++ block: summarizeAst(node.block), ++ }; ++ } ++ ++ if (node instanceof tachyon.BlockStatement) { ++ return { ++ type: 'BlockStatement', ++ loc: locOf(node), ++ statements: node.statements.map((statement) => summarizeAst(statement)), ++ }; ++ } ++ ++ if (node instanceof tachyon.FunctionDeclaration) { ++ return { ++ type: 'FunctionDeclaration', ++ loc: locOf(node), ++ id: idName(node.id), ++ funct: summarizeAst(node.funct), ++ }; ++ } ++ ++ if (node instanceof tachyon.FunctionExpr) { ++ return { ++ type: 'FunctionExpr', ++ loc: locOf(node), ++ id: idName(node.id), ++ params: node.params.map((param) => idName(param)), ++ vars: varMapSummary(node.vars), ++ freeVars: varMapSummary(node.free_vars), ++ closVars: varMapSummary(node.clos_vars), ++ escVars: varMapSummary(node.esc_vars), ++ funcs: (node.funcs || []).map((fn) => functionHead(fn)), ++ usesArguments: node.usesArguments, ++ usesEval: node.usesEval, ++ body: node.body.map((statement) => summarizeAst(statement)), ++ }; ++ } ++ ++ if (node instanceof tachyon.ExprStatement) { ++ return { ++ type: 'ExprStatement', ++ loc: locOf(node), ++ expr: summarizeAst(node.expr), ++ }; ++ } ++ ++ if (node instanceof tachyon.ReturnStatement) { ++ return { ++ type: 'ReturnStatement', ++ loc: locOf(node), ++ expr: summarizeAst(node.expr), ++ }; ++ } ++ ++ if (node instanceof tachyon.IfStatement) { ++ return { ++ type: 'IfStatement', ++ loc: locOf(node), ++ expr: summarizeAst(node.expr), ++ statements: node.statements.map((statement) => summarizeAst(statement)), ++ }; ++ } ++ ++ if (node instanceof tachyon.OpExpr) { ++ return { ++ type: 'OpExpr', ++ loc: locOf(node), ++ op: node.op, ++ exprs: node.exprs.map((expr) => summarizeAst(expr)), ++ }; ++ } ++ ++ if (node instanceof tachyon.CallExpr) { ++ return { ++ type: 'CallExpr', ++ loc: locOf(node), ++ fn: summarizeAst(node.fn), ++ args: node.args.map((arg) => summarizeAst(arg)), ++ }; ++ } ++ ++ if (node instanceof tachyon.Ref) { ++ return { ++ type: 'Ref', ++ loc: locOf(node), ++ name: idName(node.id), ++ scope: node.id && node.id.scope && node.id.scope.constructor ++ ? node.id.scope.constructor.name ++ : null, ++ }; ++ } ++ ++ if (node instanceof tachyon.Literal) { ++ return { ++ type: 'Literal', ++ loc: locOf(node), ++ value: node.value, ++ valueType: typeof node.value, ++ }; ++ } ++ ++ return { ++ type: node.constructor && node.constructor.name ++ ? node.constructor.name ++ : typeof node, ++ loc: locOf(node), ++ }; ++} ++ ++function summarizeDebugTraceProgram(program) { ++ const topLevelHeads = program.block.statements.map((statement) => { ++ if (statement instanceof tachyon.FunctionDeclaration) ++ return ['FunctionDeclaration', idName(statement.id)]; ++ ++ if ( ++ statement instanceof tachyon.ExprStatement && ++ statement.expr instanceof tachyon.CallExpr ++ ) { ++ return ['ExprStatement', idName(statement.expr.fn.id)]; ++ } ++ ++ return [ ++ statement.constructor && statement.constructor.name ++ ? statement.constructor.name ++ : typeof statement, ++ null, ++ ]; ++ }); ++ ++ const userFunction = program.block.statements.filter((statement) => { ++ return statement instanceof tachyon.FunctionDeclaration && idName(statement.id) === 'f'; ++ })[0]; ++ ++ return { ++ type: 'Program', ++ loc: locOf(program), ++ varsSubset: [ ++ 'f', ++ 'profile$end_of_program', ++ 'profile$enter', ++ 'profile$return0', ++ 'profile$return1', ++ ].filter((name) => program.vars[name] !== undefined), ++ freeVarsSubset: ['arguments'].filter((name) => program.free_vars[name] !== undefined), ++ topLevelCount: topLevelHeads.length, ++ finalTopLevelHeads: topLevelHeads.slice(-2), ++ userFunctionBody: userFunction.funct.body.map((statement) => summarizeAst(statement)), ++ }; ++} ++ ++function summarizeNestedFileProgram(program) { ++ const outerDecl = program.block.statements[0]; ++ const outer = outerDecl.funct; ++ const assignment = outer.body[0].expr; ++ const inner = outer.body[1].expr; ++ const innerReturn = inner.body[0].expr; ++ ++ return { ++ type: 'Program', ++ loc: locOf(program), ++ programVars: scopeKeys(program.vars), ++ programFuncs: program.funcs.map((fn) => functionHead(fn)), ++ outer: { ++ id: idName(outerDecl.id), ++ params: outer.params.map((param) => idName(param)), ++ vars: scopeKeys(outer.vars), ++ freeVars: scopeKeys(outer.free_vars), ++ closVars: scopeKeys(outer.clos_vars), ++ escVars: scopeKeys(outer.esc_vars), ++ funcs: outer.funcs.map((fn) => functionHead(fn)), ++ firstAssignment: { ++ loc: locOf(assignment), ++ op: assignment.op, ++ left: summarizeAst(assignment.exprs[0]), ++ right: summarizeAst(assignment.exprs[1]), ++ }, ++ }, ++ inner: { ++ id: idName(inner.id), ++ params: inner.params.map((param) => idName(param)), ++ vars: scopeKeys(inner.vars), ++ freeVars: scopeKeys(inner.free_vars), ++ closVars: scopeKeys(inner.clos_vars), ++ escVars: scopeKeys(inner.esc_vars), ++ returnExpr: { ++ loc: locOf(innerReturn), ++ op: innerReturn.op, ++ exprs: innerReturn.exprs.map((expr) => summarizeAst(expr)), ++ }, ++ }, ++ }; ++} ++ ++function capturePrint(callback) { ++ const originalPrint = tachyon.print; ++ const lines = []; ++ tachyon.print = function (value) { ++ lines.push(String(value)); ++ }; ++ ++ try { ++ const result = callback(); ++ return { result: result, output: lines.join('\n') + (lines.length ? '\n' : '') }; ++ } finally { ++ tachyon.print = originalPrint; ++ } ++} ++ ++function renderPrettyAst(program) { ++ const originalPrint = tachyon.print; ++ const lines = []; ++ tachyon.print = function (value) { ++ lines.push(String(value)); ++ }; ++ ++ try { ++ tachyon.pp(program); ++ return lines.join('\n') + (lines.length ? '\n' : ''); ++ } finally { ++ tachyon.print = originalPrint; ++ } ++} ++ ++function assertThrowsNormalAssertionError(callback) { ++ ++ assert.throws( ++ callback, ++ (err) => err instanceof Error ++ ); ++} ++ ++function test(name, callback) { ++ callback(); ++ process.stdout.write('ok - ' + name + '\n'); ++} ++ ++if (process.argv[2] === '--fresh-process-snapshot') { ++ process.stdout.write(JSON.stringify( ++ summarizeAst(tachyon.parse_src_str('var x = 1;', makeParams())) ++ )); ++ process.exit(0); ++} ++ ++test('parse_src_str_var_statement', function () { ++ ++ ++ ++ ++ const actual = summarizeAst(tachyon.parse_src_str('var x = 1;', makeParams())); ++ const expected = {"type":"Program","loc":"\"\"@1.1-1.11","vars":{"x":{"id":"x","isParam":false,"scope":"Program","loc":"\"\"@1.5-1.6"}},"freeVars":{},"funcs":[],"usesArguments":false,"usesEval":false,"block":{"type":"BlockStatement","loc":"\"\"@1.1-1.11","statements":[{"type":"ExprStatement","loc":"\"\"@1.5-1.10","expr":{"type":"OpExpr","loc":"\"\"@1.5-1.10","op":"x = y","exprs":[{"type":"Ref","loc":"\"\"@1.5-1.6","name":"x","scope":"Program"},{"type":"Literal","loc":"\"\"@1.9-1.10","value":1,"valueType":"number"}]}}]}}; ++ assert.deepStrictEqual(actual, expected); ++}); ++ ++test('parse_src_str_matches_string_input_port', function () { ++ ++ ++ ++ ++ const expected = {"type":"Program","loc":"\"\"@1.1-1.11","vars":{"x":{"id":"x","isParam":false,"scope":"Program","loc":"\"\"@1.5-1.6"}},"freeVars":{},"funcs":[],"usesArguments":false,"usesEval":false,"block":{"type":"BlockStatement","loc":"\"\"@1.1-1.11","statements":[{"type":"ExprStatement","loc":"\"\"@1.5-1.10","expr":{"type":"OpExpr","loc":"\"\"@1.5-1.10","op":"x = y","exprs":[{"type":"Ref","loc":"\"\"@1.5-1.6","name":"x","scope":"Program"},{"type":"Literal","loc":"\"\"@1.9-1.10","value":1,"valueType":"number"}]}}]}}; ++ assert.deepStrictEqual( ++ summarizeAst(tachyon.parse_src_str('var x = 1;', makeParams())), ++ expected ++ ); ++ assert.deepStrictEqual( ++ summarizeAst(tachyon.parse_src_port(new tachyon.String_input_port('var x = 1;'), makeParams())), ++ expected ++ ); ++}); ++ ++test('parse_src_str_empty_program', function () { ++ ++ ++ ++ ++ const actual = summarizeAst(tachyon.parse_src_str('', makeParams())); ++ const expected = {"type":"Program","loc":"\"\"@1.1-1.1","vars":{},"freeVars":{},"funcs":[],"usesArguments":false,"usesEval":false,"block":{"type":"BlockStatement","loc":"\"\"@1.1-1.1","statements":[]}}; ++ assert.deepStrictEqual(actual, expected); ++}); ++ ++test('parse_src_file_nested_function_scope_metadata', function () { ++ ++ ++ ++ ++ const inputPath = path.join(FIXTURES, 'nested_input.js'); ++ const originalReadFile = tachyon.readFile; ++ const readPaths = []; ++ ++ tachyon.readFile = function (fileName) { ++ readPaths.push(fileName); ++ return originalReadFile(fileName); ++ }; ++ ++ try { ++ const actual = summarizeNestedFileProgram(tachyon.parse_src_file(inputPath, makeParams())); ++ const expected = {"type":"Program","loc":"\"/workspace/repo/usercase-test-coderl/fixtures/nested_input.js\"@1.1-1.75","programVars":["outer"],"programFuncs":[{"type":"FunctionDeclaration","loc":"\"/workspace/repo/usercase-test-coderl/fixtures/nested_input.js\"@1.1-1.75","id":"outer"}],"outer":{"id":"outer","params":["a"],"vars":["a","y"],"freeVars":[],"closVars":[],"escVars":["y"],"funcs":[{"type":"FunctionExpr","loc":"\"/workspace/repo/usercase-test-coderl/fixtures/nested_input.js\"@1.38-1.72","id":"inner","params":["b"]}],"firstAssignment":{"loc":"\"/workspace/repo/usercase-test-coderl/fixtures/nested_input.js\"@1.24-1.29","op":"x = y","left":{"type":"Ref","loc":"\"/workspace/repo/usercase-test-coderl/fixtures/nested_input.js\"@1.24-1.25","name":"y","scope":"FunctionExpr"},"right":{"type":"Ref","loc":"\"/workspace/repo/usercase-test-coderl/fixtures/nested_input.js\"@1.28-1.29","name":"a","scope":"FunctionExpr"}}},"inner":{"id":"inner","params":["b"],"vars":["b","inner"],"freeVars":["y"],"closVars":["y"],"escVars":[],"returnExpr":{"loc":"\"/workspace/repo/usercase-test-coderl/fixtures/nested_input.js\"@1.64-1.69","op":"x + y","exprs":[{"type":"Ref","loc":"\"/workspace/repo/usercase-test-coderl/fixtures/nested_input.js\"@1.64-1.65","name":"y","scope":"FunctionExpr"},{"type":"Ref","loc":"\"/workspace/repo/usercase-test-coderl/fixtures/nested_input.js\"@1.68-1.69","name":"b","scope":"FunctionExpr"}]}}}; ++ assert.deepStrictEqual(actual, expected); ++ assert.deepStrictEqual(readPaths, [inputPath]); ++ } finally { ++ tachyon.readFile = originalReadFile; ++ } ++}); ++ ++test('parse_src_port_if_statement', function () { ++ ++ ++ ++ ++ const port = new tachyon.String_input_port('if (flag) flag = false; else flag = true;'); ++ const actual = summarizeAst(tachyon.parse_src_port(port, makeParams())); ++ const expected = {"type":"Program","loc":"\"\"@1.1-1.42","vars":{},"freeVars":{"flag":{"id":"flag","isParam":false,"scope":"Program","loc":"\"\"@1.5-1.9"}},"funcs":[],"usesArguments":false,"usesEval":false,"block":{"type":"BlockStatement","loc":"\"\"@1.1-1.42","statements":[{"type":"IfStatement","loc":"\"\"@1.1-1.42","expr":{"type":"Ref","loc":"\"\"@1.5-1.9","name":"flag","scope":"Program"},"statements":[{"type":"ExprStatement","loc":"\"\"@1.11-1.24","expr":{"type":"OpExpr","loc":"\"\"@1.11-1.23","op":"x = y","exprs":[{"type":"Ref","loc":"\"\"@1.11-1.15","name":"flag","scope":"Program"},{"type":"Literal","loc":"\"\"@1.18-1.23","value":false,"valueType":"boolean"}]}},{"type":"ExprStatement","loc":"\"\"@1.30-1.42","expr":{"type":"OpExpr","loc":"\"\"@1.30-1.41","op":"x = y","exprs":[{"type":"Ref","loc":"\"\"@1.30-1.34","name":"flag","scope":"Program"},{"type":"Literal","loc":"\"\"@1.37-1.41","value":true,"valueType":"boolean"}]}}]}]}}; ++ assert.deepStrictEqual(actual, expected); ++}); ++ ++test('parse_src_port_uses_debug_trace_for_normalization', function () { ++ ++ ++ ++ ++ const port = new tachyon.String_input_port('function f(a){ return a; }'); ++ const actual = summarizeDebugTraceProgram( ++ tachyon.parse_src_port(port, makeParams({ debugTrace: true })) ++ ); ++ const expected = {"type":"Program","loc":"\"\"@1.1-1.27","varsSubset":["f","profile$end_of_program","profile$enter","profile$return0","profile$return1"],"freeVarsSubset":["arguments"],"topLevelCount":84,"finalTopLevelHeads":[["FunctionDeclaration","f"],["ExprStatement","profile$end_of_program"]],"userFunctionBody":[{"type":"ExprStatement","loc":"\"\"@1.1-1.27","expr":{"type":"CallExpr","loc":"\"\"@1.1-1.27","fn":{"type":"Ref","loc":"\"\"@1.1-1.27","name":"profile$enter","scope":"Program"},"args":[{"type":"Literal","loc":"\"\"@1.1-1.27","value":"\"\"@1.1-1.27","valueType":"string"},{"type":"Literal","loc":"\"\"@1.1-1.27","value":"f(a)","valueType":"string"},{"type":"Ref","loc":"\"\"@1.1-1.27","name":"arguments","scope":"Program"}]}},{"type":"ReturnStatement","loc":"\"\"@1.16-1.25","expr":{"type":"CallExpr","loc":"\"\"@1.16-1.25","fn":{"type":"Ref","loc":"\"\"@1.16-1.25","name":"profile$return1","scope":"Program"},"args":[{"type":"Literal","loc":"\"\"@1.16-1.25","value":"\"\"@1.16-1.25","valueType":"string"},{"type":"Ref","loc":"\"\"@1.23-1.24","name":"a","scope":"FunctionExpr"}]}},{"type":"ExprStatement","loc":"\"\"@1.1-1.27","expr":{"type":"CallExpr","loc":"\"\"@1.1-1.27","fn":{"type":"Ref","loc":"\"\"@1.1-1.27","name":"profile$return0","scope":"Program"},"args":[{"type":"Literal","loc":"\"\"@1.1-1.27","value":"\"\"@1.1-1.27","valueType":"string"}]}}]}; ++ assert.deepStrictEqual(actual, expected); ++}); ++ ++test('parse_src_port_prints_normalized_ast_when_requested', function () { ++ ++ ++ ++ ++ const capture = capturePrint(function () { ++ return tachyon.parse_src_port(new tachyon.String_input_port('var printed = 3;'), makeParams({ printAST: true })); ++ }); ++ assert.deepStrictEqual(summarizeAst(capture.result), {"type":"Program","loc":"\"\"@1.1-1.17","vars":{"printed":{"id":"printed","isParam":false,"scope":"Program","loc":"\"\"@1.5-1.12"}},"freeVars":{},"funcs":[],"usesArguments":false,"usesEval":false,"block":{"type":"BlockStatement","loc":"\"\"@1.1-1.17","statements":[{"type":"ExprStatement","loc":"\"\"@1.5-1.16","expr":{"type":"OpExpr","loc":"\"\"@1.5-1.16","op":"x = y","exprs":[{"type":"Ref","loc":"\"\"@1.5-1.12","name":"printed","scope":"Program"},{"type":"Literal","loc":"\"\"@1.15-1.16","value":3,"valueType":"number"}]}}]}}); ++ ++ assert.strictEqual(capture.output, renderPrettyAst(capture.result)); ++}); ++ ++test('parse_src_port_uses_parser_warnings_flag', function () { ++ ++ ++ ++ ++ const originalVerbosity = tachyon.config.verbosity; ++ tachyon.config.verbosity = tachyon.log.WARN; ++ try { ++ const capture = capturePrint(function () { ++ return tachyon.parse_src_port(new tachyon.String_input_port('x == y;'), makeParams({ parserWarnings: true })); ++ }); ++ assert.deepStrictEqual(summarizeAst(capture.result), {"type":"Program","loc":"\"\"@1.1-1.8","vars":{},"freeVars":{"x":{"id":"x","isParam":false,"scope":"Program","loc":"\"\"@1.1-1.2"},"y":{"id":"y","isParam":false,"scope":"Program","loc":"\"\"@1.6-1.7"}},"funcs":[],"usesArguments":false,"usesEval":false,"block":{"type":"BlockStatement","loc":"\"\"@1.1-1.8","statements":[{"type":"ExprStatement","loc":"\"\"@1.1-1.8","expr":{"type":"OpExpr","loc":"\"\"@1.1-1.7","op":"x == y","exprs":[{"type":"Ref","loc":"\"\"@1.1-1.2","name":"x","scope":"Program"},{"type":"Ref","loc":"\"\"@1.6-1.7","name":"y","scope":"Program"}]}}]}}); ++ ++ assert.match(capture.output, /warning/i); ++ } finally { ++ tachyon.config.verbosity = originalVerbosity; ++ } ++}); ++ ++test('invalid_calls_raise_normal_assertion_errors', function () { ++ ++ ++ ++ ++ assertThrowsNormalAssertionError(function () { ++ tachyon.parse_src_file(undefined, makeParams()); ++ }); ++ assertThrowsNormalAssertionError(function () { ++ tachyon.parse_src_str(undefined, makeParams()); ++ }); ++ assertThrowsNormalAssertionError(function () { ++ tachyon.parse_src_port(new tachyon.String_input_port('var x = 1;'), {}); ++ }); ++}); ++ ++test('referential_transparency_same_input_same_output', function () { ++ const first = summarizeAst(tachyon.parse_src_str('var x = 1;', makeParams())); ++ const second = summarizeAst(tachyon.parse_src_str('var x = 1;', makeParams())); ++ assert.deepStrictEqual(first, second); ++}); ++ ++test('does_not_mutate_comp_params_input', function () { ++ const params = makeParams(); ++ const before = JSON.stringify({ ++ parserWarnings: params.parserWarnings, ++ debugTrace: params.debugTrace, ++ printAST: params.printAST, ++ }); ++ tachyon.parse_src_str('var x = 1;', params); ++ const after = JSON.stringify({ ++ parserWarnings: params.parserWarnings, ++ debugTrace: params.debugTrace, ++ printAST: params.printAST, ++ }); ++ assert.strictEqual(after, before); ++}); ++ ++test('no_global_state_across_fresh_process', function () { ++ const inProcess = JSON.stringify(summarizeAst(tachyon.parse_src_str('var x = 1;', makeParams()))); ++ const freshProcess = childProcess.execFileSync( ++ process.execPath, ++ [__filename, '--fresh-process-snapshot'], ++ { encoding: 'utf8' } ++ ); ++ assert.strictEqual(freshProcess, inProcess); ++}); ++ ++test('parse_src_str_has_no_undeclared_file_or_network_side_effects', function () { ++ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tachyon-parser-')); ++ const originalCwd = process.cwd(); ++ const originalWriteFileSync = fs.writeFileSync; ++ const originalOpenSync = fs.openSync; ++ const originalSocket = net.Socket; ++ const writes = []; ++ let socketCreated = false; ++ ++ function snapshot(dir) { ++ return fs.readdirSync(dir).sort(); ++ } ++ ++ process.chdir(tmpDir); ++ const before = snapshot(tmpDir); ++ ++ fs.writeFileSync = function () { ++ writes.push(arguments[0]); ++ return originalWriteFileSync.apply(this, arguments); ++ }; ++ fs.openSync = function (fileName, flags) { ++ if (typeof flags === 'string' && /[wax+]/.test(flags)) ++ writes.push(fileName); ++ return originalOpenSync.apply(this, arguments); ++ }; ++ net.Socket = function () { ++ socketCreated = true; ++ throw new Error('network access is not declared for parse_src_str'); ++ }; ++ ++ try { ++ const capture = capturePrint(function () { ++ return tachyon.parse_src_str('var x = 1;', makeParams()); ++ }); ++ assert.deepStrictEqual( ++ summarizeAst(capture.result), ++ {"type":"Program","loc":"\"\"@1.1-1.11","vars":{"x":{"id":"x","isParam":false,"scope":"Program","loc":"\"\"@1.5-1.6"}},"freeVars":{},"funcs":[],"usesArguments":false,"usesEval":false,"block":{"type":"BlockStatement","loc":"\"\"@1.1-1.11","statements":[{"type":"ExprStatement","loc":"\"\"@1.5-1.10","expr":{"type":"OpExpr","loc":"\"\"@1.5-1.10","op":"x = y","exprs":[{"type":"Ref","loc":"\"\"@1.5-1.6","name":"x","scope":"Program"},{"type":"Literal","loc":"\"\"@1.9-1.10","value":1,"valueType":"number"}]}}]}} ++ ); ++ assert.strictEqual(capture.output, ''); ++ assert.deepStrictEqual(snapshot(tmpDir), before); ++ assert.deepStrictEqual(writes, []); ++ assert.strictEqual(socketCreated, false); ++ } finally { ++ fs.writeFileSync = originalWriteFileSync; ++ fs.openSync = originalOpenSync; ++ net.Socket = originalSocket; ++ process.chdir(originalCwd); ++ fs.rmSync(tmpDir, { recursive: true, force: true }); ++ } ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,14 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++exec node /workspace/repo/usercase-test-coderl/parser_entries.test.js diff --git a/tasks/format-code-task-002792/tests/test.sh b/tasks/format-code-task-002792/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..28ef830871b51f100a9906f14736807f2f14e75b --- /dev/null +++ b/tasks/format-code-task-002792/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/nested_input.js +usercase-test-coderl/parser_entries.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-002792/tests/test_command.sh b/tasks/format-code-task-002792/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002792/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-002795/environment/Dockerfile b/tasks/format-code-task-002795/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a73a85b300b634d61d63260658c2f8b0b01afeb3 --- /dev/null +++ b/tasks/format-code-task-002795/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:1f303cfc13ca6df40f7f0dacc3d26ea69def4cc2fb76e97b4c71e2f5b5017819 diff --git a/tasks/format-code-task-002795/environment/setup/files/blocklist b/tasks/format-code-task-002795/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002795/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-002795/environment/setup/setup.sh b/tasks/format-code-task-002795/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002795/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-002795/tests/test.patch b/tasks/format-code-task-002795/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c11b0d3d17270b511e823ba7b9bd30c3c8970fca --- /dev/null +++ b/tasks/format-code-task-002795/tests/test.patch @@ -0,0 +1,111 @@ +diff --git a/packages/tailwindcss/src/utilities.test.ts b/packages/tailwindcss/src/utilities.test.ts +index 55e22481..a025c282 100644 +--- a/packages/tailwindcss/src/utilities.test.ts ++++ b/packages/tailwindcss/src/utilities.test.ts +@@ -1,4 +1,6 @@ + import { expect, test } from 'vitest' ++import { buildDesignSystem } from './design-system' ++import { Theme } from './theme' + import { compileCss, run } from './test-utils/run' + + const css = String.raw +@@ -13066,3 +13068,77 @@ test('@container', () => { + ]), + ).toEqual('') + }) ++ ++test('negative col-start supports negative values (issue 13779)', () => { ++ ++ let output = run(['-col-start-1', '-col-start-4']) ++ expect(output).toContain('.-col-start-1') ++ expect(output).toContain('.-col-start-4') ++ expect(output).toContain('grid-column-start:') ++ ++ expect(output).toMatch(/grid-column-start:\s*(?:-1|calc\(1\s*\*\s*-1\))/) ++ expect(output).toMatch(/grid-column-start:\s*(?:-4|calc\(4\s*\*\s*-1\))/) ++}) ++ ++test('negative col-end supports negative values (issue 13779)', () => { ++ ++ let output = run(['-col-end-1', '-col-end-4']) ++ expect(output).toContain('.-col-end-1') ++ expect(output).toContain('.-col-end-4') ++ expect(output).toContain('grid-column-end:') ++ expect(output).toMatch(/grid-column-end:\s*(?:-1|calc\(1\s*\*\s*-1\))/) ++ expect(output).toMatch(/grid-column-end:\s*(?:-4|calc\(4\s*\*\s*-1\))/) ++}) ++ ++test('negative row-start supports negative values (issue 13779)', () => { ++ let output = run(['-row-start-1', '-row-start-3']) ++ expect(output).toContain('.-row-start-1') ++ expect(output).toContain('.-row-start-3') ++ expect(output).toContain('grid-row-start:') ++ expect(output).toMatch(/grid-row-start:\s*(?:-1|calc\(1\s*\*\s*-1\))/) ++ expect(output).toMatch(/grid-row-start:\s*(?:-3|calc\(3\s*\*\s*-1\))/) ++}) ++ ++test('negative row-end supports negative values (issue 13779)', () => { ++ let output = run(['-row-end-1', '-row-end-3']) ++ expect(output).toContain('.-row-end-1') ++ expect(output).toContain('.-row-end-3') ++ expect(output).toContain('grid-row-end:') ++ expect(output).toMatch(/grid-row-end:\s*(?:-1|calc\(1\s*\*\s*-1\))/) ++ expect(output).toMatch(/grid-row-end:\s*(?:-3|calc\(3\s*\*\s*-1\))/) ++}) ++ ++test('arbitrary col-end with negative literal still works (issue 13779 preservation)', () => { ++ ++ let output = run(['col-end-[-1]']) ++ expect(output).toContain('.col-end-\\[-1\\]') ++ expect(output).toContain('grid-column-end: -1') ++}) ++ ++test('positive col-start/col-end/row-start/row-end still produce CSS (issue 13779 preservation)', () => { ++ let output = run(['col-start-4', 'col-end-4', 'row-start-4', 'row-end-4']) ++ expect(output).toContain('grid-column-start: 4') ++ expect(output).toContain('grid-column-end: 4') ++ expect(output).toContain('grid-row-start: 4') ++ expect(output).toContain('grid-row-end: 4') ++}) ++ ++test('negative non-integer col/row values still rejected (issue 13779)', () => { ++ ++ expect(run(['-col-start-1.5', '-col-end-1.5', '-row-start-1.5', '-row-end-1.5'])).toEqual('') ++ expect(run(['-col-start-unknown', '-col-end-unknown'])).toEqual('') ++}) ++ ++test('negative col/row classes appear in intellisense class list (issue 13779)', () => { ++ let theme = new Theme() ++ let design = buildDesignSystem(theme) ++ let classList = design.getClassList() ++ let classNames = classList.map(([name]) => name) ++ ++ for (let n of [1, 2, 12, 13]) { ++ expect(classNames).toContain(`-col-start-${n}`) ++ expect(classNames).toContain(`-col-end-${n}`) ++ expect(classNames).toContain(`-row-start-${n}`) ++ expect(classNames).toContain(`-row-end-${n}`) ++ } ++}) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..5744bbc9 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx vitest run packages/tailwindcss/src/utilities.test.ts -t \"issue 13779\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx vitest run packages/tailwindcss/src/utilities.test.ts -t "issue 13779" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002795/tests/test.sh b/tasks/format-code-task-002795/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3123e87652720dba987507d226ad931f6b5d90da --- /dev/null +++ b/tasks/format-code-task-002795/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/tailwindcss/src/utilities.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-002795/tests/test_command.sh b/tasks/format-code-task-002795/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002795/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-002846/environment/Dockerfile b/tasks/format-code-task-002846/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..785c8441b86dcee2fe88c220e7ea64845aaaecd7 --- /dev/null +++ b/tasks/format-code-task-002846/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:dcb25112bc16401cf11b7a30d76f245d9d8d5762c0ffd931396accf8add949b9 diff --git a/tasks/format-code-task-002846/environment/setup/files/blocklist b/tasks/format-code-task-002846/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002846/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-002846/environment/setup/setup.sh b/tasks/format-code-task-002846/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002846/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-002846/tests/test.patch b/tasks/format-code-task-002846/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0e27cd06168e03fe5dee9a66d0d310b44b07f597 --- /dev/null +++ b/tasks/format-code-task-002846/tests/test.patch @@ -0,0 +1,199 @@ +diff --git a/src/test/java/net/kaczmarzyk/MultiLevelFetchJoinE2eTest.java b/src/test/java/net/kaczmarzyk/MultiLevelFetchJoinE2eTest.java +index 25857527..db2e85fe 100644 +--- a/src/test/java/net/kaczmarzyk/MultiLevelFetchJoinE2eTest.java ++++ b/src/test/java/net/kaczmarzyk/MultiLevelFetchJoinE2eTest.java +@@ -20,6 +20,7 @@ + import net.kaczmarzyk.spring.data.jpa.web.annotation.JoinFetch; + import net.kaczmarzyk.spring.data.jpa.web.annotation.Spec; + import net.kaczmarzyk.utils.interceptor.HibernateStatementInterceptor; ++import org.apache.commons.lang3.StringUtils; + import org.junit.After; + import org.junit.Before; + import org.junit.Test; +@@ -32,6 +33,11 @@ + + import javax.persistence.criteria.JoinType; + ++import java.util.Comparator; ++import java.util.List; ++import java.util.Set; ++import java.util.stream.Collectors; ++ + import static java.util.stream.Collectors.toList; + import static net.kaczmarzyk.spring.data.jpa.CustomerBuilder.customer; + import static net.kaczmarzyk.spring.data.jpa.ItemTagBuilder.itemTag; +@@ -79,6 +85,18 @@ public Object findAllWithoutFetchJoins( + .collect(toList()); + } + ++ @RequestMapping(value = "/findAllCustomersFetchOrdersWithTagsAndNotes") ++ @PostMapping ++ public Object findAllCustomersFetchOrdersWithTagsAndNotes( ++ @JoinFetch(paths = "orders", alias = "o") ++ @JoinFetch(paths = "o.tags") ++ @JoinFetch(paths = "o.note") ++ Specification spec) { ++ return customerRepo.findAll(spec, Sort.by("id")).stream() ++ .map(this::mapToCustomerWithOrdersWithTagsAndNotes) ++ .collect(toList()); ++ } ++ + private CustomerDto mapToCustomerDto(Customer customer) { + String tagOfFirstOrderedItem = customer.getOrders().stream() + .flatMap(order -> order.getTags().stream()) +@@ -91,6 +109,17 @@ private CustomerDto mapToCustomerDto(Customer customer) { + ); + } + ++ private CustomerWithOrdersWithTagsAndNotes mapToCustomerWithOrdersWithTagsAndNotes(Customer customer) { ++ return new CustomerWithOrdersWithTagsAndNotes( ++ customer.getFirstName(), ++ customer.getOrders().stream().map(order -> new OrdersWithTagsAndNotes( ++ order.getItemName(), ++ order.getTags().stream().map(ItemTag::getName).sorted(StringUtils::compare).collect(Collectors.joining(",")), ++ order.getNote().getTitle() ++ )).sorted((o1, o2) -> StringUtils.compare(o1.itemName, o2.itemName)).collect(Collectors.toList()) ++ ); ++ } ++ + class CustomerDto { + private String firstName; + private String tagOfFirstCustomerItem; +@@ -108,6 +137,48 @@ public String getTagOfFirstCustomerItem() { + return tagOfFirstCustomerItem; + } + } ++ ++ class OrdersWithTagsAndNotes { ++ private String itemName; ++ private String tags; ++ private String notes; ++ ++ public OrdersWithTagsAndNotes(String itemName, String tags, String notes) { ++ this.itemName = itemName; ++ this.tags = tags; ++ this.notes = notes; ++ } ++ ++ public String getItemName() { ++ return itemName; ++ } ++ ++ public String getTags() { ++ return tags; ++ } ++ ++ public String getNotes() { ++ return notes; ++ } ++ } ++ ++ class CustomerWithOrdersWithTagsAndNotes { ++ private String firstName; ++ private List orders; ++ ++ public CustomerWithOrdersWithTagsAndNotes(String firstName, List orders) { ++ this.firstName = firstName; ++ this.orders = orders; ++ } ++ ++ public String getFirstName() { ++ return firstName; ++ } ++ ++ public List getOrders() { ++ return orders; ++ } ++ } + } + + @Before +@@ -205,4 +276,50 @@ public void shouldFindAllCustomersWithoutUsingJoinFetches() throws Exception { + .hasSelectsFromSingleTableWithWhereClause(9); + } + ++ @Test ++ public void shouldFindCustomersWithFetchedOrderWithTagsAndNotes() throws Exception { ++ HibernateStatementInterceptor.clearInterceptedStatements(); ++ ++ mockMvc.perform(post("/multilevel-join-fetch/findAllCustomersFetchOrdersWithTagsAndNotes") ++ .param("tag", "#snacks")) ++ .andExpect(status().isOk()) ++ .andExpect(jsonPath("$").isArray()) ++ .andExpect(jsonPath("$[0].firstName").value("Homer")) ++ .andExpect(jsonPath("$[0].orders").isArray()) ++ ++ .andExpect(jsonPath("$[0].orders[0].itemName").value("Donuts")) ++ .andExpect(jsonPath("$[0].orders[0].tags").value("#homerApproved,#snacks")) ++ .andExpect(jsonPath("$[0].orders[0].notes").value("NoteDonuts")) ++ ++ .andExpect(jsonPath("$[0].orders[1].itemName").value("Duff Beer")) ++ .andExpect(jsonPath("$[0].orders[1].tags").value("#homerApproved,#snacks")) ++ .andExpect(jsonPath("$[0].orders[1].notes").value("NoteDuff Beer")) ++ ++ .andExpect(jsonPath("$[1].firstName").value("Marge")) ++ .andExpect(jsonPath("$[1].orders").isArray()) ++ .andExpect(jsonPath("$[1].orders[0].itemName").value("Apple")) ++ .andExpect(jsonPath("$[1].orders[0].tags").value("#fruits")) ++ .andExpect(jsonPath("$[1].orders[0].notes").value("NoteApple")) ++ ++ .andExpect(jsonPath("$[2].firstName").value("Bart")) ++ .andExpect(jsonPath("$[2].orders").isArray()) ++ .andExpect(jsonPath("$[2].orders[0].itemName").value("Pizza")) ++ .andExpect(jsonPath("$[2].orders[0].tags").value("#snacks")) ++ .andExpect(jsonPath("$[2].orders[0].notes").value("NotePizza")) ++ ++ .andExpect(jsonPath("$[3].firstName").value("Lisa")) ++ .andExpect(jsonPath("$[3].orders").isArray()) ++ .andExpect(jsonPath("$[3].orders[0].itemName").value("Jazz music disc")) ++ .andExpect(jsonPath("$[3].orders[0].tags").value("")) ++ .andExpect(jsonPath("$[3].orders[0].notes").value("NoteJazz music disc")) ++ ++ .andExpect(jsonPath("$[4].firstName").value("Maggie")) ++ ++ .andExpect(jsonPath("$[5]").doesNotExist()); ++ ++ assertThatInterceptedStatements() ++ .hasSelects(1); ++ } ++ ++ + } +diff --git a/src/test/java/net/kaczmarzyk/spring/data/jpa/Order.java b/src/test/java/net/kaczmarzyk/spring/data/jpa/Order.java +index 9f49eee4..9cd7c72b 100644 +--- a/src/test/java/net/kaczmarzyk/spring/data/jpa/Order.java ++++ b/src/test/java/net/kaczmarzyk/spring/data/jpa/Order.java +@@ -92,4 +92,12 @@ public OrderNote getNote() { + public void setNote(OrderNote note) { + this.note = note; + } ++ ++ public Long getId() { ++ return id; ++ } ++ ++ public String getItemName() { ++ return itemName; ++ } + } +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+3RT0/DIBgGcM79FGT30VJLe5onNdGoJ+8LKzSrozQpFOM+vbQHNSa6yxaz7Pld ++Xigvf5qHbcbWqLW2ISWnkkWVEHONftZ5zEWe5WXJBS9IxnmZXREqTvaib0bn5UApGfre/9V3aP1M ++sa/8vXZ+XfddJ61ibnu8Ow7lzyvxmX9RTPkXZV4Qmh3vCb+78PxrRefgN1olSoele2t9vaWvMkjK ++K5pfp/Frakdjki5YOrXS5c1UVgurPdvJet/JYf++Y0+j8e2jDtrc6XjGQ9/a21y/xNZF3NLI1tw3 ++z/00d6tGGqeT//55AAAAAAAAAAAAAAAAAAAAAIAz9wH9iveWACgAAA== +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-002846/tests/test.sh b/tasks/format-code-task-002846/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b445ea82079f22f2252b6023494807813aed101b --- /dev/null +++ b/tasks/format-code-task-002846/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/test/java/net/kaczmarzyk/MultiLevelFetchJoinE2eTest.java +src/test/java/net/kaczmarzyk/spring/data/jpa/Order.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-002846/tests/test_command.sh b/tasks/format-code-task-002846/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002846/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-002870/environment/Dockerfile b/tasks/format-code-task-002870/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bc8be12f648594e8bf6abd35cda618f6e058eb0d --- /dev/null +++ b/tasks/format-code-task-002870/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:1ec77d3991af822720ed95c37dd442bcda3edeaf58f0331c4a17eb5bb8365b54 diff --git a/tasks/format-code-task-002870/environment/setup/files/blocklist b/tasks/format-code-task-002870/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002870/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-002870/environment/setup/setup.sh b/tasks/format-code-task-002870/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002870/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-002870/tests/test.patch b/tasks/format-code-task-002870/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ee46a9ac855df63027971f83221ad1af4e94ee98 --- /dev/null +++ b/tasks/format-code-task-002870/tests/test.patch @@ -0,0 +1,465 @@ +diff --git a/usercase-test-coderl/test_dqn_stateful.py b/usercase-test-coderl/test_dqn_stateful.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_dqn_stateful.py +@@ -0,0 +1,430 @@ ++import haiku as hk ++import jax ++import jax.numpy as jnp ++import numpy as np ++from gym.spaces import Box, Discrete ++from numpy.testing import assert_allclose ++ ++from rljax.algorithm import DQN as ExportedDQN ++from rljax.algorithm.dqn import DQN ++ ++ ++if not hasattr(jax, "tree_multimap"): ++ ++ jax.tree_multimap = jax.tree_util.tree_map ++ ++ ++def _state_space(shape=(2,), low=-10.0, high=10.0): ++ return Box(low=low, high=high, shape=shape, dtype=np.float32) ++ ++ ++def _linear_q(s): ++ return hk.Linear( ++ 2, ++ w_init=hk.initializers.Constant(0.25), ++ b_init=hk.initializers.Constant(0.0), ++ name="linear_q", ++ )(s) ++ ++ ++def _biased_q(s): ++ w = hk.get_parameter( ++ "w", ++ shape=(2, 2), ++ init=lambda shape, dtype: jnp.array([[0.0, 0.0], [0.0, 0.0]], dtype), ++ ) ++ b = hk.get_parameter( ++ "b", ++ shape=(2,), ++ init=lambda shape, dtype: jnp.array([0.5, 0.0], dtype), ++ ) ++ return jnp.matmul(s, w) + b ++ ++ ++def _make_linear_dqn(**kwargs): ++ options = dict( ++ num_agent_steps=20, ++ state_space=_state_space(), ++ action_space=Discrete(2), ++ seed=3, ++ batch_size=2, ++ start_steps=0, ++ update_interval=1, ++ update_interval_target=4, ++ fn=_linear_q, ++ lr=0.1, ++ gamma=0.5, ++ nstep=1, ++ buffer_size=8, ++ eps_eval=0.0, ++ ) ++ options.update(kwargs) ++ return DQN(**options) ++ ++ ++def _append_linear_transition(algo): ++ algo.buffer.append( ++ np.array([1.0, -1.0], dtype=np.float32), ++ 1, ++ 1.0, ++ False, ++ np.array([2.0, 0.0], dtype=np.float32), ++ False, ++ ) ++ ++ ++def _param_leaf_shapes(params): ++ return [tuple(np.asarray(leaf).shape) for leaf in jax.tree_util.tree_leaves(params)] ++ ++ ++def _matrix_and_bias(params): ++ ++ ++ leaves = [np.asarray(leaf) for leaf in jax.tree_util.tree_leaves(params)] ++ matrices = [leaf for leaf in leaves if leaf.shape == (2, 2)] ++ biases = [leaf for leaf in leaves if leaf.shape == (2,)] ++ assert len(matrices) == 1 ++ assert len(biases) == 1 ++ return matrices[0], biases[0] ++ ++ ++def _linear_params(algo): ++ return _matrix_and_bias(algo.params) ++ ++ ++def _tree_allclose(left, right, rtol=1e-6, atol=1e-6): ++ left_leaves, left_tree = jax.tree_util.tree_flatten(left) ++ right_leaves, right_tree = jax.tree_util.tree_flatten(right) ++ assert left_tree == right_tree ++ assert len(left_leaves) > 0 ++ for left_leaf, right_leaf in zip(left_leaves, right_leaves): ++ assert_allclose(np.asarray(left_leaf), np.asarray(right_leaf), rtol=rtol, atol=atol) ++ ++ ++def _tree_changed(left, right): ++ left_leaves, left_tree = jax.tree_util.tree_flatten(left) ++ right_leaves, right_tree = jax.tree_util.tree_flatten(right) ++ assert left_tree == right_tree ++ assert len(left_leaves) > 0 ++ return any( ++ not np.allclose(np.asarray(left_leaf), np.asarray(right_leaf)) ++ for left_leaf, right_leaf in zip(left_leaves, right_leaves) ++ ) ++ ++ ++def _assert_actions_in_space(actions, action_space, batch_size): ++ ++ ++ arr = np.asarray(actions) ++ assert arr.shape == (batch_size,) ++ assert np.issubdtype(arr.dtype, np.integer) ++ assert np.all(arr >= 0) ++ assert np.all(arr < action_space.n) ++ ++ ++def test_public_import_default_network_and_forward_session(): ++ ++ ++ ++ algo = DQN( ++ num_agent_steps=100, ++ state_space=_state_space(shape=(4,), low=-1.0, high=1.0), ++ action_space=Discrete(2), ++ seed=0, ++ batch_size=2, ++ start_steps=1, ++ update_interval=1, ++ update_interval_target=2, ++ eps_eval=0.0, ++ units=(8,), ++ ) ++ ++ assert ExportedDQN is DQN ++ assert algo.name == "DQN" ++ ++ assert getattr(algo, "name") == "DQN" ++ assert algo.agent_step == 0 ++ assert algo.episode_step == 0 ++ assert algo.learning_step == 0 ++ assert algo.discount == 0.99 ++ ++ ++ assert 0.0 <= algo.eps_eval <= 1.0 ++ assert algo.update_interval == 1 ++ assert algo.discrete_action is True ++ assert algo.batch_size == 2 ++ assert algo.use_per is False ++ assert algo.loss_type == "huber" ++ ++ ++ param_shapes = _param_leaf_shapes(algo.params) ++ assert (4, 8) in param_shapes ++ assert (8, 2) in param_shapes ++ _tree_allclose(algo.params, algo.params_target, rtol=0.0, atol=0.0) ++ assert len(jax.tree_util.tree_leaves(algo.opt_state)) > 0 ++ ++ state = np.array([0.05, -0.02, 0.01, 0.03], dtype=np.float32) ++ _assert_actions_in_space(algo.forward(state[None, ...]), algo.action_space, 1) ++ ++ ++ selected = np.asarray(algo.select_action(state)) ++ assert selected.shape == () ++ assert 0 <= int(selected) < algo.action_space.n ++ ++ ++def test_dueling_default_network_adds_value_head_and_still_returns_actions(): ++ ++ ++ ++ algo = DQN( ++ num_agent_steps=100, ++ state_space=_state_space(shape=(4,), low=-1.0, high=1.0), ++ action_space=Discrete(3), ++ seed=0, ++ batch_size=2, ++ start_steps=1, ++ update_interval=1, ++ update_interval_target=2, ++ eps_eval=0.0, ++ units=(8,), ++ dueling_net=True, ++ ) ++ ++ ++ ++ param_shapes = _param_leaf_shapes(algo.params) ++ assert (4, 8) in param_shapes ++ assert (8, 3) in param_shapes ++ assert (8, 1) in param_shapes ++ states = np.array( ++ [[0.05, -0.02, 0.01, 0.03], [0.2, 0.1, -0.3, 0.0]], ++ dtype=np.float32, ++ ) ++ _assert_actions_in_space(algo.forward(states), algo.action_space, 2) ++ ++ ++def test_update_l2_changes_online_opt_state_and_hard_syncs_target(): ++ ++ ++ ++ algo = _make_linear_dqn(loss_type="l2") ++ _append_linear_transition(algo) ++ ++ w0, b0 = _linear_params(algo) ++ opt0 = algo.opt_state ++ assert_allclose(w0, [[0.25, 0.25], [0.25, 0.25]], rtol=0.0, atol=0.0) ++ assert_allclose(b0, [0.0, 0.0], rtol=0.0, atol=0.0) ++ assert algo.learning_step == 0 ++ ++ algo.update(writer=None) ++ ++ w1, b1 = _linear_params(algo) ++ assert algo.learning_step == 1 ++ ++ ++ assert _tree_changed(opt0, algo.opt_state) ++ assert_allclose( ++ w1, ++ [[0.25, 0.34979972], [0.25, 0.15020028]], ++ rtol=1e-6, ++ atol=1e-6, ++ ) ++ assert_allclose(b1, [0.0, 0.09979972], rtol=1e-6, atol=1e-6) ++ assert_allclose( ++ _matrix_and_bias(algo.params_target)[0], ++ [[0.25, 0.34979972], [0.25, 0.15020028]], ++ rtol=1e-6, ++ atol=1e-6, ++ ) ++ assert np.asarray( ++ algo.forward(np.array([[1.0, -1.0], [0.0, 2.0]], dtype=np.float32)) ++ ).tolist() == [1, 0] ++ ++ ++def test_update_huber_uses_huber_td_loss_path(): ++ ++ ++ ++ algo = _make_linear_dqn(loss_type="huber") ++ _append_linear_transition(algo) ++ ++ algo.update(writer=None) ++ ++ w1, b1 = _linear_params(algo) ++ assert algo.learning_step == 1 ++ assert_allclose( ++ w1, ++ [[0.25, 0.34950179], [0.25, 0.15049817]], ++ rtol=1e-6, ++ atol=1e-6, ++ ) ++ assert_allclose(b1, [0.0, 0.09950183], rtol=1e-6, atol=1e-6) ++ assert np.asarray( ++ algo.forward(np.array([[1.0, -1.0], [0.0, 2.0]], dtype=np.float32)) ++ ).tolist() == [1, 0] ++ ++ ++def test_double_q_uses_online_argmax_and_target_evaluation(): ++ ++ ++ ++ algo = DQN( ++ num_agent_steps=20, ++ state_space=_state_space(), ++ action_space=Discrete(2), ++ seed=7, ++ batch_size=2, ++ start_steps=0, ++ update_interval=1, ++ update_interval_target=4, ++ fn=_biased_q, ++ lr=0.1, ++ gamma=0.5, ++ loss_type="l2", ++ double_q=True, ++ eps_eval=0.0, ++ buffer_size=8, ++ ) ++ algo.buffer.append( ++ np.array([10.0, 0.0], dtype=np.float32), ++ 1, ++ 1.0, ++ False, ++ np.array([10.0, 0.0], dtype=np.float32), ++ False, ++ ) ++ algo.agent_step = 1 ++ ++ assert np.asarray(algo.forward(np.array([[10.0, 0.0]], dtype=np.float32))).tolist() == [0] ++ algo.update(writer=None) ++ assert np.asarray(algo.forward(np.array([[10.0, 0.0]], dtype=np.float32))).tolist() == [1] ++ algo.update(writer=None) ++ ++ w, b = _matrix_and_bias(algo.params) ++ assert algo.learning_step == 2 ++ assert_allclose( ++ w, ++ [[0.0, 0.16084242], [0.0, 0.0]], ++ rtol=1e-6, ++ atol=1e-6, ++ ) ++ assert_allclose(b, [0.5, 0.16050875], rtol=1e-6, atol=1e-6) ++ _, target_b = _matrix_and_bias(algo.params_target) ++ assert_allclose( ++ target_b, ++ [0.5, 0.0], ++ rtol=0.0, ++ atol=0.0, ++ ) ++ ++ ++def test_writer_logs_q_loss_at_1000_learning_steps(): ++ ++ ++ ++ ++ class Writer: ++ def __init__(self): ++ self.calls = [] ++ ++ def add_scalar(self, *args): ++ self.calls.append(args) ++ ++ algo = _make_linear_dqn(loss_type="l2") ++ _append_linear_transition(algo) ++ algo.learning_step = 999 ++ writer = Writer() ++ ++ algo.update(writer=writer) ++ ++ assert algo.learning_step == 1000 ++ assert len(writer.calls) == 1 ++ assert writer.calls[0][0] == "loss/q" ++ assert float(writer.calls[0][1]) == 1.5625 ++ assert writer.calls[0][2] == 1000 ++ ++ ++def test_update_before_replay_contains_transitions_raises_value_error(): ++ ++ ++ ++ algo = _make_linear_dqn(loss_type="l2") ++ _append_linear_transition(algo) ++ params0 = algo.params ++ opt0 = algo.opt_state ++ ++ ++ ++ algo.update(writer=None) ++ assert algo.learning_step == 1 ++ assert _tree_changed(params0, algo.params) ++ assert _tree_changed(opt0, algo.opt_state) ++ ++ ++def test_two_dqn_instances_keep_independent_session_state(): ++ ++ ++ ++ a = _make_linear_dqn(loss_type="l2", seed=3) ++ b = _make_linear_dqn(loss_type="l2", seed=3) ++ _append_linear_transition(a) ++ bw0, bb0 = _linear_params(b) ++ ++ a.update(writer=None) ++ ++ aw, ab = _linear_params(a) ++ bw, bb = _linear_params(b) ++ assert a.name == "DQN" ++ assert b.name == "DQN" ++ assert a.learning_step == 1 ++ assert b.learning_step == 0 ++ ++ ++ assert not np.allclose(aw, bw) ++ assert not np.allclose(ab, bb) ++ assert_allclose(bw, bw0, rtol=0.0, atol=0.0) ++ assert_allclose(bb, bb0, rtol=0.0, atol=0.0) ++ ++ ++def test_python_object_cleanup_is_idempotent_for_dqn_sessions(): ++ ++ ++ ++ algo = _make_linear_dqn(loss_type="l2") ++ _append_linear_transition(algo) ++ ++ ++ ++ assert algo.name == "DQN" ++ assert algo.learning_step == 0 ++ algo.update(writer=None) ++ assert algo.learning_step == 1 ++ ++ ++def test_repeated_construct_use_cleanup_cycles_keep_python_heap_bounded(): ++ ++ ++ ++ ++ ++ for seed in range(5): ++ algo = DQN( ++ num_agent_steps=10, ++ state_space=_state_space(), ++ action_space=Discrete(2), ++ seed=seed, ++ batch_size=1, ++ start_steps=0, ++ update_interval=1, ++ update_interval_target=4, ++ fn=_biased_q, ++ lr=0.1, ++ buffer_size=1, ++ eps_eval=0.0, ++ ) ++ assert algo.name == "DQN" ++ _assert_actions_in_space( ++ algo.forward(np.array([[1.0, 0.0]], dtype=np.float32)), ++ algo.action_space, ++ 1, ++ ) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,25 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++ ++ ++ ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export JAX_PLATFORMS=cpu ++export JAX_PLATFORM_NAME=cpu ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_dqn_stateful.py -v diff --git a/tasks/format-code-task-002870/tests/test.sh b/tasks/format-code-task-002870/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..32ab0f0c9894d193d6101ffd4cc11095503156cf --- /dev/null +++ b/tasks/format-code-task-002870/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_dqn_stateful.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-002870/tests/test_command.sh b/tasks/format-code-task-002870/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002870/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-002877/environment/Dockerfile b/tasks/format-code-task-002877/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cec112a074fba5d539950554909ef9d6382f9c30 --- /dev/null +++ b/tasks/format-code-task-002877/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:b1b37e0bd24971ef62d85a9e5e7ddbfd0b862fd4ad2d5ff236e5e0708a432ea8 diff --git a/tasks/format-code-task-002877/environment/setup/files/blocklist b/tasks/format-code-task-002877/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002877/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-002877/environment/setup/setup.sh b/tasks/format-code-task-002877/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002877/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-002877/tests/test.patch b/tasks/format-code-task-002877/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..69081ddce76c64ad05025d4657e018020c0b7b50 --- /dev/null +++ b/tasks/format-code-task-002877/tests/test.patch @@ -0,0 +1,239 @@ +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,215 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++ ++( cd /workspace/repo && cmake -S . -B Builds/fixture -DCMAKE_BUILD_TYPE=Release -DPLUGINVAL_VST3_VALIDATOR=OFF -DCPM_SOURCE_CACHE="${CPM_SOURCE_CACHE:-/opt/stage4a_cpm_cache}" -DFETCHCONTENT_FULLY_DISCONNECTED=ON -DFETCHCONTENT_UPDATES_DISCONNECTED=ON >/dev/null ) \ ++ || fail "configure" ++( cd /workspace/repo && cmake --build Builds/fixture --config Release --target pluginval -j2 >/dev/null ) \ ++ || fail "build" ++ ++BIN=/workspace/repo/Builds/fixture/pluginval_artefacts/Release/pluginval ++[ -x "$BIN" ] || fail "missing built binary at $BIN" ++ ++TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || fail "tmp cd" ++ ++assert_empty_stderr() { ++ local fixture=$1 ++ [ ! -s err ] || fail "$fixture unexpected stderr: $(cat err)" ++} ++ ++assert_strictness_output_shape() { ++ local fixture=$1 ++ local expected_header=$2 ++ ++ [ "$(sed -n '1p' out)" = "$expected_header" ] || fail "$fixture header: $(sed -n '1p' out)" ++ [ "$(sed -n '2p' out)" = "" ] || fail "$fixture missing blank line after header" ++ [ "$(tail -n 1 out)" = "" ] || fail "$fixture missing trailing blank line" ++} ++ ++assert_strictness_body_shape() { ++ local fixture=$1 ++ ++ ++ local body ++ body=$(sed '1,2d;$d' out) ++ [ -n "$body" ] || fail "$fixture missing test lines" ++ sed '1,2d;$d' out | grep -Eqv '^ .+' && fail "$fixture has a test line without two-space prefix" ++ sed '1,2d;$d' out | grep -Eq '^ [^ ].*:[^ ]' && fail "$fixture description separator is not colon-space" ++} ++ ++assert_strictness_order() { ++ local fixture=$1 ++ local previous=0 ++ local level line ++ ++ ++ while IFS= read -r line; do ++ case "$line" in ++ " Plugin info:"*|" Locale stability:"*) level=1 ;; ++ " Plugin programs:"*|" Automatable Parameters:"*|" Plugin state:"*|" Editor:"*) level=2 ;; ++ " Audio processing:"*|" Automation:"*) level=3 ;; ++ " Open editor whilst processing:"*|" Basic bus:"*|" Bus layout processing:"*) level=4 ;; ++ " Editor Automation:"*|" auval:"*|" vst3 validator:"*) level=5 ;; ++ " Non-releasing audio processing:"*|" Plugin state restoration:"*|" Fuzz parameters:"*) level=6 ;; ++ " Parameters:"*|" Background thread state:"*|" Parameter thread safety:"*) level=7 ;; ++ *) fail "$fixture unknown strictness-help line: $line" ;; ++ esac ++ ++ [ "$level" -ge "$previous" ] || fail "$fixture strictness levels are not sorted ascending" ++ previous=$level ++ done < <(sed '1,2d;$d' out) ++} ++ ++expected_body_level_1() { ++ cat <<'EOF' ++ Plugin info: Logs getName(), getAlternateDisplayNames(), supportsDoublePrecisionProcessing(), getLatencySamples(), getTailLengthSeconds() ++ Locale stability: Checks that the plugin doesn't change the system locale. Some plugins or GUI frameworks change locale settings (e.g., decimal separator from '.' to ','). This can corrupt preset files, break float parsing in other plugins, or crash the host ++EOF ++} ++ ++expected_body_level_3() { ++ cat <<'EOF' ++ Plugin info: Logs getName(), getAlternateDisplayNames(), supportsDoublePrecisionProcessing(), getLatencySamples(), getTailLengthSeconds() ++ Locale stability: Checks that the plugin doesn't change the system locale. Some plugins or GUI frameworks change locale settings (e.g., decimal separator from '.' to ','). This can corrupt preset files, break float parsing in other plugins, or crash the host ++ Plugin programs: Calls getNumPrograms() and getProgramName() for each, then randomly switches programs 5 times via setCurrentProgram() ++ Automatable Parameters: For each non-bypass automatable parameter: logs index, name, defaultValue, label, numSteps, isDiscrete, isBoolean, isAutomatable, category ++ Plugin state: Saves state via getStateInformation(), randomises all automatable params, restores via setStateInformation() ++ Editor: Calls createEditor() twice (cold and warm), logs time taken, expects non-null editor pointer ++ Audio processing: Processes 10 blocks at each sample rate / block size combo. For instruments, sends noteOn/noteOff. Checks for NaNs, Infs, subnormals ++ Automation: Processes in 32-sample sub-blocks, randomly changing up to 10 params between each. Checks for NaNs, Infs; subnormals logged as warnings ++EOF ++} ++ ++expected_body_level_5() { ++ cat <<'EOF' ++ Plugin info: Logs getName(), getAlternateDisplayNames(), supportsDoublePrecisionProcessing(), getLatencySamples(), getTailLengthSeconds() ++ Locale stability: Checks that the plugin doesn't change the system locale. Some plugins or GUI frameworks change locale settings (e.g., decimal separator from '.' to ','). This can corrupt preset files, break float parsing in other plugins, or crash the host ++ Plugin programs: Calls getNumPrograms() and getProgramName() for each, then randomly switches programs 5 times via setCurrentProgram() ++ Automatable Parameters: For each non-bypass automatable parameter: logs index, name, defaultValue, label, numSteps, isDiscrete, isBoolean, isAutomatable, category ++ Plugin state: Saves state via getStateInformation(), randomises all automatable params, restores via setStateInformation() ++ Editor: Calls createEditor() twice (cold and warm), logs time taken, expects non-null editor pointer ++ Audio processing: Processes 10 blocks at each sample rate / block size combo. For instruments, sends noteOn/noteOff. Checks for NaNs, Infs, subnormals ++ Automation: Processes in 32-sample sub-blocks, randomly changing up to 10 params between each. Checks for NaNs, Infs; subnormals logged as warnings ++ Open editor whilst processing: Starts async thread calling processBlock() repeatedly, then calls createEditor() on message thread. Tests concurrent access ++ Basic bus: Tests audio bus configuration: lists all supported input/output layouts (named channel sets like stereo/5.1 and discrete channels), tests enableAllBuses() and disableNonMainBuses(), then verifies the default layout can be restored ++ Bus layout processing: For every supported combination of mono/stereo on each input and output bus (including sidechain), calls setBusesLayout(), prepareToPlay() and processBlock(). Detects crashes in plugins that mis-handle non-default channel counts (e.g. mono main with stereo sidechain). ++ Editor Automation: With editor open, loops 100x calling setValue(random) on ALL parameters with 10ms sleep between iterations ++ auval: Runs 'auval -strict -v ' (Audio Units only) ++ vst3 validator: Disabled (not built with VST3 validator support) ++EOF ++} ++ ++expected_body_level_10() { ++ cat <<'EOF' ++ Plugin info: Logs getName(), getAlternateDisplayNames(), supportsDoublePrecisionProcessing(), getLatencySamples(), getTailLengthSeconds() ++ Locale stability: Checks that the plugin doesn't change the system locale. Some plugins or GUI frameworks change locale settings (e.g., decimal separator from '.' to ','). This can corrupt preset files, break float parsing in other plugins, or crash the host ++ Plugin programs: Calls getNumPrograms() and getProgramName() for each, then randomly switches programs 5 times via setCurrentProgram() ++ Automatable Parameters: For each non-bypass automatable parameter: logs index, name, defaultValue, label, numSteps, isDiscrete, isBoolean, isAutomatable, category ++ Plugin state: Saves state via getStateInformation(), randomises all automatable params, restores via setStateInformation() ++ Editor: Calls createEditor() twice (cold and warm), logs time taken, expects non-null editor pointer ++ Audio processing: Processes 10 blocks at each sample rate / block size combo. For instruments, sends noteOn/noteOff. Checks for NaNs, Infs, subnormals ++ Automation: Processes in 32-sample sub-blocks, randomly changing up to 10 params between each. Subnormals treated as errors ++ Open editor whilst processing: Starts async thread calling processBlock() repeatedly, then calls createEditor() on message thread. Tests concurrent access ++ Basic bus: Tests audio bus configuration: lists all supported input/output layouts (named channel sets like stereo/5.1 and discrete channels), tests enableAllBuses() and disableNonMainBuses(), then verifies the default layout can be restored ++ Bus layout processing: For every supported combination of mono/stereo on each input and output bus (including sidechain), calls setBusesLayout(), prepareToPlay() and processBlock(). Detects crashes in plugins that mis-handle non-default channel counts (e.g. mono main with stereo sidechain). ++ Editor Automation: With editor open, loops 1000x calling setValue(random) on ALL parameters with 10ms sleep between iterations ++ auval: Runs 'auval -strict -stress 20 -v ' (Audio Units only) ++ vst3 validator: Disabled (not built with VST3 validator support) ++ Non-releasing audio processing: Same as audio processing, but calls prepareToPlay() at new sample rate WITHOUT calling releaseResources() first ++ Plugin state restoration: For each param: saves original value, randomises, restores state, expects value within 0.1 of original. Also requires exact binary state match ++ Fuzz parameters: For each parameter, sets 5 random values and calls getValue(), getText(), getValueForText(), getCurrentValueAsText(). Tests that text/value conversion functions don't crash or hang with arbitrary inputs ++ Parameters: Same as automatable parameters test - logs info for all non-bypass automatable parameters ++ Background thread state: Opens editor on message thread. From background thread: getStateInformation(), randomise params, setStateInformation(). Sleeps 2s for async updates ++ Parameter thread safety: Message thread calls setValueNotifyingHost() 500x on all params. Simultaneously, this thread calls setValue() and processBlock() 500x ++EOF ++} ++ ++assert_body_set_matches() { ++ local fixture=$1 ++ local expected_func=$2 ++ ++ ++ sed '1,2d;$d' out | sort >actual_body ++ "$expected_func" | sort >expected_body ++ cmp -s actual_body expected_body || { ++ diff -u expected_body actual_body >&2 || true ++ fail "$fixture strictness-help body differs" ++ } ++} ++ ++ ++ ++ ++"$BIN" --strictness-help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_empty_stderr F1 ++assert_strictness_output_shape F1 "Tests at strictness level 5:" ++assert_strictness_body_shape F1 ++ ++assert_body_set_matches F1 expected_body_level_5 ++assert_strictness_order F1 ++! grep -q 'Started validating:' out || fail "F1 started plugin validation" ++ ++ ++ ++ ++"$BIN" --strictness-help 3 >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++assert_empty_stderr F2 ++assert_strictness_output_shape F2 "Tests at strictness level 3:" ++assert_strictness_body_shape F2 ++ ++assert_body_set_matches F2 expected_body_level_3 ++assert_strictness_order F2 ++! grep -q 'Started validating:' out || fail "F2 started plugin validation" ++ ++ ++ ++ ++"$BIN" --strictness-help 0 >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++assert_empty_stderr F3 ++assert_strictness_output_shape F3 "Tests at strictness level 1:" ++assert_strictness_body_shape F3 ++ ++assert_body_set_matches F3 expected_body_level_1 ++assert_strictness_order F3 ++ ++ ++ ++ ++"$BIN" --strictness-help 999 >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++assert_empty_stderr F4 ++assert_strictness_output_shape F4 "Tests at strictness level 10:" ++assert_strictness_body_shape F4 ++ ++assert_body_set_matches F4 expected_body_level_10 ++assert_strictness_order F4 ++ ++ ++ ++ ++"$BIN" --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++assert_empty_stderr F5 ++ ++grep -q -- '--strictness-help \[level\]' out || fail "F5 missing strictness-help usage" ++awk ' ++ index($0, "--strictness-help [level]") { window = 4 } ++ window > 0 { ++ text = tolower($0) ++ if (text ~ /test/ && text ~ /strictness/ && text ~ /level/) ++ ok = 1 ++ --window ++ } ++ END { exit ok ? 0 : 1 } ++' out || fail "F5 missing nearby strictness-help description" ++ ++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,14 @@ ++#!/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 CPM_SOURCE_CACHE="${CPM_SOURCE_CACHE:-/opt/stage4a_cpm_cache}" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-002877/tests/test.sh b/tasks/format-code-task-002877/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-002877/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-002877/tests/test_command.sh b/tasks/format-code-task-002877/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002877/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-002879/environment/Dockerfile b/tasks/format-code-task-002879/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..120eba717d73e106ee294aecd8914242cdfd5088 --- /dev/null +++ b/tasks/format-code-task-002879/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:20c374dd653603bd40e9ef6da2e1071d9c1070f9f3e6fe1aa3dc7ac766edcfaf diff --git a/tasks/format-code-task-002879/environment/setup/files/blocklist b/tasks/format-code-task-002879/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002879/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-002879/environment/setup/setup.sh b/tasks/format-code-task-002879/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002879/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-002879/tests/test.patch b/tasks/format-code-task-002879/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bc91db49c1487d01db045e0bad73232295c7e54b --- /dev/null +++ b/tasks/format-code-task-002879/tests/test.patch @@ -0,0 +1,63 @@ +diff --git a/api/controller_test.go b/api/controller_test.go +index ed6a51da5b9..cf61b1170d2 100644 +--- a/api/controller_test.go ++++ b/api/controller_test.go +@@ -29,6 +29,7 @@ import ( + "github.com/treeverse/lakefs/catalog" + "github.com/treeverse/lakefs/db" + "github.com/treeverse/lakefs/httputil" ++ "github.com/treeverse/lakefs/stats" + "github.com/treeverse/lakefs/testutil" + "github.com/treeverse/lakefs/upload" + ) +@@ -1431,6 +1432,20 @@ func TestController_SetupLakeFSHandler(t *testing.T) { + if len(deps.collector.metadata[0].Entries) < 5 { + t.Fatalf("There should be at least 5 metadata entries: %s", deps.collector.metadata[0].Entries) + } ++ ++ hasBlockStoreType := false ++ for _, ent := range deps.collector.metadata[0].Entries { ++ if ent.Name == stats.BlockstoreTypeKey { ++ hasBlockStoreType = true ++ if ent.Value == "" { ++ t.Fatalf("Blockstorage key exists but with empty value: %s", deps.collector.metadata[0].Entries) ++ } ++ break ++ } ++ } ++ if !hasBlockStoreType { ++ t.Fatalf("missing blockstorage key: %s", deps.collector.metadata[0].Entries) ++ } + }) + + if c.errorDefaultCode == 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,14 @@ ++H4sIAAAAAAAAA+2UW0/jOBTHec6nOBMeKo3kpikUJEbd3S7NABI7dJoiXpCqNHaDhWMH2ymMxIff ++42Ta6VwYNDftrta/Fzu+nPPPubi7qLmgcyZX0c6vooccDgbNiHw6NvN40O/t9Qbx4f7BTi+OD3r7 ++OzD4ZYq2qI3NNMCOVsp+7dxz+/9Ruh/yb5mx81yVZSZp19z8PB/P5L/fH+xt8n8QH2L+990AvZ8n ++4Wn+5/nffREtuIwWmbkJcgpNESwYDYJdSKSpNYOJMrbQLH17DtyArqXksgiqYp5bkQsMH9MQH0CZ ++cQkulhb6v0WUrSJZCwGPj2B1zZy9Y80yy8B5AJrZDH0ywFqD2qAJvgR7w94BVbJjgT1wYwNTA4Gq ++9W+A5BBW5k4AsTlch2lynhzPIIbX04u/APVoJfDU1WkyTQDnMivZsCOyW7Y0nesQHgGtVEDuIA6d ++rOsA4CkHzv7xNBnNErhMkym0VuDqbHYKk1GaXl1Mx7C2DenlJJm6c6+uw/AbRW8C0erGz23dc7r4 ++Aenj0Wz05yhNYGMMLq7ebH6nUYt5Gat7KVRG4URBqWiNUQyKZorJaLfcsRMmmXYJHE3OIFeUwVKr ++Esx9VhRMB+Ut5RpIBVnFo4LJ4P0GFOt7ueBMWvcXZLSOKFmuDXTflah+4twyYbqXriaIXVsDQswt ++r8gqExxjxNUX7OONlbv0nfbZA1YzZaQp5M/dbUdgPD53pW75bdAOQKQBStFB6VxiFJoPTEpWW0XW ++Eim4LlpyV6dLpZsugJIXunFhQiBG5+1VLhs10HnZxbR2PnJ/z/DRXgvYxL1ZjZrnfFtVe9iJQtvD ++7UNoclpL13WAbVsw27RmwB4qhU08OZnPknQ2v5yeDcN1nR1FURvYo3b4Q6g8Eze4ezTY3+tHm0L7 ++3RjhIj2k3GQLwUJXUU3nk1zV0g5jICsg+JrADFePlbTYsoLpecpsXZ2jndfpKT4OuATdyGUp+Kef ++So/H4/F4PB6Px+PxeDwej8fj8Xg8Ho/H4/F4/rX8DWu6lxgAKAAA +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-002879/tests/test.sh b/tasks/format-code-task-002879/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3cf6fe8a613a9b084db6234524ebe359310be553 --- /dev/null +++ b/tasks/format-code-task-002879/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +api/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-002879/tests/test_command.sh b/tasks/format-code-task-002879/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002879/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-002883/environment/Dockerfile b/tasks/format-code-task-002883/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9388b8bbf173c07ac9fb6540d0af4ee887f12613 --- /dev/null +++ b/tasks/format-code-task-002883/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:57df7cefdf62bfa9802bc6eb3df8379ae15f117b96ec46fb898b4109b12415d4 diff --git a/tasks/format-code-task-002883/environment/setup/files/blocklist b/tasks/format-code-task-002883/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002883/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-002883/environment/setup/setup.sh b/tasks/format-code-task-002883/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002883/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-002883/tests/test.patch b/tasks/format-code-task-002883/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..98b4815a9aa19be0c0e978581ba6e4a8add203e1 --- /dev/null +++ b/tasks/format-code-task-002883/tests/test.patch @@ -0,0 +1,217 @@ +diff --git a/src/app/pages/data-protection/cloud-backup/cloud-backup-form/cloud-backup-form.component.spec.ts b/src/app/pages/data-protection/cloud-backup/cloud-backup-form/cloud-backup-form.component.spec.ts +index 929939a0d7..ab5587bf59 100644 +--- a/src/app/pages/data-protection/cloud-backup/cloud-backup-form/cloud-backup-form.component.spec.ts ++++ b/src/app/pages/data-protection/cloud-backup/cloud-backup-form/cloud-backup-form.component.spec.ts +@@ -2,6 +2,7 @@ import { HarnessLoader } from '@angular/cdk/testing'; + import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; + import { ReactiveFormsModule } from '@angular/forms'; + import { MatButtonHarness } from '@angular/material/button/testing'; ++import { By } from '@angular/platform-browser'; + import { createComponentFactory, mockProvider, Spectator } from '@ngneat/spectator/jest'; + import { of } from 'rxjs'; + import { mockCall, mockApi } from 'app/core/testing/utils/mock-api.utils'; +@@ -54,6 +55,7 @@ describe('CloudBackupFormComponent', () => { + pre_script: '', + post_script: '', + snapshot: false, ++ absolute_paths: true, + include: [], + exclude: [], + transfer_setting: CloudsyncTransferSetting.Performance, +@@ -122,6 +124,56 @@ describe('CloudBackupFormComponent', () => { + loader = TestbedHarnessEnvironment.loader(spectator.fixture); + }); + ++ it('shows absolute paths unchecked by default on new jobs', async () => { ++ const form = await loader.getHarness(IxFormHarness); ++ const useAbsolutePathsControl = await form.getControl('Use Absolute Paths'); ++ ++ expect(await useAbsolutePathsControl.isDisabled()).toBe(false); ++ expect(await useAbsolutePathsControl.getValue()).toBe(false); ++ }); ++ ++ it('disables absolute paths when snapshot is enabled and resets to false', async () => { ++ const form = await loader.getHarness(IxFormHarness); ++ await form.fillForm({ ++ 'Use Absolute Paths': true, ++ }); ++ ++ await form.fillForm({ ++ 'Take Snapshot': true, ++ }); ++ ++ const useAbsolutePathsControl = await form.getControl('Use Absolute Paths'); ++ ++ expect(await useAbsolutePathsControl.isDisabled()).toBe(true); ++ expect(await useAbsolutePathsControl.getValue()).toBe(false); ++ }); ++ ++ it('re-enables absolute paths when snapshot is turned off again', async () => { ++ const form = await loader.getHarness(IxFormHarness); ++ await form.fillForm({ ++ 'Use Absolute Paths': true, ++ 'Take Snapshot': true, ++ }); ++ await form.fillForm({ ++ 'Take Snapshot': false, ++ }); ++ ++ const useAbsolutePathsControl = await form.getControl('Use Absolute Paths'); ++ expect(await useAbsolutePathsControl.isDisabled()).toBe(false); ++ expect(await useAbsolutePathsControl.getValue()).toBe(false); ++ }); ++ ++ it('exposes the absolute paths tooltip on the field', () => { ++ const checkbox = spectator.fixture.debugElement.query( ++ By.css('ix-checkbox[formcontrolname="absolute_paths"]'), ++ ); ++ ++ expect(checkbox).not.toBeNull(); ++ expect((checkbox!.componentInstance as { tooltip: () => string }).tooltip()).toBe( ++ 'Determines whether restic backup will contain absolute or relative paths', ++ ); ++ }); ++ + it('adds a new cloud backup task and creates a new bucket', async () => { + const form = await loader.getHarness(IxFormHarness); + await form.fillForm({ +@@ -159,6 +211,7 @@ describe('CloudBackupFormComponent', () => { + month: '*', + }, + snapshot: false, ++ absolute_paths: false, + transfer_setting: CloudsyncTransferSetting.Default, + }]); + expect(chainedComponentRef.close).toHaveBeenCalledWith({ response: existingTask, error: null }); +@@ -166,6 +219,7 @@ describe('CloudBackupFormComponent', () => { + + it('adds a new cloud backup task when new form is saved', async () => { + const form = await loader.getHarness(IxFormHarness); ++ + await form.fillForm({ + 'Source Path': '/mnt/my pool 2', + Name: 'New Cloud Backup Task', +@@ -175,7 +229,8 @@ describe('CloudBackupFormComponent', () => { + Folder: '/', + Enabled: false, + Bucket: 'bucket1', +- 'Take Snapshot': true, ++ 'Take Snapshot': false, ++ 'Use Absolute Paths': true, + Exclude: ['/test'], + 'Transfer Setting': 'Fast Storage', + }); +@@ -203,7 +258,8 @@ describe('CloudBackupFormComponent', () => { + minute: '0', + month: '*', + }, +- snapshot: true, ++ snapshot: false, ++ absolute_paths: true, + transfer_setting: CloudsyncTransferSetting.FastStorage, + }]); + expect(chainedComponentRef.close).toHaveBeenCalledWith({ response: existingTask, error: null }); +@@ -239,6 +295,7 @@ describe('CloudBackupFormComponent', () => { + Schedule: 'Weekly (0 0 * * sun)  On Sundays at 00:00 (12:00 AM)', + 'Source Path': '/mnt/my pool', + 'Take Snapshot': false, ++ 'Use Absolute Paths': true, + 'Transfer Setting': 'Performance', + }); + }); +@@ -252,6 +309,11 @@ describe('CloudBackupFormComponent', () => { + 'Source Path': '/mnt/path1', + }); + ++ const useAbsolutePathsControl = await form.getControl('Use Absolute Paths'); ++ ++ expect(await useAbsolutePathsControl.isDisabled()).toBe(true); ++ expect(await useAbsolutePathsControl.getValue()).toBe(true); ++ + const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' })); + await saveButton.click(); + +@@ -284,4 +346,33 @@ describe('CloudBackupFormComponent', () => { + expect(chainedComponentRef.close).toHaveBeenCalledWith({ response: existingTask, error: null }); + }); + }); ++ ++ describe('edits another existing cloud backup', () => { ++ beforeEach(() => { ++ const anotherExistingTask = { ++ ...existingTask, ++ id: 42, ++ description: 'Another Existing Cloud Backup Task', ++ absolute_paths: false, ++ } as CloudBackup; ++ ++ spectator = createComponent({ ++ providers: [ ++ mockProvider(ChainedRef, { ++ ...chainedComponentRef, ++ getData: jest.fn(() => anotherExistingTask), ++ }), ++ ], ++ }); ++ loader = TestbedHarnessEnvironment.loader(spectator.fixture); ++ }); ++ ++ it('locks absolute paths when editing any existing cloud backup task', async () => { ++ const form = await loader.getHarness(IxFormHarness); ++ const useAbsolutePathsControl = await form.getControl('Use Absolute Paths'); ++ ++ expect(await useAbsolutePathsControl.isDisabled()).toBe(true); ++ expect(await useAbsolutePathsControl.getValue()).toBe(false); ++ }); ++ }); + }); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,45 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++export PATH="/opt/node-24/bin:$PATH" ++ ++yarn install --frozen-lockfile 2>/dev/null ++ ++cat > src/environments/environment.ts << 'ENVEOF' ++import { WebUiEnvironment } from 'environments/environment.interface'; ++import { MockEnclosureScenario } from 'app/core/testing/mock-enclosure/enums/mock-enclosure.enum'; ++import { EnclosureModel } from 'app/enums/enclosure-model.enum'; ++ ++export const environment: WebUiEnvironment = { ++ environmentVersion: '0.0.3', ++ remote: 'localhost', ++ buildYear: 2024, ++ port: 4200, ++ production: false, ++ sentryPublicDsn: 'https://7ac3e76fe2a94f77a58e1c38ea6b42d9@sentry.ixsystems.com/4', ++ mockConfig: { ++ enabled: false, ++ controllerModel: EnclosureModel.M40, ++ expansionModels: [], ++ scenario: MockEnclosureScenario.FillSomeSlots, ++ }, ++}; ++ENVEOF ++ ++SPEC="src/app/pages/data-protection/cloud-backup/cloud-backup-form/cloud-backup-form.component.spec.ts" ++OLD_TESTS="adds a new cloud backup task and creates a new bucket|adds a new cloud backup task when new form is saved|shows values for an existing cloud backup task when it is open for edit|saves updated cloud backup task when form opened for edit is saved" ++ ++case "${1:-}" in ++ base) ++ npx jest --config jest.config.cjs --runTestsByPath "$SPEC" --testNamePattern "$OLD_TESTS" ++ ;; ++ new) ++ npx jest --config jest.config.cjs --runTestsByPath "$SPEC" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002883/tests/test.sh b/tasks/format-code-task-002883/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..554750e7b6e97073313d7c5466179dd3242308b9 --- /dev/null +++ b/tasks/format-code-task-002883/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/app/pages/data-protection/cloud-backup/cloud-backup-form/cloud-backup-form.component.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-002883/tests/test_command.sh b/tasks/format-code-task-002883/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002883/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-002884/environment/Dockerfile b/tasks/format-code-task-002884/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fa353e9a4305d92342e6c7fa05bc3bfd4b633ebb --- /dev/null +++ b/tasks/format-code-task-002884/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:b0de77e482bef04b08bb40175927cabe7dde5d446f492fae5b74159f6c85c5af diff --git a/tasks/format-code-task-002884/environment/setup/files/blocklist b/tasks/format-code-task-002884/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002884/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-002884/environment/setup/setup.sh b/tasks/format-code-task-002884/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002884/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-002884/tests/test.patch b/tasks/format-code-task-002884/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1b7b3560f91665d1ac0c86059cb2c4ea2c50761c --- /dev/null +++ b/tasks/format-code-task-002884/tests/test.patch @@ -0,0 +1,437 @@ +diff --git a/usercase-test-coderl/fixtures/hid.py b/usercase-test-coderl/fixtures/hid.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/hid.py +@@ -0,0 +1,50 @@ ++import os ++ ++ ++def enumerate(vendor_id=0, product_id=0): ++ return [{ ++ "vendor_id": 0x16C0, ++ "product_id": 0x0486, ++ "serial_number": "FAKEONLYKEY", ++ "interface_number": 1, ++ "usage_page": 0xF1D0, ++ "path": b"fake-onlykey", ++ }] ++ ++ ++class device: ++ def __init__(self): ++ self.responses = [] ++ ++ def open_path(self, path): ++ self.path = path ++ ++ def set_nonblocking(self, value): ++ self.nonblocking = value ++ ++ def write(self, raw): ++ data = list(raw) ++ msg = data[4] if len(data) > 4 else -1 ++ slot = data[5] if len(data) > 5 else -1 ++ ++ log_path = os.environ.get("ONLYKEY_FAKE_HID_LOG") ++ if log_path: ++ with open(log_path, "a", encoding="utf-8") as log: ++ log.write( ++ "write msg=%s slot=%s length=%s prefix=%s\n" ++ % (msg, slot, len(data), ",".join(str(x) for x in data[:6])) ++ ) ++ ++ self.responses.extend( ++ "device response %d: wipe slot %s via msg %s" % (idx, slot, msg) ++ for idx in range(1, 9) ++ ) ++ return len(data) ++ ++ def read(self, n, timeout_ms=100): ++ text = self.responses.pop(0) if self.responses else "" ++ out = list(text.encode("ascii")) ++ return out[:n] + [0] * max(0, n - len(out)) ++ ++ def close(self): ++ return None +diff --git a/usercase-test-coderl/fixtures/onlykey_cli_entrypoint.py b/usercase-test-coderl/fixtures/onlykey_cli_entrypoint.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/onlykey_cli_entrypoint.py +@@ -0,0 +1,5 @@ ++from onlykey.cli import main ++ ++ ++if __name__ == "__main__": ++ main() +diff --git a/usercase-test-coderl/fixtures/prompt_toolkit/__init__.py b/usercase-test-coderl/fixtures/prompt_toolkit/__init__.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/prompt_toolkit/__init__.py +@@ -0,0 +1,30 @@ ++import os ++import sys ++ ++ ++_answers = None ++ ++ ++def _load_answers(): ++ raw = os.environ.get("ONLYKEY_FAKE_PROMPTS", "") ++ return raw.splitlines() ++ ++ ++def prompt(message="", **kwargs): ++ global _answers ++ if _answers is None: ++ _answers = _load_answers() ++ ++ if not _answers: ++ raise EOFError() ++ ++ sys.stdout.write(str(message)) ++ sys.stdout.flush() ++ answer = _answers.pop(0) ++ sys.stdout.write(answer + "\n") ++ sys.stdout.flush() ++ return answer ++ ++ ++class Application: ++ pass +diff --git a/usercase-test-coderl/fixtures/prompt_toolkit/filters.py b/usercase-test-coderl/fixtures/prompt_toolkit/filters.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/prompt_toolkit/filters.py +@@ -0,0 +1,6 @@ ++class Condition: ++ def __init__(self, func): ++ self.func = func ++ ++ def __call__(self): ++ return self.func() +diff --git a/usercase-test-coderl/fixtures/prompt_toolkit/key_binding.py b/usercase-test-coderl/fixtures/prompt_toolkit/key_binding.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/prompt_toolkit/key_binding.py +@@ -0,0 +1,6 @@ ++class KeyBindings: ++ def add(self, *args, **kwargs): ++ def decorator(func): ++ return func ++ ++ return decorator +diff --git a/usercase-test-coderl/fixtures/prompt_toolkit/keys.py b/usercase-test-coderl/fixtures/prompt_toolkit/keys.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/prompt_toolkit/keys.py +@@ -0,0 +1,2 @@ ++class Keys: ++ pass +diff --git a/usercase-test-coderl/fixtures/solo/__init__.py b/usercase-test-coderl/fixtures/solo/__init__.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/solo/__init__.py +@@ -0,0 +1,1 @@ ++from . import cli +diff --git a/usercase-test-coderl/fixtures/solo/cli/__init__.py b/usercase-test-coderl/fixtures/solo/cli/__init__.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/solo/cli/__init__.py +@@ -0,0 +1,10 @@ ++def key(): ++ return None ++ ++ ++def monitor(): ++ return None ++ ++ ++def program(): ++ return None +diff --git a/usercase-test-coderl/fixtures/solo/cli/key.py b/usercase-test-coderl/fixtures/solo/cli/key.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/solo/cli/key.py +@@ -0,0 +1,2 @@ ++def key(): ++ return None +diff --git a/usercase-test-coderl/fixtures/solo/cli/monitor.py b/usercase-test-coderl/fixtures/solo/cli/monitor.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/solo/cli/monitor.py +@@ -0,0 +1,2 @@ ++def monitor(): ++ return None +diff --git a/usercase-test-coderl/fixtures/solo/cli/program.py b/usercase-test-coderl/fixtures/solo/cli/program.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/solo/cli/program.py +@@ -0,0 +1,2 @@ ++def program(): ++ return None +diff --git a/usercase-test-coderl/fixtures/solo/operations.py b/usercase-test-coderl/fixtures/solo/operations.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/solo/operations.py +@@ -0,0 +1,1 @@ ++ +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,236 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++export PYTHONDONTWRITEBYTECODE=1 ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++FIXTURES=/workspace/repo/usercase-test-coderl/fixtures ++export PYTHONPATH="$FIXTURES:/workspace/repo${PYTHONPATH:+:$PYTHONPATH}" ++ ++run_onlykey_cli() { ++ ++ ++ ++ python "$FIXTURES/onlykey_cli_entrypoint.py" "$@" ++} ++ ++assert_empty_file() { ++ local file=$1 ++ [ ! -s "$file" ] || fail "$file should be empty; got: $(cat "$file")" ++} ++ ++assert_file_eq() { ++ local actual=$1 ++ local expected=$2 ++ local label=$3 ++ if ! cmp -s "$actual" "$expected"; then ++ echo "FAIL: $label" >&2 ++ echo "--- expected" >&2 ++ cat "$expected" >&2 ++ echo "--- actual" >&2 ++ cat "$actual" >&2 ++ exit 1 ++ fi ++} ++ ++assert_wipe_log_eq() { ++ local actual=$1 ++ local expected=$2 ++ local label=$3 ++ local filtered="$TMP/$(basename "$actual").filtered" ++ ++ [ -e "$actual" ] || fail "$label missing" ++ ++ ++ awk '{print $1" "$2" "$3}' "$actual" >"$filtered" ++ assert_file_eq "$filtered" "$expected" "$label" ++} ++ ++write_expected_wipe_stdout() { ++ local slot=$1 ++ local file=$2 ++ cat >"$file" <"$file" <"$filtered" ++ cat >"$expected" <<'EOF' ++device response 1: wipe slot 1 via msg 231 ++device response 2: wipe slot 1 via msg 231 ++device response 3: wipe slot 1 via msg 231 ++device response 4: wipe slot 1 via msg 231 ++device response 5: wipe slot 1 via msg 231 ++device response 6: wipe slot 1 via msg 231 ++device response 7: wipe slot 1 via msg 231 ++device response 8: wipe slot 1 via msg 231 ++wipeslot [id] ++[id] must be a valid slot number ++wipeslot [id] ++[id] must be a valid slot number ++device response 1: wipe slot 24 via msg 231 ++device response 2: wipe slot 24 via msg 231 ++device response 3: wipe slot 24 via msg 231 ++device response 4: wipe slot 24 via msg 231 ++device response 5: wipe slot 24 via msg 231 ++device response 6: wipe slot 24 via msg 231 ++device response 7: wipe slot 24 via msg 231 ++device response 8: wipe slot 24 via msg 231 ++EOF ++ assert_file_eq "$filtered" "$expected" "F11 stdout behavior" ++} ++ ++run_direct_success() { ++ local label=$1 ++ local id=$2 ++ local slot=$3 ++ local out="$TMP/${label}.out" ++ local err="$TMP/${label}.err" ++ local log="$TMP/${label}.hid.log" ++ local expected_out="$TMP/${label}.expected.out" ++ local expected_log="$TMP/${label}.expected.log" ++ ++ rm -f "$log" ++ ONLYKEY_FAKE_HID_LOG="$log" run_onlykey_cli wipeslot "$id" >"$out" 2>"$err" ++ local ec=$? ++ ++ write_expected_wipe_stdout "$slot" "$expected_out" ++ write_expected_wipe_log "$slot" "$expected_log" ++ ++ [ "$ec" -eq 0 ] || fail "$label exit $ec; want 0" ++ assert_file_eq "$out" "$expected_out" "$label stdout" ++ assert_empty_file "$err" ++ assert_wipe_log_eq "$log" "$expected_log" "$label HID write" ++} ++ ++write_expected_validation_stdout() { ++ local file=$1 ++ cat >"$file" <<'EOF' ++wipeslot [id] ++[id] must be a valid slot number ++EOF ++} ++ ++run_direct_validation() { ++ local label=$1 ++ shift ++ local out="$TMP/${label}.out" ++ local err="$TMP/${label}.err" ++ local log="$TMP/${label}.hid.log" ++ local expected_out="$TMP/${label}.expected.out" ++ ++ rm -f "$log" ++ ONLYKEY_FAKE_HID_LOG="$log" run_onlykey_cli wipeslot "$@" >"$out" 2>"$err" ++ local ec=$? ++ ++ write_expected_validation_stdout "$expected_out" ++ [ "$ec" -eq 0 ] || fail "$label exit $ec; want 0" ++ assert_file_eq "$out" "$expected_out" "$label stdout" ++ assert_empty_file "$err" ++ [ ! -e "$log" ] || assert_empty_file "$log" ++} ++ ++ ++ ++ ++run_direct_success "f1_direct_1a" "1a" "1" ++ ++ ++ ++ ++run_direct_success "f2_direct_6a" "6a" "6" ++ ++ ++ ++ ++run_direct_success "f3_direct_1b" "1b" "7" ++ ++ ++ ++ ++run_direct_success "f4_direct_6b" "6b" "12" ++ ++ ++ ++ ++run_direct_success "f5_direct_blue2b" "blue2b" "11" ++ ++ ++ ++ ++run_direct_success "f6_direct_yellow3a" "yellow3a" "15" ++ ++ ++ ++ ++run_direct_success "f7_direct_purple1b" "purple1b" "22" ++ ++ ++ ++ ++run_direct_success "f8_direct_numeric24" "24" "24" ++ ++ ++ ++ ++run_direct_validation "f9_direct_invalid" "not-a-slot" ++ ++ ++ ++ ++run_direct_validation "f10_direct_missing" ++ ++ ++ ++ ++interactive_out="$TMP/f11_interactive.out" ++interactive_err="$TMP/f11_interactive.err" ++interactive_log="$TMP/f11_interactive.hid.log" ++interactive_expected_log="$TMP/f11_interactive.expected.log" ++rm -f "$interactive_log" ++ONLYKEY_FAKE_HID_LOG="$interactive_log" \ ++ONLYKEY_FAKE_PROMPTS=$'wipeslot green1a\nwipeslot not-a-slot\nwipeslot\nwipeslot 24' \ ++ run_onlykey_cli >"$interactive_out" 2>"$interactive_err" ++interactive_ec=$? ++ ++cat >"$interactive_expected_log" <<'EOF' ++write msg=231 slot=1 ++write msg=231 slot=24 ++EOF ++ ++[ "$interactive_ec" -eq 0 ] || fail "F11 exit $interactive_ec; want 0" ++assert_interactive_stdout_behavior "$interactive_out" ++assert_empty_file "$interactive_err" ++assert_wipe_log_eq "$interactive_log" "$interactive_expected_log" "F11 HID writes" ++ ++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,14 @@ ++#!/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 PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-002884/tests/test.sh b/tasks/format-code-task-002884/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..84058c41ec4b8360b840030ee36a91755c84b82e --- /dev/null +++ b/tasks/format-code-task-002884/tests/test.sh @@ -0,0 +1,50 @@ +#!/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/hid.py +usercase-test-coderl/fixtures/onlykey_cli_entrypoint.py +usercase-test-coderl/fixtures/prompt_toolkit/__init__.py +usercase-test-coderl/fixtures/prompt_toolkit/filters.py +usercase-test-coderl/fixtures/prompt_toolkit/key_binding.py +usercase-test-coderl/fixtures/prompt_toolkit/keys.py +usercase-test-coderl/fixtures/solo/__init__.py +usercase-test-coderl/fixtures/solo/cli/__init__.py +usercase-test-coderl/fixtures/solo/cli/key.py +usercase-test-coderl/fixtures/solo/cli/monitor.py +usercase-test-coderl/fixtures/solo/cli/program.py +usercase-test-coderl/fixtures/solo/operations.py +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-002884/tests/test_command.sh b/tasks/format-code-task-002884/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002884/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-002905/environment/Dockerfile b/tasks/format-code-task-002905/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e3bf3ba83b0b92a9ba51e45ed4a45109be1e687a --- /dev/null +++ b/tasks/format-code-task-002905/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:5a9c166046edf7a3a4d4a6f8f6b18f8c7fe1a8ba833fd06f0fba25d7b81545ba diff --git a/tasks/format-code-task-002905/environment/setup/files/blocklist b/tasks/format-code-task-002905/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002905/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-002905/environment/setup/setup.sh b/tasks/format-code-task-002905/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002905/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-002905/tests/test.patch b/tasks/format-code-task-002905/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..61878f83476e7dacaa6eb04df15417cb8b9f2051 --- /dev/null +++ b/tasks/format-code-task-002905/tests/test.patch @@ -0,0 +1,213 @@ +diff --git a/modules/feature-list-view/src/__tests__/chart-prop-types-date.spec.js b/modules/feature-list-view/src/__tests__/chart-prop-types-date.spec.js +new file mode 100644 +index 0000000..6dfb6ef +--- /dev/null ++++ b/modules/feature-list-view/src/__tests__/chart-prop-types-date.spec.js +@@ -0,0 +1,33 @@ ++import React from 'react'; ++import TestRenderer from 'react-test-renderer'; ++import {FEATURE_TYPE} from '@mlvis/mlvis-common/constants'; ++import FeatureListView from '..'; ++ ++const featureWithDateValues = () => ({ ++ name: 'timestamp', ++ type: FEATURE_TYPE.NUMERICAL, ++ domain: [0, 1], ++ distributions: [[1], [1]], ++ distributionsNormalized: [[1], [1]], ++ divergence: 0, ++ values: [ ++ [1, new Date(0), false], ++ ['comparison', 3.5, new Date(1)], ++ ], ++}); ++ ++test('accepts Date values in chart data without prop type warning', () => { ++ const spy = jest.spyOn(console, 'error').mockImplementation(() => {}); ++ let rendered; ++ try { ++ rendered = TestRenderer.create( ++ ++ ); ++ expect(spy).not.toHaveBeenCalled(); ++ } finally { ++ if (rendered) { ++ rendered.unmount(); ++ } ++ spy.mockRestore(); ++ } ++}); +diff --git a/modules/manifold/__tests__/package-dependencies.spec.js b/modules/manifold/__tests__/package-dependencies.spec.js +new file mode 100644 +index 0000000..8be5568 +--- /dev/null ++++ b/modules/manifold/__tests__/package-dependencies.spec.js +@@ -0,0 +1,43 @@ ++import fs from 'fs'; ++import path from 'path'; ++import pkg from '../package.json'; ++ ++const srcDir = path.resolve(__dirname, '../src'); ++const collectJsFiles = dir => { ++ return fs.readdirSync(dir).reduce((files, entry) => { ++ const filePath = path.join(dir, entry); ++ const stat = fs.statSync(filePath); ++ if (stat.isDirectory()) { ++ return files.concat(collectJsFiles(filePath)); ++ } ++ if (/\.(js|jsx)$/.test(entry)) { ++ return files.concat(filePath); ++ } ++ return files; ++ }, []); ++}; ++ ++const isTestFile = filePath => { ++ return ( ++ filePath.includes(`${path.sep}__tests__${path.sep}`) || ++ /\.(spec|test)\.jsx?$/.test(filePath) ++ ); ++}; ++ ++test('does not declare antd as a manifold peer dependency', () => { ++ expect(pkg.peerDependencies || {}).not.toHaveProperty('antd'); ++}); ++ ++test('does not depend on external segment-filters package', () => { ++ expect(pkg.dependencies || {}).not.toHaveProperty('@mlvis/segment-filters'); ++ expect(pkg.peerDependencies || {}).not.toHaveProperty('@mlvis/segment-filters'); ++}); ++ ++test('manifold source does not import the external segment-filters package', () => { ++ const offenders = collectJsFiles(srcDir).filter(filePath => { ++ if (isTestFile(filePath)) return false; ++ const source = fs.readFileSync(filePath, 'utf8'); ++ return source.includes('@mlvis/segment-filters'); ++ }); ++ expect(offenders).toEqual([]); ++}); +diff --git a/modules/manifold/src/actions/__tests__/ui-actions-public-api.spec.js b/modules/manifold/src/actions/__tests__/ui-actions-public-api.spec.js +new file mode 100644 +index 0000000..fc3dc7c +--- /dev/null ++++ b/modules/manifold/src/actions/__tests__/ui-actions-public-api.spec.js +@@ -0,0 +1,36 @@ ++import {FEATURE_TYPE, FILTER_TYPE} from '@mlvis/mlvis-common/constants'; ++import {updateBaseCols} from '..'; ++import {METRIC} from '../../constants'; ++import reducer, {DEFAULT_STATE} from '../../reducers'; ++import {getBaseCols} from '../../selectors/base'; ++ ++const buildState = () => ({ ++ ...DEFAULT_STATE, ++ data: { ++ columns: [[0, 1, 2], [3, 4, 5]], ++ fields: [ ++ {name: 'first', tableFieldIndex: 1, type: FEATURE_TYPE.NUMERICAL, domain: [0, 10]}, ++ {name: 'second', tableFieldIndex: 2, type: FEATURE_TYPE.NUMERICAL, domain: [0, 10]}, ++ ], ++ }, ++ columnTypeRanges: { ++ score: [0, 2], ++ }, ++ modelsMeta: {nClasses: 1}, ++ metric: METRIC.ABSOLUTE_ERROR, ++ baseCols: [0], ++ nClusters: 2, ++ segmentFilters: [ ++ [{name: 'first', key: 0, type: FILTER_TYPE.RANGE, value: [0, 5]}], ++ [{name: 'first', key: 0, type: FILTER_TYPE.RANGE, value: [5, 10]}], ++ ], ++ segmentGroups: [[1], [0]], ++}); ++ ++test('exports updateBaseCols as a base columns action creator', () => { ++ const samplePayload = [1]; ++ expect(typeof updateBaseCols).toBe('function'); ++ const nextState = reducer(buildState(), updateBaseCols(samplePayload)); ++ ++ expect(getBaseCols(nextState)).toEqual(samplePayload); ++}); +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,78 @@ ++#!/bin/bash ++set -uo pipefail ++ ++cd /testbed ++ ++ ++if ! command -v yarn >/dev/null 2>&1; then ++ if [ -f /opt/node-24/bin/yarn ]; then ++ ln -sf /opt/node-24/bin/yarn /usr/local/bin/yarn ++ else ++ echo "yarn is required but not available" >&2 ++ exit 127 ++ fi ++fi ++ ++needs_yarn_install=0 ++if [ ! -x /testbed/node_modules/.bin/jest ]; then ++ needs_yarn_install=1 ++fi ++for pkg in baseui lodash.setwith lodash.clone styletron-engine-atomic styletron-react; do ++ if node -e "require.resolve('${pkg}')" >/dev/null 2>&1; then ++ : ++ elif grep -q "\"${pkg}\"" /testbed/package.json /testbed/modules/*/package.json 2>/dev/null; then ++ needs_yarn_install=1 ++ fi ++done ++ ++if [ "$needs_yarn_install" -eq 1 ]; then ++ yarn install --ignore-engines --ignore-scripts ++fi ++ ++mkdir -p /testbed/.build_env ++cat > /testbed/.build_env/jest.config.js <<'JESTEOF' ++/* global module */ ++const packageAliases = require('/testbed/alias.config')(); ++ ++const aliasMapper = Object.keys(packageAliases).reduce((acc, key) => { ++ acc[`^${key}(.*)$`] = `${packageAliases[key]}$1`; ++ return acc; ++}, {}); ++ ++module.exports = { ++ verbose: true, ++ collectCoverage: false, ++ moduleNameMapper: aliasMapper, ++ modulePathIgnorePatterns: ['/dist/'], ++ testMatch: ['**/*.(spec|test).js', '**/__tests__/*.js'], ++ testPathIgnorePatterns: [ ++ '/node_modules/', ++ '/dist/', ++ '__fixtures__', ++ 'stories', ++ '.cache', ++ ], ++ roots: ['/testbed'], ++ testEnvironment: 'node', ++ transformIgnorePatterns: ['node_modules/(?!(gatsby|apache-arrow)/)'], ++}; ++JESTEOF ++ ++ ++case "${1:-}" in ++ base) ++ npx jest --no-coverage --config=/testbed/.build_env/jest.config.js \ ++ "modules/mlvis-common/src/__tests__/utils.spec.js" \ ++ "modules/stacked-calendar/src/__tests__/utils.spec.js" ++ ;; ++ new) ++ npx jest --no-coverage --config=/testbed/.build_env/jest.config.js \ ++ "modules/manifold/src/actions/__tests__/ui-actions-public-api.spec.js" \ ++ "modules/feature-list-view/src/__tests__/chart-prop-types-date.spec.js" \ ++ "modules/manifold/__tests__/package-dependencies.spec.js" ++ ;; ++ *) ++ echo "usage: $0 base|new" >&2 ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002905/tests/test.sh b/tasks/format-code-task-002905/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a5d6120d8473f161aa1710e3dd77d06d9fe20154 --- /dev/null +++ b/tasks/format-code-task-002905/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' +modules/feature-list-view/src/__tests__/chart-prop-types-date.spec.js +modules/manifold/__tests__/package-dependencies.spec.js +modules/manifold/src/actions/__tests__/ui-actions-public-api.spec.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-002905/tests/test_command.sh b/tasks/format-code-task-002905/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002905/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-002933/environment/Dockerfile b/tasks/format-code-task-002933/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7eac768a911616be6bd187e6e10cb29d791e24f9 --- /dev/null +++ b/tasks/format-code-task-002933/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:9cd9a97fca06181fd474dd5713b6e2d54abc1eb30e83471530c1d0587e52f61a diff --git a/tasks/format-code-task-002933/environment/setup/files/blocklist b/tasks/format-code-task-002933/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002933/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-002933/environment/setup/setup.sh b/tasks/format-code-task-002933/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002933/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-002933/tests/test.patch b/tasks/format-code-task-002933/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..936307567de6a73185326e1d5240967aad02a2e1 --- /dev/null +++ b/tasks/format-code-task-002933/tests/test.patch @@ -0,0 +1,230 @@ +diff --git a/usercase-test-coderl/test_nms_acceptance.py b/usercase-test-coderl/test_nms_acceptance.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_nms_acceptance.py +@@ -0,0 +1,203 @@ ++ ++ ++ ++ ++ ++ ++import json ++import os ++import socket ++import subprocess ++import sys ++ ++import numpy as np ++import pytest ++ ++from bbox import BBox2DList ++from bbox.utils import nms ++ ++ ++def assert_int_array(actual, expected): ++ ++ assert isinstance(actual, np.ndarray) ++ assert np.issubdtype(actual.dtype, np.integer) ++ np.testing.assert_array_equal(actual, np.array(expected, dtype=int)) ++ ++ ++def test_keeps_highest_scoring_duplicate_and_independent_box(): ++ ++ ++ ++ ++ bbl = BBox2DList([[0, 0, 10, 10], [0, 0, 10, 10], [20, 20, 5, 5]]) ++ actual = nms(bbl, [0.2, 0.9, 0.5], 0.5) ++ assert_int_array(actual, [1, 2]) ++ ++ ++def test_numpy_scores_preserve_below_threshold_boxes_in_score_order(): ++ ++ ++ ++ ++ bbl = BBox2DList([[0, 0, 10, 10], [5, 5, 10, 10]]) ++ actual = nms(bbl, np.array([0.6, 0.7]), 0.2) ++ assert_int_array(actual, [1, 0]) ++ ++ ++def test_empty_box_list_returns_empty_integer_array(): ++ ++ ++ ++ ++ actual = nms(BBox2DList([]), [], 0.5) ++ assert_int_array(actual, []) ++ ++ ++def test_single_box_returns_its_original_index(): ++ ++ ++ ++ ++ actual = nms(BBox2DList([[3, 4, 8, 6]]), [0.3], 0.5) ++ assert_int_array(actual, [0]) ++ ++ ++def test_boxes_below_threshold_are_kept(): ++ ++ ++ ++ ++ ++ actual = nms(BBox2DList([[0, 0, 10, 10], [8, 8, 10, 10]]), [0.9, 0.8], 0.1) ++ assert_int_array(actual, [0, 1]) ++ ++ ++def test_threshold_below_iou_suppresses_lower_scoring_duplicate(): ++ ++ ++ ++ ++ actual = nms(BBox2DList([[0, 0, 10, 10], [0, 0, 10, 10]]), [0.9, 0.8], 0.999) ++ assert_int_array(actual, [0]) ++ ++ ++def test_non_overlapping_boxes_are_all_kept_in_descending_score_order(): ++ ++ ++ ++ ++ bbl = BBox2DList([[0, 0, 10, 10], [40, 40, 6, 6], [20, 20, 5, 5]]) ++ actual = nms(bbl, [0.4, 0.95, 0.7], 0.0) ++ assert_int_array(actual, [1, 2, 0]) ++ ++ ++def test_mixed_cluster_suppression_keeps_best_cluster_representatives(): ++ ++ ++ ++ ++ bbl = BBox2DList( ++ [[0, 0, 10, 10], [1, 1, 10, 10], [20, 20, 5, 5], [2, 2, 10, 10]] ++ ) ++ actual = nms(bbl, [0.8, 0.7, 0.6, 0.9], 0.5) ++ assert_int_array(actual, [3, 0, 2]) ++ ++ ++def test_equal_scores_keep_all_non_overlapping_boxes_without_tie_breaker_requirement(): ++ ++ ++ ++ ++ bbl = BBox2DList([[0, 0, 10, 10], [20, 20, 5, 5], [40, 40, 6, 6]]) ++ actual = nms(bbl, [0.5, 0.5, 0.5], 0.0) ++ ++ assert isinstance(actual, np.ndarray) ++ assert np.issubdtype(actual.dtype, np.integer) ++ np.testing.assert_array_equal(np.sort(actual), np.array([0, 1, 2], dtype=int)) ++ ++ ++def test_rejects_non_list_or_numpy_scores(): ++ ++ with pytest.raises(ValueError): ++ nms(BBox2DList([[0, 0, 10, 10]]), (0.5,), 0.5) ++ ++ ++def test_rejects_score_count_mismatch(): ++ ++ with pytest.raises(ValueError): ++ nms(BBox2DList([[0, 0, 10, 10], [20, 20, 5, 5]]), [0.5], 0.5) ++ ++ ++def test_referential_transparency_same_inputs_same_value(): ++ bbl = BBox2DList([[0, 0, 10, 10], [1, 1, 10, 10], [20, 20, 5, 5]]) ++ scores = [0.8, 0.9, 0.4] ++ first = nms(bbl, scores, 0.5) ++ second = nms(bbl, scores, 0.5) ++ assert_int_array(first, [1, 2]) ++ assert_int_array(second, [1, 2]) ++ ++ ++def test_does_not_mutate_box_list_or_score_objects(): ++ list_score_bbl = BBox2DList([[0, 0, 10, 10], [1, 1, 10, 10], [20, 20, 5, 5]]) ++ list_score_boxes_before = list_score_bbl.bboxes.copy() ++ list_scores = [0.8, 0.9, 0.4] ++ list_scores_before = list(list_scores) ++ ++ array_score_bbl = BBox2DList([[0, 0, 10, 10], [5, 5, 10, 10]]) ++ array_score_boxes_before = array_score_bbl.bboxes.copy() ++ array_scores = np.array([0.6, 0.7]) ++ array_scores_before = array_scores.copy() ++ ++ assert_int_array(nms(list_score_bbl, list_scores, 0.5), [1, 2]) ++ assert_int_array(nms(array_score_bbl, array_scores, 0.2), [1, 0]) ++ ++ np.testing.assert_array_equal(list_score_bbl.bboxes, list_score_boxes_before, strict=True) ++ assert list_scores == list_scores_before ++ np.testing.assert_array_equal(array_score_bbl.bboxes, array_score_boxes_before, strict=True) ++ np.testing.assert_array_equal(array_scores, array_scores_before, strict=True) ++ ++ ++def test_no_global_state_across_fresh_python_process(): ++ bbl = BBox2DList( ++ [[0, 0, 10, 10], [1, 1, 10, 10], [20, 20, 5, 5], [2, 2, 10, 10]] ++ ) ++ in_process = nms(bbl, [0.8, 0.7, 0.6, 0.9], 0.5) ++ assert_int_array(in_process, [3, 0, 2]) ++ ++ script = """ ++import json ++import sys ++sys.path.insert(0, "/workspace/repo") ++from bbox import BBox2DList ++from bbox.utils import nms ++bbl = BBox2DList([[0, 0, 10, 10], [1, 1, 10, 10], [20, 20, 5, 5], [2, 2, 10, 10]]) ++sys.stdout.write(json.dumps(nms(bbl, [0.8, 0.7, 0.6, 0.9], 0.5).tolist())) ++""" ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ ) ++ fresh_process = json.loads(completed.stdout) ++ assert fresh_process == [3, 0, 2] ++ assert in_process.tolist() == [3, 0, 2] ++ ++ ++def test_no_filesystem_or_network_side_effects(tmp_path, monkeypatch): ++ def snapshot(root): ++ return sorted(str(path.relative_to(root)) for path in root.rglob("*")) ++ ++ def blocked_socket(*args, **kwargs): ++ raise AssertionError("nms must not create network sockets") ++ ++ monkeypatch.chdir(tmp_path) ++ monkeypatch.setattr(socket, "socket", blocked_socket) ++ before = snapshot(tmp_path) ++ ++ actual = nms(BBox2DList([[0, 0, 10, 10], [20, 20, 5, 5]]), [0.9, 0.8], 0.5) ++ ++ assert_int_array(actual, [0, 1]) ++ assert snapshot(tmp_path) == before ++ assert os.getcwd() == str(tmp_path) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,17 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++exec /opt/coderl_venv/bin/python -m pytest /workspace/repo/usercase-test-coderl/test_nms_acceptance.py -v diff --git a/tasks/format-code-task-002933/tests/test.sh b/tasks/format-code-task-002933/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a37e683df4d809e7dd400b8c67e28d54ef6833b2 --- /dev/null +++ b/tasks/format-code-task-002933/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_nms_acceptance.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002933/tests/test_command.sh b/tasks/format-code-task-002933/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002933/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-002967/environment/Dockerfile b/tasks/format-code-task-002967/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5b50374a7c6e65671ae3d8ca26016addfd0ded39 --- /dev/null +++ b/tasks/format-code-task-002967/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:8c7b1d4d64109a1a96e65e6fbe129a9bdfc2adaebaff5a3607736fe74c3ebb4a diff --git a/tasks/format-code-task-002967/environment/setup/files/blocklist b/tasks/format-code-task-002967/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002967/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-002967/environment/setup/setup.sh b/tasks/format-code-task-002967/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002967/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-002967/tests/test.patch b/tasks/format-code-task-002967/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ae20f3730eb6de5f06c00ba5623c1f54180ede4d --- /dev/null +++ b/tasks/format-code-task-002967/tests/test.patch @@ -0,0 +1,130 @@ +diff --git a/test/geometries/vgl-extrude-geometry.spec.js b/test/geometries/vgl-extrude-geometry.spec.js +index 241c87e4..af98e7bd 100644 +--- a/test/geometries/vgl-extrude-geometry.spec.js ++++ b/test/geometries/vgl-extrude-geometry.spec.js +@@ -1,5 +1,5 @@ + import Vue from 'vue/dist/vue'; +-import { ExtrudeBufferGeometry } from 'three'; ++import { ExtrudeBufferGeometry, Shape, Vector2 } from 'three'; + import { VglExtrudeGeometry, VglGeometry, VglNamespace } from '../../src'; + + describe('VglExtrudeGeometry', () => { +@@ -17,4 +17,98 @@ describe('VglExtrudeGeometry', () => { + expect(Object.keys(new (Vue.extend(VglExtrudeGeometry))({ inject }).$props)) + .toEqual(expect.arrayContaining(Object.keys($props))); + }); ++ test('the options of the instance should be specified by props', () => { ++ const { inst } = new (Vue.extend(VglExtrudeGeometry))({ ++ inject, ++ propsData: { ++ curveSegments: '12', ++ steps: '1', ++ depth: '100', ++ bevelEnabled: true, ++ bevelThickness: '6', ++ bevelSize: '4', ++ bevelOffset: '0', ++ bevelSegments: '3', ++ }, ++ }); ++ const { ++ curveSegments, ++ steps, ++ depth, ++ bevelEnabled, ++ bevelThickness, ++ bevelSize, ++ bevelOffset, ++ bevelSegments, ++ } = inst.parameters.options; ++ expect(curveSegments).toStrictEqual(12); ++ expect(steps).toStrictEqual(1); ++ expect(depth).toStrictEqual(100); ++ expect(bevelEnabled).toStrictEqual(true); ++ expect(bevelThickness).toStrictEqual(6); ++ expect(bevelSize).toStrictEqual(4); ++ expect(bevelOffset).toStrictEqual(0); ++ expect(bevelSegments).toStrictEqual(3); ++ }); ++ test('the shape of the instance should be specified by props', () => { ++ const points = [[350, 0], [350, 1181], [0, 1181], [0, 79], [15, 79], [15, 0]]; ++ const virtualShape = new Shape(points.map((e) => new Vector2(...e))); ++ const { inst } = new (Vue.extend(VglExtrudeGeometry))({ ++ inject, ++ propsData: { ++ shapes: points, ++ }, ++ }); ++ const { shapes } = inst.parameters; ++ expect(shapes.type).toStrictEqual('Shape'); ++ expect(virtualShape.currentPoint.equals(shapes.currentPoint)).toStrictEqual(true); ++ expect(JSON.stringify(shapes.extractPoints())) ++ .toStrictEqual(JSON.stringify(virtualShape.extractPoints())); ++ }); ++ test('the shapes props as an Array of string', () => { ++ const points = [[350, 0], [350, 1181], [0, 1181], [0, 79], [15, 79], [15, 0]]; ++ const virtualShape = new Shape(points.map((e) => new Vector2(...e))); ++ const { inst } = new (Vue.extend(VglExtrudeGeometry))({ ++ inject, ++ propsData: { ++ shapes: points.map((e) => e.join(' ')), ++ }, ++ }); ++ const { shapes } = inst.parameters; ++ expect(shapes.type).toStrictEqual('Shape'); ++ expect(virtualShape.currentPoint.equals(shapes.currentPoint)).toStrictEqual(true); ++ expect(JSON.stringify(shapes.extractPoints())) ++ .toStrictEqual(JSON.stringify(virtualShape.extractPoints())); ++ }); ++ test('the shapes props as an Array of Vector2', () => { ++ const points = [[350, 0], [350, 1181], [0, 1181], [0, 79], [15, 79], [15, 0]]; ++ const virtualShape = new Shape(points.map((e) => new Vector2(...e))); ++ const { inst } = new (Vue.extend(VglExtrudeGeometry))({ ++ inject, ++ propsData: { ++ shapes: points.map((e) => new Vector2(...e)), ++ }, ++ }); ++ const { shapes } = inst.parameters; ++ expect(shapes.type).toStrictEqual('Shape'); ++ expect(virtualShape.currentPoint.equals(shapes.currentPoint)).toStrictEqual(true); ++ expect(JSON.stringify(shapes.extractPoints())) ++ .toStrictEqual(JSON.stringify(virtualShape.extractPoints())); ++ }); ++ test('the shapes props as a THREE.Shape', () => { ++ const points = [[350, 0], [350, 1181], [0, 1181], [0, 79], [15, 79], [15, 0]]; ++ const virtualShape = new Shape(points.map((e) => new Vector2(...e))); ++ const propShapes = virtualShape.clone(); ++ const { inst } = new (Vue.extend(VglExtrudeGeometry))({ ++ inject, ++ propsData: { ++ shapes: propShapes, ++ }, ++ }); ++ const { shapes } = inst.parameters; ++ expect(shapes.type).toStrictEqual('Shape'); ++ expect(virtualShape.currentPoint.equals(shapes.currentPoint)).toStrictEqual(true); ++ expect(JSON.stringify(shapes.extractPoints())) ++ .toStrictEqual(JSON.stringify(virtualShape.extractPoints())); ++ }); + }); +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+3R0QqCMBQGYK97ir3AphOnjxO2HcxIJ9uUevuWBElQ3SQR/d/NGWcHdsYvdmN7 ++NFvqpzRZSxZVSs01eqzzWao8y+OQquKclKUsE6ZW22hh9KF2jCXO2vBq7t39jxL3/AP5sNW26+re ++CL//3Bvv8pf5In8V+7IoZZGw7HMrPPfn+WvD5uB3ZDb9cGKHeGbXRtqQ7Si4lnw6NUdOp+BGQ/zW ++Pgs/kBYHzzjvLdd2Ilc3tPn2fwAAAAAAAAAAAAAAAAAAAAAA/skFqyYbqwAoAAA= +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-002967/tests/test.sh b/tasks/format-code-task-002967/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..500c9695786f5b83c1ca5f61895dfe85980aa121 --- /dev/null +++ b/tasks/format-code-task-002967/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/geometries/vgl-extrude-geometry.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-002967/tests/test_command.sh b/tasks/format-code-task-002967/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002967/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-002969/environment/Dockerfile b/tasks/format-code-task-002969/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d4383f78a1b765c3970f6f60b57df3d7e85a3f88 --- /dev/null +++ b/tasks/format-code-task-002969/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:ebf074b4509a672b15df1773f025b4af9b6d90da79bfcbe6af973d7cd9130d4a diff --git a/tasks/format-code-task-002969/environment/setup/files/blocklist b/tasks/format-code-task-002969/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002969/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-002969/environment/setup/setup.sh b/tasks/format-code-task-002969/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002969/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-002969/tests/test.patch b/tasks/format-code-task-002969/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..691797bfdd73bcd617e535a3b636f435a1bbc3b2 --- /dev/null +++ b/tasks/format-code-task-002969/tests/test.patch @@ -0,0 +1,173 @@ +diff --git a/test/unit/specs/apps-cleanup.spec.js b/test/unit/specs/apps-cleanup.spec.js +new file mode 100644 +index 0000000..5954bdc +--- /dev/null ++++ b/test/unit/specs/apps-cleanup.spec.js +@@ -0,0 +1,145 @@ ++import Router from '../../../src/index' ++ ++ ++ ++ ++function createMockApp (uid) { ++ const handlers = {} ++ return { ++ _uid: uid, ++ _isDestroyed: false, ++ $once (event, cb) { ++ handlers[event] = cb ++ }, ++ ++ $destroy () { ++ this._isDestroyed = true ++ const cb = handlers['hook:destroyed'] ++ if (cb) cb() ++ } ++ } ++} ++ ++function newRouter () { ++ return new Router({ mode: 'abstract', routes: [] }) ++} ++ ++describe('router.apps memory cleanup (issue #2639)', () => { ++ it('init() pushes the app into router.apps and sets router.app', () => { ++ const router = newRouter() ++ const app = createMockApp(1) ++ ++ router.init(app) ++ ++ expect(router.apps.length).toBe(1) ++ expect(router.apps[0]).toBe(app) ++ expect(router.app).toBe(app) ++ }) ++ ++ it('removes destroyed app from router.apps', () => { ++ const router = newRouter() ++ const app = createMockApp(1) ++ ++ router.init(app) ++ expect(router.apps.length).toBe(1) ++ ++ app.$destroy() ++ ++ expect(router.apps.length).toBe(0) ++ expect(router.apps.indexOf(app)).toBe(-1) ++ }) ++ ++ it('sets router.app to null when the only app is destroyed', () => { ++ const router = newRouter() ++ const app = createMockApp(1) ++ ++ router.init(app) ++ app.$destroy() ++ ++ expect(router.app).toBe(null) ++ }) ++ ++ it('reassigns router.app to a remaining app when the main app is destroyed', () => { ++ const router = newRouter() ++ const main = createMockApp(1) ++ const secondary = createMockApp(2) ++ ++ router.init(main) ++ router.init(secondary) ++ ++ expect(router.app).toBe(main) ++ expect(router.apps.length).toBe(2) ++ ++ main.$destroy() ++ ++ ++ expect(router.apps.length).toBe(1) ++ expect(router.apps.indexOf(main)).toBe(-1) ++ expect(router.apps[0]).toBe(secondary) ++ ++ expect(router.app).toBe(secondary) ++ expect(router.app).not.toBe(null) ++ }) ++ ++ it('leaves router.app intact when a non-main app is destroyed', () => { ++ const router = newRouter() ++ const main = createMockApp(1) ++ const secondary = createMockApp(2) ++ ++ router.init(main) ++ router.init(secondary) ++ ++ secondary.$destroy() ++ ++ expect(router.apps.length).toBe(1) ++ expect(router.apps[0]).toBe(main) ++ expect(router.app).toBe(main) ++ }) ++ ++ it('does not accumulate destroyed apps across many create/destroy cycles', () => { ++ ++ ++ ++ const router = newRouter() ++ const first = createMockApp(0) ++ router.init(first) ++ ++ for (let i = 1; i <= 10; i++) { ++ const next = createMockApp(i) ++ router.init(next) ++ ++ next.$destroy() ++ } ++ ++ ++ expect(router.apps.length).toBe(1) ++ expect(router.apps[0]).toBe(first) ++ expect(router.app).toBe(first) ++ }) ++ ++ it('handles destroying multiple apps sequentially down to empty', () => { ++ const router = newRouter() ++ const a = createMockApp(1) ++ const b = createMockApp(2) ++ const c = createMockApp(3) ++ ++ router.init(a) ++ router.init(b) ++ router.init(c) ++ ++ expect(router.apps.length).toBe(3) ++ expect(router.app).toBe(a) ++ ++ a.$destroy() ++ expect(router.apps.length).toBe(2) ++ expect(router.app).toBe(b) ++ ++ b.$destroy() ++ expect(router.apps.length).toBe(1) ++ expect(router.app).toBe(c) ++ ++ c.$destroy() ++ expect(router.apps.length).toBe(0) ++ expect(router.app).toBe(null) ++ }) ++}) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..b8dd13e +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json --filter='router.apps memory cleanup'"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx jasmine JASMINE_CONFIG_PATH=test/unit/jasmine.json --filter='router.apps memory cleanup' ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002969/tests/test.sh b/tasks/format-code-task-002969/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4922218964b4f5f3e8b831439045858f5435faa9 --- /dev/null +++ b/tasks/format-code-task-002969/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/unit/specs/apps-cleanup.spec.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-002969/tests/test_command.sh b/tasks/format-code-task-002969/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002969/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-002993/environment/Dockerfile b/tasks/format-code-task-002993/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a9ca8f225a7ddf7eb6ec8b182423c23ff84958df --- /dev/null +++ b/tasks/format-code-task-002993/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:d1e8df25ffd7f7453565aff6e44bb2d72680a69d0ff1c7c571bb90c7f4351a2c diff --git a/tasks/format-code-task-002993/environment/setup/files/blocklist b/tasks/format-code-task-002993/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002993/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-002993/environment/setup/setup.sh b/tasks/format-code-task-002993/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002993/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-002993/tests/test.patch b/tasks/format-code-task-002993/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b753e48fcea546e4d15726fe5741b6d6c7af5da0 --- /dev/null +++ b/tasks/format-code-task-002993/tests/test.patch @@ -0,0 +1,64 @@ +diff --git a/tests/pylint/runpylint.py b/tests/pylint/runpylint.py +index 3e200f976..be47f226d 100755 +--- a/tests/pylint/runpylint.py ++++ b/tests/pylint/runpylint.py +@@ -9,9 +9,6 @@ def __init__(self): + PocketLintConfig.__init__(self) + + self.falsePositives = [ FalsePositive(r"Module 'pylorax' has no 'version' member"), +- # threading.Lock() is a factory function which returns an +- # instance of the Lock class that is supported by the platform +- FalsePositive(r"Context manager 'lock' doesn't implement __enter__ and __exit__"), + FalsePositive(r"Catching too general exception Exception"), + FalsePositive(r"^E0712.*: Catching an exception which doesn't inherit from (Base|)Exception: GError$"), + FalsePositive(r"Module 'composer' has no 'version' member"), +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,34 @@ ++H4sIAAAAAAAAA+1cTW/bNhh2u24YhBX7C5zbg1Ostr4sD8EyNF9NiyZ2ELsbuosgS4zDRpZUUkpr ++DNtpf2Z/qdeddu6tp5GSEyuyHNWtrKTb+wD+ol5RFB/y/SLl5jAirmNi76xVWxVkjk67HX9yZD/j ++70pbVVS1o+gGL1cUQ1ZqqL2yFqUQsdCiCNWo74dXyRUd/0zRnPHPwmjIVjEKluFfUTXOv9rR2sB/ ++FZjj3/GOyx4Dy/AvG4J/rS13gP8qkMu/aRKPhKbZDCZlXEMQbOj6Iv4Vw9Az/LcNlfMvl3HxIvzP +++b+H+px2NPadyMXo2KeIDwDJdi3GkCkOrUuIw8HHyDRHOLTCkJpmg2H3+HvkWWO8lggIUBxG1EtO ++a6ylzrMt17046YFFR4x/PDh9Lb4tPn/aii2L4Y9vxLQS0YKhZZ8mcknZjv/ac33LOaT+iGLGZnUE ++/HD8oz/YHDzvm71naOPSbSUVDKjlMcsOie8tqGN6dRYNX2I7TF+8ny6a3Vwy7xb11Kxh52fwzjCH ++mIXmqwjTycLz8jsFv7FxIFrP0i07sOgp8Ua7lPq0sXsukr74tPtwwHz3DBcLTvu5UPCQE2SNcNcP ++H/uRVyx/hAO/UGiBwLQLKK9iPVPlp3KCPWvo4g+XF31ztbREg3FqBJY5/3P1v+uPRnwIlOUHLGH/ ++uZwi9L+iy2D/q8CV/JfkBxTYf1nmnF/mv6PqbbD/VSDX/jenA0Da2dnder7HVY9aqtIB3Bjkzv9w ++5tiUYQOW1/+GrEH8VwkK+S/BBhTpf0XO6H9Vju0/6P/VI1//pwaAdPhsz3za5ZHQ/j43BIo0ONrs ++9s3DXn8AduHzx9z8H5HSU8DL639N01XQ/1Ugj/+S038foP/n4j9d8A/6f/WY1/8jIomsBMWvIkKx ++eYYp42agsSA1cd3tB3wa8ud/MLEt+wSbZim2YCn9b8Tzv93WQP9XgSL+L2yBHUzCE997qHW4WbCX ++ukaR/tf42LjEv6p0uDjo/wqwdfdurMP/ebX28hH//Dt98DZ/iUL2DX9zas6tP2u/1pzb/draF3Za ++5hZ/9YTcnViOH7/V/au2dvvtHWEq3n6VmAwqxOK3941WiFk4xE6rwP94+23GDonLvRPXpV/yt+7a ++rfhzVnXyJtrx9usfE6v2kziHfrW6Pvyckdf/YlGEkdCnk3JCgSX0vyIraqL/If9fCQr4LyUUKND/ ++SrtjZPjvGB3w/ytBnv/fnA2AG7UTYG9EpgvmW9Ty7JPBJMCZhfltfzwmYaZwQHFWrk9GnsWvkS1/ ++TFx84DvZ4i3XH2aKek+d7GWsUabkCJ8RYbR+sdxTTDMHd8jxcS9Zfs85kr0viq0QP3atUVb4ER+/ ++IbHHmHtnzkVPi1mbE7Ll8DJb904Y/5TV7/m2nNfjBzgvhMxpz9X1xK2ZDc/iKs+HDpku6+d31zGn ++3fTwa5NPADOwwpMPr3ifDNMbCPau2JAwIGP8s+WuaCX/41Co/0sIBZeJ/wzVEPq/04H8XyVYgv+P ++DgWL4j/O/GX+VV0R8T/Y/9XjPP77g8d/qJaJ/0Qs9aiWjesywdZ77cpgLt+ZnAVnoop3Vd4xII05 ++ylwyFJSVuQi0VP4vzv/rWgfW/yvBQv5LXAQq0v+KrGb3f7TF8z+g/1eP+fhvOgCkZGvqyGQ4NIV/ ++DCtA/0XMzf+xNSJ2uVsAlsn/qYp4/k8XaSDQ/xVgAf+lbgEo0v+armX4N8RjgKD/K8C8/o8HAGpw ++M5B8S4I9NCSeQzyu9qWDzb2n22a3191FG0g+T4QcCOFZijD7UMMsgSJfyrrky9TrknSRNjoWWS9+ ++DN3jbXGJF64jhzDxjMUGxVyKeNh5KIZxSDwplT2MW3Qjkiw3GHPznwbja3z+83z/V1uH578rQS7/ ++1T7/Keuakd3/ZbTh+Y9KMK//+QC4Ias+qecr+zi9qHN0eHDw9GjX3NvvbV0u3t7c39/a3H5mPu+K ++Pctmf9A7TEkMLYYtap/wovqbHwzT0OvczoTYFosKLuZHzy6t01w3O6vH3PznJBEvenPN+R9dA/+/ ++Eizkv8r8j96ey//o4P9Xgnn9Px0Asf9NmDn9aSZPNTuNmZP+2HIZjsUYtiNKwokwENjjldi4kXb4 ++r/smAQsxN/8n0XX6/4oqT/1/HfR/Fcjlv2L//1L+Rwb/v0rM638+AG6I/5+04kU0/rS/gLnuLr7R ++SM1/sYpv2v54bHlOk52Ud40i/a93OhfzX9Pawv8X20Bg/leAe9+1hsRr8cD4RLIddL6VQ5LuoV2P ++iQ2SwYQPDu4JIuvMIq5wAiX8JvBpiA43B0826vef9A52W81YTNS1fl+U1yV8Zrmofr8xPZ8bFPRw ++rS4qFsH84YvBk15XSKLQ50dtN3Iwik1QkoUmjBFvhNiEhXiMguSvgXgjPAcF1Bf/nYSYH3FP86I1 ++FzVu1BfuSFm//9tM7vf1ZotRuxU36ijypulldEYsFPj2KQ7FT6kZ18ZaydEWjbzkG79l0C0AAAAA ++AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADg+vAvGaEUrAB4AAA= +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-002993/tests/test.sh b/tasks/format-code-task-002993/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..79b67f656ad756944968cfea8efc65dfd7e4f48f --- /dev/null +++ b/tasks/format-code-task-002993/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/pylint/runpylint.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-002993/tests/test_command.sh b/tasks/format-code-task-002993/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002993/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-003011/environment/Dockerfile b/tasks/format-code-task-003011/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f0c6566f84afbf764135e12d23622c61ada10b2a --- /dev/null +++ b/tasks/format-code-task-003011/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:aa9f36f85ddd75b8f32cdfc7be42af9354ccca7b92bff96785298057b54d68dd diff --git a/tasks/format-code-task-003011/environment/setup/files/blocklist b/tasks/format-code-task-003011/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003011/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-003011/environment/setup/setup.sh b/tasks/format-code-task-003011/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003011/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-003011/tests/test.patch b/tasks/format-code-task-003011/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..be5083077d4949f411eeda59f3594f2d93c73411 --- /dev/null +++ b/tasks/format-code-task-003011/tests/test.patch @@ -0,0 +1,421 @@ +diff --git a/usercase-test-coderl/test_pubsub_unsubscribe.py b/usercase-test-coderl/test_pubsub_unsubscribe.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_pubsub_unsubscribe.py +@@ -0,0 +1,389 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import importlib ++import warnings ++ ++import pytest ++ ++import wx ++ ++if not hasattr(wx, "wxPyDeprecationWarning"): ++ wx.wxPyDeprecationWarning = DeprecationWarning ++ ++warnings.filterwarnings("ignore", category=DeprecationWarning) ++ ++from wx.lib.pubsub import pub as pub_module ++from wx.lib.pubsub.core import Listener, Publisher ++from wx.lib.pubsub.utils.notification import IgnoreNotificationsMixin ++ ++ ++def fresh_pub(): ++ return importlib.reload(pub_module) ++ ++ ++def make_listener(name, sink): ++ def listener(payload=None): ++ sink.append((name, payload)) ++ ++ listener.__name__ = name ++ return listener ++ ++ ++class UnsubscribeRecorder(IgnoreNotificationsMixin): ++ def __init__(self): ++ self.events = [] ++ ++ def notifyUnsubscribe(self, pubListener, topicObj): ++ ++ self.events.append((pubListener.getCallable(), topicObj.getName())) ++ ++ ++def assert_removed_callables(removed, expected_callables): ++ ++ assert isinstance(removed, list) ++ assert len(removed) == len(expected_callables) ++ assert all(isinstance(wrapper, Listener) for wrapper in removed) ++ assert {wrapper.getCallable() for wrapper in removed} == set(expected_callables) ++ ++ ++def test_default_pub_and_publisher_expose_unsubscribe_methods(): ++ ++ ++ ++ ++ pub = fresh_pub() ++ publisher = Publisher() ++ ++ assert callable(pub.unsubscribe) == True ++ assert callable(pub.unsubAll) == True ++ assert callable(publisher.unsubscribe) == True ++ assert callable(publisher.unsubAll) == True ++ ++ ++def test_unsubscribe_removes_only_requested_listener_and_notifies_once(): ++ ++ ++ ++ ++ pub = fresh_pub() ++ calls = [] ++ first_listener = make_listener("first_listener", calls) ++ second_listener = make_listener("second_listener", calls) ++ recorder = UnsubscribeRecorder() ++ ++ pub.addNotificationHandler(recorder) ++ pub.setNotificationFlags(all=False, unsubscribe=True) ++ first_wrapper, first_is_new = pub.subscribe(first_listener, "orders.created") ++ second_wrapper, second_is_new = pub.subscribe(second_listener, "orders.created") ++ topic = pub.getDefaultTopicMgr().getTopic("orders.created") ++ ++ assert first_is_new == True ++ assert second_is_new == True ++ assert topic.getNumListeners() == 2 ++ ++ assert first_wrapper.getCallable() is first_listener ++ assert second_wrapper.getCallable() is second_listener ++ ++ pub.sendMessage("orders.created", payload="before") ++ ++ assert sorted(calls) == [("first_listener", "before"), ("second_listener", "before")] ++ ++ removed = pub.unsubscribe(first_listener, "orders.created") ++ ++ assert isinstance(removed, Listener) ++ assert removed.getCallable() is first_listener ++ assert topic.getNumListeners() == 1 ++ assert recorder.events == [(first_listener, "orders.created")] ++ ++ calls.clear() ++ pub.sendMessage("orders.created", payload="after") ++ assert calls == [("second_listener", "after")] ++ ++ ++def test_unsubscribe_again_returns_none_and_does_not_notify(): ++ ++ ++ ++ ++ pub = fresh_pub() ++ calls = [] ++ first_listener = make_listener("first_listener", calls) ++ second_listener = make_listener("second_listener", calls) ++ recorder = UnsubscribeRecorder() ++ ++ pub.addNotificationHandler(recorder) ++ pub.setNotificationFlags(all=False, unsubscribe=True) ++ pub.subscribe(first_listener, "orders.created") ++ pub.subscribe(second_listener, "orders.created") ++ topic = pub.getDefaultTopicMgr().getTopic("orders.created") ++ pub.unsubscribe(first_listener, "orders.created") ++ assert topic.getNumListeners() == 1 ++ assert recorder.events == [(first_listener, "orders.created")] ++ ++ second_removed = pub.unsubscribe(first_listener, "orders.created") ++ assert second_removed == None ++ assert topic.getNumListeners() == 1 ++ assert recorder.events == [(first_listener, "orders.created")] ++ ++ pub.sendMessage("orders.created", payload="still-subscribed") ++ assert calls == [("second_listener", "still-subscribed")] ++ ++ ++def test_unsubscribe_missing_topic_raises_topic_name_error(): ++ ++ ++ ++ ++ pub = fresh_pub() ++ calls = [] ++ listener = make_listener("missing_topic_listener", calls) ++ ++ with pytest.raises(pub.TopicNameError) as excinfo: ++ pub.unsubscribe(listener, "missing.topic") ++ ++ ++ assert isinstance(excinfo.value, pub.TopicNameError) ++ assert calls == [] ++ ++ ++def test_unsub_all_topic_removes_direct_listeners_and_notifies_each(): ++ ++ ++ ++ ++ pub = fresh_pub() ++ calls = [] ++ bulk_first = make_listener("bulk_first", calls) ++ bulk_second = make_listener("bulk_second", calls) ++ parent_listener = make_listener("parent_listener", calls) ++ recorder = UnsubscribeRecorder() ++ ++ pub.addNotificationHandler(recorder) ++ pub.setNotificationFlags(all=False, unsubscribe=True) ++ pub.subscribe(bulk_first, "orders.created") ++ pub.subscribe(bulk_second, "orders.created") ++ pub.subscribe(parent_listener, "orders") ++ created_topic = pub.getDefaultTopicMgr().getTopic("orders.created") ++ parent_topic = pub.getDefaultTopicMgr().getTopic("orders") ++ ++ assert created_topic.getNumListeners() == 2 ++ assert parent_topic.getNumListeners() == 1 ++ ++ removed = pub.unsubAll("orders.created") ++ assert_removed_callables(removed, [bulk_first, bulk_second]) ++ assert created_topic.getNumListeners() == 0 ++ assert parent_topic.getNumListeners() == 1 ++ ++ assert len(recorder.events) == 2 ++ assert set(recorder.events) == { ++ (bulk_first, "orders.created"), ++ (bulk_second, "orders.created"), ++ } ++ ++ pub.sendMessage("orders.created", payload="post-bulk") ++ assert calls == [("parent_listener", "post-bulk")] ++ ++ ++def test_unsub_all_topic_listener_filter_removes_matching_wrappers_only(): ++ ++ ++ ++ ++ pub = fresh_pub() ++ calls = [] ++ seen_by_filter = [] ++ alpha = make_listener("filter_alpha", calls) ++ beta = make_listener("filter_beta", calls) ++ gamma = make_listener("filter_gamma", calls) ++ ++ pub.subscribe(alpha, "orders.created") ++ pub.subscribe(beta, "orders.created") ++ pub.subscribe(gamma, "orders.created") ++ ++ def predicate(wrapper): ++ ++ assert isinstance(wrapper, Listener) ++ seen_by_filter.append(wrapper.getCallable()) ++ return wrapper.getCallable() is beta ++ ++ removed = pub.unsubAll("orders.created", listenerFilter=predicate) ++ topic = pub.getDefaultTopicMgr().getTopic("orders.created") ++ ++ ++ assert len(seen_by_filter) == 3 ++ assert set(seen_by_filter) == {alpha, beta, gamma} ++ assert_removed_callables(removed, [beta]) ++ assert topic.getNumListeners() == 2 ++ ++ pub.sendMessage("orders.created", payload="post-filter") ++ ++ assert set(calls) == { ++ ("filter_alpha", "post-filter"), ++ ("filter_gamma", "post-filter"), ++ } ++ ++ ++def test_unsub_all_listener_filter_applies_across_topics(): ++ ++ ++ ++ ++ pub = fresh_pub() ++ calls = [] ++ keep_created = make_listener("global_keep_created", calls) ++ remove_created = make_listener("global_remove_created", calls) ++ remove_cancelled = make_listener("global_remove_cancelled", calls) ++ keep_cancelled = make_listener("global_keep_cancelled", calls) ++ ++ pub.subscribe(keep_created, "orders.created") ++ pub.subscribe(remove_created, "orders.created") ++ pub.subscribe(remove_cancelled, "orders.cancelled") ++ pub.subscribe(keep_cancelled, "orders.cancelled") ++ ++ def remove_global(wrapper): ++ ++ assert isinstance(wrapper, Listener) ++ return wrapper.getCallable() in {remove_created, remove_cancelled} ++ ++ removed = pub.unsubAll(listenerFilter=remove_global) ++ created_topic = pub.getDefaultTopicMgr().getTopic("orders.created") ++ cancelled_topic = pub.getDefaultTopicMgr().getTopic("orders.cancelled") ++ ++ assert_removed_callables(removed, [remove_created, remove_cancelled]) ++ assert created_topic.getNumListeners() == 1 ++ assert cancelled_topic.getNumListeners() == 1 ++ ++ pub.sendMessage("orders.created", payload="created") ++ pub.sendMessage("orders.cancelled", payload="cancelled") ++ ++ assert set(calls) == { ++ ("global_keep_created", "created"), ++ ("global_keep_cancelled", "cancelled"), ++ } ++ ++ ++def test_unsub_all_topic_filter_limits_bulk_removal_to_matching_topics(): ++ ++ ++ ++ ++ pub = fresh_pub() ++ calls = [] ++ topic_created = make_listener("topic_created", calls) ++ topic_cancelled = make_listener("topic_cancelled", calls) ++ invoice_created = make_listener("invoice_created", calls) ++ ++ pub.subscribe(topic_created, "orders.created") ++ pub.subscribe(topic_cancelled, "orders.cancelled") ++ pub.subscribe(invoice_created, "invoices.created") ++ ++ removed = pub.unsubAll(topicFilter=lambda name: name.startswith("orders.")) ++ orders_created = pub.getDefaultTopicMgr().getTopic("orders.created") ++ orders_cancelled = pub.getDefaultTopicMgr().getTopic("orders.cancelled") ++ invoices_created = pub.getDefaultTopicMgr().getTopic("invoices.created") ++ ++ assert_removed_callables(removed, [topic_created, topic_cancelled]) ++ assert orders_created.getNumListeners() == 0 ++ assert orders_cancelled.getNumListeners() == 0 ++ assert invoices_created.getNumListeners() == 1 ++ ++ pub.sendMessage("orders.created", payload="created") ++ pub.sendMessage("orders.cancelled", payload="cancelled") ++ pub.sendMessage("invoices.created", payload="invoice") ++ assert calls == [("invoice_created", "invoice")] ++ ++ ++def test_unsub_all_without_arguments_removes_all_and_is_idempotent_cleanup(): ++ ++ ++ ++ ++ pub = fresh_pub() ++ calls = [] ++ all_orders = make_listener("all_orders", calls) ++ all_invoices = make_listener("all_invoices", calls) ++ ++ pub.subscribe(all_orders, "orders.created") ++ pub.subscribe(all_invoices, "invoices.created") ++ orders_topic = pub.getDefaultTopicMgr().getTopic("orders.created") ++ invoices_topic = pub.getDefaultTopicMgr().getTopic("invoices.created") ++ ++ assert orders_topic.getNumListeners() == 1 ++ assert invoices_topic.getNumListeners() == 1 ++ ++ removed = pub.unsubAll() ++ assert_removed_callables(removed, [all_orders, all_invoices]) ++ assert orders_topic.getNumListeners() == 0 ++ assert invoices_topic.getNumListeners() == 0 ++ ++ second_removed = pub.unsubAll() ++ assert second_removed == [] ++ assert orders_topic.getNumListeners() == 0 ++ assert invoices_topic.getNumListeners() == 0 ++ ++ ++def test_publisher_instances_keep_independent_subscription_state(): ++ ++ ++ ++ ++ calls = [] ++ publisher_a = Publisher() ++ publisher_b = Publisher() ++ instance_a = make_listener("instance_a", calls) ++ instance_a_two = make_listener("instance_a_two", calls) ++ instance_b = make_listener("instance_b", calls) ++ ++ publisher_a.subscribe(instance_a, "orders.created") ++ publisher_a.subscribe(instance_a_two, "orders.created") ++ publisher_b.subscribe(instance_b, "orders.created") ++ ++ topic_a = publisher_a.getTopicMgr().getTopic("orders.created") ++ topic_b = publisher_b.getTopicMgr().getTopic("orders.created") ++ assert topic_a.getNumListeners() == 2 ++ assert topic_b.getNumListeners() == 1 ++ ++ removed = publisher_a.unsubAll("orders.created") ++ assert_removed_callables(removed, [instance_a, instance_a_two]) ++ assert topic_a.getNumListeners() == 0 ++ assert topic_b.getNumListeners() == 1 ++ ++ publisher_b.sendMessage("orders.created", payload="alive") ++ assert calls == [("instance_b", "alive")] ++ ++ ++def test_unsub_all_leak_floor_listener_count_stays_bounded_over_cycles(): ++ ++ ++ ++ ++ publisher = Publisher() ++ kept_alive = [] ++ ++ for index in range(120): ++ sink = [] ++ listener = make_listener("cycle_listener_%03d" % index, sink) ++ kept_alive.append(listener) ++ wrapper, is_new = publisher.subscribe(listener, "orders.created") ++ topic = publisher.getTopicMgr().getTopic("orders.created") ++ assert is_new == True ++ ++ assert wrapper.getCallable() is listener ++ assert topic.getNumListeners() == 1 ++ ++ removed = publisher.unsubAll() ++ assert_removed_callables(removed, [listener]) ++ assert topic.getNumListeners() == 0 ++ ++ final_topic = publisher.getTopicMgr().getTopic("orders.created") ++ assert final_topic.getNumListeners() == 0 ++ assert len(kept_alive) == 120 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,22 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:$PYTHONPATH}" ++export PYTHONNOUSERSITE=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++unset PYTEST_ADDOPTS ++unset PYTEST_PLUGINS ++ ++python -m pytest -p no:pastebin /workspace/repo/usercase-test-coderl/test_pubsub_unsubscribe.py -v diff --git a/tasks/format-code-task-003011/tests/test.sh b/tasks/format-code-task-003011/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d9b51678a93e7facd0079e63604792cce8dbb14b --- /dev/null +++ b/tasks/format-code-task-003011/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_pubsub_unsubscribe.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-003011/tests/test_command.sh b/tasks/format-code-task-003011/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003011/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-003016/environment/Dockerfile b/tasks/format-code-task-003016/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b096b5afc7450250cb575e64446681e91a930780 --- /dev/null +++ b/tasks/format-code-task-003016/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:1fac1c69c9628b77de077672389564da15b0e408a7ba8d1f37d3c1cd08625765 diff --git a/tasks/format-code-task-003016/environment/setup/files/blocklist b/tasks/format-code-task-003016/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003016/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-003016/environment/setup/setup.sh b/tasks/format-code-task-003016/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003016/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-003016/tests/test.patch b/tasks/format-code-task-003016/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..dea237627744c4bf0c9a7fe820eb17def0f29b4f --- /dev/null +++ b/tasks/format-code-task-003016/tests/test.patch @@ -0,0 +1,306 @@ +diff --git a/tests/classes/test_hypergraph.py b/tests/classes/test_hypergraph.py +index f1932dc..1db74b8 100644 +--- a/tests/classes/test_hypergraph.py ++++ b/tests/classes/test_hypergraph.py +@@ -4,6 +4,48 @@ import xgi + from xgi.exception import XGIError + + ++def _edge_memberships(raw_edges): ++ raw_edges = list(raw_edges) ++ if raw_edges and all( ++ not isinstance(edge, (frozenset, set, list, tuple)) for edge in raw_edges ++ ): ++ return {frozenset(raw_edges)} ++ return {frozenset(edge) for edge in raw_edges} ++ ++ ++def _find_duplicate_membership_helper(H, expected): ++ for name in dir(H): ++ lowered = name.lower() ++ if name.startswith("_") or "duplicate" not in lowered: ++ continue ++ helper = getattr(H, name) ++ if not callable(helper): ++ continue ++ try: ++ if _edge_memberships(helper()) == expected: ++ return name ++ except Exception: ++ continue ++ raise AssertionError("No public duplicate-membership helper found") ++ ++ ++def _test_reports_repeated_edge_memberships(): ++ H = xgi.Hypergraph() ++ H.add_edges_from([[1, 2], [3, 4], [2, 1], [5, 6]]) ++ ++ expected = {frozenset({1, 2})} ++ helper_name = _find_duplicate_membership_helper(H, expected) ++ assert _edge_memberships(getattr(H, helper_name)()) == expected ++ ++ unique = xgi.Hypergraph([[10, 11], [12, 13], [14, 15]]) ++ assert _edge_memberships(getattr(unique, helper_name)()) == set() ++ ++ ++globals()["test_duplicate" + "_edges_reports_repeated_memberships"] = ( ++ _test_reports_repeated_edge_memberships ++) ++ ++ + def test_constructor(edgelist5, dict5, incidence5, dataframe5): + H_list = xgi.Hypergraph(edgelist5) + H_dict = xgi.Hypergraph(dict5) +diff --git a/tests/classes/test_simplicialcomplex.py b/tests/classes/test_simplicialcomplex.py +new file mode 100644 +index 0000000..eaa38f5 +--- /dev/null ++++ b/tests/classes/test_simplicialcomplex.py +@@ -0,0 +1,193 @@ ++import itertools ++ ++import pytest ++ ++import xgi ++from xgi.exception import XGIError ++ ++ ++def _memberships(sc): ++ return {frozenset(sc.edges.members(edge_id)) for edge_id in sc.edges} ++ ++ ++_EDGE_MUTATION_METHODS = { ++ "add_edge", ++ "add_edges_from", ++ "add_weighted_edges_from", ++ "remove_edge", ++ "remove_edges_from", ++} ++ ++ ++def _expected_non_singleton_faces(nodes): ++ nodes = set(nodes) ++ return { ++ frozenset(face) ++ for size in range(2, len(nodes) + 1) ++ for face in itertools.combinations(nodes, size) ++ } ++ ++ ++def _public_simplex_callables(sc): ++ for name in dir(sc): ++ lowered = name.lower() ++ if name.startswith("_") or name in _EDGE_MUTATION_METHODS: ++ continue ++ if "simplex" not in lowered and "simplic" not in lowered: ++ continue ++ method = getattr(sc, name) ++ if callable(method): ++ yield name, method ++ ++ ++def _find_single_simplex_adder(simplex): ++ for name, _ in _public_simplex_callables(xgi.SimplicialComplex()): ++ lowered = name.lower() ++ if "add" not in lowered or "weighted" in lowered: ++ continue ++ trial = xgi.SimplicialComplex() ++ try: ++ getattr(trial, name)(list(simplex)) ++ except Exception: ++ continue ++ if _memberships(trial) == _expected_non_singleton_faces(simplex): ++ return name ++ raise AssertionError("No public single-simplex add method found") ++ ++ ++def _add_one_simplex(sc, simplex): ++ getattr(sc, _find_single_simplex_adder(simplex))(list(simplex)) ++ ++ ++def _find_bulk_simplex_adder(simplices): ++ expected = set().union(*(_expected_non_singleton_faces(s) for s in simplices)) ++ for name, _ in _public_simplex_callables(xgi.SimplicialComplex()): ++ lowered = name.lower() ++ if "add" not in lowered or "weighted" in lowered: ++ continue ++ trial = xgi.SimplicialComplex() ++ try: ++ getattr(trial, name)([list(s) for s in simplices]) ++ except Exception: ++ continue ++ if _memberships(trial) == expected: ++ return name ++ raise AssertionError("No public bulk simplex add method found") ++ ++ ++def _add_many_simplices(sc, simplices): ++ getattr(sc, _find_bulk_simplex_adder(simplices))([list(s) for s in simplices]) ++ ++ ++def _simplex_is_present(sc, simplex): ++ for name, method in _public_simplex_callables(sc): ++ lowered = name.lower() ++ if not any(word in lowered for word in ("has", "contain", "present")): ++ continue ++ try: ++ result = method(simplex) ++ except Exception: ++ continue ++ if isinstance(result, bool): ++ return result ++ raise AssertionError("No public simplex membership-check method found") ++ ++ ++def test_simplicial_complex_public_api_and_subclass(): ++ from xgi.classes import SimplicialComplex ++ ++ sc_from_top_level = xgi.SimplicialComplex() ++ sc_from_classes = SimplicialComplex() ++ ++ assert isinstance(sc_from_top_level, xgi.Hypergraph) ++ assert isinstance(sc_from_classes, xgi.Hypergraph) ++ ++ ++@pytest.mark.parametrize( ++ ("method_name", "args"), ++ [ ++ ("add_edge", ([1, 2],)), ++ ("add_edges_from", ([[1, 2]],)), ++ ("add_weighted_edges_from", ([([1, 2], 1.0)],)), ++ ("remove_edge", (0,)), ++ ("remove_edges_from", ([0],)), ++ ], ++) ++def test_regular_edge_mutation_methods_are_rejected(method_name, args): ++ sc = xgi.SimplicialComplex() ++ ++ with pytest.raises(XGIError) as excinfo: ++ getattr(sc, method_name)(*args) ++ ++ assert str(excinfo.value).strip() ++ ++ ++def test_single_simplex_adds_downward_closure(): ++ sc = xgi.SimplicialComplex() ++ ++ _add_one_simplex(sc, [1, 2, 3]) ++ ++ expected = _expected_non_singleton_faces({1, 2, 3}) ++ assert sc.num_nodes == 3 ++ assert sc.num_edges == 4 ++ assert _memberships(sc) == expected ++ ++ for simplex in expected: ++ assert _simplex_is_present(sc, simplex) ++ ++ ++def test_single_simplex_add_canonicalizes_nodes(): ++ sc = xgi.SimplicialComplex() ++ ++ _add_one_simplex(sc, [1, 2]) ++ assert sc.num_nodes == 2 ++ assert sc.num_edges == 1 ++ assert _simplex_is_present(sc, [2, 1]) ++ assert _memberships(sc) == {frozenset({1, 2})} ++ ++ _add_one_simplex(sc, [2, 1]) ++ assert sc.num_edges == 1 ++ ++ ++def test_bulk_simplex_adds_downward_closure(): ++ sc = xgi.SimplicialComplex() ++ ++ _add_many_simplices(sc, [[10, 11, 12, 13]]) ++ ++ nodes = {10, 11, 12, 13} ++ expected = _expected_non_singleton_faces(nodes) ++ ++ assert sc.num_nodes == 4 ++ assert sc.num_edges == 11 ++ assert _memberships(sc) == expected ++ ++ ++def test_duplicate_simplex_inputs_do_not_create_new_simplices(): ++ sc = xgi.SimplicialComplex() ++ ++ _add_one_simplex(sc, [1, 2, 3]) ++ count_after_first_add = sc.num_edges ++ ++ _add_one_simplex(sc, [3, 2, 1]) ++ assert sc.num_edges == count_after_first_add ++ ++ _add_one_simplex(sc, [1, 2]) ++ assert sc.num_edges == count_after_first_add ++ assert _simplex_is_present(sc, [2, 1]) ++ assert not _simplex_is_present(sc, [1, 4]) ++ ++ ++def test_simplicial_complex_string_summary(): ++ unnamed = xgi.SimplicialComplex() ++ unnamed_summary = str(unnamed) ++ assert type(unnamed).__name__ in unnamed_summary ++ assert "simplic" in unnamed_summary.lower() ++ assert "hyperedge" not in unnamed_summary.lower() ++ ++ named = xgi.SimplicialComplex(name="example") ++ _add_one_simplex(named, [1, 2, 3]) ++ named_summary = str(named) ++ assert type(named).__name__ in named_summary ++ assert "example" in named_summary ++ assert "simplic" in named_summary.lower() ++ assert "hyperedge" not in named_summary.lower() +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 ++ ++setup_env() { ++ ++ export PATH="$HOME/.pyenv/bin:$PATH" ++ set +u ++ eval "$(pyenv init --path)" ++ eval "$(pyenv init -)" ++ pyenv shell 3.9.21 ++ set -u ++ ++ python3 -m venv /testbed/.venv ++ set +u ++ source /testbed/.venv/bin/activate ++ set -u ++ ++ ++ if [ ! -f /testbed/.venv/.stage3a_deps_installed ]; then ++ pip install --upgrade pip "setuptools<70" wheel --no-input ++ pip install "numpy>=1.19,<1.22" "scipy>=1.5,<1.8.0" "pandas>=1.0,<=1.3.5" "networkx>=2.0" pytest pytest-cov --no-input ++ touch /testbed/.venv/.stage3a_deps_installed ++ fi ++ pip install -e /testbed --no-build-isolation --no-input ++} ++ ++setup_env ++ ++case "${1:-}" in ++ base) ++ python -m pytest \ ++ tests/classes/test_hypergraph.py \ ++ tests/generators/test_classic.py \ ++ tests/linalg/test_matrix.py \ ++ -k "not test_duplicate_edges_reports_repeated_memberships" \ ++ -v ++ ;; ++ new) ++ python -m pytest \ ++ tests/classes/test_hypergraph.py::test_duplicate_edges_reports_repeated_memberships \ ++ tests/classes/test_simplicialcomplex.py \ ++ -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-003016/tests/test.sh b/tasks/format-code-task-003016/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1b47952ca8eff74d42e5a62b824ae52c0dbfd664 --- /dev/null +++ b/tasks/format-code-task-003016/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/classes/test_hypergraph.py +tests/classes/test_simplicialcomplex.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-003016/tests/test_command.sh b/tasks/format-code-task-003016/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-003016/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-003018/environment/Dockerfile b/tasks/format-code-task-003018/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3e7d59ff70e26b657edd9845d35865afd3ab0dcd --- /dev/null +++ b/tasks/format-code-task-003018/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:23769b45d5efab40d72a28a26e694d111184d0fae0d0ad274bc1e6c39fb805ce diff --git a/tasks/format-code-task-003018/environment/setup/files/blocklist b/tasks/format-code-task-003018/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003018/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-003018/environment/setup/setup.sh b/tasks/format-code-task-003018/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003018/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-003018/tests/test.patch b/tasks/format-code-task-003018/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..81a98f67bdbc89b2b0d40f3c5721972817171a18 --- /dev/null +++ b/tasks/format-code-task-003018/tests/test.patch @@ -0,0 +1,329 @@ +diff --git a/usercase-test-coderl/fixtures/bigbench_colors.json b/usercase-test-coderl/fixtures/bigbench_colors.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/bigbench_colors.json +@@ -0,0 +1,24 @@ ++{ ++ "description": "Pick a color", ++ "task_prefix": "Choose the best answer.", ++ "examples": [ ++ { ++ "input": "Which color is the sky on a clear day?", ++ "target_scores": { ++ "red": 0, ++ "blue": 1, ++ "green": 0, ++ "yellow": 0 ++ } ++ }, ++ { ++ "input": "Which color names fresh grass?", ++ "target_scores": { ++ "red": 0, ++ "blue": 0, ++ "green": 1, ++ "yellow": 0 ++ } ++ } ++ ] ++} +diff --git a/usercase-test-coderl/fixtures/bigbench_mixed_options.json b/usercase-test-coderl/fixtures/bigbench_mixed_options.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/bigbench_mixed_options.json +@@ -0,0 +1,22 @@ ++{ ++ "description": "Pick an object", ++ "task_prefix": "Choose the best answer.", ++ "examples": [ ++ { ++ "input": "Which object is used for writing?", ++ "target_scores": { ++ "pen": 1, ++ "cup": 0 ++ } ++ }, ++ { ++ "input": "Which object tells time?", ++ "target_scores": { ++ "spoon": 0, ++ "clock": 1, ++ "blanket": 0, ++ "lamp": 0 ++ } ++ } ++ ] ++} +diff --git a/usercase-test-coderl/fixtures/bigbench_shapes.json b/usercase-test-coderl/fixtures/bigbench_shapes.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/bigbench_shapes.json +@@ -0,0 +1,22 @@ ++{ ++ "description": "Pick a shape", ++ "task_prefix": "Choose the best answer.", ++ "examples": [ ++ { ++ "input": "What shape has three sides?", ++ "target_scores": { ++ "circle": 0, ++ "triangle": 1, ++ "square": 0 ++ } ++ }, ++ { ++ "input": "What shape is round?", ++ "target_scores": { ++ "circle": 1, ++ "triangle": 0, ++ "square": 0 ++ } ++ } ++ ] ++} +diff --git a/usercase-test-coderl/fixtures/bigbench_shapes_no_prefix.json b/usercase-test-coderl/fixtures/bigbench_shapes_no_prefix.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/bigbench_shapes_no_prefix.json +@@ -0,0 +1,21 @@ ++{ ++ "description": "Pick a shape", ++ "examples": [ ++ { ++ "input": "What shape has three sides?", ++ "target_scores": { ++ "circle": 0, ++ "triangle": 1, ++ "square": 0 ++ } ++ }, ++ { ++ "input": "What shape is round?", ++ "target_scores": { ++ "circle": 1, ++ "triangle": 0, ++ "square": 0 ++ } ++ } ++ ] ++} +diff --git a/usercase-test-coderl/test_bigbench_adapter.py b/usercase-test-coderl/test_bigbench_adapter.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_bigbench_adapter.py +@@ -0,0 +1,186 @@ ++import os ++ ++import pytest ++ ++from tasks import get_task ++ ++ ++FIXTURES = "/workspace/repo/usercase-test-coderl/fixtures" ++ ++def _make_task(filename, train_size=2, eval_size=2): ++ CustomTask = get_task("bigbench") ++ assert CustomTask.__name__ == "CustomTask" ++ return CustomTask( ++ train_size, ++ eval_size, ++ task_name="bigbench", ++ task_description="task from bigbench", ++ data_dir=os.path.join(FIXTURES, filename), ++ seed=None, ++ post_instruction=True, ++ option_num=5, ++ ) ++ ++ ++def test_get_task_constructs_prefixed_bigbench_examples(): ++ ++ ++ ++ ++ task = _make_task("bigbench_shapes.json") ++ ++ assert task.task_name == "bigbench" ++ assert task.task_description == "Pick a shape" ++ assert task.option_num == 3 ++ assert len(task.train_size) == 2 ++ assert len(task.eval_size) == 2 ++ assert len(task.test_size) == 2 ++ assert task.dataset == { ++ "train": [ ++ { ++ "question": "Choose the best answer.\nWhat shape has three sides?\nOptions:\n(A) circle\n(B) triangle\n(C) square\n", ++ "answer": "B", ++ }, ++ { ++ "question": "Choose the best answer.\nWhat shape is round?\nOptions:\n(A) circle\n(B) triangle\n(C) square\n", ++ "answer": "A", ++ }, ++ ], ++ "eval": [ ++ { ++ "question": "Choose the best answer.\nWhat shape has three sides?\nOptions:\n(A) circle\n(B) triangle\n(C) square\n", ++ "answer": "B", ++ }, ++ { ++ "question": "Choose the best answer.\nWhat shape is round?\nOptions:\n(A) circle\n(B) triangle\n(C) square\n", ++ "answer": "A", ++ }, ++ ], ++ "test": [ ++ { ++ "question": "Choose the best answer.\nWhat shape has three sides?\nOptions:\n(A) circle\n(B) triangle\n(C) square\n", ++ "answer": "B", ++ }, ++ { ++ "question": "Choose the best answer.\nWhat shape is round?\nOptions:\n(A) circle\n(B) triangle\n(C) square\n", ++ "answer": "A", ++ }, ++ ], ++ } ++ ++ ++def test_formats_examples_without_task_prefix(): ++ ++ ++ ++ ++ task = _make_task("bigbench_shapes_no_prefix.json") ++ ++ assert task.task_description == "Pick a shape" ++ assert task.option_num == 3 ++ assert task.dataset["train"] == [ ++ { ++ "question": "What shape has three sides?\nOptions:\n(A) circle\n(B) triangle\n(C) square\n", ++ "answer": "B", ++ }, ++ { ++ "question": "What shape is round?\nOptions:\n(A) circle\n(B) triangle\n(C) square\n", ++ "answer": "A", ++ }, ++ ] ++ ++ ++def test_option_num_uses_largest_target_scores_example(): ++ ++ ++ ++ ++ task = _make_task("bigbench_mixed_options.json") ++ ++ assert task.task_description == "Pick an object" ++ assert task.option_num == 4 ++ assert task.dataset["train"] == [ ++ { ++ "question": "Choose the best answer.\nWhich object is used for writing?\nOptions:\n(A) pen\n(B) cup\n", ++ "answer": "A", ++ }, ++ { ++ "question": "Choose the best answer.\nWhich object tells time?\nOptions:\n(A) spoon\n(B) clock\n(C) blanket\n(D) lamp\n", ++ "answer": "B", ++ }, ++ ] ++ assert task.clean_response("(D)") == "D" ++ assert task.clean_response("d") == "D" ++ assert task.clean_response("E") == "N/A: Format error" ++ ++ ++def test_clean_response_parses_tags_fallbacks_and_format_errors(): ++ ++ ++ ++ ++ task = _make_task("bigbench_shapes.json") ++ ++ assert task.clean_response("(B)") == "B" ++ assert task.clean_response("b") == "B" ++ assert task.clean_response("I choose triangle") == "B" ++ assert task.clean_response("") == "N/A: Format error" ++ assert task.clean_response("Z") == "N/A: Format error" ++ assert task.clean_response("No known option here") == "N/A: Format error" ++ ++ ++def test_instances_keep_option_text_fallbacks_independent(): ++ ++ ++ ++ ++ shapes = _make_task("bigbench_shapes.json") ++ colors = _make_task("bigbench_colors.json") ++ ++ assert shapes.task_description == "Pick a shape" ++ assert shapes.option_num == 3 ++ assert shapes.clean_response("I choose triangle") == "B" ++ assert shapes.clean_response("I choose blue") == "N/A: Format error" ++ assert colors.task_description == "Pick a color" ++ assert colors.option_num == 4 ++ assert colors.clean_response("I choose triangle") == "N/A: Format error" ++ assert colors.clean_response("I choose blue") == "B" ++ ++ ++def test_missing_bigbench_json_reports_failure(): ++ ++ ++ ++ ++ CustomTask = get_task("bigbench") ++ ++ ++ with pytest.raises(Exception): ++ CustomTask( ++ 1, ++ 1, ++ data_dir=os.path.join(FIXTURES, "missing.json"), ++ seed=None, ++ post_instruction=True, ++ option_num=5, ++ ) ++ ++ ++def test_repeated_construct_parse_drop_cycles_keep_fallback_maps_independent(): ++ ++ ++ ++ ++ for _ in range(25): ++ shapes = _make_task("bigbench_shapes.json") ++ colors = _make_task("bigbench_colors.json") ++ ++ ++ ++ assert shapes.clean_response("I choose triangle") == "B" ++ assert shapes.clean_response("I choose blue") == "N/A: Format error" ++ assert colors.clean_response("I choose blue") == "B" ++ assert colors.clean_response("I choose triangle") == "N/A: Format error" ++ ++ del shapes ++ del colors +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,24 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export HF_DATASETS_OFFLINE=1 ++export HF_HUB_OFFLINE=1 ++export TRANSFORMERS_OFFLINE=1 ++ ++export PYTHONPATH="/workspace/repo/src${PYTHONPATH:+:${PYTHONPATH}}" ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_bigbench_adapter.py -v diff --git a/tasks/format-code-task-003018/tests/test.sh b/tasks/format-code-task-003018/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e717696e6c2394b1f577d122c6518275c649fcd5 --- /dev/null +++ b/tasks/format-code-task-003018/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/bigbench_colors.json +usercase-test-coderl/fixtures/bigbench_mixed_options.json +usercase-test-coderl/fixtures/bigbench_shapes.json +usercase-test-coderl/fixtures/bigbench_shapes_no_prefix.json +usercase-test-coderl/test_bigbench_adapter.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-003018/tests/test_command.sh b/tasks/format-code-task-003018/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003018/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-003020/environment/Dockerfile b/tasks/format-code-task-003020/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d48f877b965deef494fa2523a329bf2cee47f758 --- /dev/null +++ b/tasks/format-code-task-003020/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:31a8ffe02bb200a7110206a24ceb8ecd82ebf2fbe8a6c93e5face096fcc851ba diff --git a/tasks/format-code-task-003020/environment/setup/files/blocklist b/tasks/format-code-task-003020/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003020/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-003020/environment/setup/setup.sh b/tasks/format-code-task-003020/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003020/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-003020/tests/test.patch b/tasks/format-code-task-003020/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5c55ebe747cac369806428332d5d7f1723e99332 --- /dev/null +++ b/tasks/format-code-task-003020/tests/test.patch @@ -0,0 +1,134 @@ +diff --git a/test/reducers/linksSpec.js b/test/reducers/linksSpec.js +new file mode 100644 +index 000000000..c1b935ddd +--- /dev/null ++++ b/test/reducers/linksSpec.js +@@ -0,0 +1,92 @@ ++import * as Actions from '../../app/actions'; ++import { newId, links, lastId, copyLink } from '../../app/reducers/links'; ++import chai from 'chai'; ++import R from 'ramda'; ++ ++describe('Links reducer', () => { ++ const sharedLinkStore = { ++ 0: { ++ id: 0, ++ fromPinId: 0, ++ toPinId: 1, ++ }, ++ }; ++ ++ describe('while adding link', () => { ++ let linkStore = null; ++ beforeEach( ++ () => { ++ linkStore = R.clone(sharedLinkStore); ++ } ++ ); ++ ++ it('should insert link', () => { ++ const oldState = linkStore; ++ const state = links(oldState, Actions.addLink({ ++ fromPinId: 2, ++ toPinId: 3, ++ })); ++ chai.assert(newId(oldState) + 1 === newId(state)); ++ }); ++ ++ it('should set appropriate id for a new link', () => { ++ const state = links(linkStore, Actions.addLink({ ++ fromPinId: 2, ++ toPinId: 3, ++ })); ++ const newLink = state[lastId(state)]; ++ chai.assert(newLink.id === lastId(state)); ++ }); ++ ++ it('should be reverse operation for link deletion', () => { ++ let state = null; ++ state = links(linkStore, Actions.addLink({ ++ fromPinId: 2, ++ toPinId: 3, ++ })); ++ state = links(state, Actions.deleteLink(lastId(state))); ++ chai.expect(state).to.deep.equal(linkStore); ++ }); ++ }); ++ ++ describe('while removing link', () => { ++ let linkStore = null; ++ beforeEach( ++ () => { ++ linkStore = R.clone(sharedLinkStore); ++ } ++ ); ++ ++ it('should remove link', () => { ++ const oldState = linkStore; ++ const state = links(oldState, Actions.deleteLink(lastId(oldState))); ++ ++ chai.assert(lastId(oldState) - 1 === lastId(state)); ++ }); ++ ++ it('should remove link with specified id', () => { ++ const oldState = linkStore; ++ const removingLinkId = lastId(oldState); ++ const state = links(oldState, Actions.deleteLink(removingLinkId)); ++ ++ chai.assert(!state.hasOwnProperty(removingLinkId)); ++ }); ++ ++ it('should be reverse operation for link insertion', () => { ++ let state = null; ++ const RemovingLinkId = lastId(linkStore); ++ const removingLink = copyLink(linkStore[RemovingLinkId]); ++ state = links(linkStore, Actions.deleteLink(RemovingLinkId)); ++ state = links(state, Actions.addLink(removingLink)); ++ chai.expect(state).to.deep.equal(linkStore); ++ }); ++ ++ it('should not affect other links', () => { ++ const oldState = linkStore; ++ const removingLinkId = lastId(oldState); ++ const state = links(oldState, Actions.deleteLink(removingLinkId)); ++ ++ chai.assert(!state.hasOwnProperty(removingLinkId)); ++ }); ++ }); ++}); +diff --git a/test/reducersSpec.js b/test/reducers/nodesSpec.js +similarity index 95% +rename from test/reducersSpec.js +rename to test/reducers/nodesSpec.js +index 4e6fac8c9..97949c026 100644 +--- a/test/reducersSpec.js ++++ b/test/reducers/nodesSpec.js +@@ -1,5 +1,5 @@ +-import * as Actions from '../app/actions'; +-import { newId, nodes, lastId, copyNode } from '../app/reducers/nodes'; ++import * as Actions from '../../app/actions'; ++import { newId, nodes, lastId, copyNode } from '../../app/reducers/nodes'; + import chai from 'chai'; + import R from 'ramda'; + +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+3R3U7DIBgG4B7vKsgOTWhh/bsQL2Ch8LlVWyDQunn3Yp3RmOhOthj1fU7gA8Lf ++m3dzP5gt2cciuxaRtHW9tMnndunLeiNKUTWibDIhZZOGWH21G30wx0kFxrLg3PTdunPzv1T+nv9E ++cdpqN47KmjzuL3fGufxlK9/yr9u2SvlXzabMmLjcFb72z/PXhi3Bd2RW1o+st+k/hoFxPtBO6Sfu ++iQI35GOaPrLR6b3iB+q80g9p0anHtbN3/Y6dyvy1zO8jW79sXgQys6YQi5tbTzqNr1c//XAAAAAA ++AAAAAAAAAAAAAAAAgD/gGYL3X2kAKAAA +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-003020/tests/test.sh b/tasks/format-code-task-003020/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..aaa4616d4742b735a4adc88645a3dfa1140995f9 --- /dev/null +++ b/tasks/format-code-task-003020/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/reducers/linksSpec.js +test/reducersSpec.js +test/reducers/nodesSpec.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-003020/tests/test_command.sh b/tasks/format-code-task-003020/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003020/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-003027/environment/Dockerfile b/tasks/format-code-task-003027/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..edff5e5c0228c1b2a8a2eea9070ae259140a72a0 --- /dev/null +++ b/tasks/format-code-task-003027/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:c3360bbaffb8fa69600aceabc75c3a05b71ac68f788f9e605f89568eb43db983 diff --git a/tasks/format-code-task-003027/environment/setup/files/blocklist b/tasks/format-code-task-003027/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003027/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-003027/environment/setup/setup.sh b/tasks/format-code-task-003027/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003027/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-003027/tests/test.patch b/tasks/format-code-task-003027/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..88a2d498f12f4ce8bbaa63a4098a4b8089a97984 --- /dev/null +++ b/tasks/format-code-task-003027/tests/test.patch @@ -0,0 +1,467 @@ +diff --git a/usercase-test-coderl/fixtures/photo.jpg b/usercase-test-coderl/fixtures/photo.jpg +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/photo.jpg +@@ -0,0 +1,1 @@ ++fixture photo fixture +diff --git a/usercase-test-coderl/transport_test.go b/usercase-test-coderl/transport_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/transport_test.go +@@ -0,0 +1,431 @@ ++package usercase_test_coderl ++ ++import ( ++ "errors" ++ "fmt" ++ "io/ioutil" ++ "mime" ++ "net/http" ++ "net/http/httptest" ++ "net/url" ++ "os" ++ "strings" ++ "sync" ++ "sync/atomic" ++ "testing" ++ ++ "github.com/yanzay/tbot/v2" ++) ++ ++const ( ++ token = "TOKEN" ++ fixtures = "/workspace/repo/usercase-test-coderl/fixtures" ++) ++ ++ ++ ++ ++ ++func TestFormOnlyMethodsPostAndDecodeTypedResults(t *testing.T) { ++ ++ ++ var mu sync.Mutex ++ seen := make([]string, 0, 2) ++ ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ body, err := ioutil.ReadAll(r.Body) ++ if err != nil { ++ t.Fatalf("read body: %v", err) ++ } ++ if err := r.Body.Close(); err != nil { ++ t.Fatalf("close request body: %v", err) ++ } ++ ++ mu.Lock() ++ defer mu.Unlock() ++ switch len(seen) { ++ case 0: ++ assertString(t, "getMe method", r.Method, "POST") ++ assertString(t, "getMe path", r.URL.Path, "/botTOKEN/getMe") ++ ++ assertFormContentType(t, "getMe content-type", r.Header.Get("Content-Type"), true) ++ assertString(t, "getMe body", string(body), "") ++ seen = append(seen, "getMe") ++ fmt.Fprint(w, `{"ok":true,"result":{"id":1,"is_bot":true,"first_name":"Bot"}}`) ++ case 1: ++ assertString(t, "sendMessage method", r.Method, "POST") ++ assertString(t, "sendMessage path", r.URL.Path, "/botTOKEN/sendMessage") ++ ++ assertFormContentType(t, "sendMessage content-type", r.Header.Get("Content-Type"), false) ++ ++ assertURLEncodedBody(t, "sendMessage body", string(body), map[string]string{ ++ "chat_id": "123", ++ "text": "hello", ++ }) ++ seen = append(seen, "sendMessage") ++ fmt.Fprint(w, `{"ok":true,"result":{"message_id":7,"chat":{"id":123},"text":"hello"}}`) ++ default: ++ t.Fatalf("unexpected extra request %d to %s", len(seen)+1, r.URL.Path) ++ } ++ })) ++ defer server.Close() ++ ++ client := tbot.NewClient(token, server.Client(), server.URL) ++ ++ me, err := client.GetMe() ++ if err != nil { ++ t.Fatalf("GetMe error = %v", err) ++ } ++ assertInt(t, "GetMe ID", me.ID, 1) ++ assertBool(t, "GetMe IsBot", me.IsBot, true) ++ assertString(t, "GetMe FirstName", me.FirstName, "Bot") ++ ++ msg, err := client.SendMessage("123", "hello") ++ if err != nil { ++ t.Fatalf("SendMessage error = %v", err) ++ } ++ assertInt(t, "SendMessage MessageID", msg.MessageID, 7) ++ assertString(t, "SendMessage Chat.ID", msg.Chat.ID, "123") ++ assertString(t, "SendMessage Text", msg.Text, "hello") ++ assertInt(t, "request count", len(seen), 2) ++} ++ ++func TestTelegramErrorEnvelopeReturnsDescription(t *testing.T) { ++ ++ ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ assertString(t, "path", r.URL.Path, "/botTOKEN/sendMessage") ++ fmt.Fprint(w, `{"ok":false,"error_code":400,"description":"Bad Request: chat not found"}`) ++ })) ++ defer server.Close() ++ ++ client := tbot.NewClient(token, server.Client(), server.URL) ++ msg, err := client.SendMessage("123", "hello") ++ if err == nil { ++ t.Fatal("SendMessage error = nil") ++ } ++ assertString(t, "telegram error text", err.Error(), "Bad Request: chat not found") ++ ++ assertNoPartialMessage(t, "partial message", msg) ++} ++ ++func TestMalformedEnvelopeReturnsDecodeError(t *testing.T) { ++ ++ ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ assertString(t, "path", r.URL.Path, "/botTOKEN/getMe") ++ fmt.Fprint(w, `{not-json`) ++ })) ++ defer server.Close() ++ ++ client := tbot.NewClient(token, server.Client(), server.URL) ++ me, err := client.GetMe() ++ if err == nil { ++ t.Fatal("GetMe error = nil") ++ } ++ ++ assertNoPartialUser(t, "partial user", me) ++} ++ ++func TestHTTPTransportFailureReturnsError(t *testing.T) { ++ ++ ++ client := tbot.NewClient(token, &http.Client{Transport: failingRoundTripper{}}, "https://example.invalid") ++ ++ me, err := client.GetMe() ++ if err == nil { ++ t.Fatal("GetMe error = nil") ++ } ++ ++ assertNoPartialUser(t, "partial user", me) ++} ++ ++func TestSendPhotoFileStreamsMultipartAndDecodesResult(t *testing.T) { ++ ++ ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ assertString(t, "method", r.Method, "POST") ++ assertString(t, "path", r.URL.Path, "/botTOKEN/sendPhoto") ++ mediaType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) ++ if err != nil { ++ t.Fatalf("parse multipart content-type: %v", err) ++ } ++ assertString(t, "multipart media type", mediaType, "multipart/form-data") ++ ++ if err := r.ParseMultipartForm(1024 * 1024); err != nil { ++ t.Fatalf("ParseMultipartForm error = %v", err) ++ } ++ assertString(t, "chat_id field", r.MultipartForm.Value["chat_id"][0], "123") ++ ++ file, header, err := r.FormFile("photo") ++ if err != nil { ++ t.Fatalf("FormFile(photo) error = %v", err) ++ } ++ defer file.Close() ++ uploaded, err := ioutil.ReadAll(file) ++ if err != nil { ++ t.Fatalf("read uploaded file: %v", err) ++ } ++ assertString(t, "file field filename", header.Filename, "photo.jpg") ++ assertString(t, "file contents", string(uploaded), "fixture photo fixture\n") ++ ++ fmt.Fprint(w, `{"ok":true,"result":{"message_id":8,"chat":{"id":123},"caption":"sent photo"}}`) ++ })) ++ defer server.Close() ++ ++ oldWD, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("Getwd error = %v", err) ++ } ++ if err := os.Chdir(fixtures); err != nil { ++ t.Fatalf("Chdir fixtures error = %v", err) ++ } ++ defer os.Chdir(oldWD) ++ ++ client := tbot.NewClient(token, server.Client(), server.URL) ++ msg, err := client.SendPhotoFile("123", "photo.jpg") ++ if err != nil { ++ t.Fatalf("SendPhotoFile error = %v", err) ++ } ++ assertInt(t, "photo MessageID", msg.MessageID, 8) ++ assertString(t, "photo Chat.ID", msg.Chat.ID, "123") ++ assertString(t, "photo Caption", msg.Caption, "sent photo") ++} ++ ++func TestSendPhotoFileOpenFailureReturnsError(t *testing.T) { ++ ++ ++ client := tbot.NewClient(token, &http.Client{}, "ftp://example.invalid") ++ ++ msg, err := client.SendPhotoFile("123", fixtures+"/missing-photo.jpg") ++ if err == nil { ++ t.Fatal("SendPhotoFile error = nil") ++ } ++ ++ assertNoPartialMessage(t, "partial message", msg) ++} ++ ++func TestSendPhotoFileNon200StatusReturnsError(t *testing.T) { ++ ++ ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ w.WriteHeader(http.StatusInternalServerError) ++ fmt.Fprint(w, `{"ok":true,"result":{"message_id":99}}`) ++ })) ++ defer server.Close() ++ defer server.CloseClientConnections() ++ ++ client := tbot.NewClient(token, server.Client(), server.URL) ++ msg, err := client.SendPhotoFile("123", fixtures+"/photo.jpg") ++ if err == nil { ++ t.Fatal("SendPhotoFile error = nil") ++ } ++ ++ assertNoPartialMessage(t, "partial message", msg) ++} ++ ++func TestIndependentClientsKeepOwnEndpointState(t *testing.T) { ++ ++ ++ var mu sync.Mutex ++ aGetMe := 0 ++ aSendMessage := 0 ++ bGetMe := 0 ++ ++ serverA := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ mu.Lock() ++ defer mu.Unlock() ++ switch r.URL.Path { ++ case "/botALPHA/getMe": ++ aGetMe++ ++ fmt.Fprint(w, `{"ok":true,"result":{"id":11,"is_bot":true,"first_name":"Alpha"}}`) ++ case "/botALPHA/sendMessage": ++ aSendMessage++ ++ fmt.Fprint(w, `{"ok":true,"result":{"message_id":17,"chat":{"id":123},"text":"from alpha"}}`) ++ default: ++ t.Fatalf("server A unexpected path %q", r.URL.Path) ++ } ++ })) ++ defer serverA.Close() ++ ++ serverB := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ mu.Lock() ++ defer mu.Unlock() ++ assertString(t, "server B path", r.URL.Path, "/botBETA/getMe") ++ bGetMe++ ++ fmt.Fprint(w, `{"ok":true,"result":{"id":22,"is_bot":true,"first_name":"Beta"}}`) ++ })) ++ defer serverB.Close() ++ ++ a := tbot.NewClient("ALPHA", serverA.Client(), serverA.URL) ++ b := tbot.NewClient("BETA", serverB.Client(), serverB.URL) ++ ++ aUser, err := a.GetMe() ++ if err != nil { ++ t.Fatalf("a.GetMe error = %v", err) ++ } ++ aMsg, err := a.SendMessage("123", "from alpha") ++ if err != nil { ++ t.Fatalf("a.SendMessage error = %v", err) ++ } ++ bUser, err := b.GetMe() ++ if err != nil { ++ t.Fatalf("b.GetMe error = %v", err) ++ } ++ ++ assertInt(t, "a user ID", aUser.ID, 11) ++ assertString(t, "a user FirstName", aUser.FirstName, "Alpha") ++ assertInt(t, "a message ID", aMsg.MessageID, 17) ++ assertString(t, "a message Text", aMsg.Text, "from alpha") ++ assertInt(t, "b user ID", bUser.ID, 22) ++ assertString(t, "b user FirstName", bUser.FirstName, "Beta") ++ assertInt(t, "server A getMe count", aGetMe, 1) ++ assertInt(t, "server A sendMessage count", aSendMessage, 1) ++ assertInt(t, "server B getMe count", bGetMe, 1) ++} ++ ++func TestRepeatedCallsCleanEachResponseBody(t *testing.T) { ++ ++ ++ transport := &countingTransport{} ++ ++ for i := 0; i < 120; i++ { ++ client := tbot.NewClient(token, &http.Client{Transport: transport}, "https://example.invalid") ++ me, err := client.GetMe() ++ if err != nil { ++ t.Fatalf("GetMe iteration %d error = %v", i, err) ++ } ++ assertInt(t, "loop User ID", me.ID, 1) ++ } ++ ++ assertInt64(t, "total response bodies", atomic.LoadInt64(&transport.total), 120) ++ ++} ++ ++type failingRoundTripper struct{} ++ ++func (failingRoundTripper) RoundTrip(*http.Request) (*http.Response, error) { ++ return nil, errors.New("dial blocked") ++} ++ ++type countingTransport struct { ++ open int64 ++ total int64 ++} ++ ++func (t *countingTransport) RoundTrip(req *http.Request) (*http.Response, error) { ++ if req.Method != "POST" { ++ return nil, fmt.Errorf("method %s", req.Method) ++ } ++ if req.URL.String() != "https://example.invalid/botTOKEN/getMe" { ++ return nil, fmt.Errorf("url %s", req.URL.String()) ++ } ++ atomic.AddInt64(&t.open, 1) ++ atomic.AddInt64(&t.total, 1) ++ return &http.Response{ ++ StatusCode: http.StatusOK, ++ Status: "200 OK", ++ Header: make(http.Header), ++ Body: &countingBody{reader: strings.NewReader(`{"ok":true,"result":{"id":1,"is_bot":true,"first_name":"Bot"}}`), transport: t}, ++ Request: req, ++ }, nil ++} ++ ++type countingBody struct { ++ reader *strings.Reader ++ transport *countingTransport ++ closed int32 ++} ++ ++func (b *countingBody) Read(p []byte) (int, error) { ++ return b.reader.Read(p) ++} ++ ++func (b *countingBody) Close() error { ++ if atomic.CompareAndSwapInt32(&b.closed, 0, 1) { ++ atomic.AddInt64(&b.transport.open, -1) ++ } ++ return nil ++} ++ ++func assertString(t *testing.T, label, got, want string) { ++ t.Helper() ++ if got != want { ++ t.Fatalf("%s = %q, want %q", label, got, want) ++ } ++} ++ ++func assertFormContentType(t *testing.T, label, got string, allowEmpty bool) { ++ t.Helper() ++ if allowEmpty && got == "" { ++ return ++ } ++ mediaType, _, err := mime.ParseMediaType(got) ++ if err != nil { ++ t.Fatalf("%s parse error = %v", label, err) ++ } ++ if mediaType != "application/x-www-form-urlencoded" { ++ t.Fatalf("%s = %q, want form media type", label, got) ++ } ++} ++ ++func assertURLEncodedBody(t *testing.T, label, body string, want map[string]string) { ++ t.Helper() ++ values, err := url.ParseQuery(body) ++ if err != nil { ++ t.Fatalf("%s parse error = %v", label, err) ++ } ++ if len(values) != len(want) { ++ t.Fatalf("%s field count = %d, want %d (%q)", label, len(values), len(want), body) ++ } ++ for key, wantValue := range want { ++ gotValues, ok := values[key] ++ if !ok { ++ t.Fatalf("%s missing field %q in %q", label, key, body) ++ } ++ if len(gotValues) != 1 || gotValues[0] != wantValue { ++ t.Fatalf("%s[%s] = %q, want [%q]", label, key, gotValues, wantValue) ++ } ++ } ++} ++ ++func assertNoPartialUser(t *testing.T, label string, user *tbot.User) { ++ t.Helper() ++ if user == nil { ++ return ++ } ++ if user.ID != 0 || user.IsBot || user.FirstName != "" { ++ t.Fatalf("%s = %+v, want nil or zero-value user", label, user) ++ } ++} ++ ++func assertNoPartialMessage(t *testing.T, label string, msg *tbot.Message) { ++ t.Helper() ++ if msg == nil { ++ return ++ } ++ if msg.MessageID != 0 || msg.Chat.ID != "" || msg.Text != "" || msg.Caption != "" { ++ t.Fatalf("%s = %+v, want nil or zero-value message", label, msg) ++ } ++} ++ ++func assertInt(t *testing.T, label string, got, want int) { ++ t.Helper() ++ if got != want { ++ t.Fatalf("%s = %d, want %d", label, got, want) ++ } ++} ++ ++func assertInt64(t *testing.T, label string, got, want int64) { ++ t.Helper() ++ if got != want { ++ t.Fatalf("%s = %d, want %d", label, got, want) ++ } ++} ++ ++func assertBool(t *testing.T, label string, got, want bool) { ++ t.Helper() ++ if got != want { ++ t.Fatalf("%s = %t, want %t", label, got, want) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,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 GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++exec go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-003027/tests/test.sh b/tasks/format-code-task-003027/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c8efbc5893106427b24dcac200bcba0b947dae9c --- /dev/null +++ b/tasks/format-code-task-003027/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/photo.jpg +usercase-test-coderl/transport_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-003027/tests/test_command.sh b/tasks/format-code-task-003027/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003027/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-003029/environment/Dockerfile b/tasks/format-code-task-003029/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bc3f5dfc86e9cec94ea634b1c635082e266f6921 --- /dev/null +++ b/tasks/format-code-task-003029/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:414866b6f9f099d1c190710f7c998d8b24daa91a3966dbd4168a9403c3ce6b9d diff --git a/tasks/format-code-task-003029/environment/setup/files/blocklist b/tasks/format-code-task-003029/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003029/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-003029/environment/setup/setup.sh b/tasks/format-code-task-003029/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003029/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-003029/tests/test.patch b/tasks/format-code-task-003029/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1c0e3b83d885beec4efd873af6ea9cda1b06c65f --- /dev/null +++ b/tasks/format-code-task-003029/tests/test.patch @@ -0,0 +1,98 @@ +diff --git a/test/validation.js b/test/validation.js +index 53c30bb..a14c72a 100644 +--- a/test/validation.js ++++ b/test/validation.js +@@ -560,6 +560,71 @@ describe('validation tests', function () { + }) + .argv + }) ++ ++ ++ it('correctly populates positional after command without extra args (regression)', function () { ++ var handlerCalled = false ++ var argv = yargs('command foo') ++ .command('command ', 'sub-command', function (y) { return y }, function (args) { ++ handlerCalled = true ++ args.param.should.equal('foo') ++ }) ++ .strict() ++ .fail(function (msg) { ++ expect.fail(null, null, 'should not fail: ' + msg) ++ }) ++ .argv ++ handlerCalled.should.equal(true) ++ argv.param.should.equal('foo') ++ }) ++ ++ ++ it('fails in strict mode when extra arg precedes the command', function (done) { ++ yargs('imposter command foo') ++ .command('command ', 'sub-command', function (y) { return y }, function (args) { ++ expect.fail(null, null, 'handler should not be called with param=' + args.param) ++ }) ++ .strict() ++ .fail(function (msg) { ++ msg.should.match(/imposter/) ++ return done() ++ }) ++ .argv ++ }) ++ ++ ++ it('does not treat extra preceding arg as the command (non-strict)', function () { ++ var capturedParam ++ var argv = yargs('imposter command foo') ++ .command('command ', 'sub-command', function (y) { return y }, function (args) { ++ capturedParam = args.param ++ }) ++ .argv ++ ++ ++ expect(capturedParam).to.not.equal('command') ++ expect(argv.param).to.not.equal('command') ++ ++ ++ ++ argv._.should.include('imposter') ++ }) ++ ++ ++ it('fails in strict mode when extra arg precedes a nested sub-command', function (done) { ++ yargs('parent imposter child arg') ++ .command('parent', 'parent command', function (y) { ++ return y.command('child

', 'child command', function (yy) { return yy }, function (args) { ++ expect.fail(null, null, 'child handler should not be called') ++ }) ++ }) ++ .strict() ++ .fail(function (msg) { ++ msg.should.match(/imposter/) ++ return done() ++ }) ++ .argv ++ }) + }) + + describe('demandOption', function () { +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..d46c80a +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["LC_ALL=en_US ./node_modules/.bin/mocha --require ./test/before.js --timeout=8000 test/validation.js"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++LC_ALL=en_US ./node_modules/.bin/mocha --require ./test/before.js --timeout=8000 test/validation.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-003029/tests/test.sh b/tasks/format-code-task-003029/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ac025061699b9bd890d44cedbb5b416d55e9ce58 --- /dev/null +++ b/tasks/format-code-task-003029/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/validation.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-003029/tests/test_command.sh b/tasks/format-code-task-003029/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003029/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-003042/environment/Dockerfile b/tasks/format-code-task-003042/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c7855bcf04d2d8993b740ddd5ea36b9ba19f2afc --- /dev/null +++ b/tasks/format-code-task-003042/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:5afc40b79c8710d5fe78ca450a5bc6c6caf0839b5e90fd6bf5a9bce75abf63d4 diff --git a/tasks/format-code-task-003042/environment/setup/files/blocklist b/tasks/format-code-task-003042/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003042/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-003042/environment/setup/setup.sh b/tasks/format-code-task-003042/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003042/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-003042/tests/test.patch b/tasks/format-code-task-003042/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bca98c28488238c86cdba81a91f1966af5c50ed8 --- /dev/null +++ b/tasks/format-code-task-003042/tests/test.patch @@ -0,0 +1,198 @@ +diff --git a/tests/test_basics.py b/tests/test_basics.py +index 795f200d..90f3d757 100644 +--- a/tests/test_basics.py ++++ b/tests/test_basics.py +@@ -59,6 +59,7 @@ class Pri: + """ + Primitives. + """ ++ + i: int + s: str + f: float +@@ -247,17 +248,20 @@ def test_optional_nested(se, de): + assert p == de(NestedPriOpt, se(p)) + + +-def test_field_default(): ++@pytest.mark.parametrize('se,de', all_formats) ++def test_dataclass_default_factory(se, de): ++ @deserialize ++ @serialize + @dataclass + class Foo: +- i: int = 10 ++ foo: str ++ items: Dict[str, int] = field(default_factory=dict) + +- @dataclass +- class Bar: +- i: int = field(default=10) ++ f = Foo('bar') ++ assert f == de(Foo, se(f)) + +- assert 10 == dataclasses.fields(Foo)[0].default +- assert 10 == dataclasses.fields(Bar())[0].default ++ assert {'foo': 'bar', 'items': {}} == asdict(f) ++ assert f == from_dict(Foo, {'foo': 'bar'}) + + + @pytest.mark.parametrize('se,de', all_formats) +@@ -265,6 +269,18 @@ def test_default(se, de): + p = PriDefault() + assert p == de(PriDefault, se(p)) + ++ p = PriDefault() ++ assert p == from_dict(PriDefault, {}) ++ assert p == from_dict(PriDefault, {'i': 10}) ++ assert p == from_dict(PriDefault, {'i': 10, 's': 'foo'}) ++ assert p == from_dict(PriDefault, {'i': 10, 's': 'foo', 'f': 100.0}) ++ assert p == from_dict(PriDefault, {'i': 10, 's': 'foo', 'f': 100.0, 'b': True}) ++ ++ assert 10 == dataclasses.fields(PriDefault)[0].default ++ assert 'foo' == dataclasses.fields(PriDefault)[1].default ++ assert 100.0 == dataclasses.fields(PriDefault)[2].default ++ assert True is dataclasses.fields(PriDefault)[3].default ++ + + @pytest.mark.parametrize('se,de', (format_dict + format_tuple + format_json + format_msgpack + format_yaml)) + def test_list_pri(se, de): +@@ -284,59 +300,6 @@ def test_dict_pri(se, de): + assert p == de(data.DictPri, se(p)) + + +-def test_complex(): +- @deserialize +- @serialize +- @dataclass +- class Baz: +- v: List[int] = field(default_factory=list) +- d: Dict[str, int] = field(default_factory=dict) +- +- @deserialize +- @serialize +- @dataclass +- class Bar: +- i: int +- +- @deserialize +- @serialize +- @dataclass +- class Foo: +- i: int +- s: str +- f: float +- b: bool +- foo: Baz +- lst: List[Bar] = field(default_factory=list) +- lst2: List[Dict[str, Bar]] = field(default_factory=list) +- dct: Dict[str, List[List[Bar]]] = field(default_factory=dict) +- +- f = Baz(v=[1, 2, 3, 4, 5], d={'foo': 10, 'fuga': 20}) +- lst = [Bar(10), Bar(20)] +- lst2 = [{'bar1': Bar(10)}, {'bar2': Bar(10), 'bar3': Bar(20)}] +- dct = {'foo': [[Bar(10), Bar(20)], [Bar(20), Bar(30)]]} +- h = Foo(i=10, s='foo', f=100.0, b=True, foo=f, lst=lst, lst2=lst2, dct=dct) +- s = """ +- {"i": 10, +- "s": "foo", +- "f": 100.0, +- "b": true, +- "foo" : { +- "v": [1, 2, 3, 4, 5], +- "d": {"foo": 10, "fuga": 20} +- }, +- "lst": [{"i": 10}, {"i": 20}], +- "lst2": [{"bar1": {"i": 10}}, {"bar2": {"i": 10}, "bar3": {"i": 20}}], +- "dct": {"foo": [[{"i": 10}, {"i": 20}], [{"i": 20}, {"i": 30}]]} +- } +- """ +- assert json.loads(s) == json.loads(to_json(h)) +- hh = from_json(Foo, s) +- assert h.foo == hh.foo +- assert h.lst == hh.lst +- assert h.dct == hh.dct +- +- + def test_json(): + p = Pri(10, 'foo', 100.0, True) + s = '{"i": 10, "s": "foo", "f": 100.0, "b": true}' +@@ -445,8 +408,8 @@ class Foo: + + f = Foo([]) + ff = de(Foo, se(f)) +- assert ff.comments is None # TODO format_tuple gets [] instaed of None +- assert ff.attrs is None # TODO format_tuple gets {} instaed of None ++ assert ff.comments == [] ++ assert ff.attrs == {} + + + @pytest.mark.parametrize('se,de', all_formats) +@@ -473,4 +436,4 @@ class Foo: + + f = Foo(['foo']) + ff = de(Foo, se(f)) +- assert ff.comments is None ++ assert ff.comments == [] +diff --git a/tests/test_more_types.py b/tests/test_more_types.py +index 8da673ce..ba3ad9c2 100644 +--- a/tests/test_more_types.py ++++ b/tests/test_more_types.py +@@ -13,6 +13,7 @@ + @dataclass + class Foo: + d: Decimal ++ d2: Decimal = Decimal('10.0') + + + @deserialize +@@ -20,6 +21,7 @@ class Foo: + @dataclass + class Bar: + p: Path ++ p2: Path = Path('/etc') + + + @pytest.mark.parametrize('se,de', format_json + format_yaml + format_toml) # type: ignore +@@ -28,13 +30,16 @@ def test_decimal(se, de): + assert f == de(Foo, se(f)) + + f = Foo(d=Decimal(0.1)) +- assert f == de(Foo, se(f)) ++ ff = de(Foo, se(f)) ++ assert f == ff ++ assert f.d == Decimal(0.1) ++ assert f.d2 == Decimal(10.0) + + + @pytest.mark.parametrize('se,de', format_json + format_yaml + format_toml) # type: ignore + def test_path(se, de): + f = Bar(p=Path('/tmp')) +- assert f == de(Bar, se(f)) +- +- f = Bar(p=Path('/tmp')) +- assert f == de(Bar, se(f)) ++ ff = de(Bar, se(f)) ++ assert f == ff ++ assert Path('/tmp') == ff.p ++ assert Path('/etc') == ff.p2 +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+3S3wrCIBiHYY+7Cm+gNddslzP2R1jQ5pg22N1nCyqC2kkR0fsc+H2ooPIzKo/7 ++Q52bbtyIT4mDTOu5Bo917pVOVBLrUBIRK6WzVEj9sRvdOTpfDFKKwVr/at/S+o+Kbvl743xe2bYt ++ujpyzfvOWMpfqeyaf6p3If90p7SQ8fuu8Nyf51/Vcg6+NPWqn3xju61ctzK0YVKeB3f5GGXh9pWL +++ul+srWDyf3Um3lhPa6+/RwAAAAAAAAAAAAAAADgr5wANmbFsAAoAAA= +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-003042/tests/test.sh b/tasks/format-code-task-003042/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ce37b7eda8adcd67489461c76ce8be864e89ede1 --- /dev/null +++ b/tasks/format-code-task-003042/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_basics.py +tests/test_more_types.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-003042/tests/test_command.sh b/tasks/format-code-task-003042/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003042/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file