diff --git a/tasks/format-code-task-000011/environment/Dockerfile b/tasks/format-code-task-000011/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1676e568e3869000258a6bd8e5c1bb52399278b7 --- /dev/null +++ b/tasks/format-code-task-000011/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c8522aaf8f02f486d9dfadc34812d082efbca8b337cf987d2940045cd93f00a3 diff --git a/tasks/format-code-task-000011/environment/setup/files/blocklist b/tasks/format-code-task-000011/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000011/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000011/environment/setup/setup.sh b/tasks/format-code-task-000011/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000011/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000011/tests/test.patch b/tasks/format-code-task-000011/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..61cb2e7a72335a93cad2990b873cbf5c88808cf6 --- /dev/null +++ b/tasks/format-code-task-000011/tests/test.patch @@ -0,0 +1,72 @@ +diff --git a/leetcode/1201-1300/1277.Count-Square-Submatrices-with-All-Ones/Solution_test.go b/leetcode/1201-1300/1277.Count-Square-Submatrices-with-All-Ones/Solution_test.go +index 3e51ecacf..b0eb74396 100644 +--- a/leetcode/1201-1300/1277.Count-Square-Submatrices-with-All-Ones/Solution_test.go ++++ b/leetcode/1201-1300/1277.Count-Square-Submatrices-with-All-Ones/Solution_test.go +@@ -10,12 +10,19 @@ func TestSolution(t *testing.T) { + // 测试用例 + cases := []struct { + name string +- inputs bool +- expect bool ++ inputs [][]int ++ expect int + }{ +- {"TestCase", true, true}, +- {"TestCase", true, true}, +- {"TestCase", false, false}, ++ {"TestCase", [][]int{ ++ {0,1,1,1}, ++ {1,1,1,1}, ++ {0,1,1,1}, ++ }, 15}, ++ {"TestCase", [][]int{ ++ {1,0,1}, ++ {1,1,0}, ++ {1,1,0}, ++ }, 7}, + } + + // 开始测试 +diff --git a/leetcode/301-400/0338.Counting-Bits/Solution_test.go b/leetcode/301-400/0338.Counting-Bits/Solution_test.go +index 3e51ecacf..ed701b1ad 100644 +--- a/leetcode/301-400/0338.Counting-Bits/Solution_test.go ++++ b/leetcode/301-400/0338.Counting-Bits/Solution_test.go +@@ -10,12 +10,12 @@ func TestSolution(t *testing.T) { + // 测试用例 + cases := []struct { + name string +- inputs bool +- expect bool ++ inputs int ++ expect []int + }{ +- {"TestCase", true, true}, +- {"TestCase", true, true}, +- {"TestCase", false, false}, ++ {"TestCase", 2, []int{0,1,1}}, ++ {"TestCase", 5, []int{0,1,1,2,1,2}}, ++ {"TestCase", 10, []int{0,1,1,2,1,2,2,3,1,2,2}}, + } + + // 开始测试 +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+3SvW7DIBQFYM9+CqrO/Bk7dG37AB3yABE2KLFkg2pw8volzpCoUpslUVv1fAsg ++0OWKA2vnfrAb5/e8uBeR6aZZxuzzuMxlU0mpha50VQgpV6IpSHO3ji7MMZmJkGIKIX137tr+H8XO +++ScX06YL42i8ZXF3uzuu5V/V6py/0jn/elXJgojbtfC1f57/4wNve89bE3dlZ8nyCVpny3IbyBgs ++seHgh2DscX3cI4wPzqUuWMdlJSSVSog805q9htknun6fzeToem5Hk6a+c5Ee+rSjz8NA37yLnDF2 ++WUTlGnUuIZR6OpXo/Za+9Ol0ku7Ln34iAAAAAAAAAAAAAAAAAAAAAIBf6wPgDnkJACgAAA== +diff --git 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-000011/tests/test.sh b/tasks/format-code-task-000011/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8884af79cd34b1f0492586dc6563895058e7c8e2 --- /dev/null +++ b/tasks/format-code-task-000011/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' +leetcode/1201-1300/1277.Count-Square-Submatrices-with-All-Ones/Solution_test.go +leetcode/301-400/0338.Counting-Bits/Solution_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-000011/tests/test_command.sh b/tasks/format-code-task-000011/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000011/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000016/environment/Dockerfile b/tasks/format-code-task-000016/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..95a98e41c18ea71f62f985b7fe06e18ec446bb67 --- /dev/null +++ b/tasks/format-code-task-000016/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5f46605969f46946830b492ccca83d68404d50cce97b3796b8bd2257715d0ba1 diff --git a/tasks/format-code-task-000016/environment/setup/files/blocklist b/tasks/format-code-task-000016/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000016/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000016/environment/setup/setup.sh b/tasks/format-code-task-000016/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000016/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000016/tests/test.patch b/tasks/format-code-task-000016/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e457051e5cbd6878c6e6259a8ef98077bb91793e --- /dev/null +++ b/tasks/format-code-task-000016/tests/test.patch @@ -0,0 +1,981 @@ +diff --git a/tests/tests_api.py b/tests/tests_api.py +index 79ff485..702b681 100755 +--- a/tests/tests_api.py ++++ b/tests/tests_api.py +@@ -1,4 +1,7 @@ + #!/usr/bin/env python ++""" ++ This module implements all the tests for the API view. ++""" + import os + import unittest + import tempfile +@@ -25,7 +28,7 @@ def setUp(self): + with poli.app.app_context(): + api = APIControl() + api.usercontrol.create("john", "password") +- self.create_sample() ++ self._create_sample() + poli.db.session.commit() + + def tearDown(self): +@@ -34,17 +37,17 @@ def tearDown(self): + os.close(self.db_fd) + os.unlink(self.fname) + +- def login(self, username, password): ++ def _login(self, username, password): + return self.app.post("/login/", + data=dict( + username=username, + password=password), + follow_redirects=True) + +- def create_sample(self): ++ def _create_sample(self): + with open("tests/example_pe.bin", "rb") as hfile: + data = StringIO(hfile.read()) +- self.login("john", "password") ++ self._login("john", "password") + retval = self.app.post("/samples/", + content_type='multipart/form-data', + data=dict({'file': (data, "toto")}, +@@ -53,101 +56,20 @@ def create_sample(self): + sleep(1) + return retval + +- def push_comment(self, sid=1, address=None, comment=None): +- retval = self.app.post('/api/1.0/samples/'+str(sid)+'/comments/', +- data=json.dumps(dict(address=address, comment=comment)), +- content_type="application/json") +- return retval +- +- +- def create_struct(self, sid=1, name=None): +- retval = self.app.post('/api/1.0/samples/'+str(sid)+'/structs/', +- data=json.dumps(dict(name=name)), +- content_type="application/json") +- return retval +- +- def create_struct_member(self, sid=1, struct_id=None, mname=None, size=0, offset=0): +- url = '/api/1.0/samples/' + str(sid) +- url += '/structs/' + str(struct_id) +- url += '/members/' +- retval = self.app.post(url, +- data=json.dumps(dict(name=mname, +- size=size, +- offset=offset)), +- content_type="application/json") +- return retval +- +- def update_struct_member_name(self, sid=1, struct_id=None, mid=None, newname=""): +- url = '/api/1.0/samples/' + str(sid) +- url += '/structs/' + str(struct_id) +- url += '/members/' +- retval = self.app.patch(url, +- data=json.dumps(dict(mid=mid, newname=newname)), +- content_type="application/json") +- return retval +- +- def update_struct_member_size(self, sid=1, struct_id=None, mid=None, newsize=0): +- url = '/api/1.0/samples/' + str(sid) +- url += '/structs/' + str(struct_id) +- url += '/members/' +- retval = self.app.patch(url, +- data=json.dumps(dict(mid=mid, newsize=newsize)), +- content_type="application/json") +- return retval +- +- +- +- def get_all_structs(self, sid=1, name=None): +- retval = self.app.get('/api/1.0/samples/' + str(sid) + +- '/structs/') +- return retval +- +- def get_one_struct(self, sid=1, struct_id=1): +- url = '/api/1.0/samples/' + str(sid) +- url += '/structs/' +- url += str(struct_id) + '/' +- retval = self.app.get(url) +- return retval +- +- +- def get_comment(self, sid=1, address=None): +- retval = self.app.get('/api/1.0/samples/' + str(sid) + +- '/comments/', +- data=json.dumps({'address':address}), +- content_type="application/json") +- return retval +- +- def push_name(self, sid=1, address=None, name=None): +- retval = self.app.post('/api/1.0/samples/'+str(sid)+'/names/', +- data=json.dumps(dict(address=address, name=name)), +- content_type="application/json") +- return retval +- +- def get_name(self, sid=1, address=None): +- retval = self.app.get('/api/1.0/samples/' + str(sid) + +- '/names/') +- return retval +- +- def create_family(self, name, tlp_level=None, parent=None): ++ def _create_family(self, name, tlp_level=None, parent=None): + data = dict(name=name, tlp_level=tlp_level) + if parent is not None: + data["parent"] = parent + retval = self.app.post('/api/1.0/family/', +- data=json.dumps(data), +- content_type="application/json") ++ data=json.dumps(data), ++ content_type="application/json") + return retval + +- def create_yara(self, name, rule, tlp_level=None): +- retval = self.app.post('/api/1.0/yaras/', +- data=json.dumps(dict(name=name, rule=rule, tlp_level=tlp_level)), +- content_type="application/json") +- return retval + +- def update_yara(self, name, rule, tlp_level=None): +- retval = self.app.patch('/api/1.0/yaras/', +- data=json.dumps(dict(name=name, rule=rule, tlp_level=tlp_level)), +- content_type="application/json") +- return retval ++class ApiSampleTests(ApiTestCase): ++ """ ++ Tests cases relatives to sample analysis and metadata ++ """ + + def test_get_sample_info(self): + """ +@@ -156,11 +78,14 @@ def test_get_sample_info(self): + retval = self.app.get('/api/1.0/samples/1/') + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) +- self.assertEqual(len(data),1) ++ self.assertEqual(len(data), 1) + data = data['samples'] + self.assertEqual(data['id'], 1) + + def test_get_sample_id(self): ++ """ ++ Test access to the sample by using MD5, SHA1 and SHA256 ++ """ + # test getting ID by MD5 + retval = self.app.get('/api/1.0/samples/0f6f0c6b818f072a7a6f02441d00ac69/') + self.assertEqual(retval.status_code, 200) +@@ -179,15 +104,20 @@ def test_get_sample_id(self): + data = json.loads(retval.data) + self.assertEqual(data['sample_id'], 1) + +- # Bug when using incorrect value for hash ++ def test_wrong_sample_hash(self): ++ """ ++ This triggered a bug when using incorrect value for hash ++ """ + url = "api/1.0/samples/abcdef/" + retval = self.app.get(url) + self.assertEqual(retval.status_code, 400) + data = json.loads(retval.data) + self.assertEqual(data['error'], 400) + +- + def test_get_multiples_sample_info(self): ++ """ ++ Extract some expected informations from the API ++ """ + retval = self.app.get('/api/1.0/samples/') + self.assertEqual(retval.status_code, 200) + +@@ -243,11 +173,32 @@ def test_get_strings_data(self): + data = json.loads(retval.data) + self.assertEqual(len(data), 1) + ++ def test_sample_abstract(self): ++ """ ++ Sets and gets the sample abstract ++ """ ++ data = json.dumps(dict(abstract="This is a test for abstract")) ++ retval = self.app.post('/api/1.0/samples/1/abstract/', data=data, ++ content_type="application/json") ++ self.assertEqual(retval.status_code, 200) ++ result = json.loads(retval.data) ++ self.assertTrue(result['result']) ++ ++ retval = self.app.get('/api/1.0/samples/1/abstract/') ++ self.assertEqual(retval.status_code, 200) ++ result = json.loads(retval.data) ++ self.assertIn(result['abstract'], 'This is a test for abstract') ++ ++ ++class ApiFamilyTests(ApiTestCase): ++ """ ++ Tests the families creation, hierarchy and manipulation ++ """ + def test_family_creation(self): + """ + This will test the families creation and access + """ +- retval = self.create_family("TESTFAMILY1") ++ retval = self._create_family("TESTFAMILY1") + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertEqual(data['family'], 1) +@@ -270,7 +221,7 @@ def test_family_tlp(self): + Test the TLP level affectation for a family + """ + +- retval = self.create_family("TESTFAMILY2", tlp_level=5) ++ retval = self._create_family("TESTFAMILY2", tlp_level=5) + self.assertEqual(retval.status_code, 200) + + retval = self.app.get('/api/1.0/family/1/') +@@ -283,7 +234,7 @@ def test_family_abstract(self): + """ + Try to update the family abstract + """ +- self.create_family("TESTFAMILY1") ++ self._create_family("TESTFAMILY1") + data = json.dumps(dict(abstract="Test abstract")) + retval = self.app.post("/api/1.0/family/1/abstract/", data=data, + content_type="application/json") +@@ -295,8 +246,11 @@ def test_family_abstract(self): + self.assertIn(data["abstract"], "Test abstract") + + def test_subfamilies(self): +- self.create_family("MOTHER FAMILY") +- self.create_family("CHILD FAMILY", parent="MOTHER FAMILY") ++ """ ++ Can we manage a hierarchical family organization? ++ """ ++ self._create_family("MOTHER FAMILY") ++ self._create_family("CHILD FAMILY", parent="MOTHER FAMILY") + + + retval = self.app.get('/api/1.0/family/1/') +@@ -309,11 +263,222 @@ def test_subfamilies(self): + data = json.loads(retval.data)["family"] + self.assertEqual(data["parent_id"], 1) + ++ ++class ApiYaraTests(ApiTestCase): ++ """ ++ Yara rules creation and management ++ """ ++ def _create_yara(self, name, rule, tlp_level=None): ++ retval = self.app.post('/api/1.0/yaras/', ++ data=json.dumps(dict(name=name, ++ rule=rule, ++ tlp_level=tlp_level)), ++ content_type="application/json") ++ return retval ++ ++ def _update_yara(self, name, rule, tlp_level=None): ++ retval = self.app.patch('/api/1.0/yaras/', ++ data=json.dumps(dict(name=name, ++ rule=rule, ++ tlp_level=tlp_level)), ++ content_type="application/json") ++ return retval ++ ++ def test_yara_creation(self): ++ """ ++ Creates an example yara rule, ++ and try to get it back ++ """ ++ rule_text = """rule toto{ ++ strings: ++ $1 = {4D 5A} ++ condition: ++ $1 at 0 ++ }""" ++ retval = self._create_yara("TESTYARA", rule_text) ++ self.assertEqual(retval.status_code, 200) ++ data = json.loads(retval.data) ++ self.assertEqual(data["id"], 1) ++ ++ retval = self.app.get("/api/1.0/yaras/") ++ self.assertEqual(retval.status_code, 200) ++ data = json.loads(retval.data) ++ self.assertEqual(len(data['yara_rules']), 1) ++ rule = data['yara_rules'][0] ++ self.assertIn(rule['name'], "TESTYARA") ++ self.assertEqual(rule['TLP_sensibility'], 3) ++ self.assertIn(rule['raw_rule'], rule_text) ++ ++ def test_yara_tlp(self): ++ """ ++ Is the TLP correctly managed for a yara rule? ++ """ ++ rule_text = """rule toto{ ++ strings: ++ $1 = {4D 5A} ++ condition: ++ $1 at 0 ++ }""" ++ retval = self._create_yara("TESTYARA", rule_text, tlp_level=4) ++ retval = self.app.get("/api/1.0/yaras/") ++ data = json.loads(retval.data) ++ rule = data['yara_rules'][0] ++ self.assertEqual(rule['TLP_sensibility'], 4) ++ ++ def test_yara_family(self): ++ """ ++ Test for correct affectation of a yara to a family ++ """ ++ rule_text = """rule toto{ ++ strings: ++ $1 = {4D 5A} ++ condition: ++ $1 at 0 ++ }""" ++ retval = self._create_yara("TESTYARA", rule_text) ++ self._create_family("TESTFAMILY") ++ retval = self.app.post('/api/1.0/family/1/yaras/', ++ data=json.dumps(dict(rule_name="TESTYARA")), ++ content_type="application/json") ++ self.assertEqual(retval.status_code, 200) ++ data = json.loads(retval.data) ++ self.assertTrue(data["result"]) ++ ++ retval = self.app.get('/api/1.0/family/1/export/1/detection/yara') ++ self.assertEqual(retval.status_code, 200) ++ self.assertIn("TESTYARA", retval.data) ++ self.assertIn("4D 5A", retval.data) ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++class ApiIDAActionsTests(ApiTestCase): ++ """ ++ Tests storage and synchronization for implemented IDA Pro types. ++ """ ++ def _push_comment(self, sid=1, address=None, comment=None): ++ retval = self.app.post('/api/1.0/samples/'+str(sid)+'/comments/', ++ data=json.dumps(dict(address=address, comment=comment)), ++ content_type="application/json") ++ return retval ++ ++ def _create_struct(self, sid=1, name=None): ++ retval = self.app.post('/api/1.0/samples/'+str(sid)+'/structs/', ++ data=json.dumps(dict(name=name)), ++ content_type="application/json") ++ return retval ++ ++ def _create_struct_member(self, sid=1, struct_id=None, mname=None, size=0, offset=0): ++ url = '/api/1.0/samples/' + str(sid) ++ url += '/structs/' + str(struct_id) ++ url += '/members/' ++ retval = self.app.post(url, ++ data=json.dumps(dict(name=mname, ++ size=size, ++ offset=offset)), ++ content_type="application/json") ++ return retval ++ ++ def _update_struct_member_name(self, sid=1, struct_id=None, mid=None, newname=""): ++ url = '/api/1.0/samples/' + str(sid) ++ url += '/structs/' + str(struct_id) ++ url += '/members/' ++ retval = self.app.patch(url, ++ data=json.dumps(dict(mid=mid, newname=newname)), ++ content_type="application/json") ++ return retval ++ ++ def _update_struct_member_size(self, sid=1, struct_id=None, mid=None, newsize=0): ++ url = '/api/1.0/samples/' + str(sid) ++ url += '/structs/' + str(struct_id) ++ url += '/members/' ++ retval = self.app.patch(url, ++ data=json.dumps(dict(mid=mid, newsize=newsize)), ++ content_type="application/json") ++ return retval ++ ++ def _get_all_structs(self, sid=1): ++ retval = self.app.get('/api/1.0/samples/' + str(sid) + ++ '/structs/') ++ return retval ++ ++ def _get_one_struct(self, sid=1, struct_id=1): ++ url = '/api/1.0/samples/' + str(sid) ++ url += '/structs/' ++ url += str(struct_id) + '/' ++ retval = self.app.get(url) ++ return retval ++ ++ def _get_comment(self, sid=1, address=None): ++ retval = self.app.get('/api/1.0/samples/' + str(sid) + ++ '/comments/', ++ data=json.dumps({'address':address}), ++ content_type="application/json") ++ return retval ++ ++ def _push_name(self, sid=1, address=None, name=None): ++ retval = self.app.post('/api/1.0/samples/'+str(sid)+'/names/', ++ data=json.dumps(dict(address=address, name=name)), ++ content_type="application/json") ++ return retval ++ ++ def _get_name(self, sid=1, address=None): ++ url = '/api/1.0/samples/' + str(sid) + '/names/' ++ if address is not None: ++ url += '?addr=' ++ url += hex(address) ++ retval = self.app.get(url) ++ return retval ++ ++ def _create_type(self, sid=1, address=None, typedef=None): ++ retval = self.app.post('/api/1.0/samples/'+str(sid)+'/types/', ++ data=json.dumps(dict(address=address, ++ typedef=typedef)), ++ content_type="application/json") ++ return retval ++ ++ def _get_type(self, sid=1, address=None): ++ url = '/api/1.0/samples/' + str(sid) ++ url += '/types/' ++ if address is not None: ++ url += "?addr=" ++ url += hex(address) ++ ++ return self.app.get(url) ++ ++ @staticmethod ++ def _format_timedelta(): ++ """ ++ wrapper for strftime and 1 day offset ++ """ ++ offset = datetime.datetime.now() + datetime.timedelta(days=1) ++ offset = datetime.datetime.strftime(offset, '%Y-%m-%dT%H:%M:%S.%f') ++ return offset ++ + def test_push_comments(self): + """ + Can we push comments for a sample? + """ +- retval = self.push_comment(address=0xDEADBEEF, comment="TESTCOMMENT1") ++ retval = self._push_comment(address=0xDEADBEEF, comment="TESTCOMMENT1") + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data['result']) +@@ -322,29 +487,29 @@ def test_get_comment(self): + """ + This endpoint is used to get comments for a specific address + """ +- retval = self.push_comment(address=0xDEADBEEF, comment="TESTCOMMENT1") ++ retval = self._push_comment(address=0xDEADBEEF, comment="TESTCOMMENT1") + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data['result']) + +- retval = self.get_comment(address=0xDEADBEEF) ++ retval = self._get_comment(address=0xDEADBEEF) + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertIn(data['comments'][0]["data"], "TESTCOMMENT1") + self.assertEqual(data['comments'][0]["address"], 0xDEADBEEF) + + def test_get_multiple_comments(self): +- retval = self.push_comment(address=0xDEADBEEF, comment="TESTCOMMENT1") ++ retval = self._push_comment(address=0xDEADBEEF, comment="TESTCOMMENT1") + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data['result']) + +- retval = self.push_comment(address=0xBADF00D, comment="TESTCOMMENT2") ++ retval = self._push_comment(address=0xBADF00D, comment="TESTCOMMENT2") + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data['result']) + +- retval = self.get_comment() ++ retval = self._get_comment() + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertEqual(len(data['comments']), 2) +@@ -353,21 +518,12 @@ def test_get_multiple_comments(self): + self.assertIn(data['comments'][1]["data"], "TESTCOMMENT2") + self.assertEqual(data['comments'][1]["address"], 0xBADF00D) + +- @staticmethod +- def format_timedelta(): +- """ +- wrapper for strftime and 1 day offset +- """ +- offset = datetime.datetime.now() + datetime.timedelta(days=1) +- offset = datetime.datetime.strftime(offset, '%Y-%m-%dT%H:%M:%S.%f') +- return offset +- + def test_action_timestamp(self): + """ + Test getting different results with different timestamps + """ +- self.push_comment(address=0xDEADBEEF, comment="TESTCOMMENT1") +- offset = self.format_timedelta() ++ self._push_comment(address=0xDEADBEEF, comment="TESTCOMMENT1") ++ offset = self._format_timedelta() + retval = self.app.get('/api/1.0/samples/1/comments/?timestamp='+offset) + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) +@@ -383,8 +539,8 @@ def test_action_timestamp(self): + data = json.loads(retval.data) + self.assertEqual(len(data["comments"]), 1) + +- self.push_name(address=0xDEADBEEF, name="TESTNAME") +- offset = self.format_timedelta() ++ self._push_name(address=0xDEADBEEF, name="TESTNAME") ++ offset = self._format_timedelta() + retval = self.app.get('/api/1.0/samples/1/names/?timestamp='+offset) + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) +@@ -395,8 +551,8 @@ def test_action_timestamp(self): + data = json.loads(retval.data) + self.assertEqual(len(data["names"]), 1) + +- self.create_struct(name="TESTSTRUCTURE") +- offset = self.format_timedelta() ++ self._create_struct(name="TESTSTRUCTURE") ++ offset = self._format_timedelta() + retval = self.app.get('/api/1.0/samples/1/structs/?timestamp='+offset) + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) +@@ -407,12 +563,11 @@ def test_action_timestamp(self): + data = json.loads(retval.data) + self.assertEqual(len(data["structs"]), 1) + +- + def test_push_name(self): + """ + Simulate a renaming done from IDA + """ +- retval = self.push_name(address=0xDEADBEEF, name="TESTNAME1") ++ retval = self._push_name(address=0xDEADBEEF, name="TESTNAME1") + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data['result']) +@@ -421,12 +576,12 @@ def test_get_names(self): + """ + This endpoint is used to get names for a specific address + """ +- retval = self.push_name(address=0xDEADBEEF, name="TESTNAME1") ++ retval = self._push_name(address=0xDEADBEEF, name="TESTNAME1") + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data['result']) + +- retval = self.get_name(address=0xDEADBEEF) ++ retval = self._get_name(address=0xDEADBEEF) + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertIn(data['names'][0]["data"], "TESTNAME1") +@@ -436,20 +591,20 @@ def test_create_struct(self): + """ + Simple structure creation and access + """ +- retval = self.create_struct(sid=1, name="StructName1") ++ retval = self._create_struct(sid=1, name="StructName1") + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data["result"]) + + # check if the structure is in the complete listing +- retval = self.get_all_structs(sid=1) ++ retval = self._get_all_structs(sid=1) + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertIn("StructName1", data["structs"][0]["name"]) + self.assertEqual(0, data["structs"][0]["size"]) + + # check if we can access the structure alone +- retval = self.get_one_struct(sid=1, struct_id=1) ++ retval = self._get_one_struct(sid=1, struct_id=1) + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + struct = data["structs"] +@@ -461,17 +616,17 @@ def test_create_multiple_structs(self): + This will test if we can access multiple structs for one sample + """ + # create structs +- retval = self.create_struct(sid=1, name="StructName1") ++ retval = self._create_struct(sid=1, name="StructName1") + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data["result"]) + +- retval = self.create_struct(sid=1, name="StructName2") ++ retval = self._create_struct(sid=1, name="StructName2") + data = json.loads(retval.data) + self.assertTrue(data["result"]) + + # get the structs +- retval = self.get_all_structs(sid=1) ++ retval = self._get_all_structs(sid=1) + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertEqual(2, len(data["structs"])) +@@ -482,25 +637,24 @@ def test_create_multiple_structs(self): + self.assertEqual(0, struct1["size"]) + self.assertEqual(0, struct2["size"]) + +- + def test_create_struct_member(self): + """ + Member creation + """ + # first create a structre +- self.create_struct(sid=1, name="StructName1") ++ self._create_struct(sid=1, name="StructName1") + # then add a member to it +- retval = self.create_struct_member(struct_id=1, +- mname="MemberName1", +- size=4, +- offset=0) ++ retval = self._create_struct_member(struct_id=1, ++ mname="MemberName1", ++ size=4, ++ offset=0) + # Is the member OK? + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data["result"]) + + # can we get the member in the structure +- retval = self.get_one_struct(sid=1, struct_id=1) ++ retval = self._get_one_struct(sid=1, struct_id=1) + data = json.loads(retval.data) + struct = data["structs"] + +@@ -511,32 +665,32 @@ def test_create_struct_member(self): + self.assertEqual(4, member["size"]) + self.assertEqual(0, member["offset"]) + +- def test_create_multiple_struct_members(self): ++ def test_create_struct_members(self): + """ + Test for multiples members + """ +- self.create_struct(sid=1, name="StructName1") +- self.create_struct_member(struct_id=1, +- mname="MemberName1", +- size=4, +- offset=0) ++ self._create_struct(sid=1, name="StructName1") ++ self._create_struct_member(struct_id=1, ++ mname="MemberName1", ++ size=4, ++ offset=0) + +- self.create_struct_member(struct_id=1, +- mname="MemberName2", +- size=2, +- offset=4) ++ self._create_struct_member(struct_id=1, ++ mname="MemberName2", ++ size=2, ++ offset=4) + +- self.create_struct_member(struct_id=1, +- mname="MemberName3", +- size=2, +- offset=6) ++ self._create_struct_member(struct_id=1, ++ mname="MemberName3", ++ size=2, ++ offset=6) + +- self.create_struct_member(struct_id=1, +- mname="MemberName4", +- size=4, +- offset=8) ++ self._create_struct_member(struct_id=1, ++ mname="MemberName4", ++ size=4, ++ offset=8) + +- retval = self.get_one_struct(sid=1, struct_id=1) ++ retval = self._get_one_struct(sid=1, struct_id=1) + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + +@@ -566,45 +720,83 @@ def test_create_multiple_struct_members(self): + self.assertEqual(4, member["size"]) + self.assertEqual(8, member["offset"]) + ++ def test_idatypes(self): ++ """ ++ IDA Types ++ """ ++ ret = self._create_type(sid=1, address=0xDEADBEEF, typedef='void *') ++ self.assertEqual(ret.status_code, 200) ++ res = json.loads(ret.data) ++ self.assertTrue(res["result"]) ++ ++ ++ ret = self._get_type(sid=1) ++ self.assertEqual(ret.status_code, 200) ++ types = json.loads(ret.data)['typedefs'] ++ self.assertEqual(len(types), 1) ++ self.assertIn(types[0]["data"], 'void *') ++ ++ ++ ret = self._get_type(sid=1, address=0xDEADBEEF) ++ self.assertEqual(ret.status_code, 200) ++ types = json.loads(ret.data)['typedefs'] ++ self.assertEqual(len(types), 1) ++ self.assertIn(types[0]["data"], 'void *') ++ ++ ++ ret = self._get_type(sid=1, address=0x1234) ++ self.assertEqual(ret.status_code, 200) ++ types = json.loads(ret.data)['typedefs'] ++ self.assertEqual(len(types), 0) ++ ++ ++ self._create_type(sid=1, address=0xBADF00D, typedef='int testtype(int dwTest, char cType)') ++ ret = self._get_type(sid=1) ++ self.assertEqual(ret.status_code, 200) ++ types = json.loads(ret.data)['typedefs'] ++ self.assertEqual(len(types), 2) ++ self.assertIn(types[0]["data"], 'void *') ++ self.assertIn(types[1]["data"], 'int testtype(int dwTest, char cType)') ++ + + def test_struct_member_update(self): + """ + Update size, name or offset + """ +- self.create_struct(sid=1, name="StructName1") +- self.create_struct_member(struct_id=1, +- mname="MemberName1", +- size=4, +- offset=0) ++ self._create_struct(sid=1, name="StructName1") ++ self._create_struct_member(struct_id=1, ++ mname="MemberName1", ++ size=4, ++ offset=0) + +- self.create_struct_member(struct_id=1, +- mname="MemberName2", +- size=2, +- offset=4) ++ self._create_struct_member(struct_id=1, ++ mname="MemberName2", ++ size=2, ++ offset=4) + +- retval = self.update_struct_member_name(struct_id=1, +- mid=1, +- newname="NewMemberName1") ++ retval = self._update_struct_member_name(struct_id=1, ++ mid=1, ++ newname="NewMemberName1") + + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data['result']) + +- retval = self.get_one_struct(sid=1, struct_id=1) ++ retval = self._get_one_struct(sid=1, struct_id=1) + data = json.loads(retval.data) + mstruct = data['structs'] + member = mstruct['members'][0] + self.assertIn('NewMemberName1', member['name']) + + # test when downgrading the size of first member +- retval = self.update_struct_member_size(struct_id=1, +- mid=1, +- newsize=2) ++ retval = self._update_struct_member_size(struct_id=1, ++ mid=1, ++ newsize=2) + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data["result"]) + +- retval = self.get_one_struct(sid=1, struct_id=1) ++ retval = self._get_one_struct(sid=1, struct_id=1) + data = json.loads(retval.data) + mstruct = data['structs'] + member = mstruct['members'][0] +@@ -612,10 +804,10 @@ def test_struct_member_update(self): + self.assertEqual(mstruct['size'], 6) + + # test when downgrading the last member size +- retval = self.update_struct_member_size(struct_id=1, +- mid=2, +- newsize=1) +- retval = self.get_one_struct(sid=1, struct_id=1) ++ retval = self._update_struct_member_size(struct_id=1, ++ mid=2, ++ newsize=1) ++ retval = self._get_one_struct(sid=1, struct_id=1) + data = json.loads(retval.data) + mstruct = data['structs'] + member = mstruct['members'][1] +@@ -624,119 +816,26 @@ def test_struct_member_update(self): + + + # test when upgrading the last member size +- retval = self.update_struct_member_size(struct_id=1, +- mid=2, +- newsize=4) ++ retval = self._update_struct_member_size(struct_id=1, ++ mid=2, ++ newsize=4) + + self.assertEqual(retval.status_code, 200) + data = json.loads(retval.data) + self.assertTrue(data["result"]) + +- retval = self.get_one_struct(sid=1, struct_id=1) ++ retval = self._get_one_struct(sid=1, struct_id=1) + + data = json.loads(retval.data) + mstruct = data['structs'] + member = mstruct['members'][1] + self.assertEqual(member['size'], 4) + self.assertEqual(mstruct['size'], 8) +- + # if upgrading the size and overlapping the next member, + # adopt the same behavior as IDA and remove the second member + # TODO!!! + # self.assertTrue(False) + +- def test_sample_abstract(self): +- data = json.dumps(dict(abstract="This is a test for abstract")) +- retval = self.app.post('/api/1.0/samples/1/abstract/', data=data, +- content_type="application/json") +- self.assertEqual(retval.status_code, 200) +- result = json.loads(retval.data) +- self.assertTrue(result['result']) +- +- retval = self.app.get('/api/1.0/samples/1/abstract/') +- self.assertEqual(retval.status_code, 200) +- result = json.loads(retval.data) +- self.assertIn(result['abstract'], 'This is a test for abstract') +- +- def test_yara_creation(self): +- rule_text = """rule toto{ +- strings: +- $1 = {4D 5A} +- condition: +- $1 at 0 +- }""" +- retval = self.create_yara("TESTYARA", rule_text) +- self.assertEqual(retval.status_code, 200) +- data = json.loads(retval.data) +- self.assertEqual(data["id"], 1) +- +- retval= self.app.get("/api/1.0/yaras/") +- self.assertEqual(retval.status_code, 200) +- data = json.loads(retval.data) +- self.assertEqual(len(data['yara_rules']), 1) +- rule = data['yara_rules'][0] +- self.assertIn(rule['name'], "TESTYARA") +- self.assertEqual(rule['TLP_sensibility'], 3) +- self.assertIn(rule['raw_rule'], rule_text) +- +- def test_yara_tlp(self): +- rule_text = """rule toto{ +- strings: +- $1 = {4D 5A} +- condition: +- $1 at 0 +- }""" +- retval = self.create_yara("TESTYARA", rule_text, tlp_level=4) +- retval= self.app.get("/api/1.0/yaras/") +- data = json.loads(retval.data) +- rule = data['yara_rules'][0] +- self.assertEqual(rule['TLP_sensibility'], 4) +- +- def test_yara_family(self): +- """ +- Test for correct affectation of a yara to a family +- """ +- rule_text = """rule toto{ +- strings: +- $1 = {4D 5A} +- condition: +- $1 at 0 +- }""" +- retval = self.create_yara("TESTYARA", rule_text) +- self.create_family("TESTFAMILY") +- retval = self.app.post('/api/1.0/family/1/yaras/', +- data=json.dumps(dict(rule_name="TESTYARA")), +- content_type="application/json") +- self.assertEqual(retval.status_code, 200) +- data = json.loads(retval.data) +- self.assertTrue(data["result"]) +- +- retval = self.app.get('/api/1.0/family/1/export/1/detection/yara') +- self.assertEqual(retval.status_code, 200) +- self.assertIn("TESTYARA", retval.data) +- self.assertIn("4D 5A", retval.data) +- +- +-# def test_yara_update(self): +- # rule_text = """rule toto{ +- # strings: +- # $1 = {4D 5A} +- # condition: +- # $1 at 0 +- # }""" +- # retval = self.create_yara("TESTYARA", rule_text, tlp_level=4) +- +- # # Try to update the yara +- # retval = self.update_yara("TESTYARA", rule_text.replace('$1', '$MZ')) +- # self.assertEqual(retval.status_code, 200) +- # data = json.loads(retval.data) +- # self.assertTrue(data["result"]) +- +- # # Next check for the changes in the resulting data +- # retval= self.app.get("/api/1.0/yaras/") +- # data = json.loads(retval.data) +- # rule = data['yara_rules'][0] +- # self.assertIn(rule["raw_rule"], rule_text.replace('$1', '$MZ')) + + if __name__ == '__main__': + unittest.main() +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3STU+DQBAGYM78igly0AMfC2wxJh56MKkHY6O9N3ysQlJYAgux/96FJmqM2kuJ ++Mb7PZZeZWXbC4KZ9ucu3oh48Yy6+FnM+rdrnddozHjC2CBgPA8NnjMexQXy2jj7oO5W0REYrpfqp ++7lj+j3Lf569Ep7aZrKqkzt2uON0dx+YfRuHb/KMw0vOPFiwyyD9dC9/75/PPcpoGn4rcNM/oUSjq ++G2r2+oegJ9nSeq8KWVPgxqZ4aWSraL3crK4te3V/d+O5U6GXlvWVPcYtUwzJjiz7/PCGsi4VOU6T ++qOLi65wOHx6fdzLVaX2Ryy7HVh76mlQhaLm+pbHDThdOvTgV9frsGKO87DI5iJac7lBETkPWtNsm ++Tan7s8zf/sQAAAAAAAAAAAAAAAAAAAAAALN5BXSVXu8AKAAA +diff --git 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-000016/tests/test.sh b/tasks/format-code-task-000016/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..aca715a9ce89e3dc97fce62a7f9347e293428fe8 --- /dev/null +++ b/tasks/format-code-task-000016/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_api.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-000016/tests/test_command.sh b/tasks/format-code-task-000016/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000016/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000018/environment/Dockerfile b/tasks/format-code-task-000018/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e352050d1c8842ecbf710b190d503a32da80dbdb --- /dev/null +++ b/tasks/format-code-task-000018/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:627524c653f2b1669cafec6ac48ceeadbc3cd695383a5954f060fb4ee4d1f4a5 diff --git a/tasks/format-code-task-000018/environment/setup/files/blocklist b/tasks/format-code-task-000018/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000018/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000018/environment/setup/setup.sh b/tasks/format-code-task-000018/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000018/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000018/tests/test.patch b/tasks/format-code-task-000018/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0fd8f2035829bf255e1227825ce9c718341d7953 --- /dev/null +++ b/tasks/format-code-task-000018/tests/test.patch @@ -0,0 +1,225 @@ +diff --git a/tests/covalent_tests/results_manager_tests/root_dispatch_id_test.py b/tests/covalent_tests/results_manager_tests/root_dispatch_id_test.py +new file mode 100644 +index 00000000..25eb4532 +--- /dev/null ++++ b/tests/covalent_tests/results_manager_tests/root_dispatch_id_test.py +@@ -0,0 +1,191 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import tempfile ++ ++import pytest ++ ++import covalent as ct ++from covalent._data_store.datastore import DataStore ++from covalent._data_store.models import Lattice ++from covalent._results_manager import result as result_module ++from covalent._results_manager.result import Result, initialize_result_object ++from covalent._results_manager import write_result_to_db ++from covalent._workflow.lattice import Lattice as LatticeClass ++ ++ ++@pytest.fixture ++def test_db(): ++ ++ ++ return DataStore( ++ db_URL="sqlite+pysqlite:///:memory:", ++ initialize_db=True, ++ ) ++ ++ ++@pytest.fixture(autouse=True) ++def patch_db(test_db, monkeypatch): ++ monkeypatch.setattr(result_module, "workflow_db", test_db) ++ monkeypatch.setattr(write_result_to_db, "workflow_db", test_db) ++ ++ ++ ++ monkeypatch.setattr(result_module, "insert_electron_dependency_data", lambda *a, **k: None) ++ monkeypatch.setattr( ++ write_result_to_db, "insert_electron_dependency_data", lambda *a, **k: None ++ ) ++ return test_db ++ ++ ++def _make_json_lattice(name="workflow"): ++ results_dir = tempfile.mkdtemp() ++ ++ @ct.electron ++ def task(x): ++ return x ++ ++ @ct.lattice(results_dir=results_dir) ++ def workflow(x): ++ return task(x) ++ ++ workflow.__name__ = name ++ workflow.build_graph(2) ++ return workflow.serialize_to_json() ++ ++ ++def _make_result_directly(dispatch_id="dispatch_x"): ++ json_lattice = _make_json_lattice() ++ lattice = LatticeClass.deserialize_from_json(json_lattice) ++ result = Result( ++ lattice=lattice, ++ results_dir=lattice.metadata["results_dir"], ++ dispatch_id=dispatch_id, ++ ) ++ result._initialize_nodes() ++ return result ++ ++ ++ ++ ++ ++def test_root_dispatch_id_defaults_to_own_dispatch_id(): ++ result = _make_result_directly(dispatch_id="dispatch_abc") ++ assert result.root_dispatch_id == "dispatch_abc" ++ ++ ++def test_root_dispatch_id_is_read_only(): ++ result = _make_result_directly(dispatch_id="dispatch_abc") ++ with pytest.raises(AttributeError): ++ result.root_dispatch_id = "something_else" ++ ++ ++ ++ ++ ++def test_persist_without_electron_id_keeps_null(test_db): ++ result = _make_result_directly(dispatch_id="dispatch_top") ++ result.persist() ++ ++ with test_db.session() as session: ++ lattice_row = session.query(Lattice).filter_by(dispatch_id="dispatch_top").first() ++ assert lattice_row is not None ++ assert lattice_row.electron_id is None ++ ++ ++def test_persist_with_electron_id_writes_it(test_db): ++ result = _make_result_directly(dispatch_id="dispatch_sub") ++ result.persist(electron_id=42) ++ ++ with test_db.session() as session: ++ lattice_row = session.query(Lattice).filter_by(dispatch_id="dispatch_sub").first() ++ assert lattice_row is not None ++ assert lattice_row.electron_id == 42 ++ ++ ++ ++ ++ ++def test_initialize_result_object_toplevel(test_db): ++ json_lattice = _make_json_lattice() ++ result = initialize_result_object(json_lattice) ++ ++ assert result.dispatch_id is not None ++ assert result.root_dispatch_id == result.dispatch_id ++ ++ with test_db.session() as session: ++ lattice_row = ( ++ session.query(Lattice).filter_by(dispatch_id=result.dispatch_id).first() ++ ) ++ assert lattice_row is not None ++ assert lattice_row.electron_id is None ++ ++ ++def test_initialize_result_object_unique_dispatch_ids(): ++ json_lattice = _make_json_lattice() ++ r1 = initialize_result_object(json_lattice) ++ r2 = initialize_result_object(json_lattice) ++ assert r1.dispatch_id != r2.dispatch_id ++ ++ ++def test_initialize_result_object_sublattice_inherits_root(test_db): ++ parent = initialize_result_object(_make_json_lattice(name="parent")) ++ ++ sub = initialize_result_object( ++ _make_json_lattice(name="sub"), ++ parent_result_object=parent, ++ parent_electron_id=7, ++ ) ++ ++ ++ assert sub.dispatch_id != parent.dispatch_id ++ ++ assert sub.root_dispatch_id == parent.root_dispatch_id ++ assert sub.root_dispatch_id == parent.dispatch_id ++ ++ ++ with test_db.session() as session: ++ lattice_row = ( ++ session.query(Lattice).filter_by(dispatch_id=sub.dispatch_id).first() ++ ) ++ assert lattice_row is not None ++ assert lattice_row.electron_id == 7 ++ ++ ++def test_initialize_result_object_nested_sublattice_inherits_root(test_db): ++ root = initialize_result_object(_make_json_lattice(name="root")) ++ mid = initialize_result_object( ++ _make_json_lattice(name="mid"), ++ parent_result_object=root, ++ parent_electron_id=1, ++ ) ++ leaf = initialize_result_object( ++ _make_json_lattice(name="leaf"), ++ parent_result_object=mid, ++ parent_electron_id=2, ++ ) ++ ++ assert mid.root_dispatch_id == root.dispatch_id ++ assert leaf.root_dispatch_id == root.dispatch_id ++ assert leaf.dispatch_id != root.dispatch_id ++ assert leaf.dispatch_id != mid.dispatch_id +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,23 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++python -m pytest -q \ ++ tests/covalent_tests/data_store/data_store_test.py \ ++ tests/covalent_tests/workflow/lattice_serialization_test.py ++ ++ ++python -m pytest -q \ ++ tests/covalent_tests/results_manager_tests/root_dispatch_id_test.py diff --git a/tasks/format-code-task-000018/tests/test.sh b/tasks/format-code-task-000018/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a928be73e50522517a9746ea660cea5b778b9e11 --- /dev/null +++ b/tasks/format-code-task-000018/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/covalent_tests/results_manager_tests/root_dispatch_id_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-000018/tests/test_command.sh b/tasks/format-code-task-000018/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000018/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000020/environment/Dockerfile b/tasks/format-code-task-000020/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..37b6af2004f91e5a9cf2ee0e8789ccbbf9ff754b --- /dev/null +++ b/tasks/format-code-task-000020/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e8f805c67ada7162c7dfea3a3d48857b90ac0c5376b4822500c9053bf1987127 diff --git a/tasks/format-code-task-000020/environment/setup/files/blocklist b/tasks/format-code-task-000020/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000020/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000020/environment/setup/setup.sh b/tasks/format-code-task-000020/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000020/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000020/tests/test.patch b/tasks/format-code-task-000020/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fe8c5b381bcbbaeeb055ff9fbb908f8738c170f5 --- /dev/null +++ b/tasks/format-code-task-000020/tests/test.patch @@ -0,0 +1,133 @@ +diff --git a/test/categorical_algebra/CatElements.jl b/test/categorical_algebra/CatElements.jl +index 21b9ef184..2363f4efb 100644 +--- a/test/categorical_algebra/CatElements.jl ++++ b/test/categorical_algebra/CatElements.jl +@@ -1,6 +1,63 @@ + module TestCatElements + using Test + using Catlab.GATs, Catlab.Theories, Catlab.Graphs, Catlab.CategoricalAlgebra ++import Catlab.CategoricalAlgebra.CSets: ACSetTransformation ++import ACSets ++import ACSets: ACSet, acset_schema, add_parts!, codom_parts, dom_parts, ++ has_part, has_subpart, incident, IntParts, nparts, parts, set_subpart!, ++ subpart ++ ++struct WrappedGraph <: ACSet{IntParts} ++ data::Graph ++end ++WrappedGraph() = WrappedGraph(Graph()) ++ ++acset_schema(::WrappedGraph) = acset_schema(Graph()) ++nparts(g::WrappedGraph, p::Symbol) = nparts(g.data, p) ++parts(g::WrappedGraph, p::Symbol) = parts(g.data, p) ++add_parts!(g::WrappedGraph, p::Symbol, n::Int) = add_parts!(g.data, p, n) ++set_subpart!(g::WrappedGraph, part::Int, f::Symbol, val) = ++ set_subpart!(g.data, part, f, val) ++subpart(g::WrappedGraph, f::Symbol) = subpart(g.data, f) ++subpart(g::WrappedGraph, part, f::Symbol) = subpart(g.data, part, f) ++subpart(g::WrappedGraph, names::Tuple{Vararg{Symbol}}) = subpart(g.data, names) ++subpart(g::WrappedGraph, part, names::Tuple{Vararg{Symbol}}) = ++ subpart(g.data, part, names) ++dom_parts(g::WrappedGraph, f::Symbol) = dom_parts(g.data, f) ++codom_parts(g::WrappedGraph, f::Symbol) = codom_parts(g.data, f) ++has_part(g::WrappedGraph, p::Symbol) = has_part(g.data, p) ++has_subpart(g::WrappedGraph, f::Symbol) = has_subpart(g.data, f) ++incident(g::WrappedGraph, part, f::Symbol) = incident(g.data, part, f) ++incident(g::WrappedGraph, part, names::Tuple{Vararg{Symbol}}) = ++ incident(g.data, part, names) ++ACSetTransformation(components, X::WrappedGraph, Y::WrappedGraph) = ++ ACSetTransformation(components, X.data, Y.data) ++ ++@testset "Custom ACSet category-of-elements APIs" begin ++ arr = path_graph(Graph, 2) ++ wrapped_arr = WrappedGraph(arr) ++ @test elements(wrapped_arr) == elements(arr) ++ ++ wrapped_two_edge = WrappedGraph(path_graph(Graph, 3)) ++ el_wrapped_two_edge = elements(wrapped_two_edge) ++ @test nparts(el_wrapped_two_edge, :El) == 5 ++ @test nparts(el_wrapped_two_edge, :Arr) == 4 ++ ++ round_trip_wrapped = inverse_elements(el_wrapped_two_edge, WrappedGraph()) ++ @test nparts(round_trip_wrapped, :V) == 3 ++ @test nparts(round_trip_wrapped, :E) == 2 ++ @test subpart(round_trip_wrapped, :src) == [1, 2] ++ @test subpart(round_trip_wrapped, :tgt) == [2, 3] ++ ++ graph_two_edge = path_graph(Graph, 3) ++ graph_hom = homomorphism(arr, graph_two_edge; initial=(V=[1, 2], E=[1])) ++ el_hom = elements(graph_hom) ++ inv_wrapped_hom = inverse_elements(el_hom, WrappedGraph()) ++ @test nparts(dom(inv_wrapped_hom), :E) == 1 ++ @test nparts(codom(inv_wrapped_hom), :E) == 2 ++ @test collect(force(inv_wrapped_hom)[:V]) == [1, 2] ++ @test collect(force(inv_wrapped_hom)[:E]) == [1] ++end + + arr = @acset Graph begin + V = 2 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,60 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++set -e ++pkg_instantiate() { ++ if ! julia --project=. -e 'using Pkg; Pkg.instantiate()' > /tmp/fixture_pkg_instantiate.log 2>&1; then ++ cat /tmp/fixture_pkg_instantiate.log ++ return 1 ++ fi ++} ++ ++pkg_instantiate ++ACSETS_DIR=$(julia --project=. -e 'using ACSets; println(dirname(dirname(pathof(ACSets))))') ++sed -i 's/abstract type SimpleACSet{PT} <: ACSet{PT} end/abstract type SimpleACSet{PT<:PartsType} <: ACSet{PT} end/' "$ACSETS_DIR/src/DenseACSets.jl" ++sed -i 's/struct DynamicACSet{PT} <: SimpleACSet{PT}/struct DynamicACSet{PT<:PartsType} <: SimpleACSet{PT}/' "$ACSETS_DIR/src/DenseACSets.jl" ++rm -rf /root/.julia/compiled/v1.10/ACSets /root/.julia/compiled/v1.10/Catlab ++ ++ ++instantiate() { ++ pkg_instantiate ++} ++ ++case "${1:-}" in ++ base) ++ instantiate ++ awk ' ++ /^@testset "Custom ACSet category-of-elements APIs" begin$/ { skip=1; next } ++ skip && /^end$/ { skip=0; next } ++ !skip { print } ++ ' test/categorical_algebra/CatElements.jl > /tmp/cat_elements_base.jl ++ julia --project=. /tmp/cat_elements_base.jl ++ ;; ++ new) ++ instantiate ++ printf '%s\n' 'module FixtureDynamicCatElements' > /tmp/cat_elements_dynamic.jl ++ printf '%s\n' 'using Test' >> /tmp/cat_elements_dynamic.jl ++ printf '%s\n' 'using Catlab.GATs, Catlab.Theories, Catlab.Graphs, Catlab.CategoricalAlgebra' >> /tmp/cat_elements_dynamic.jl ++ set +e ++ awk ' ++ /^import Catlab.CategoricalAlgebra.CSets: ACSetTransformation$/ { capture=1 } ++ capture && /^arr = @acset Graph begin$/ { found=1; exit } ++ capture { print } ++ END { if (!found) exit 3 } ++ ' test/categorical_algebra/CatElements.jl >> /tmp/cat_elements_dynamic.jl ++ awk_status=$? ++ set -e ++ printf '%s\n' 'end # module' >> /tmp/cat_elements_dynamic.jl ++ if [ "$awk_status" -ne 0 ]; then ++ echo "Custom ACSet testset not found in CatElements test file" ++ exit "$awk_status" ++ fi ++ julia --project=. /tmp/cat_elements_dynamic.jl ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000020/tests/test.sh b/tasks/format-code-task-000020/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..481f5dca6c9ed4aa354b92fb59338068bec7914f --- /dev/null +++ b/tasks/format-code-task-000020/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/categorical_algebra/CatElements.jl +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000020/tests/test_command.sh b/tasks/format-code-task-000020/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000020/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-000027/environment/Dockerfile b/tasks/format-code-task-000027/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0638050290cb2f2c03d85de6ab2936b03282de19 --- /dev/null +++ b/tasks/format-code-task-000027/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b342c819994822f62255717bd8ed7917e91965ca9bc7fab36f339edd596bdb2f diff --git a/tasks/format-code-task-000027/environment/setup/files/blocklist b/tasks/format-code-task-000027/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000027/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000027/environment/setup/setup.sh b/tasks/format-code-task-000027/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000027/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000027/tests/test.patch b/tasks/format-code-task-000027/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e2408e16baeb1980adfe496633f8b02ce8b76734 --- /dev/null +++ b/tasks/format-code-task-000027/tests/test.patch @@ -0,0 +1,78 @@ +diff --git a/test/types/schema.test.ts b/test/types/schema.test.ts +index fc0204e2a..fc7ae0fa0 100644 +--- a/test/types/schema.test.ts ++++ b/test/types/schema.test.ts +@@ -1230,3 +1230,51 @@ async function gh13797() { + expectType(this); return ''; + } } }); + } ++ ++function gh13900StringMapOfNumber() { ++ const schema = new Schema({ ++ myMap: { type: 'Map', of: Number, required: true } ++ }); ++ const Test = model('Test_gh13900_num', schema); ++ ++ const doc = new Test({ myMap: { answer: 42 } }); ++ expectType>(doc.myMap); ++ expectType(doc.myMap!.get('answer')); ++} ++ ++function gh13900StringMapOfString() { ++ const schema = new Schema({ ++ myMap: { type: 'Map', of: String, required: true } ++ }); ++ const Test = model('Test_gh13900_str', schema); ++ ++ const doc = new Test({ myMap: { answer: 'hi' } }); ++ expectType>(doc.myMap); ++ expectType(doc.myMap!.get('answer')); ++} ++ ++function gh13900StringMapOfMixed() { ++ ++ const schema = new Schema({ ++ instance: { ++ type: 'Map', ++ of: Schema.Types.Mixed, ++ required: true ++ } ++ }); ++ const Test = model('Test_gh13900_mixed', schema); ++ ++ const doc = new Test({ instance: { foo: 1 } }); ++ expectType>(doc.instance); ++} ++ ++function gh13900StringMapPreservesConstructorBehavior() { ++ ++ const schema = new Schema({ ++ myMap: { type: Map, of: Number, required: true } ++ }); ++ const Test = model('Test_gh13900_ctor', schema); ++ ++ const doc = new Test({ myMap: { x: 1 } }); ++ expectType>(doc.myMap); ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..0f7dbefd0 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx tsd"] ++} +diff --git 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 tsd ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000027/tests/test.sh b/tasks/format-code-task-000027/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ccd6e65c5ab4a981070b6a9f20aacff70e36ac15 --- /dev/null +++ b/tasks/format-code-task-000027/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/types/schema.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-000027/tests/test_command.sh b/tasks/format-code-task-000027/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000027/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000029/environment/Dockerfile b/tasks/format-code-task-000029/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4984222268bde263e04c290283166880502a8593 --- /dev/null +++ b/tasks/format-code-task-000029/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:83c68bed4b1c6ec51847df71e135dd5635b377dfabfcc7f856f03e6203e1621e diff --git a/tasks/format-code-task-000029/environment/setup/files/blocklist b/tasks/format-code-task-000029/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000029/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000029/environment/setup/setup.sh b/tasks/format-code-task-000029/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000029/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000029/tests/test.patch b/tasks/format-code-task-000029/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..de4d1871c986e7a9fef512ed30977c3baea531ff --- /dev/null +++ b/tasks/format-code-task-000029/tests/test.patch @@ -0,0 +1,79 @@ +diff --git a/test/model.test.js b/test/model.test.js +index c2e3f68c1e8..cca70e32fd8 100644 +--- a/test/model.test.js ++++ b/test/model.test.js +@@ -5891,6 +5891,54 @@ describe('Model', function() { + assert.equal(called, 1); + }); + ++ it('custom statics that overwrite model functions dont get hooks by default', async function() { ++ ++ const schema = new Schema({ name: String }); ++ ++ schema.statics.insertMany = function(docs) { ++ return model.insertMany.apply(this, [docs]); ++ }; ++ ++ let called = 0; ++ schema.pre('insertMany', function(next) { ++ ++called; ++ next(); ++ }); ++ const Model = db.model('Test', schema); ++ ++ const res = await Model.insertMany([ ++ { name: 'foo' }, ++ { name: 'boo' } ++ ]); ++ ++ assert.ok(res[0].name); ++ assert.ok(res[1].name); ++ assert.equal(called, 1); ++ }); ++ ++ it('custom statics that overwrite document functions dont get hooks by default', async function() { ++ ++ const schema = new Schema({ name: String }); ++ ++ schema.statics.save = function() { ++ return 'foo'; ++ }; ++ ++ let called = 0; ++ schema.pre('save', function(next) { ++ ++called; ++ next(); ++ }); ++ ++ const Model = db.model('Test', schema); ++ ++ const doc = await Model.save(); ++ ++ assert.ok(doc); ++ assert.equal(doc, 'foo'); ++ assert.equal(called, 0); ++ }); ++ + it('error handling middleware passes saved doc (gh-7832)', async function() { + const schema = new Schema({ _id: Number }); + +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+3RUYrCMBSF4Ty7irsBY9KayXKkNgE7mGawqbj8afsyIji+KMPg/72cC7mQC0fv ++x+4YdrE/b9SrmIl3bsnJbS6zdZWtjNk6XyljrfNeiXvZRVfGoTQnEXXKufy29+j9n9I//Zc4lF2b ++U2r6oIfD8/541L+97r/2U//bD1MrMc874b43778NshS/j2HVf10k5fbQyHodL12ZonQp5rFIPfck ++8+Im5RCPeh7157D66/sBAAAAAAAAAAAAAACAd/YNrbE5AwAoAAA= +diff --git 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-000029/tests/test.sh b/tasks/format-code-task-000029/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..121c1bf9d48315f3d540e92e7e9dbd1f5e704082 --- /dev/null +++ b/tasks/format-code-task-000029/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/model.test.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000029/tests/test_command.sh b/tasks/format-code-task-000029/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000029/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000042/environment/Dockerfile b/tasks/format-code-task-000042/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..89ed8fe430f325fe22f4f3a1291f64439045effb --- /dev/null +++ b/tasks/format-code-task-000042/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:df6d414cfb63da9b2b2766392a7de94f58a57b4f6d1656766599ceace007f75c diff --git a/tasks/format-code-task-000042/environment/setup/files/blocklist b/tasks/format-code-task-000042/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000042/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000042/environment/setup/setup.sh b/tasks/format-code-task-000042/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000042/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000042/tests/test.patch b/tasks/format-code-task-000042/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3f5b1bc49ec41a5545912e37245e8664a73ff4c7 --- /dev/null +++ b/tasks/format-code-task-000042/tests/test.patch @@ -0,0 +1,55 @@ +diff --git a/test/data/dataset/test_dataset.py b/test/data/dataset/test_dataset.py +index 3d7e6b776..caa299491 100644 +--- a/test/data/dataset/test_dataset.py ++++ b/test/data/dataset/test_dataset.py +@@ -14,7 +14,7 @@ + from cartoframes.auth import Credentials + from cartoframes.data.clients import SQLClient + from cartoframes.utils.geom_utils import setting_value_exception +-from cartoframes.utils.columns import normalize_name ++from cartoframes.utils.columns import normalize_name, DataframeColumnsInfo + from cartoframes.utils.utils import load_geojson + from cartoframes.data import StrategiesRegistry + from cartoframes.data.dataset.registry.dataframe_dataset import DataFrameDataset, _rows +@@ -906,3 +906,14 @@ def test_rows_null_geom(self): + rows = _rows(df, dataframe_columns_info, with_lnglat) + + self.assertEqual(list(rows), [b'|\n', b'|\n']) ++ ++ def test_rows_non_ascii(self): ++ attribute = 'áéí' ++ unicode_attribute = u'áéí' ++ encoded_attribute = unicode_attribute.encode('utf-8') ++ encoded_line = encoded_attribute + '\n'.encode() ++ ++ df = pd.DataFrame.from_dict({'test': [attribute, unicode_attribute, encoded_attribute, 'xyz']}) ++ columns_info = DataframeColumnsInfo(df) ++ rows = _rows(df, columns_info, None) ++ self.assertEqual(list(rows), [encoded_line, encoded_line, encoded_line, b'xyz\n']) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,11 @@ ++H4sIAAAAAAAAA+2UT2/TQBDFc/anGFqkwsFJ7DaphChSxR+1F1qVcEBCqta7k3gbZ3e7u04aUb47 ++YyehBVF6aQWI+R3seD1583beJt2i1pU6RzPvdR6LPrE/GLR34ud7+zkb5FmeDwb53n6nn2XD/rAD ++g0dzdIs6ROEBOt7a+Lu6+97/o3Rv8o8Y4rm0s5kwqhvKh+txT/5ZPsy+559lu5T/3jDLO9B/OAt3 ++85/nv/2kV2jTK0QoE6mgPQQFqiTZhrcm1B7hdBlLa2C3m+WgAwgZ9RwThfM0LHSUJbi2YHdVkb/q ++0aueqasKrq8h+hobrWNDY6YlhQ6NQiM1BtBjMDaCqDwKtQTnMaCJyUYvnYHTDvT6q2laUN00DcsQ ++cZY6IadiQirpZeOAbIOjgysCSOGjhVAKh9US4qWaQW20QmkVwgILaSvrA1xocyFyEM4pTY9uKby3 ++C5igXevsBIy1i9ZW4eV+f+eurX3ACKefRkcn708PR0dArbWRVU29Yom0KXuBMsKzVqzrllCStIDC ++2ykamKMPmqYbHEo91uifJ3jlrL8tebAJ5cXTLzerX5veZ7Vpu9ARnpCNdgpjXSGkgFcrEyNaeyOi ++oP5kLOLEi9h0bGoDLEpNCXq8rDVF/frwbHQC0iMlFLWowg9ZrIbcXHqKBNsLqa7+N9YPzQY/J0Ck ++U9ja9H7nxQzXJj4aHcH6275+sXRsxnZrozSn7GNxEEqaS/KnfzAMwzAMwzAMwzAMwzAMwzAMwzAM ++wzAMwzB/Gd8AiYEWdwAoAAA= +diff --git 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-000042/tests/test.sh b/tasks/format-code-task-000042/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6946b9b072ad165435fcd72aebaa5dd5d9de2730 --- /dev/null +++ b/tasks/format-code-task-000042/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/dataset/test_dataset.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-000042/tests/test_command.sh b/tasks/format-code-task-000042/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000042/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000045/environment/Dockerfile b/tasks/format-code-task-000045/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fd11c283bad1750710bf99d4d8054f26ddbbd315 --- /dev/null +++ b/tasks/format-code-task-000045/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fcb5d0910fc4725ca505d3cfb8e05b990140a83fe1c17f0152db8c742982feab diff --git a/tasks/format-code-task-000045/environment/setup/files/blocklist b/tasks/format-code-task-000045/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000045/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000045/environment/setup/setup.sh b/tasks/format-code-task-000045/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000045/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000045/tests/test.patch b/tasks/format-code-task-000045/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c7239a5d4460a99785eba278adc747a307f576cb --- /dev/null +++ b/tasks/format-code-task-000045/tests/test.patch @@ -0,0 +1,120 @@ +diff --git a/test/BootBot.spec.js b/test/BootBot.spec.js +index 39f0157..68df63c 100644 +--- a/test/BootBot.spec.js ++++ b/test/BootBot.spec.js +@@ -116,6 +116,93 @@ describe('BootBot', () => { + expect(spy.calledWith(expected)).to.equal(true); + }); + ++ it('formats a string quick reply with default content_type, title, and payload', () => { ++ const spy = sinon.spy(bot, 'sendRequest'); ++ bot.sendTextMessage(userId, 'Hello', ['Red']); ++ const body = spy.firstCall.args[0]; ++ expect(body.message.quick_replies).to.deep.equal([ ++ { content_type: 'text', title: 'Red', payload: 'BOOTBOT_QR_RED' } ++ ]); ++ }); ++ ++ it('passes through a location quick reply object as-is', () => { ++ const spy = sinon.spy(bot, 'sendRequest'); ++ bot.sendTextMessage(userId, 'Where are you?', [{ content_type: 'location' }]); ++ const body = spy.firstCall.args[0]; ++ expect(body.message.quick_replies).to.deep.equal([ ++ { content_type: 'location' } ++ ]); ++ }); ++ ++ it('preserves all fields of a text quick reply with image_url', () => { ++ const spy = sinon.spy(bot, 'sendRequest'); ++ const reply = { ++ content_type: 'text', ++ title: 'Green', ++ payload: 'DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_GREEN', ++ image_url: 'http://petersfantastichats.com/img/green.png' ++ }; ++ bot.sendTextMessage(userId, 'Pick a color', [reply]); ++ const body = spy.firstCall.args[0]; ++ expect(body.message.quick_replies).to.deep.equal([reply]); ++ }); ++ ++ it('auto-generates payload and content_type for an object with only a title', () => { ++ const spy = sinon.spy(bot, 'sendRequest'); ++ bot.sendTextMessage(userId, 'Pick', [{ title: 'Red' }]); ++ const body = spy.firstCall.args[0]; ++ expect(body.message.quick_replies).to.deep.equal([ ++ { content_type: 'text', title: 'Red', payload: 'BOOTBOT_QR_RED' } ++ ]); ++ }); ++ ++ it('preserves user-provided payload when title is supplied', () => { ++ const spy = sinon.spy(bot, 'sendRequest'); ++ bot.sendTextMessage(userId, 'Pick', [{ title: 'Red', payload: 'CUSTOM_RED_PAYLOAD' }]); ++ const body = spy.firstCall.args[0]; ++ const qr = body.message.quick_replies[0]; ++ expect(qr.title).to.equal('Red'); ++ expect(qr.payload).to.equal('CUSTOM_RED_PAYLOAD'); ++ expect(qr.content_type).to.equal('text'); ++ }); ++ ++ it('formats a mixed array of string and object quick replies correctly', () => { ++ const spy = sinon.spy(bot, 'sendRequest'); ++ bot.sendTextMessage(userId, 'Pick', [ ++ 'Red', ++ { content_type: 'location' }, ++ { content_type: 'text', title: 'Blue', payload: 'PICK_BLUE', image_url: 'http://x/blue.png' } ++ ]); ++ const body = spy.firstCall.args[0]; ++ expect(body.message.quick_replies).to.deep.equal([ ++ { content_type: 'text', title: 'Red', payload: 'BOOTBOT_QR_RED' }, ++ { content_type: 'location' }, ++ { content_type: 'text', title: 'Blue', payload: 'PICK_BLUE', image_url: 'http://x/blue.png' } ++ ]); ++ }); ++ ++ it('preserves extra fields on a location quick reply', () => { ++ const spy = sinon.spy(bot, 'sendRequest'); ++ bot.sendTextMessage(userId, 'Where?', [{ content_type: 'location', extra_field: 'KEEP_ME' }]); ++ const body = spy.firstCall.args[0]; ++ const qr = body.message.quick_replies[0]; ++ expect(qr.content_type).to.equal('location'); ++ expect(qr.extra_field).to.equal('KEEP_ME'); ++ }); ++ ++ it('formats quick replies on sendAttachment the same way as sendTextMessage', () => { ++ const spy = sinon.spy(bot, 'sendRequest'); ++ bot.sendAttachment(userId, 'image', 'http://x/img.png', [ ++ { content_type: 'location' }, ++ { title: 'Red' } ++ ]); ++ const body = spy.firstCall.args[0]; ++ expect(body.message.quick_replies).to.deep.equal([ ++ { content_type: 'location' }, ++ { content_type: 'text', title: 'Red', payload: 'BOOTBOT_QR_RED' } ++ ]); ++ }); ++ + it('can send an attachment', () => { + const spy = sinon.spy(bot, 'sendRequest'); + const type = 'image'; +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..fdb8120 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx mocha test/BootBot.spec.js"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx mocha test/BootBot.spec.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000045/tests/test.sh b/tasks/format-code-task-000045/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d9c465ace98be4b675f512e74ffb1135a2438766 --- /dev/null +++ b/tasks/format-code-task-000045/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/BootBot.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-000045/tests/test_command.sh b/tasks/format-code-task-000045/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000045/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000089/environment/Dockerfile b/tasks/format-code-task-000089/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..796f092726f75a77fec628b13aa2dfae6b749100 --- /dev/null +++ b/tasks/format-code-task-000089/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:02c1b61699c8ba5562395a4c5ba9f565c5d5a31733ae3fe5603ddb069efea7c9 diff --git a/tasks/format-code-task-000089/environment/setup/files/blocklist b/tasks/format-code-task-000089/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000089/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000089/environment/setup/setup.sh b/tasks/format-code-task-000089/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000089/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000089/tests/test.patch b/tasks/format-code-task-000089/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1b999704a3dd4b3e1974bae66e475a07d8a244a5 --- /dev/null +++ b/tasks/format-code-task-000089/tests/test.patch @@ -0,0 +1,53 @@ +diff --git a/tests/test_common.py b/tests/test_common.py +index 1f07f955a..c2012a693 100644 +--- a/tests/test_common.py ++++ b/tests/test_common.py +@@ -1148,7 +1148,7 @@ async def test_import_xml_data_type_definition(opc): + s = ua.MyStruct() + s.toto = 0.1 + ss = ua.MySubstruct() +- assert ss.titi == 0 ++ assert ss.titi == None + assert isinstance(ss.structs, list) + + ss.titi = 1 +@@ -1253,6 +1253,11 @@ async def test_custom_struct_with_optional_fields(opc): + await opc.opc.load_data_type_definitions() + + my_struct_optional = ua.MyOptionalStruct() ++ assert my_struct_optional.MyBool is not None ++ assert my_struct_optional.MyUInt32 is not None ++ assert my_struct_optional.MyString is None ++ assert my_struct_optional.MyInt64 is None ++ + my_struct_optional.MyUInt32 = 45 + my_struct_optional.MyInt64 = -67 + var = await opc.opc.nodes.objects.add_variable(idx, "my_struct_optional", ua.Variant(my_struct_optional, ua.VariantType.ExtensionObject)) +@@ -1664,4 +1669,4 @@ async def test_sql_injection(): + validate_table_name(table) + table = "user'" + with pytest.raises(SqlInjectionError) as _: +- validate_table_name(table) +\ No newline at end of file ++ validate_table_name(table) +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+3SwUrEMBAG4Jz7FCOCt7ZJ3aQnfZUlaQMt2KQ008K+vW09rAq6l11E/b9DEshA ++JvxTuLl/aY8+LKW4Fbmqtd731ed9Pytdyao2pjYHIZUylRSkb9bRO3NiOxGJKUb+ru7S/S9VnPNn ++n/jYxGGwoS1Sd703LuWv1sw/5n8wj1qQvF4LX/vn+d/fla4PpbOpy5qW9iFwvs1SnKfGUxlHfhuM ++ZRuRrdQ23C+WfTaeuIuB8oHW01pC25LOYxRDMZ4oXyjP2T2lLk5M1fODyn76zwAAAAAAAAAAAAAA ++AAAAAAAAf8UruuAXQgAoAAA= +diff --git 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-000089/tests/test.sh b/tasks/format-code-task-000089/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c65a5d09040417649c4b3f6221c93edab09a1720 --- /dev/null +++ b/tasks/format-code-task-000089/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_common.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-000089/tests/test_command.sh b/tasks/format-code-task-000089/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000089/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000212/environment/Dockerfile b/tasks/format-code-task-000212/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c31e848c556eee352525220afef7ff0273ff21ce --- /dev/null +++ b/tasks/format-code-task-000212/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0af42fef65891372abbeea8cddcf11bc2c4f3f8a436b338777dc7877988d37bc diff --git a/tasks/format-code-task-000212/environment/setup/files/blocklist b/tasks/format-code-task-000212/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000212/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000212/environment/setup/setup.sh b/tasks/format-code-task-000212/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000212/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000212/tests/test.patch b/tasks/format-code-task-000212/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..32d793c5fb8725c69f89f64ac408e9d1f95fcbc2 --- /dev/null +++ b/tasks/format-code-task-000212/tests/test.patch @@ -0,0 +1,67 @@ +diff --git a/tests/agent/test_docker_agent.py b/tests/agent/test_docker_agent.py +index d327a3b1f408..112de35a0d48 100644 +--- a/tests/agent/test_docker_agent.py ++++ b/tests/agent/test_docker_agent.py +@@ -315,14 +315,20 @@ def test_docker_agent_deploy_flow_sets_container_name_with_index(api, collision_ + + if collision_count: + # Add the basic name first +- existing_containers = [{"name": "flow-run-name"}] ++ existing_names = ["flow-run-name"] + for i in range(1, collision_count): +- existing_containers.append({"name": f"flow-run-name-{i}"}) ++ existing_names.append(f"flow-run-name-{i}") + else: +- # Ensure a random container doesn't matter +- existing_containers = [{"name": "foobar"}] ++ existing_names = [] + +- api.containers.return_value = existing_containers ++ def fail_if_name_exists(*args, **kwargs): ++ if kwargs.get("name") in existing_names: ++ raise docker.errors.APIError( ++ "Conflict. The container name 'foobar' is already in use" ++ ) ++ return {} ++ ++ api.create_container = MagicMock(side_effect=fail_if_name_exists) + + agent = DockerAgent() + agent.deploy_flow( +@@ -345,10 +351,9 @@ def test_docker_agent_deploy_flow_sets_container_name_with_index(api, collision_ + ) + ) + +- expected_name = "flow-run-name" +- if collision_count: +- expected_name += f"-{collision_count}" +- ++ expected_name = ( ++ "flow-run-name" if not collision_count else f"flow-run-name-{collision_count}" ++ ) + assert api.create_container.call_args[1]["name"] == expected_name + + +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+3SS26DMBAG4Kw5xSjdhjcJqpRk1wv0AhGPSUExNsKGltvX0EXaSm1UKVFV9f8W ++2BpbZuC3l/e1KA8sB39xK4GVrtfzaH0e53m4joIoDeMktfUw3ATRgtY36+idXpusI1p0Spnv9l1a ++/6O8c/6GtTkUqmkyWXq6ut47LuWfhOk5/3jKP9mEyYKC67XwtX+ef1HSHHzOpePc0YPUfcdkb0Gb ++mToXTCW3LEuWxUgDd7pWUjtt3VIt7Y8TgpZ9J0Sdx/td6EWJF6+20ZKWTdbpqrHr6nm/i73AC/Lw ++frVNPi65SrI66qLiJtvvonlbtNrGS3LdvOPs5OpRG27cNitO2RNrivZ+yYMveyGmdh97SaZishE+ ++saHpQ+hYC3ba0VRKktuQnU3V6aF9e4Y0bxe9VMWJu8Nc8dqR3BdyB+e34wAAAAAAAAAAAAAAAAAA ++AAAA+JFXj6pr+wAoAAA= +diff --git 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-000212/tests/test.sh b/tasks/format-code-task-000212/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c90991296045e1be0e8405f998774e262d2d53d7 --- /dev/null +++ b/tasks/format-code-task-000212/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/agent/test_docker_agent.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-000212/tests/test_command.sh b/tasks/format-code-task-000212/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000212/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000215/environment/Dockerfile b/tasks/format-code-task-000215/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ddff25f9e6ecc5120c4750aa1fc5c75b720e6e37 --- /dev/null +++ b/tasks/format-code-task-000215/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:95c36bf49ce81bddcba69e014ae6a1938f3862422687ea2f7441bb3c7326c86a diff --git a/tasks/format-code-task-000215/environment/setup/files/blocklist b/tasks/format-code-task-000215/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000215/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000215/environment/setup/setup.sh b/tasks/format-code-task-000215/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000215/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000215/tests/test.patch b/tasks/format-code-task-000215/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1ff40ce874eb6e8ce04601d46d4bc706b9b3fd31 --- /dev/null +++ b/tasks/format-code-task-000215/tests/test.patch @@ -0,0 +1,117 @@ +diff --git a/tests/test_handler_transform_inverter.py b/tests/test_handler_transform_inverter.py +index 7039abf091..e5f46ea19e 100644 +--- a/tests/test_handler_transform_inverter.py ++++ b/tests/test_handler_transform_inverter.py +@@ -16,7 +16,7 @@ + import torch + from ignite.engine import Engine + +-from monai.data import CacheDataset, DataLoader, create_test_image_3d ++from monai.data import CacheDataset, DataLoader, create_test_image_3d, pad_list_data_collate + from monai.engines.utils import IterationEvents + from monai.handlers import TransformInverter + from monai.transforms import ( +@@ -104,6 +104,7 @@ def _train_func(engine, batch): + nearest_interp=[True, False], + post_func=[lambda x: x + 10, lambda x: x], + postfix="inverted2", ++ collate_fn=pad_list_data_collate, + num_workers=0 if sys.platform == "darwin" or torch.cuda.is_available() else 2, + ).attach(engine) + +@@ -133,15 +134,15 @@ def _train_func(engine, batch): + self.assertTrue((reverted.size - n_good) in (25300, 1812, 1824), "diff. in 3 possible values") + + # check the case that different items use different interpolation mode to invert transforms +- for i in engine.state.output["image_inverted2"]: +- # if the interpolation mode is nearest, accumulated diff should be smaller than 1 +- self.assertLess(torch.sum(i.to(torch.float) - i.to(torch.uint8).to(torch.float)).item(), 1.0) +- self.assertTupleEqual(i.shape, (1, 100, 101, 107)) +- +- for i in engine.state.output["label_inverted2"]: +- # if the interpolation mode is not nearest, accumulated diff should be greater than 10000 +- self.assertGreater(torch.sum(i.to(torch.float) - i.to(torch.uint8).to(torch.float)).item(), 10000.0) +- self.assertTupleEqual(i.shape, (1, 100, 101, 107)) ++ d = engine.state.output["image_inverted2"] ++ ++ self.assertLess(torch.sum(d.to(torch.float) - d.to(torch.uint8).to(torch.float)).item(), 1.0) ++ self.assertTupleEqual(d.shape, (2, 1, 100, 101, 107)) ++ ++ d = engine.state.output["label_inverted2"] ++ ++ self.assertGreater(torch.sum(d.to(torch.float) - d.to(torch.uint8).to(torch.float)).item(), 10000.0) ++ self.assertTupleEqual(d.shape, (2, 1, 100, 101, 107)) + + + if __name__ == "__main__": +diff --git a/tests/test_save_image.py b/tests/test_save_image.py +index 141960e09b..a279d3a4ec 100644 +--- a/tests/test_save_image.py ++++ b/tests/test_save_image.py +@@ -83,9 +83,37 @@ + False, + ] + ++TEST_CASE_7 = [ ++ [torch.randint(0, 255, (1, 2, 3, 4)), torch.randint(0, 255, (1, 2, 3, 4))], ++ [{"filename_or_obj": "testfile0.nii.gz"}, {"filename_or_obj": "testfile1.nii.gz"}], ++ ".nii.gz", ++ False, ++ False, ++] ++ ++TEST_CASE_8 = [ ++ [torch.randint(0, 255, (1, 2, 3, 4))], ++ {"filename_or_obj": ["testfile0.nii.gz"]}, ++ ".nii.gz", ++ False, ++ False, ++] ++ + + class TestSaveImage(unittest.TestCase): +- @parameterized.expand([TEST_CASE_0, TEST_CASE_1, TEST_CASE_2, TEST_CASE_3, TEST_CASE_4, TEST_CASE_5, TEST_CASE_6]) ++ @parameterized.expand( ++ [ ++ TEST_CASE_0, ++ TEST_CASE_1, ++ TEST_CASE_2, ++ TEST_CASE_3, ++ TEST_CASE_4, ++ TEST_CASE_5, ++ TEST_CASE_6, ++ TEST_CASE_7, ++ TEST_CASE_8, ++ ] ++ ) + def test_saved_content(self, test_data, meta_data, output_ext, resample, save_batch): + with tempfile.TemporaryDirectory() as tempdir: + trans = SaveImage( +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,12 @@ ++H4sIAAAAAAAAA+2X32vbMBDH86y/4sgKSaBxYsc/oNCHsg36Mja27mkModhKLGpJRpK95b+f7KZt ++urULtGnL2H0eIudOlpTcfU9SsGxEVVCu2tnguZh7siTpW8/vbf8cJlEYxXHY28MwSdMBJM+2oh0a ++65gBGBit3d/67fP/owS38c+1WjluXVBvDjtHF+A0jh+MfxhG2/gvsjgMffwXWRYNYH7YZdzPfx5/ ++IWttHDht8jKQTeVEbXTOrRVqDcyCrImsA8sdtSUz3kitM8zx9WY8WomKU7uxjsvRhLz2L0Eew47+ ++pVaXfFMzl5c0bwp2sDqwT//RIr3Rv2+8/pM4i1H/L8Gu/gmh2oi1UKyiwlLWMlGxZcXhdFsf+qzY ++9RBS8BXQPmd4ceel8eSEgMdw1xgFF6bxvR8Yxk9w7xhYU56dHf2bRtFu/7eHPgDs0/9ivrg+/83T ++tNN/HGYp6v8luKP/h+VZMbks2MlWxtuX/NZ//VhvuswhxJsC/lO48ZUhkEyo8be+EIz63Jp1n7Rk ++qqi4of4ooexKG0mFarlx3PjcGx3/0d+yllMh2Zrv+KftiHyf4MHjSezov/+ncy2lD05gy8PNse/+ ++l0bJjf6zMOv0n0YL1P9LkBfQB37JC0LewBfuoKm9nH1CEP6z1/ans4vz0+HR+ccP72dB75kthTo5 ++6uxDwltWwfBo3DtAKOFgOvWbeTm53+fNV19Z7kTrbxLgz51MTLsJ/QI+Nwp64cMP4Up4+/Xdme+Q ++X/oKBazVooDuHsILkFxqs4FKSOGYE1pZP64rtYJpDkPymLp2W9aOrwvaa9SzIVY0BEEQBEEQBEEQ ++BEEQBEEQ5Kn8Au+3QK8AKAAA +diff --git 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-000215/tests/test.sh b/tasks/format-code-task-000215/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..11934f1195c65ca7c4687f0eacf338dcf38e0e20 --- /dev/null +++ b/tasks/format-code-task-000215/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_handler_transform_inverter.py +tests/test_save_image.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-000215/tests/test_command.sh b/tasks/format-code-task-000215/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000215/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000223/environment/Dockerfile b/tasks/format-code-task-000223/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a6f64f9c0f9fa38d7187d4454e467dbcb5c836be --- /dev/null +++ b/tasks/format-code-task-000223/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8974cc151357c8eb3f3680ac9f8b8b89f5fb2c7444ce76ad72f257538d9244c1 diff --git a/tasks/format-code-task-000223/environment/setup/files/blocklist b/tasks/format-code-task-000223/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000223/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000223/environment/setup/setup.sh b/tasks/format-code-task-000223/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000223/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000223/tests/test.patch b/tasks/format-code-task-000223/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c45d2738ccfea8c19d1106adc2c6236a8407565f --- /dev/null +++ b/tasks/format-code-task-000223/tests/test.patch @@ -0,0 +1,37 @@ +diff --git a/test_isort.py b/test_isort.py +index 3506405c7..04a14cca6 100644 +--- a/test_isort.py ++++ b/test_isort.py +@@ -1507,3 +1507,12 @@ def test_basic_comment(): + '# Foo\n' + 'import os\n') + assert SortImports(file_contents=test_input).output == test_input ++ ++ ++def test_shouldnt_add_lines(): ++ """Ensure that isort doesn't add a blank line when a top of import comment is present, issue #316""" ++ test_input = ('"""Text"""\n' ++ '# This is a comment\n' ++ 'import pkg_resources\n') ++ assert SortImports(file_contents=test_input).output == test_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,4 @@ ++H4sIAAAAAAAAA+3SzYrCMBSG4ax7FUdm4aptMjb2cqR/0IJtpImCd2/sxmFA3SjD4PtkkZATSMJ3 ++svo47NtdN51y9S46Kq1d5uj3vKyN/TZxFJtio7QxttwqsW970Q9HH6pZRM3OhUfnntX/qeyWf+h8 ++2DVuHKupzXz/ujue5W+0veVvyph/sdWlEv26J9z34fl/rfJ6mPK68n3StLI0Qd21yXVD0n0j68M5 ++9G6SdJS4ilVZ+mTwbg7Z4SzpaZ389ScAAAAAAAAAAAAAAACAD3UBbqszkQAoAAA= +diff --git 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-000223/tests/test.sh b/tasks/format-code-task-000223/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..258ed7d5255ea5cc9e4fae90ec73f6e611a9c52e --- /dev/null +++ b/tasks/format-code-task-000223/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_isort.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-000223/tests/test_command.sh b/tasks/format-code-task-000223/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000223/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000224/environment/Dockerfile b/tasks/format-code-task-000224/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1d8510929960fd3a93c068290eab9936645eaf90 --- /dev/null +++ b/tasks/format-code-task-000224/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:121e1c44a3bdf037e1a0c5fd6c47d322fc2ab5514d9bdbba0f226fc32ac70d82 diff --git a/tasks/format-code-task-000224/environment/setup/files/blocklist b/tasks/format-code-task-000224/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000224/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000224/environment/setup/setup.sh b/tasks/format-code-task-000224/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000224/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000224/tests/test.patch b/tasks/format-code-task-000224/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..78bc32a8a92ee066ca00830881821ec4fcb6abbc --- /dev/null +++ b/tasks/format-code-task-000224/tests/test.patch @@ -0,0 +1,58 @@ +diff --git a/src/tests/test_cases/superfluous_quotes.py b/src/tests/test_cases/superfluous_quotes.py +new file mode 100644 +index 00000000..7d468393 +--- /dev/null ++++ b/src/tests/test_cases/superfluous_quotes.py +@@ -0,0 +1,20 @@ ++"""A valid module docstring.""" ++ ++from .expected import Expectation ++ ++expectation = Expectation() ++expect = expectation.expect ++ ++ ++def correct_func(): ++ """Three quotes in both sides.""" ++ ++ ++@expect('D300: Use """triple double quotes""" (found """"-quotes)') ++def extra_opening(): ++ """"Extra quote on the left.""" ++ ++ ++@expect('D300: Use """triple double quotes""" (found """""-quotes)') ++def two_extra_opening(): ++ """""Two extra quotes on the left.""" +diff --git a/src/tests/test_definitions.py b/src/tests/test_definitions.py +index bb0cc1e5..63b395b5 100644 +--- a/src/tests/test_definitions.py ++++ b/src/tests/test_definitions.py +@@ -276,6 +276,7 @@ def test_token_stream(): + 'multi_line_summary_start', + 'all_import', + 'all_import_as', ++ 'superfluous_quotes', + ]) + def test_pep257(test_case): + """Run domain-specific tests from test.py 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,4 @@ ++H4sIAAAAAAAAA+3SzY7CIBSG4a69Cm6gPzCil2NswUhioSnYpHcv01k4mcRxozHG99lwcoAA+aja ++szuZnfVTXTxLk221Xsbs77jUUispN2ultCqaXDWyEPppN/rlHNN+FKIYQ0j/rbs3/6aqa/7JxrTr ++Qt/vvani8XFn3Mtfqu01/6/cl+uNzPk3j7vCbR+ef2fEEnxrzaoOQ6qH2YQupvlky+n7V7TO5146 ++Bi/KXuQqLxZx7JZd8efTGHtw3iUXfKyGWZTT6tXPAgAAAAAAAAAAAAAAAD7CBXFGk50AKAAA +diff --git 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-000224/tests/test.sh b/tasks/format-code-task-000224/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d8e2bce492f3430f3a761031718c7003ad5b28f5 --- /dev/null +++ b/tasks/format-code-task-000224/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/tests/test_cases/superfluous_quotes.py +src/tests/test_definitions.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-000224/tests/test_command.sh b/tasks/format-code-task-000224/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000224/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000248/environment/Dockerfile b/tasks/format-code-task-000248/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..74258743811c34edce862c2f9deb13981099c484 --- /dev/null +++ b/tasks/format-code-task-000248/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:63c47777ae6c930bf48e41c858d91d08bfa57ecea10f1ad8c2a0fbf70ceaf00d diff --git a/tasks/format-code-task-000248/environment/setup/files/blocklist b/tasks/format-code-task-000248/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000248/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000248/environment/setup/setup.sh b/tasks/format-code-task-000248/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000248/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000248/tests/test.patch b/tasks/format-code-task-000248/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..060efeeff7023dd6719b6ca9f0efa4e1183ce2d8 --- /dev/null +++ b/tasks/format-code-task-000248/tests/test.patch @@ -0,0 +1,95 @@ +diff --git a/api_test.go b/api_test.go +index 33c754a5..c8635380 100644 +--- a/api_test.go ++++ b/api_test.go +@@ -1,7 +1,6 @@ + package main + + import ( +- "bytes" + "encoding/json" + "io/ioutil" + "net/http" +@@ -92,13 +91,8 @@ func ListToxics(t *testing.T, addr, proxy, direction string) map[string]interfac + return toxics + } + +-func SetToxic(t *testing.T, addr, proxy, direction, name string, toxic Toxic) map[string]interface{} { +- body, err := json.Marshal(toxic) +- if err != nil { +- t.Fatal("Failed to marshal JSON post data for toxic") +- } +- +- resp, err := http.Post(addr+"/proxies/"+proxy+"/"+direction+"/toxics/"+name, "application/json", bytes.NewBuffer(body)) ++func SetToxic(t *testing.T, addr, proxy, direction, name string, toxic string) map[string]interface{} { ++ resp, err := http.Post(addr+"/proxies/"+proxy+"/"+direction+"/toxics/"+name, "application/json", strings.NewReader(toxic)) + if err != nil { + t.Fatal("Failed to get index", err) + } +@@ -210,7 +204,7 @@ func TestSetToxics(t *testing.T) { + t.Fatal("Unable to create proxy") + } + +- latency := SetToxic(t, addr, "mysql_master", "downstream", "latency", &LatencyToxic{Enabled: true, Latency: 100, Jitter: 10}) ++ latency := SetToxic(t, addr, "mysql_master", "downstream", "latency", `{"enabled": true, "latency": 100, "jitter": 10}`) + if latency["enabled"] != true { + t.Fatal("Latency toxic did not start up") + } +@@ -246,6 +240,30 @@ func TestSetToxics(t *testing.T) { + }) + } + ++func TestUpdateToxics(t *testing.T) { ++ WithServer(t, func(addr string) { ++ if resp := CreateProxy(t, addr, "mysql_master"); resp.StatusCode != http.StatusCreated { ++ t.Fatal("Unable to create proxy") ++ } ++ ++ latency := SetToxic(t, addr, "mysql_master", "downstream", "latency", `{"enabled": true, "latency": 100, "jitter": 10}`) ++ if latency["enabled"] != true { ++ t.Fatal("Latency toxic did not start up") ++ } ++ if latency["latency"] != 100.0 || latency["jitter"] != 10.0 { ++ t.Fatal("Latency toxic did not start up with correct settings") ++ } ++ ++ latency = SetToxic(t, addr, "mysql_master", "downstream", "latency", `{"latency": 1000}`) ++ if latency["enabled"] != true { ++ t.Fatal("Latency toxic did not stay enabled") ++ } ++ if latency["latency"] != 1000.0 || latency["jitter"] != 10.0 { ++ t.Fatal("Latency toxic did not get updated with the correct settings") ++ } ++ }) ++} ++ + func TestVersionEndpointReturnsVersion(t *testing.T) { + WithServer(t, func(addr string) { + resp, err := http.Get(addr + "/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,11 @@ ++H4sIAAAAAAAAA+2U32/TMBDH+5y/4tgeaB+SNC1tJdCQEEzlAbSJwXOV2pfELLEj22k7aX/8LmnX ++DgQMpE4IcR9VSmrfj+/d2YmWjSrlAvUq7j0VQ2I2mXRP4vtn955MRsloOEuSZNYbJslkNu3B5MkU ++PaBxPrUAPWuM/5XdY/v/KNFh/h6dXwhTVamWkSuOl+OR+Sfj6Ww//+GU7JIX09G4B8PjSfg5//n8 ++T5/FS6XjZeqKQEjoDsESZRCcwrl2jUWYG0ii0RiUg1R4tULo1xZDpalxZYlyEEhchW6tvCgg3xmP ++Xse0GuumLOH2FrxtsA15hR6aGuYXl28+vwdHy8K3OTJjwReUoY1cGdmU2L6bryh8UF1LZSGsSVxV ++x7mpU1/Ezoo4V75olhEd2fiqMLXKboJSQ+iyfRm/4RJ7s1GUanPTCnxrdKbyXdl0KZQ1ukLtO4Vz ++I7F2IfWKIt+rw01trN+VdHZynzneGseLtbHXrk4Fvnyg5eTgRl+8jxfvvnw4PzNZtpVQ1apEaAMB ++zSa1N9Cnvnb/QzGAJYq0cdS0Ms2jy9Q67A9Aafop3x9QBEFFlEp4BzSUbiat73MHZq07L9eaU5vR ++6rbOFVqnjHbbA/AHDTuogtBsXfebUbdDs8eN8pC0lX1qNE0ZSV9XofymRJoxtbOkWvUu6lapRpQo ++X5E7nbZuo1UvykYqnUNaq0W7FpEUS+Hp0wUVXWmoU+cG1GUUP9IV/O1rxzAMwzAMwzAMwzAMwzAM ++wzAMwzAMwzAMczTuAHBtsKoAKAAA +diff --git 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-000248/tests/test.sh b/tasks/format-code-task-000248/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f291a98fddcfd8bca448e14768e521e482bea7f9 --- /dev/null +++ b/tasks/format-code-task-000248/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_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-000248/tests/test_command.sh b/tasks/format-code-task-000248/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000248/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000270/environment/Dockerfile b/tasks/format-code-task-000270/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5613ac8f72d68a0e676849bb0a6d5642dc716208 --- /dev/null +++ b/tasks/format-code-task-000270/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e71702d413a737a73017b96ad83d848815a71b4d661dacb6e7612bafca00a7fd diff --git a/tasks/format-code-task-000270/environment/setup/files/blocklist b/tasks/format-code-task-000270/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000270/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000270/environment/setup/setup.sh b/tasks/format-code-task-000270/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000270/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000270/tests/test.patch b/tasks/format-code-task-000270/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c3bfb383590e26fb5c1e9b630b3e0e6e86842418 --- /dev/null +++ b/tasks/format-code-task-000270/tests/test.patch @@ -0,0 +1,107 @@ +diff --git a/ci/tests/python-plugins/src/tyk.conf b/ci/tests/python-plugins/src/tyk.conf +index 34358d93f95..f80419e18bf 100644 +--- a/ci/tests/python-plugins/src/tyk.conf ++++ b/ci/tests/python-plugins/src/tyk.conf +@@ -47,6 +47,7 @@ + "normalise_urls": { + "enabled": true, + "normalise_uuids": true, ++ "normalise_ulids": true, + "normalise_numbers": true, + "custom_patterns": [] + } +diff --git a/gateway/analytics_test.go b/gateway/analytics_test.go +index 8c3f90bc3cb..7246a79c6a3 100644 +--- a/gateway/analytics_test.go ++++ b/gateway/analytics_test.go +@@ -551,6 +551,7 @@ func TestURLReplacer(t *testing.T) { + ts := StartTest(func(globalConf *config.Config) { + globalConf.AnalyticsConfig.NormaliseUrls.Enabled = true + globalConf.AnalyticsConfig.NormaliseUrls.NormaliseUUIDs = true ++ globalConf.AnalyticsConfig.NormaliseUrls.NormaliseULIDs = true + globalConf.AnalyticsConfig.NormaliseUrls.NormaliseNumbers = true + globalConf.AnalyticsConfig.NormaliseUrls.Custom = []string{"ihatethisstring"} + }) +@@ -561,6 +562,9 @@ func TestURLReplacer(t *testing.T) { + recordUUID2 := analytics.AnalyticsRecord{Path: "/CA761232-ED42-11CE-BACD-00AA0057B223/search"} + recordUUID3 := analytics.AnalyticsRecord{Path: "/ca761232-ed42-11ce-BAcd-00aa0057b223/search"} + recordUUID4 := analytics.AnalyticsRecord{Path: "/ca761232-ed42-11ce-BAcd-00aa0057b223/search"} ++ recordULID1 := analytics.AnalyticsRecord{Path: "/posts/01G9HHNKWGBHCQX7VG3JKSZ055/comments"} ++ recordULID2 := analytics.AnalyticsRecord{Path: "/posts/01g9hhnkwgbhcqx7vg3jksz055/comments"} ++ recordULID3 := analytics.AnalyticsRecord{Path: "/posts/01g9HHNKwgbhcqx7vg3JKSZ055/comments"} + recordID1 := analytics.AnalyticsRecord{Path: "/widgets/123456/getParams"} + recordCust := analytics.AnalyticsRecord{Path: "/widgets/123456/getParams/ihatethisstring"} + +@@ -571,6 +575,9 @@ func TestURLReplacer(t *testing.T) { + NormalisePath(&recordUUID2, &globalConf) + NormalisePath(&recordUUID3, &globalConf) + NormalisePath(&recordUUID4, &globalConf) ++ NormalisePath(&recordULID1, &globalConf) ++ NormalisePath(&recordULID2, &globalConf) ++ NormalisePath(&recordULID3, &globalConf) + NormalisePath(&recordID1, &globalConf) + NormalisePath(&recordCust, &globalConf) + +@@ -595,6 +602,10 @@ func TestURLReplacer(t *testing.T) { + t.Error(recordUUID4.Path) + } + ++ assert.Equal(t, "/posts/{ulid}/comments", recordULID1.Path, "Path not altered, is: ", recordULID1.Path) ++ assert.Equal(t, "/posts/{ulid}/comments", recordULID2.Path, "Path not altered, is: ", recordULID2.Path) ++ assert.Equal(t, "/posts/{ulid}/comments", recordULID3.Path, "Path not altered, is: ", recordULID3.Path) ++ + if recordID1.Path != "/widgets/{id}/getParams" { + t.Error("Path not altered, is:") + t.Error(recordID1.Path) +@@ -611,6 +622,7 @@ func BenchmarkURLReplacer(b *testing.B) { + ts := StartTest(func(globalConf *config.Config) { + globalConf.AnalyticsConfig.NormaliseUrls.Enabled = true + globalConf.AnalyticsConfig.NormaliseUrls.NormaliseUUIDs = true ++ globalConf.AnalyticsConfig.NormaliseUrls.NormaliseULIDs = true + globalConf.AnalyticsConfig.NormaliseUrls.NormaliseNumbers = true + globalConf.AnalyticsConfig.NormaliseUrls.Custom = []string{"ihatethisstring"} + }) +@@ -625,6 +637,9 @@ func BenchmarkURLReplacer(b *testing.B) { + recordUUID2 := analytics.AnalyticsRecord{Path: "/CA761232-ED42-11CE-BACD-00AA0057B223/search"} + recordUUID3 := analytics.AnalyticsRecord{Path: "/ca761232-ed42-11ce-BAcd-00aa0057b223/search"} + recordUUID4 := analytics.AnalyticsRecord{Path: "/ca761232-ed42-11ce-BAcd-00aa0057b223/search"} ++ recordULID1 := analytics.AnalyticsRecord{Path: "/posts/01G9HHNKWGBHCQX7VG3JKSZ055/comments"} ++ recordULID2 := analytics.AnalyticsRecord{Path: "/posts/01g9hhnkwgbhcqx7vg3jksz055/comments"} ++ recordULID3 := analytics.AnalyticsRecord{Path: "/posts/01g9HHNKwgbhcqx7vg3JKSZ055/comments"} + recordID1 := analytics.AnalyticsRecord{Path: "/widgets/123456/getParams"} + recordCust := analytics.AnalyticsRecord{Path: "/widgets/123456/getParams/ihatethisstring"} + +@@ -632,6 +647,9 @@ func BenchmarkURLReplacer(b *testing.B) { + NormalisePath(&recordUUID2, &globalConf) + NormalisePath(&recordUUID3, &globalConf) + NormalisePath(&recordUUID4, &globalConf) ++ NormalisePath(&recordULID1, &globalConf) ++ NormalisePath(&recordULID2, &globalConf) ++ NormalisePath(&recordULID3, &globalConf) + NormalisePath(&recordID1, &globalConf) + NormalisePath(&recordCust, &globalConf) + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,8 @@ ++H4sIAAAAAAAAA+3TT4+UMBQAcM58iuds4sABCow4iRv3YOLFGE1G1+umtHWoCy32DwazH34Lo+tk ++E10Pu9kY3y+EEvraPvpK3njZ8QuhRhI9lCLY1vXSBrfb5bmsq2JTVM+rTRkVZVlvNxHUD5bREW8d ++NQCR0dr9Ke6u/n9U/qv+Tlh3wXTfU8Vz297fGnfVf1uWN/UPlQ/1fxbaCIr7S+H3/vP6nzwhjVSk ++obaNGYflEDSCx/EJvFbWGwE7waWFcBmvlFR7SIz46qURHJoJ9tSJb3SCeZxNYzMHZ6yTMMyhZ0C4 ++GInyXQfV2dMSrq7gEGKFGYWBLONU9FrJ7wImYedlP9FO8jArMLlkY8kwuVarbOj8XipLrGHETZc5 ++0+rznNc4D4A3H96/iw+RG8gYrGQ/aOPgi9XqdLnnnaY80YNQyfpv5l6n6SkMRiqXrH++e3G02jpd ++zfnuvALXCqCKdpOTzB72ApKPoTnfvd2JoaMsfGv4reCVUKztqbk86kjjvV7GQDaGzLVX7mUJWdhu ++WN2aYwU5+bHjBDIne6G9g7IqbPzYBwkhhBBCCCGEEEIIIYQQQgghhBBCCD2Ka4bgzfQAKAAA +diff --git 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-000270/tests/test.sh b/tasks/format-code-task-000270/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4817a3dbe44e8c4df09db1bbd0052254de96957 --- /dev/null +++ b/tasks/format-code-task-000270/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' +ci/tests/python-plugins/src/tyk.conf +gateway/analytics_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-000270/tests/test_command.sh b/tasks/format-code-task-000270/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000270/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000277/environment/Dockerfile b/tasks/format-code-task-000277/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c9a9463a854cc87d18ef493c8e5fb94c46d84def --- /dev/null +++ b/tasks/format-code-task-000277/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d3a151db477b7c24c8830c30499c3f4531d93c3402dd4fce30e8ca00fea7d91f diff --git a/tasks/format-code-task-000277/environment/setup/files/blocklist b/tasks/format-code-task-000277/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000277/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000277/environment/setup/setup.sh b/tasks/format-code-task-000277/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000277/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000277/tests/test.patch b/tasks/format-code-task-000277/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c6f748e3399d1ba1bb9ef89eb6653dbb6c2583f2 --- /dev/null +++ b/tasks/format-code-task-000277/tests/test.patch @@ -0,0 +1,102 @@ +diff --git a/test/ERC6551.t.sol b/test/ERC6551.t.sol +index 9c4b259..6e1b018 100644 +--- a/test/ERC6551.t.sol ++++ b/test/ERC6551.t.sol +@@ -361,6 +361,70 @@ contract ERC6551Test is SoladyTest { + assertEq(calls[1].target.balance, 456); + } + ++ ++ function _callIsValidSigner(address account, address signer, bytes memory context) ++ internal ++ view ++ returns (bool ok, bytes4 result) ++ { ++ bytes memory data; ++ (ok, data) = account.staticcall( ++ abi.encodeWithSignature("isValidSigner(address,bytes)", signer, context) ++ ); ++ if (ok && data.length >= 4) { ++ result = abi.decode(data, (bytes4)); ++ } ++ } ++ ++ function testIsValidSignerAcceptsCurrentOwnerWithArbitraryContext() public { ++ _TestTemps memory t = _testTemps(); ++ ++ (bool ok, bytes4 result) = _callIsValidSigner( ++ address(t.account), t.owner, abi.encodePacked(bytes32(uint256(0xabc123)), uint8(7)) ++ ); ++ ++ assertTrue(ok); ++ ++ assertEq(result, bytes4(0x523e3260)); ++ } ++ ++ function testIsValidSignerRejectsMultipleInvalidSigners() public { ++ _TestTemps memory t = _testTemps(); ++ address invalidSigner0 = address(uint160(t.owner) ^ uint160(0x1111111111111111111111111111111111111111)); ++ address invalidSigner1 = address(uint160(t.owner) ^ uint160(0x2222222222222222222222222222222222222222)); ++ ++ (bool ok0, bytes4 result0) = ++ _callIsValidSigner(address(t.account), invalidSigner0, hex"0102030405"); ++ (bool ok1, bytes4 result1) = ++ _callIsValidSigner(address(t.account), invalidSigner1, abi.encode(uint256(0xdeadbeef))); ++ ++ assertTrue(ok0); ++ assertTrue(ok1); ++ ++ assertTrue(result0 != bytes4(0x523e3260)); ++ assertTrue(result1 != bytes4(0x523e3260)); ++ } ++ ++ function testIsValidSignerUsesSignerArgumentInsteadOfCaller() public { ++ _TestTemps memory t = _testTemps(); ++ address invalidSigner = address(uint160(t.owner) ^ uint160(0x3333333333333333333333333333333333333333)); ++ address nonOwnerCaller = address(uint160(t.owner) ^ uint160(0x4444444444444444444444444444444444444444)); ++ ++ vm.prank(nonOwnerCaller); ++ (bool okValid, bytes4 validResult) = ++ _callIsValidSigner(address(t.account), t.owner, abi.encodePacked("valid-signer-parameter")); ++ ++ vm.prank(t.owner); ++ (bool okInvalid, bytes4 invalidResult) = ++ _callIsValidSigner(address(t.account), invalidSigner, abi.encodePacked("invalid-signer-parameter")); ++ ++ assertTrue(okValid); ++ ++ assertEq(validResult, bytes4(0x523e3260)); ++ assertTrue(okInvalid); ++ assertTrue(invalidResult != bytes4(0x523e3260)); ++ } ++ + function testIsValidSignature() public { + _TestTemps memory t = _testTemps(); + (t.signer, t.privateKey) = _randomSigner(); +diff --git 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 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++export PATH="$HOME/.foundry/bin:$PATH" ++ ++ ++NEW_TEST_REGEX='testIsValidSigner(AcceptsCurrentOwnerWithArbitraryContext|RejectsMultipleInvalidSigners|UsesSignerArgumentInsteadOfCaller)' ++ ++case "${1:-}" in ++ base) ++ forge test --match-path test/ERC6551.t.sol --no-match-test "$NEW_TEST_REGEX" -q ++ ;; ++ new) ++ forge test --match-path test/ERC6551.t.sol --match-test "$NEW_TEST_REGEX" -q ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000277/tests/test.sh b/tasks/format-code-task-000277/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6d3a4c6c89bb36a8b7f8e37cc606d89e7eae8ed2 --- /dev/null +++ b/tasks/format-code-task-000277/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/ERC6551.t.sol +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000277/tests/test_command.sh b/tasks/format-code-task-000277/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000277/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-000283/environment/Dockerfile b/tasks/format-code-task-000283/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2f353e613cc4eeee59092779b70301a584fecdd3 --- /dev/null +++ b/tasks/format-code-task-000283/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:29cfdb628a5086a0bffd299ed3f9c5daf0d5e0427e1f9c5981e63fe3b02d4469 diff --git a/tasks/format-code-task-000283/environment/setup/files/blocklist b/tasks/format-code-task-000283/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000283/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000283/environment/setup/setup.sh b/tasks/format-code-task-000283/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000283/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000283/tests/test.patch b/tasks/format-code-task-000283/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..223d6148a5fbd9a08de0fef5f2faac3da7bb8824 --- /dev/null +++ b/tasks/format-code-task-000283/tests/test.patch @@ -0,0 +1,175 @@ +diff --git a/packages/js/tests/shared-admin/components/unsaved-changes-modal.test.js b/packages/js/tests/shared-admin/components/unsaved-changes-modal.test.js +index 677167fee9..b7dec721fa 100644 +--- a/packages/js/tests/shared-admin/components/unsaved-changes-modal.test.js ++++ b/packages/js/tests/shared-admin/components/unsaved-changes-modal.test.js +@@ -1,36 +1,123 @@ +-import { render, screen } from "../../test-utils"; ++import PropTypes from "prop-types"; ++import { render, screen, fireEvent } from "../../test-utils"; + import { UnsavedChangesModal } from "../../../src/shared-admin/components"; + + describe( "UnsavedChangesModal", () => { +- beforeEach( () => { +- render( ); +- } ); ++ describe( "rendered with all props", () => { ++ beforeEach( () => { ++ render( ); ++ } ); + +- it( "should have dismiss and leave page buttons", () => { +- const leaveButton = screen.queryByText( "Yes, leave page" ); +- expect( leaveButton ).toBeInTheDocument(); ++ it( "should have dismiss and leave page buttons", () => { ++ const leaveButton = screen.queryByText( "Yes, leave page" ); ++ expect( leaveButton ).toBeInTheDocument(); + +- expect( screen.queryByText( "Close" ) ).toBeInTheDocument(); ++ expect( screen.queryByText( "Close" ) ).toBeInTheDocument(); + +- const dismissButton = screen.queryByText( "No, continue editing" ); +- expect( dismissButton ).toBeInTheDocument(); +- } ); ++ const dismissButton = screen.queryByText( "No, continue editing" ); ++ expect( dismissButton ).toBeInTheDocument(); ++ } ); ++ ++ it( "should have a title", () => { ++ const title = screen.queryByText( "Unsaved changes" ); ++ expect( title ).toBeInTheDocument(); ++ } ); + +- it( "should have a title", () => { +- const title = screen.queryByText( "Unsaved changes" ); +- expect( title ).toBeInTheDocument(); ++ it( "should have a description", () => { ++ const title = screen.queryByText( "There are unsaved changes in one or more steps of the first-time configuration. Leaving means that those changes will be lost. Are you sure you want to leave this page?" ); ++ expect( title ).toBeInTheDocument(); ++ } ); + } ); + +- it( "should have a description", () => { +- const title = screen.queryByText( "There are unsaved changes in one or more steps of the first-time configuration. Leaving means that those changes will be lost. Are you sure you want to leave this page?" ); +- expect( title ).toBeInTheDocument(); ++ describe( "onDiscard prop being optional", () => { ++ let errorSpy; ++ ++ beforeEach( () => { ++ PropTypes.checkPropTypes.resetWarningCache(); ++ errorSpy = jest.spyOn( console, "error" ).mockImplementation( () => {} ); ++ } ); ++ ++ afterEach( () => { ++ errorSpy.mockRestore(); ++ } ); ++ ++ it( "does not declare onDiscard as a required propType", () => { ++ ++ PropTypes.checkPropTypes( ++ UnsavedChangesModal.propTypes, ++ { ++ isOpen: true, ++ title: "t", ++ description: "d", ++ dismissLabel: "dismiss", ++ discardLabel: "discard", ++ ++ }, ++ "prop", ++ "UnsavedChangesModal" ++ ); ++ const onDiscardWarnings = errorSpy.mock.calls.filter( ++ ( args ) => args.some( ++ ( a ) => typeof a === "string" && a.includes( "onDiscard" ) ++ ) ++ ); ++ expect( onDiscardWarnings ).toHaveLength( 0 ); ++ } ); ++ ++ it( "does not log a missing-required-prop warning for onDiscard when it is omitted", () => { ++ render( ); ++ ++ const onDiscardWarnings = errorSpy.mock.calls.filter( ++ ( args ) => args.some( ++ ( a ) => typeof a === "string" && a.includes( "onDiscard" ) ++ ) ++ ); ++ expect( onDiscardWarnings ).toHaveLength( 0 ); ++ } ); ++ ++ it( "does not throw when the discard button is clicked while onDiscard is omitted", () => { ++ render( ); ++ ++ const discardButton = screen.getByText( "Yes, leave page" ); ++ expect( () => fireEvent.click( discardButton ) ).not.toThrow(); ++ } ); ++ ++ it( "still invokes the provided onDiscard handler when supplied", () => { ++ const onDiscard = jest.fn(); ++ render( ); ++ ++ fireEvent.click( screen.getByText( "Yes, leave page" ) ); ++ expect( onDiscard ).toHaveBeenCalledTimes( 1 ); ++ } ); + } ); + } ); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..12752309c4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd packages/js && npx jest tests/shared-admin/components/unsaved-changes-modal.test.js"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++cd packages/js && npx jest tests/shared-admin/components/unsaved-changes-modal.test.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000283/tests/test.sh b/tasks/format-code-task-000283/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..53677e48e05bcc7409e2ce1dfaba22ed3fb6075e --- /dev/null +++ b/tasks/format-code-task-000283/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/js/tests/shared-admin/components/unsaved-changes-modal.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-000283/tests/test_command.sh b/tasks/format-code-task-000283/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000283/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000284/environment/Dockerfile b/tasks/format-code-task-000284/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..708d13058647895ded2e63cedc01645727c7b8ac --- /dev/null +++ b/tasks/format-code-task-000284/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:97092fafcac1a7e3e8c96e147374296ef432fd062492cf09864fae859cc3046c diff --git a/tasks/format-code-task-000284/environment/setup/files/blocklist b/tasks/format-code-task-000284/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000284/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000284/environment/setup/setup.sh b/tasks/format-code-task-000284/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000284/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000284/tests/test.patch b/tasks/format-code-task-000284/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..22656b317acf40d510063ab23d758cd31d30e69f --- /dev/null +++ b/tasks/format-code-task-000284/tests/test.patch @@ -0,0 +1,188 @@ +diff --git a/test/alias-ref-dedup.test.ts b/test/alias-ref-dedup.test.ts +new file mode 100644 +index 0000000..37f9066 +--- /dev/null ++++ b/test/alias-ref-dedup.test.ts +@@ -0,0 +1,56 @@ ++import {assert} from "chai"; ++import * as TJS from "../typescript-json-schema"; ++import {readFileSync} from "fs"; ++import {resolve} from "path"; ++import * as Ajv from "ajv"; ++ ++const ajv = new Ajv(); ++ ++const base = "test/programs/"; ++ ++function generate(group: string, type: string, settings: any) { ++ const defaults = TJS.getDefaultArgs(); ++ defaults.generateRequired = true; ++ ++ for (let pref in defaults) { ++ if (!(pref in settings)) { ++ settings[pref] = defaults[pref]; ++ } ++ } ++ ++ return TJS.generateSchema(TJS.getProgramFromFiles([resolve(base + group + "/main.ts")]), type, settings); ++} ++ ++function expected(group: string) { ++ return JSON.parse(readFileSync(base + group + "/schema.json", "utf8")); ++} ++ ++describe("type alias reference deduplication", function() { ++ it("emits aliases of named types as $ref instead of duplicating their schema", function() { ++ const group = "type-alias-reference-dedup"; ++ const actual = generate(group, "MyObject", { ++ useTypeAliasRef: true, ++ useRootRef: false ++ }); ++ ++ assert.isObject(actual); ++ assert.deepEqual(actual, expected(group), "The schema is not as expected"); ++ ++ ajv.validateSchema(actual); ++ assert.equal(ajv.errors, null, "The schema is not valid"); ++ }); ++ ++ it("deduplicates recursive alias definitions", function() { ++ const group = "type-alias-recursive-dedup"; ++ const actual = generate(group, "MyObject", { ++ useTypeAliasRef: true, ++ useRootRef: true ++ }); ++ ++ assert.isObject(actual); ++ assert.deepEqual(actual, expected(group), "The schema is not as expected"); ++ ++ ajv.validateSchema(actual); ++ assert.equal(ajv.errors, null, "The schema is not valid"); ++ }); ++}); +diff --git a/test/programs/type-alias-recursive-dedup/main.ts b/test/programs/type-alias-recursive-dedup/main.ts +new file mode 100644 +index 0000000..cc28fce +--- /dev/null ++++ b/test/programs/type-alias-recursive-dedup/main.ts +@@ -0,0 +1,6 @@ ++interface MyObject { ++ alias: MyAlias; ++ self: MyObject; ++} ++ ++type MyAlias = MyObject; +diff --git a/test/programs/type-alias-recursive-dedup/schema.json b/test/programs/type-alias-recursive-dedup/schema.json +new file mode 100644 +index 0000000..01b1b4a +--- /dev/null ++++ b/test/programs/type-alias-recursive-dedup/schema.json +@@ -0,0 +1,24 @@ ++{ ++ "$schema": "http://json-schema.org/draft-04/schema#", ++ "definitions": { ++ "MyAlias": { ++ "$ref": "#/definitions/MyObject" ++ }, ++ "MyObject": { ++ "type": "object", ++ "properties": { ++ "alias": { ++ "$ref": "#/definitions/MyAlias" ++ }, ++ "self": { ++ "$ref": "#/definitions/MyObject" ++ } ++ }, ++ "required": [ ++ "alias", ++ "self" ++ ] ++ } ++ }, ++ "$ref": "#/definitions/MyObject" ++} +diff --git a/test/programs/type-alias-reference-dedup/main.ts b/test/programs/type-alias-reference-dedup/main.ts +new file mode 100644 +index 0000000..822dbea +--- /dev/null ++++ b/test/programs/type-alias-reference-dedup/main.ts +@@ -0,0 +1,11 @@ ++interface MyTarget { ++ value: string; ++ count: number; ++} ++ ++type MyAlias = MyTarget; ++ ++interface MyObject { ++ direct: MyTarget; ++ aliased: MyAlias; ++} +diff --git a/test/programs/type-alias-reference-dedup/schema.json b/test/programs/type-alias-reference-dedup/schema.json +new file mode 100644 +index 0000000..3497f7a +--- /dev/null ++++ b/test/programs/type-alias-reference-dedup/schema.json +@@ -0,0 +1,36 @@ ++{ ++ "$schema": "http://json-schema.org/draft-04/schema#", ++ "definitions": { ++ "MyAlias": { ++ "$ref": "#/definitions/MyTarget" ++ }, ++ "MyTarget": { ++ "type": "object", ++ "properties": { ++ "value": { ++ "type": "string" ++ }, ++ "count": { ++ "type": "number" ++ } ++ }, ++ "required": [ ++ "value", ++ "count" ++ ] ++ } ++ }, ++ "type": "object", ++ "properties": { ++ "direct": { ++ "$ref": "#/definitions/MyTarget" ++ }, ++ "aliased": { ++ "$ref": "#/definitions/MyAlias" ++ } ++ }, ++ "required": [ ++ "direct", ++ "aliased" ++ ] ++} +diff --git 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 ++ ++ ++ ++ ++ ++./node_modules/.bin/tsc -p . ++ ++ ++./node_modules/.bin/mocha -t 5000 --require source-map-support/register test/schema.test.js ++ ++ ++./node_modules/.bin/mocha -t 5000 --require source-map-support/register test/alias-ref-dedup.test.js diff --git a/tasks/format-code-task-000284/tests/test.sh b/tasks/format-code-task-000284/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b98670258f1781dfe7815f5a7147ebbb1ae30352 --- /dev/null +++ b/tasks/format-code-task-000284/tests/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/alias-ref-dedup.test.ts +test/programs/type-alias-recursive-dedup/main.ts +test/programs/type-alias-recursive-dedup/schema.json +test/programs/type-alias-reference-dedup/main.ts +test/programs/type-alias-reference-dedup/schema.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-000284/tests/test_command.sh b/tasks/format-code-task-000284/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000284/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000417/environment/Dockerfile b/tasks/format-code-task-000417/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f30b0d562290541727e8293a0923f428784522ff --- /dev/null +++ b/tasks/format-code-task-000417/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4de1ddaa99ca52d76bcf1bc747d57298d9874fb3339d0d2012ac6036303d6217 diff --git a/tasks/format-code-task-000417/environment/setup/files/blocklist b/tasks/format-code-task-000417/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000417/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000417/environment/setup/setup.sh b/tasks/format-code-task-000417/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000417/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000417/tests/test.patch b/tasks/format-code-task-000417/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..20cfeb1269b3e51ffd23d7248168eeb595691502 --- /dev/null +++ b/tasks/format-code-task-000417/tests/test.patch @@ -0,0 +1,150 @@ +diff --git a/tests/dag_processing/test_job_runner.py b/tests/dag_processing/test_job_runner.py +index 9b8437d77d50a..8112b7222a697 100644 +--- a/tests/dag_processing/test_job_runner.py ++++ b/tests/dag_processing/test_job_runner.py +@@ -26,7 +26,6 @@ + import random + import socket + import sys +-import tempfile + import textwrap + import threading + import time +@@ -639,7 +638,7 @@ def test_scan_stale_dags(self): + manager = DagProcessorJobRunner( + job=Job(), + processor=DagFileProcessorManager( +- dag_directory=str(TEST_DAG_FOLDER), ++ dag_directory="directory", + max_runs=1, + processor_timeout=timedelta(minutes=10), + signal_conn=MagicMock(), +@@ -713,11 +712,11 @@ def test_scan_stale_dags_standalone_mode(self): + """ + Ensure only dags from current dag_directory are updated + """ +- dag_directory = str(TEST_DAG_FOLDER) ++ dag_directory = "directory" + manager = DagProcessorJobRunner( + job=Job(), + processor=DagFileProcessorManager( +- dag_directory=TEST_DAG_FOLDER, ++ dag_directory=dag_directory, + max_runs=1, + processor_timeout=timedelta(minutes=10), + signal_conn=MagicMock(), +@@ -741,7 +740,7 @@ def test_scan_stale_dags_standalone_mode(self): + # Add stale DAG to the DB + other_dag = other_dagbag.get_dag("test_start_date_scheduling") + other_dag.last_parsed_time = timezone.utcnow() +- other_dag.sync_to_db(processor_subdir="/other") ++ other_dag.sync_to_db(processor_subdir="other") + + # Add DAG to the file_parsing_stats + stat = DagFileStat( +@@ -763,69 +762,6 @@ def test_scan_stale_dags_standalone_mode(self): + active_dag_count = session.query(func.count(DagModel.dag_id)).filter(DagModel.is_active).scalar() + assert active_dag_count == 1 + +- @pytest.mark.skip_if_database_isolation_mode # Test is broken in db isolation mode +- def test_scan_stale_dags_when_dag_folder_change(self): +- """ +- Ensure dags from old dag_folder is marked as stale when dag processor +- is running as part of scheduler. +- """ +- +- def get_dag_string(filename) -> str: +- return open(TEST_DAG_FOLDER / filename).read() +- +- with tempfile.TemporaryDirectory() as tmpdir: +- old_dag_home = tempfile.mkdtemp(dir=tmpdir) +- old_dag_file = tempfile.NamedTemporaryFile(dir=old_dag_home, suffix=".py") +- old_dag_file.write(get_dag_string("test_example_bash_operator.py").encode()) +- old_dag_file.flush() +- new_dag_home = tempfile.mkdtemp(dir=tmpdir) +- new_dag_file = tempfile.NamedTemporaryFile(dir=new_dag_home, suffix=".py") +- new_dag_file.write(get_dag_string("test_scheduler_dags.py").encode()) +- new_dag_file.flush() +- +- manager = DagProcessorJobRunner( +- job=Job(), +- processor=DagFileProcessorManager( +- dag_directory=new_dag_home, +- max_runs=1, +- processor_timeout=timedelta(minutes=10), +- signal_conn=MagicMock(), +- dag_ids=[], +- pickle_dags=False, +- async_mode=True, +- ), +- ) +- +- dagbag = DagBag(old_dag_file.name, read_dags_from_db=False) +- other_dagbag = DagBag(new_dag_file.name, read_dags_from_db=False) +- +- with create_session() as session: +- # Add DAG from old dah home to the DB +- dag = dagbag.get_dag("test_example_bash_operator") +- dag.fileloc = old_dag_file.name +- dag.last_parsed_time = timezone.utcnow() +- dag.sync_to_db(processor_subdir=old_dag_home) +- +- # Add DAG from new DAG home to the DB +- other_dag = other_dagbag.get_dag("test_start_date_scheduling") +- other_dag.fileloc = new_dag_file.name +- other_dag.last_parsed_time = timezone.utcnow() +- other_dag.sync_to_db(processor_subdir=new_dag_home) +- +- manager.processor._file_paths = [new_dag_file] +- +- active_dag_count = ( +- session.query(func.count(DagModel.dag_id)).filter(DagModel.is_active).scalar() +- ) +- assert active_dag_count == 2 +- +- manager.processor._scan_stale_dags() +- +- active_dag_count = ( +- session.query(func.count(DagModel.dag_id)).filter(DagModel.is_active).scalar() +- ) +- assert active_dag_count == 1 +- + @mock.patch( + "airflow.dag_processing.processor.DagFileProcessorProcess.waitable_handle", new_callable=PropertyMock + ) +diff --git a/tests/jobs/test_scheduler_job.py b/tests/jobs/test_scheduler_job.py +index c2d5ca1a587b2..372a6ae2d9dfe 100644 +--- a/tests/jobs/test_scheduler_job.py ++++ b/tests/jobs/test_scheduler_job.py +@@ -3581,7 +3581,6 @@ def test_retry_still_in_executor(self, dag_maker): + dag_id="test_retry_still_in_executor", + schedule="@once", + session=session, +- fileloc=os.devnull + "/test_retry_still_in_executor.py", + ): + dag_task1 = BashOperator( + task_id="test_retry_handling_op", +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,8 @@ ++H4sIAAAAAAAAA+3TW0+DMBgGYK75FTVecxqCiQkXODGabCNuLOpVw6G6KlDsYbp/b5mHmRn1RmOM ++33NBS/s2LfmKXShaV5i0S8f4Ka62HwTrVttu130vGHjefjgIQ99wPS/0BgYKfuxEbyghc46QwRmT ++n+W+mv+j7E39JRESl6xp8rayxeL79viq/qG/qX/g65y3Fw58A7nfd4SP/fP67+44BW2dIhcLs6zQ +++hIUpDJNwRQvyeuAYy/7O9Jn81LSZS6JaZKHjnGJ4tPp8Sg9xyfpOIkc2XROTvlVze5xv3g7hYfp ++NMF4PjnNcJbMMjxOj5Io44q8Sx7FWXwYz3R6djbC8Wh4kowv9frJJBJ3NZXkwNG2N3x5savig72T ++i2Q4z9JpNCN3irSS5nXyQEolGTeb24pyZHXo/YeY3UouWIusBumeHkH9QzhVfo07zkoiBG2vn/6j ++G1ZgrtqWcLtbPef0mHiaFeWCVKomvM/1AWuJLEvShjAlI991zd++FwAAAAAAAAAAAAAAAAAAAAAA ++AAAA4G94BOY2PicAKAAA +diff --git 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-000417/tests/test.sh b/tasks/format-code-task-000417/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..672145469a618e380b06ffbb45a7a270bd56e614 --- /dev/null +++ b/tasks/format-code-task-000417/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/dag_processing/test_job_runner.py +tests/jobs/test_scheduler_job.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-000417/tests/test_command.sh b/tasks/format-code-task-000417/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000417/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000419/environment/Dockerfile b/tasks/format-code-task-000419/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bb0beb58af1d4c10ad8ac9acd0c9f68e8b5d31fd --- /dev/null +++ b/tasks/format-code-task-000419/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9b7f677bef3a12de42de0e07b3f9209bd9b9931406bf9f0220b34f1b56eff25d diff --git a/tasks/format-code-task-000419/environment/setup/files/blocklist b/tasks/format-code-task-000419/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000419/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000419/environment/setup/setup.sh b/tasks/format-code-task-000419/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000419/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000419/tests/test.patch b/tasks/format-code-task-000419/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d5a7e35c789b26cfe888d55b7819ab327b60cc7a --- /dev/null +++ b/tasks/format-code-task-000419/tests/test.patch @@ -0,0 +1,52 @@ +diff --git a/tests/contrib/operators/test_gcp_container_operator.py b/tests/contrib/operators/test_gcp_container_operator.py +index 8fe322dbbb947..e3e41b46415f5 100644 +--- a/tests/contrib/operators/test_gcp_container_operator.py ++++ b/tests/contrib/operators/test_gcp_container_operator.py +@@ -55,7 +55,7 @@ def test_create_execute(self, mock_hook): + + operator.execute(None) + mock_hook.return_value.create_cluster.assert_called_once_with( +- cluster=PROJECT_BODY_CREATE) ++ cluster=PROJECT_BODY_CREATE, project_id=TEST_GCP_PROJECT_ID) + + @mock.patch('airflow.contrib.operators.gcp_container_operator.GKEClusterHook') + def test_create_execute_error_body(self, mock_hook): +@@ -97,7 +97,7 @@ def test_delete_execute(self, mock_hook): + + operator.execute(None) + mock_hook.return_value.delete_cluster.assert_called_once_with( +- name=CLUSTER_NAME) ++ name=CLUSTER_NAME, project_id=TEST_GCP_PROJECT_ID) + + @mock.patch('airflow.contrib.operators.gcp_container_operator.GKEClusterHook') + def test_delete_execute_error_project_id(self, mock_hook): +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+2VbWvbMBDH81qfQssGsSGT47RJYdAXo+yJtTSshb0YQyi2kogplpHktvn2O0n2 ++smTZIyvbmH4vLOXudLr7S3bIvBGypLy6yXr3xQg4mUz8COyPfp5Pxvl4dHR0NM17ozyfnEx6eHJv ++FX1GYyzTGPe0UvZbcd/z/6OQ7flbbiwt1HrNqpKY1e/b4zvnP55Optvzz8GeH0/z4x4e/b4Svs5/ ++fv4PH2RzUWVzZlaoKLG/BHNeIsTvaqUtfvrqzfPzy7f05eXFs9PMruuMCb2Q6rYLmD29fnnaz1Rt ++Ow+9cbcJsj555Jx9hOqNXakKPy5wH4m1X2Y2ZogLJSUvrFDV7g/C5gVaKI0rtuZYVLgUOtnzp08Q ++BsQCV8r6QOJO0ppbYVfJgA5SDPfYO1fMMGt3Mgz9ijaHw3B7OGaIl1+6XAFtihShh3im+eNa1Y1k ++lmMnocFrVTYSfihcaw6K2GDPKBWVsJSSeoMXWq2xbqpKVMtOGLupuUE+lkIOfBos5MLnu4Z5MvDe ++QbqNIpTWzK4ohfB3g+4QsxD3fi+u+MCW3Ie2iRAcBgn1mnet7b3buFvmWjxXrAwWAt8I2A0kq5mG ++huWmqz0MUsxJY4VEpuYFpNm1EmelrnO6EJJTqQrmNG27apMPhnivjSw4QDZoPMxbffbyh0bCDm6v ++xD1SXwyR0ATXhN9BCSEu2aZKD+jQlePk2EZ+JmirxY73k1qrcBnau+BLGP+kIHRZ1PBRriwTFddU ++1RwkV/qgPpXVYp51ISb7xvog44/rNw4Cjg8p6KXrrkADl9vti0IgpO8s5Boe596aQLZGwKuy571y ++xs5JWFk6o0naPd3gDc+hNDc5Y8bvTl4otZT8TKqmnMErCF+O9VnX8mXbsVuQ/kLq189mqtxLgtw7 ++u9/cnXXeN96T3HA9V0bYzSkop7lppLsjYRmBIfF1hBvH74RNRu5LFgLJLTNXTVFwYxaNTFLMpeE4 ++T1Ef/el/i0gkEolEIpFIJBKJRCKRSCQSiUQikUgkEon8rXwE7Ew4OgAoAAA= +diff --git 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-000419/tests/test.sh b/tasks/format-code-task-000419/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..eafce73828f74e6ba71e4f0620936ced36260e68 --- /dev/null +++ b/tasks/format-code-task-000419/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/operators/test_gcp_container_operator.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-000419/tests/test_command.sh b/tasks/format-code-task-000419/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000419/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000421/environment/Dockerfile b/tasks/format-code-task-000421/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..616f2de8caf2622fa5c0ed0958d4717dde80c7b4 --- /dev/null +++ b/tasks/format-code-task-000421/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:032d9905c4b43ccf37ea4eb9404d41b8913c1657bef048a6232c0b69d96ece74 diff --git a/tasks/format-code-task-000421/environment/setup/files/blocklist b/tasks/format-code-task-000421/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000421/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000421/environment/setup/setup.sh b/tasks/format-code-task-000421/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000421/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000421/tests/test.patch b/tasks/format-code-task-000421/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2ab9565f938df616679c7956eca8bfaa8b9c27a9 --- /dev/null +++ b/tasks/format-code-task-000421/tests/test.patch @@ -0,0 +1,346 @@ +diff --git a/usercase-test-coderl/test_memory_recall.py b/usercase-test-coderl/test_memory_recall.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_memory_recall.py +@@ -0,0 +1,316 @@ ++from __future__ import annotations ++ ++import sys ++from pathlib import Path ++ ++import numpy as np ++import pytest ++ ++sys.path.insert(0, "/workspace/repo") ++ ++from Agent_module.carbon_data import LambdaEmbedder, MemoryHit, MemoryItem, create ++ ++ ++VECTORS = { ++ "loves vim": [1.0, 0.0, 0.0], ++ "prefers emacs": [0.55, 0.83, 0.0], ++ "likes nano": [0.10, 0.0, 0.99], ++ "vim editor": [0.95, 0.05, 0.0], ++ "a": [1.0, 0.0, 0.0], ++ "b": [0.0, 1.0, 0.0], ++ "c": [0.0, 0.0, 1.0], ++ "doc-text": [1.0, 0.0, 0.0], ++ "mem-text": [1.0, 0.0, 0.0], ++ "old": [1.0, 0.0, 0.0], ++ "fresh": [0.4, 0.0, 0.0], ++ "q": [1.0, 0.0, 0.0], ++ "dot-high": [2.0, 0.0, 0.0], ++ "dot-low": [0.5, 0.0, 0.0], ++ "near": [0.8, 0.0, 0.0], ++ "far": [-1.0, 0.0, 0.0], ++} ++ ++ ++def fixed_embedder(): ++ def encode(texts): ++ out = np.zeros((len(texts), 3), dtype=np.float32) ++ for i, text in enumerate(texts): ++ out[i] = np.asarray(VECTORS[text], dtype=np.float32) ++ return out ++ ++ return LambdaEmbedder(encode, model="accept-model", dim=3) ++ ++ ++def hit_contents(hits): ++ return [hit.memory.content for hit in hits] ++ ++ ++def hit_scores(hits): ++ return [float(hit.score) for hit in hits] ++ ++ ++def assert_memory_hit_shape(hits): ++ ++ assert all(isinstance(hit, MemoryHit) for hit in hits) ++ assert all(isinstance(hit.memory, MemoryItem) for hit in hits) ++ assert all(isinstance(hit.score, (int, float, np.floating)) for hit in hits) ++ ++ ++@pytest.fixture ++def store(tmp_path: Path): ++ s = create(tmp_path / "case.carbondata") ++ try: ++ yield s ++ finally: ++ s.close() ++ ++ ++def test_semantic_recall_returns_ranked_memory_hits(store): ++ ++ ++ ++ ++ emb = fixed_embedder() ++ ++ store.remember("loves vim", embedder=emb, id="mem-loves-vim") ++ store.remember("prefers emacs", embedder=emb, id="mem-prefers-emacs") ++ store.remember("likes nano", embedder=emb, id="mem-likes-nano") ++ ++ hits = store.recall("vim editor", top_k=3, embedder=emb) ++ ++ ++ assert hit_contents(hits) == ["loves vim", "prefers emacs", "likes nano"] ++ assert hit_scores(hits) == sorted(hit_scores(hits), reverse=True) ++ assert_memory_hit_shape(hits) ++ ++ ++def test_filters_compose_with_and_and_empty_match_returns_empty(store): ++ ++ ++ ++ ++ emb = fixed_embedder() ++ store.remember( ++ "a", ++ session_id="s1", ++ actor="bot", ++ namespace="alpha", ++ salience=0.9, ++ embedder=emb, ++ id="a-id", ++ ) ++ store.remember( ++ "b", ++ session_id="s1", ++ actor="bot", ++ namespace="beta", ++ salience=0.8, ++ embedder=emb, ++ id="b-id", ++ ) ++ store.remember( ++ "c", ++ session_id="s2", ++ actor="human", ++ namespace="alpha", ++ salience=0.4, ++ embedder=emb, ++ id="c-id", ++ ) ++ ++ ++ session_hits = store.recall("a", session_id="s1", top_k=5, embedder=emb) ++ assert hit_contents(session_hits)[:1] == ["a"] ++ assert all(hit.memory.session_id == "s1" for hit in session_hits) ++ assert_memory_hit_shape(session_hits) ++ ++ actor_hits = store.recall("a", actor="bot", top_k=5, embedder=emb) ++ assert hit_contents(actor_hits)[:1] == ["a"] ++ assert all(hit.memory.actor == "bot" for hit in actor_hits) ++ assert_memory_hit_shape(actor_hits) ++ ++ namespace_hits = store.recall("a", namespace="alpha", top_k=5, embedder=emb) ++ assert hit_contents(namespace_hits)[:1] == ["a"] ++ assert all(hit.memory.namespace == "alpha" for hit in namespace_hits) ++ assert_memory_hit_shape(namespace_hits) ++ ++ salience_hits = store.recall("a", min_salience=0.5, top_k=5, embedder=emb) ++ assert hit_contents(salience_hits)[:1] == ["a"] ++ assert all(hit.memory.salience >= 0.5 for hit in salience_hits) ++ assert_memory_hit_shape(salience_hits) ++ ++ and_hits = store.recall( ++ "a", ++ session_id="s1", ++ actor="bot", ++ namespace="alpha", ++ min_salience=0.85, ++ top_k=5, ++ embedder=emb, ++ ) ++ assert hit_contents(and_hits) == ["a"] ++ assert all(hit.memory.session_id == "s1" for hit in and_hits) ++ assert all(hit.memory.actor == "bot" for hit in and_hits) ++ assert all(hit.memory.namespace == "alpha" for hit in and_hits) ++ assert all(hit.memory.salience >= 0.85 for hit in and_hits) ++ assert_memory_hit_shape(and_hits) ++ assert store.recall("a", session_id="missing", top_k=5, embedder=emb) == [] ++ ++ ++def test_recall_ignores_embedded_non_memory_entities(store): ++ ++ ++ ++ ++ emb = fixed_embedder() ++ ++ store.put_entity(id="doc1", kind="document", content="doc-text") ++ store.add_chunks("doc1", ["doc-text"]) ++ store.embed_chunks(emb, entity_id="doc1") ++ store.remember("mem-text", embedder=emb, id="memory1") ++ ++ ++ hits = store.recall("doc-text", top_k=5, embedder=emb) ++ assert hit_contents(hits) == ["mem-text"] ++ assert_memory_hit_shape(hits) ++ ++ ++def test_expired_memories_are_hidden_until_include_expired_is_true(store): ++ ++ ++ ++ ++ emb = fixed_embedder() ++ ++ store.remember("old", expires_at=100.0, embedder=emb, id="old-id") ++ store.remember("fresh", embedder=emb, id="fresh-id") ++ ++ ++ default_hits = store.recall("old", top_k=5, embedder=emb) ++ assert hit_contents(default_hits) == ["fresh"] ++ assert_memory_hit_shape(default_hits) ++ ++ with_expired_hits = store.recall("old", top_k=5, embedder=emb, include_expired=True) ++ assert set(hit_contents(with_expired_hits)) == {"old", "fresh"} ++ assert_memory_hit_shape(with_expired_hits) ++ ++ ++def test_vector_query_uses_model_without_embedder_and_dot_metric(store): ++ ++ ++ ++ ++ emb = fixed_embedder() ++ ++ store.remember("dot-high", embedder=emb, id="dot-high-id") ++ store.remember("dot-low", embedder=emb, id="dot-low-id") ++ ++ hits = store.recall( ++ np.array([1.0, 0.0, 0.0], dtype=np.float32), ++ model="accept-model", ++ top_k=5, ++ metric="dot", ++ ) ++ ++ ++ assert hit_contents(hits) == ["dot-high", "dot-low"] ++ assert hit_scores(hits) == pytest.approx([2.0, 0.5]) ++ assert_memory_hit_shape(hits) ++ ++ ++def test_l2_metric_returns_negative_distance_ranking(store): ++ ++ ++ ++ ++ emb = fixed_embedder() ++ ++ store.remember("near", embedder=emb, id="near-id") ++ store.remember("far", embedder=emb, id="far-id") ++ ++ hits = store.recall( ++ np.array([1.0, 0.0, 0.0], dtype=np.float32), ++ model="accept-model", ++ top_k=5, ++ metric="l2", ++ ) ++ ++ ++ assert hit_contents(hits) == ["near", "far"] ++ assert hit_scores(hits) == pytest.approx([-0.2, -2.0]) ++ assert_memory_hit_shape(hits) ++ ++ ++def test_string_query_requires_embedder(store): ++ ++ ++ ++ ++ ++ with pytest.raises(Exception): ++ store.recall("q") ++ ++ ++ with pytest.raises(Exception): ++ store.recall("q", model="accept-model") ++ ++ ++def test_no_matching_memories_returns_empty_list(store): ++ ++ ++ ++ ++ ++ emb = fixed_embedder() ++ assert store.recall("q", top_k=5, embedder=emb) == [] ++ ++ ++def test_top_k_limits_ranked_memory_hits(store): ++ ++ ++ ++ ++ ++ emb = fixed_embedder() ++ store.remember("a", embedder=emb, id="a-id") ++ store.remember("b", embedder=emb, id="b-id") ++ ++ hits = store.recall("a", top_k=1, embedder=emb) ++ ++ assert hit_contents(hits) == ["a"] ++ assert_memory_hit_shape(hits) ++ ++ ++def test_vector_query_with_model_uses_cosine_without_embedder(store): ++ ++ ++ ++ ++ ++ emb = fixed_embedder() ++ store.remember("a", embedder=emb, id="a-id") ++ store.remember("b", embedder=emb, id="b-id") ++ ++ hits = store.recall( ++ np.array([1.0, 0.0, 0.0], dtype=np.float32), ++ model="accept-model", ++ top_k=5, ++ ) ++ ++ ++ assert hit_contents(hits)[:1] == ["a"] ++ assert hit_scores(hits) == sorted(hit_scores(hits), reverse=True) ++ assert_memory_hit_shape(hits) ++ ++ ++def test_filters_compose_to_empty_when_any_clause_rejects(store): ++ ++ ++ ++ ++ ++ emb = fixed_embedder() ++ store.remember("a", session_id="s1", actor="bot", embedder=emb, id="a-id") ++ store.remember("b", session_id="s2", actor="human", embedder=emb, id="b-id") ++ ++ assert store.recall("a", session_id="s1", actor="human", top_k=5, embedder=emb) == [] +diff --git 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 PYTHONNOUSERSITE=1 ++export PIP_NO_INDEX=1 ++ ++exec python3 -m pytest /workspace/repo/usercase-test-coderl/test_memory_recall.py -v diff --git a/tasks/format-code-task-000421/tests/test.sh b/tasks/format-code-task-000421/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..71f08eb9404ceeff39f657e6463c7cde8aaeb5e3 --- /dev/null +++ b/tasks/format-code-task-000421/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_memory_recall.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-000421/tests/test_command.sh b/tasks/format-code-task-000421/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000421/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-000426/environment/Dockerfile b/tasks/format-code-task-000426/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4d4128b32d7d1eb431d88864be0bccbff29b926b --- /dev/null +++ b/tasks/format-code-task-000426/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a0b524514effdd02bd7b92f204be874b8fdd2ea921d48308d22530291a464379 diff --git a/tasks/format-code-task-000426/environment/setup/files/blocklist b/tasks/format-code-task-000426/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000426/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000426/environment/setup/setup.sh b/tasks/format-code-task-000426/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000426/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000426/tests/test.patch b/tasks/format-code-task-000426/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b7657079033a72c4852c30379b3dfd4300ba45b0 --- /dev/null +++ b/tasks/format-code-task-000426/tests/test.patch @@ -0,0 +1,387 @@ +diff --git a/usercase-test-coderl/stats_reducer.test.js b/usercase-test-coderl/stats_reducer.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/stats_reducer.test.js +@@ -0,0 +1,351 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++'use strict'; ++ ++const assert = require('assert'); ++const os = require('os'); ++const path = require('path'); ++ ++const PouchDB = require('../packages/node_modules/pouchdb-node'); ++ ++const TMP_ROOT = os.tmpdir(); ++const DB_PREFIX = 'coderl-pouchdb-stats-'; ++let dbCounter = 0; ++ ++function nextDbName(label) { ++ dbCounter += 1; ++ return path.join(TMP_ROOT, `${DB_PREFIX}${process.pid}-${Date.now()}-${dbCounter}-${label}`); ++} ++ ++async function destroyByName(name) { ++ try { ++ await new PouchDB(name).destroy(); ++ } catch (error) { ++ ++ } ++} ++ ++async function withDb(label, fn) { ++ const name = nextDbName(label); ++ const db = new PouchDB(name); ++ try { ++ await fn(db, name); ++ } finally { ++ try { ++ await db.close(); ++ } catch (error) { ++ ++ } ++ await destroyByName(name); ++ } ++} ++ ++const EMPTY_STATS_VALUE = {sum: 0, min: null, max: null, count: 0, sumsqr: 0}; ++ ++function assertGroupedRows(result, expectedByKey) { ++ assert.ok(result && Array.isArray(result.rows)); ++ assert.strictEqual(result.rows.length, expectedByKey.length); ++ for (const [key, expectedValue] of expectedByKey) { ++ const row = result.rows.find((candidate) => candidate.key === key); ++ assert.ok(row, `expected grouped row for key ${key}`); ++ assert.deepStrictEqual(row.value, expectedValue); ++ } ++} ++ ++async function assertInvalidStatsQuery(db, docs) { ++ await db.bulkDocs({docs}); ++ let rejected = false; ++ try { ++ await db.query({ ++ map: function (doc) { ++ emit('bad', doc.v); ++ }, ++ reduce: '_stats' ++ }, {reduce: true, group_level: 999}); ++ } catch (error) { ++ rejected = true; ++ } ++ ++ assert.strictEqual(rejected, true); ++} ++ ++describe('usercase _stats reducer acceptance', function () { ++ this.timeout(60000); ++ ++ it('groups scalar number emits and updates after later writes', async function () { ++ ++ ++ ++ ++ await withDb('scalar', async (db) => { ++ await db.bulkDocs({ ++ docs: [ ++ {_id: 'a', val: 'bar'}, ++ {_id: 'b', val: 'bar'}, ++ {_id: 'c', val: 'baz'} ++ ] ++ }); ++ ++ const first = await db.query({ ++ map: function (doc) { ++ emit(doc.val, 1); ++ }, ++ reduce: '_stats' ++ }, {reduce: true, group_level: 999}); ++ ++ assertGroupedRows(first, [ ++ ['bar', {sum: 2, min: 1, max: 1, count: 2, sumsqr: 2}], ++ ['baz', {sum: 1, min: 1, max: 1, count: 1, sumsqr: 1}] ++ ]); ++ ++ await db.bulkDocs({docs: [{_id: 'd', val: 'bar'}]}); ++ const second = await db.query({ ++ map: function (doc) { ++ emit(doc.val, 1); ++ }, ++ reduce: '_stats' ++ }, {reduce: true, group_level: 999}); ++ ++ assertGroupedRows(second, [ ++ ['bar', {sum: 3, min: 1, max: 1, count: 3, sumsqr: 3}], ++ ['baz', {sum: 1, min: 1, max: 1, count: 1, sumsqr: 1}] ++ ]); ++ }); ++ }); ++ ++ it('reduces array emits position by position', async function () { ++ ++ ++ ++ ++ await withDb('arrays', async (db) => { ++ await db.bulkDocs({ ++ docs: [ ++ {_id: 'one', nums: [1, 2, 3]}, ++ {_id: 'two', nums: [4, 5, 6]}, ++ {_id: 'three', nums: [7, 8, 9]} ++ ] ++ }); ++ const result = await db.query({ ++ map: function (doc) { ++ emit('all', doc.nums); ++ }, ++ reduce: '_stats' ++ }, {reduce: true, group_level: 999}); ++ ++ ++ assertGroupedRows(result, [ ++ ['all', [ ++ {sum: 12, min: 1, max: 7, count: 3, sumsqr: 66}, ++ {sum: 15, min: 2, max: 8, count: 3, sumsqr: 93}, ++ {sum: 18, min: 3, max: 9, count: 3, sumsqr: 126} ++ ]] ++ ]); ++ }); ++ }); ++ ++ it('returns the public empty result when no values are emitted', async function () { ++ ++ ++ ++ ++ await withDb('empty', async (db) => { ++ const result = await db.query({ ++ map: function (doc) { ++ emit(doc.val, 1); ++ }, ++ reduce: '_stats' ++ }, {reduce: true}); ++ ++ ++ assert.ok(result && Array.isArray(result.rows)); ++ if (result.rows.length === 0) { ++ return; ++ } ++ assert.strictEqual(result.rows.length, 1); ++ assert.deepStrictEqual(result.rows[0].value, EMPTY_STATS_VALUE); ++ }); ++ }); ++ ++ it('rejects string emitted values', async function () { ++ ++ ++ ++ ++ await withDb('string-invalid', async (db) => { ++ await assertInvalidStatsQuery( ++ db, ++ [{_id: 'a', v: 'not-a-number'}] ++ ); ++ }); ++ }); ++ ++ it('rejects mixed scalar and array emitted values', async function () { ++ ++ ++ ++ ++ await withDb('mixed-invalid', async (db) => { ++ await assertInvalidStatsQuery( ++ db, ++ [{_id: 'a', v: 1}, {_id: 'b', v: [2]}] ++ ); ++ }); ++ }); ++ ++ it('rejects arrays with inconsistent lengths', async function () { ++ ++ ++ ++ ++ await withDb('length-invalid', async (db) => { ++ await assertInvalidStatsQuery( ++ db, ++ [{_id: 'a', v: [1, 2]}, {_id: 'b', v: [3]}] ++ ); ++ }); ++ }); ++ ++ it('supports _stats queries before database cleanup', async function () { ++ ++ ++ ++ ++ const name = nextDbName('closed'); ++ const db = new PouchDB(name); ++ try { ++ await db.bulkDocs({docs: [{_id: 'a', val: 'bar'}]}); ++ const result = await db.query({ ++ map: function (doc) { ++ emit(doc.val, 1); ++ }, ++ reduce: '_stats' ++ }, {reduce: true, group_level: 999}); ++ ++ assertGroupedRows(result, [ ++ ['bar', {sum: 1, min: 1, max: 1, count: 1, sumsqr: 1}] ++ ]); ++ await db.close(); ++ } finally { ++ await destroyByName(name); ++ } ++ }); ++ ++ it('allows repeated public _stats query calls', async function () { ++ ++ ++ ++ ++ await withDb('repeated-query', async (db) => { ++ await db.bulkDocs({docs: [{_id: 'a', val: 'bar'}]}); ++ const firstResult = await db.query({ ++ map: function (doc) { ++ emit(doc.val, 1); ++ }, ++ reduce: '_stats' ++ }, {reduce: true, group_level: 999}); ++ ++ assertGroupedRows(firstResult, [ ++ ['bar', {sum: 1, min: 1, max: 1, count: 1, sumsqr: 1}] ++ ]); ++ ++ const secondResult = await db.query({ ++ map: function (doc) { ++ emit(doc.val, 1); ++ }, ++ reduce: '_stats' ++ }, {reduce: true, group_level: 999}); ++ ++ assertGroupedRows(secondResult, [ ++ ['bar', {sum: 1, min: 1, max: 1, count: 1, sumsqr: 1}] ++ ]); ++ }); ++ }); ++ ++ it('keeps _stats view state independent across database instances', async function () { ++ ++ ++ ++ ++ const nameA = nextDbName('independent-a'); ++ const nameB = nextDbName('independent-b'); ++ const a = new PouchDB(nameA); ++ const b = new PouchDB(nameB); ++ try { ++ await a.bulkDocs({ ++ docs: [ ++ {_id: 'a1', val: 'bar'}, ++ {_id: 'a2', val: 'bar'}, ++ {_id: 'a3', val: 'baz'} ++ ] ++ }); ++ await b.bulkDocs({docs: [{_id: 'b1', val: 'baz'}]}); ++ ++ const mapReduce = { ++ map: function (doc) { ++ emit(doc.val, 1); ++ }, ++ reduce: '_stats' ++ }; ++ const resultA = await a.query(mapReduce, {reduce: true, group_level: 999}); ++ const resultB = await b.query(mapReduce, {reduce: true, group_level: 999}); ++ ++ ++ assertGroupedRows(resultA, [ ++ ['bar', {sum: 2, min: 1, max: 1, count: 2, sumsqr: 2}], ++ ['baz', {sum: 1, min: 1, max: 1, count: 1, sumsqr: 1}] ++ ]); ++ ++ assertGroupedRows(resultB, [ ++ ['baz', {sum: 1, min: 1, max: 1, count: 1, sumsqr: 1}] ++ ]); ++ } finally { ++ try { ++ await a.close(); ++ } catch (error) { ++ ++ } ++ try { ++ await b.close(); ++ } catch (error) { ++ ++ } ++ await destroyByName(nameA); ++ await destroyByName(nameB); ++ } ++ }); ++ ++ it('supports repeated _stats queries across database cleanup cycles', async function () { ++ ++ ++ ++ ++ const cleanupPrefix = `${DB_PREFIX}${process.pid}-cleanup-`; ++ ++ ++ for (let i = 0; i < 3; i += 1) { ++ const name = path.join(TMP_ROOT, `${cleanupPrefix}${i}`); ++ const db = new PouchDB(name); ++ await db.bulkDocs({docs: [{_id: 'doc', val: 'bar'}]}); ++ const result = await db.query({ ++ map: function (doc) { ++ emit(doc.val, 1); ++ }, ++ reduce: '_stats' ++ }, {reduce: true, group_level: 999}); ++ ++ assertGroupedRows(result, [ ++ ['bar', {sum: 1, min: 1, max: 1, count: 1, sumsqr: 1}] ++ ]); ++ await db.destroy(); ++ } ++ }); ++}); +diff --git 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 ++ ++ ++ ++ ++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_audit=false ++export npm_config_fund=false ++export npm_config_update_notifier=false ++ ++for module in mocha rollup rollup-plugin-node-resolve rollup-plugin-replace leveldown; do ++ node -e "require(process.argv[1])" "$module" >/dev/null ++done ++ ++node ./bin/build-module.js packages/node_modules/pouchdb-node >/dev/null ++ ++exec node --expose-gc ./node_modules/.bin/mocha --no-config --no-package --exit /workspace/repo/usercase-test-coderl/stats_reducer.test.js diff --git a/tasks/format-code-task-000426/tests/test.sh b/tasks/format-code-task-000426/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b03ae4a4759bf60eb8a9da3c23bcff712429c9aa --- /dev/null +++ b/tasks/format-code-task-000426/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/stats_reducer.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-000426/tests/test_command.sh b/tasks/format-code-task-000426/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000426/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-000428/tests/test_command.sh b/tasks/format-code-task-000428/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000428/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000444/environment/Dockerfile b/tasks/format-code-task-000444/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..299960ffb3e42de525bb2520966eea0cf132baec --- /dev/null +++ b/tasks/format-code-task-000444/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ec78a7603e31c2bf6ea67ce2a1a269dadbe68143ba3af09af29b19c3941f752f diff --git a/tasks/format-code-task-000444/environment/setup/files/blocklist b/tasks/format-code-task-000444/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000444/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000444/environment/setup/setup.sh b/tasks/format-code-task-000444/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000444/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000444/tests/test.patch b/tasks/format-code-task-000444/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..83fe056176b4d5ec898a1e0d995ca9191c5d1312 --- /dev/null +++ b/tasks/format-code-task-000444/tests/test.patch @@ -0,0 +1,99 @@ +diff --git a/tests/common.py b/tests/common.py +index 7ebbfc3b..54068c54 100644 +--- a/tests/common.py ++++ b/tests/common.py +@@ -5,6 +5,8 @@ + from transformers import ( + AutoConfig, + CLIPVisionConfig, ++ GPT2Config, ++ GPT2LMHeadModel, + LlamaConfig, + LlamaForCausalLM, + LlavaConfig, +@@ -81,6 +83,20 @@ def make_picollama(path: str, vocab_size: int = 64): + return str(path) + + ++def make_gpt2size(path: str): ++ cfg = GPT2Config( ++ n_ctx=1024, ++ n_embd=768, ++ n_head=12, ++ n_layer=12, ++ n_positions=1024, ++ vocab_size=50257, ++ ) ++ model = GPT2LMHeadModel(cfg) ++ model.save_pretrained(path, safe_serialization=True) ++ return str(path) ++ ++ + def make_picoLlaVa(path: str): + # Define minimal vision configuration + vision_config = CLIPVisionConfig( +diff --git a/tests/test_basic_merges.py b/tests/test_basic_merges.py +index 1ddeabcd..8aac2322 100644 +--- a/tests/test_basic_merges.py ++++ b/tests/test_basic_merges.py +@@ -1,7 +1,7 @@ + from typing import Dict, Optional + + import pytest +-from common import make_picollama, make_picoLlaVa, run_and_check_merge ++from common import make_gpt2size, make_picollama, make_picoLlaVa, run_and_check_merge + from transformers import AutoConfig + + from mergekit.config import ( +@@ -44,21 +44,26 @@ def vlm_c(tmp_path_factory): + return make_picoLlaVa(tmp_path_factory.mktemp("vlm_c")) + + ++@pytest.fixture(scope="session") ++def gpt2_like(tmp_path_factory): ++ return make_gpt2size(tmp_path_factory.mktemp("gpt2_like")) ++ ++ + class TestBasicMerges: +- def test_gpt2_copy(self): ++ def test_gpt2_copy(self, gpt2_like): + config = MergeConfiguration( + merge_method="passthrough", +- models=[InputModelDefinition(model="gpt2")], ++ models=[InputModelDefinition(model=gpt2_like)], + dtype="bfloat16", + ) + run_and_check_merge(config) + +- def test_gpt2_stack(self): ++ def test_gpt2_stack(self, gpt2_like): + config = MergeConfiguration( + merge_method="passthrough", + slices=[ + OutputSliceDefinition( +- sources=[InputSliceDefinition(model="gpt2", layer_range=[0, 12])] ++ sources=[InputSliceDefinition(model=gpt2_like, layer_range=[0, 12])] + ) + ] + * 2, +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+3S0QrCIBQG4F3vKXyB3M5Ke5zhnLRB05hu0NvnRqwIqpsiqv+70CMKKv/h1dDu ++69LYMUveJY+2QsxzdDvPNYmCCiIp8yLJicRWJEy87UVXBh9Uz1jSOxcenXu2/6X4Jf9gfCi16zpl ++a+6b193xLH8Scsl/LSnmv5EU889f94T7/jx/XbM5+MrUqXdDr82yzvg4tUXV2kzp0I4qmPRwDI2z ++bNWxWMVjbBp8NnWNs/xwPK/nVqqUb3XZmX5n/LS1GtNP/xYAAAAAAAAAAAAAAAAAAAAA4LecALnc ++b0gAKAAA +diff --git 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-000444/tests/test.sh b/tasks/format-code-task-000444/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..925d3e5dd8ec8ecc435a96012ee1d1f1aede538b --- /dev/null +++ b/tasks/format-code-task-000444/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/common.py +tests/test_basic_merges.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-000444/tests/test_command.sh b/tasks/format-code-task-000444/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000444/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000472/environment/Dockerfile b/tasks/format-code-task-000472/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a09bb5526c62a4a1e485068b5ccec4bc66712fed --- /dev/null +++ b/tasks/format-code-task-000472/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3e3d6dd9270e7bf56f465b5857bf6ae844bb1573904b8a050ea6734d82977033 diff --git a/tasks/format-code-task-000472/environment/setup/files/blocklist b/tasks/format-code-task-000472/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000472/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000472/environment/setup/setup.sh b/tasks/format-code-task-000472/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000472/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000472/tests/test.patch b/tasks/format-code-task-000472/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..82f94bf5310b47a1519e56d144625f1855678eb9 --- /dev/null +++ b/tasks/format-code-task-000472/tests/test.patch @@ -0,0 +1,164 @@ +diff --git a/specutils/tests/test_region_extract.py b/specutils/tests/test_region_extract.py +index 96789038..96de3017 100644 +--- a/specutils/tests/test_region_extract.py ++++ b/specutils/tests/test_region_extract.py +@@ -265,3 +265,137 @@ def test_slab_multid_flux(): + + assert extracted.shape == (10, 11) + assert extracted[0,0].flux == spec[0,9].flux ++ ++ ++def test_return_single_spectrum_default_returns_list(): ++ """Default behavior preserved: multi-region returns list of Spectrum1D.""" ++ spec = Spectrum1D(spectral_axis=np.arange(50) * u.nm, ++ flux=np.arange(50) * u.Jy) ++ region = SpectralRegion([(5 * u.nm, 10 * u.nm), (20 * u.nm, 25 * u.nm)]) ++ ++ result = extract_region(spec, region) ++ ++ assert isinstance(result, list) ++ assert len(result) == 2 ++ assert isinstance(result[0], Spectrum1D) ++ assert isinstance(result[1], Spectrum1D) ++ ++ ++def test_return_single_spectrum_true_returns_spectrum1d(): ++ """return_single_spectrum=True returns a single Spectrum1D, not a list.""" ++ spec = Spectrum1D(spectral_axis=np.arange(50) * u.nm, ++ flux=np.arange(50) * u.Jy) ++ region = SpectralRegion([(5 * u.nm, 10 * u.nm), (20 * u.nm, 25 * u.nm)]) ++ ++ result = extract_region(spec, region, return_single_spectrum=True) ++ ++ assert isinstance(result, Spectrum1D) ++ assert not isinstance(result, list) ++ ++ ++def test_return_single_spectrum_flux_concatenated(): ++ """Flux array should be concatenation of all sub-regions' fluxes.""" ++ spec = Spectrum1D(spectral_axis=np.arange(50) * u.nm, ++ flux=np.arange(50) * u.Jy) ++ region = SpectralRegion([(5 * u.nm, 10 * u.nm), (20 * u.nm, 25 * u.nm)]) ++ ++ result = extract_region(spec, region, return_single_spectrum=True) ++ ++ expected_flux = np.array([5., 6., 7., 8., 9., 10., ++ 20., 21., 22., 23., 24., 25.]) ++ assert quantity_allclose(result.flux, expected_flux * u.Jy) ++ ++ ++def test_return_single_spectrum_spectral_axis_concatenated(): ++ """Spectral axis should contain values from all sub-regions.""" ++ spec = Spectrum1D(spectral_axis=np.arange(50) * u.nm, ++ flux=np.arange(50) * u.Jy) ++ region = SpectralRegion([(5 * u.nm, 10 * u.nm), (20 * u.nm, 25 * u.nm)]) ++ ++ result = extract_region(spec, region, return_single_spectrum=True) ++ ++ expected_axis = np.array([5., 6., 7., 8., 9., 10., ++ 20., 21., 22., 23., 24., 25.]) ++ assert quantity_allclose(result.spectral_axis, expected_axis * u.nm) ++ ++ ++def test_return_single_spectrum_length_sum_of_subregions(): ++ """Length of returned spectrum equals the sum of sub-region lengths.""" ++ spec = Spectrum1D(spectral_axis=np.arange(50) * u.nm, ++ flux=np.arange(50) * u.Jy) ++ region = SpectralRegion([(5 * u.nm, 10 * u.nm), (20 * u.nm, 25 * u.nm)]) ++ ++ list_result = extract_region(spec, region) ++ expected_len = len(list_result[0].spectral_axis) + len(list_result[1].spectral_axis) ++ ++ single_result = extract_region(spec, region, return_single_spectrum=True) ++ ++ assert len(single_result.spectral_axis) == expected_len ++ assert len(single_result.flux) == expected_len ++ ++ ++def test_return_single_spectrum_with_uncertainty(): ++ """Uncertainty is concatenated when return_single_spectrum=True.""" ++ flux = np.arange(50, dtype=float) * u.Jy ++ uncert = StdDevUncertainty(0.1 * np.arange(50, dtype=float)) ++ spec = Spectrum1D(spectral_axis=np.arange(50) * u.nm, ++ flux=flux, uncertainty=uncert) ++ region = SpectralRegion([(5 * u.nm, 10 * u.nm), (20 * u.nm, 25 * u.nm)]) ++ ++ result = extract_region(spec, region, return_single_spectrum=True) ++ ++ assert result.uncertainty is not None ++ expected = np.array([0.5, 0.6, 0.7, 0.8, 0.9, 1.0, ++ 2.0, 2.1, 2.2, 2.3, 2.4, 2.5]) ++ assert np.allclose(result.uncertainty.array, expected) ++ ++ ++def test_return_single_spectrum_with_mask(): ++ """Mask is concatenated when return_single_spectrum=True.""" ++ mask = np.zeros(50, dtype=bool) ++ ++ mask[7] = True ++ mask[22] = True ++ spec = Spectrum1D(spectral_axis=np.arange(50) * u.nm, ++ flux=np.arange(50) * u.Jy, ++ mask=mask) ++ region = SpectralRegion([(5 * u.nm, 10 * u.nm), (20 * u.nm, 25 * u.nm)]) ++ ++ result = extract_region(spec, region, return_single_spectrum=True) ++ ++ assert result.mask is not None ++ ++ ++ expected_mask = np.zeros(12, dtype=bool) ++ expected_mask[2] = True ++ expected_mask[8] = True ++ assert np.array_equal(np.asarray(result.mask), expected_mask) ++ ++ ++def test_return_single_spectrum_single_subregion(): ++ """Single-subregion case still returns a Spectrum1D when flag is True.""" ++ spec = Spectrum1D(spectral_axis=np.arange(50) * u.nm, ++ flux=np.arange(50) * u.Jy) ++ region = SpectralRegion(5 * u.nm, 10 * u.nm) ++ ++ result = extract_region(spec, region, return_single_spectrum=True) ++ ++ assert isinstance(result, Spectrum1D) ++ assert quantity_allclose(result.flux, ++ np.array([5., 6., 7., 8., 9., 10.]) * u.Jy) ++ ++ ++def test_return_single_spectrum_three_subregions(): ++ """Three sub-regions concatenated correctly into a single spectrum.""" ++ spec = Spectrum1D(spectral_axis=np.arange(50) * u.nm, ++ flux=np.arange(50) * u.Jy) ++ region = SpectralRegion([(2 * u.nm, 4 * u.nm), ++ (10 * u.nm, 12 * u.nm), ++ (30 * u.nm, 32 * u.nm)]) ++ ++ result = extract_region(spec, region, return_single_spectrum=True) ++ ++ assert isinstance(result, Spectrum1D) ++ expected_flux = np.array([2., 3., 4., 10., 11., 12., 30., 31., 32.]) ++ assert quantity_allclose(result.flux, expected_flux * u.Jy) ++ assert quantity_allclose(result.spectral_axis, expected_flux * u.nm) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..313f42c4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest specutils/tests/test_region_extract.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 specutils/tests/test_region_extract.py::test_return_single_spectrum_default_returns_list specutils/tests/test_region_extract.py::test_return_single_spectrum_true_returns_spectrum1d specutils/tests/test_region_extract.py::test_return_single_spectrum_flux_concatenated specutils/tests/test_region_extract.py::test_return_single_spectrum_spectral_axis_concatenated specutils/tests/test_region_extract.py::test_return_single_spectrum_length_sum_of_subregions specutils/tests/test_region_extract.py::test_return_single_spectrum_with_uncertainty specutils/tests/test_region_extract.py::test_return_single_spectrum_with_mask specutils/tests/test_region_extract.py::test_return_single_spectrum_single_subregion specutils/tests/test_region_extract.py::test_return_single_spectrum_three_subregions ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000472/tests/test.sh b/tasks/format-code-task-000472/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c44aa6df8ff2f74be937d1241e1fb696eeb71fea --- /dev/null +++ b/tasks/format-code-task-000472/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' +specutils/tests/test_region_extract.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-000472/tests/test_command.sh b/tasks/format-code-task-000472/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000472/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000475/environment/Dockerfile b/tasks/format-code-task-000475/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..12018e5532206ff4146516c616adfaf0d4fe2cc2 --- /dev/null +++ b/tasks/format-code-task-000475/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2482503ddd57c835e7a33514f4cd87533cbcb577f8779c43f41b174ac1bb63a3 diff --git a/tasks/format-code-task-000475/environment/setup/files/blocklist b/tasks/format-code-task-000475/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000475/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000475/environment/setup/setup.sh b/tasks/format-code-task-000475/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000475/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000475/tests/test.patch b/tasks/format-code-task-000475/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a378fc7b10e06974714ceb52f905148c1f3639e1 --- /dev/null +++ b/tasks/format-code-task-000475/tests/test.patch @@ -0,0 +1,104 @@ +diff --git a/test/unit/view/server-side-rendering.spec.js b/test/unit/view/server-side-rendering.spec.js +new file mode 100644 +index 00000000..30a81d4a +--- /dev/null ++++ b/test/unit/view/server-side-rendering.spec.js +@@ -0,0 +1,76 @@ ++ ++import createStyleMarshal from '../../../src/view/style-marshal/style-marshal'; ++import { resetServerContext } from '../../../src/'; ++import type { StyleMarshal } from '../../../src/view/style-marshal/style-marshal-types'; ++ ++describe('server side rendering', () => { ++ beforeEach(() => { ++ jest.spyOn(console, 'error').mockImplementation(() => { }); ++ }); ++ ++ afterEach(() => { ++ console.error.mockRestore(); ++ }); ++ ++ it('should export resetServerContext as a function from the package entry point', () => { ++ expect(resetServerContext).toBeDefined(); ++ expect(typeof resetServerContext).toBe('function'); ++ }); ++ ++ it('should increment the styleContext on each call to createStyleMarshal by default', () => { ++ const first: StyleMarshal = createStyleMarshal(); ++ const second: StyleMarshal = createStyleMarshal(); ++ const third: StyleMarshal = createStyleMarshal(); ++ ++ ++ expect(Number(second.styleContext)).toBe(Number(first.styleContext) + 1); ++ expect(Number(third.styleContext)).toBe(Number(second.styleContext) + 1); ++ }); ++ ++ it('should reset the counter so the next createStyleMarshal returns styleContext "0"', () => { ++ ++ createStyleMarshal(); ++ createStyleMarshal(); ++ createStyleMarshal(); ++ ++ ++ resetServerContext(); ++ ++ const after: StyleMarshal = createStyleMarshal(); ++ expect(after.styleContext).toBe('0'); ++ }); ++ ++ it('should support being called repeatedly across simulated server renders', () => { ++ ++ resetServerContext(); ++ const firstRender: StyleMarshal = createStyleMarshal(); ++ expect(firstRender.styleContext).toBe('0'); ++ ++ ++ resetServerContext(); ++ const secondRender: StyleMarshal = createStyleMarshal(); ++ expect(secondRender.styleContext).toBe('0'); ++ ++ ++ resetServerContext(); ++ const thirdRender: StyleMarshal = createStyleMarshal(); ++ expect(thirdRender.styleContext).toBe('0'); ++ }); ++ ++ it('should continue incrementing from 0 after a reset', () => { ++ resetServerContext(); ++ const first: StyleMarshal = createStyleMarshal(); ++ const second: StyleMarshal = createStyleMarshal(); ++ const third: StyleMarshal = createStyleMarshal(); ++ ++ expect(first.styleContext).toBe('0'); ++ expect(second.styleContext).toBe('1'); ++ expect(third.styleContext).toBe('2'); ++ }); ++ ++ it('should not raise or change behaviour when resetServerContext is called before any marshal is created', () => { ++ resetServerContext(); ++ const marshal: StyleMarshal = createStyleMarshal(); ++ expect(marshal.styleContext).toBe('0'); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..548fe37a +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["yarn jest test/unit/view/server-side-rendering.spec.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 ++yarn jest test/unit/view/server-side-rendering.spec.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000475/tests/test.sh b/tasks/format-code-task-000475/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b2d930ef77e6ee8d591945cf8f332d4b1ef42ffc --- /dev/null +++ b/tasks/format-code-task-000475/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/view/server-side-rendering.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-000475/tests/test_command.sh b/tasks/format-code-task-000475/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000475/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000481/environment/Dockerfile b/tasks/format-code-task-000481/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..54b64b1e6b20134adcdb7d8f8eec14141846303f --- /dev/null +++ b/tasks/format-code-task-000481/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e84d20a1afa3eeb959345fd7777ea49e2af00155aaaec11bff0857a525ec3d85 diff --git a/tasks/format-code-task-000481/environment/setup/files/blocklist b/tasks/format-code-task-000481/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000481/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000481/environment/setup/setup.sh b/tasks/format-code-task-000481/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000481/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000481/tests/test.patch b/tasks/format-code-task-000481/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cad78ae025f03627f8fcf62c286d852aaa4d267b --- /dev/null +++ b/tasks/format-code-task-000481/tests/test.patch @@ -0,0 +1,364 @@ +diff --git a/usercase-test-coderl/authentication-configuration.test.js b/usercase-test-coderl/authentication-configuration.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/authentication-configuration.test.js +@@ -0,0 +1,328 @@ ++import test from 'ava'; ++import { expect } from 'chai'; ++import base64url from 'base64url'; ++ ++ ++ ++ ++const SPEC = { ++ openapi: '3.0.3', ++ info: { title: 'Authentication Configuration Acceptance', version: '1.0.0' }, ++ servers: [{ url: 'https://api.example.test' }], ++ paths: { ++ '/pets': { ++ get: { ++ tags: ['Pets'], ++ summary: 'List pets', ++ security: [{ bearerAuth: [] }], ++ responses: { 200: { description: 'OK' } } ++ } ++ }, ++ '/reports': { ++ get: { ++ tags: ['Reports'], ++ summary: 'List reports', ++ security: [{ basicAuth: [] }], ++ responses: { 200: { description: 'OK' } } ++ } ++ }, ++ '/oauth': { ++ get: { ++ tags: ['OAuth'], ++ summary: 'OAuth data', ++ security: [{ oauthAuth: [] }], ++ responses: { 200: { description: 'OK' } } ++ } ++ } ++ }, ++ components: { ++ securitySchemes: { ++ bearerAuth: { type: 'http', scheme: 'bearer' }, ++ basicAuth: { type: 'http', scheme: 'basic' }, ++ oauthAuth: { ++ type: 'oauth2', ++ flows: { ++ implicit: { ++ authorizationUrl: '/oauth/authorize', ++ scopes: { read: 'Read data' } ++ } ++ } ++ } ++ } ++ } ++}; ++ ++let OpenApiExplorer; ++let JSDOM; ++ ++function installDom(url = 'https://docs.example.test/root/page.html') { ++ const dom = new JSDOM('', { ++ url, ++ pretendToBeVisual: true ++ }); ++ const btoaPolyfill = value => Buffer.from(String(value), 'binary').toString('base64'); ++ const atobPolyfill = value => Buffer.from(String(value), 'base64').toString('binary'); ++ ++ Object.assign(globalThis, { ++ window: dom.window, ++ document: dom.window.document, ++ customElements: dom.window.customElements, ++ HTMLElement: dom.window.HTMLElement, ++ Element: dom.window.Element, ++ Node: dom.window.Node, ++ Document: dom.window.Document, ++ ShadowRoot: dom.window.ShadowRoot, ++ CSSStyleSheet: dom.window.CSSStyleSheet, ++ Event: dom.window.Event, ++ CustomEvent: dom.window.CustomEvent, ++ EventTarget: dom.window.EventTarget, ++ URL: dom.window.URL, ++ URLSearchParams: dom.window.URLSearchParams, ++ Headers: dom.window.Headers, ++ localStorage: dom.window.localStorage, ++ history: dom.window.history, ++ location: dom.window.location, ++ navigator: dom.window.navigator, ++ btoa: btoaPolyfill, ++ atob: atobPolyfill, ++ getComputedStyle: dom.window.getComputedStyle.bind(dom.window), ++ IntersectionObserver: class { ++ observe() {} ++ disconnect() {} ++ }, ++ matchMedia: () => ({ ++ matches: false, ++ addListener() {}, ++ removeListener() {}, ++ addEventListener() {}, ++ removeEventListener() {}, ++ dispatchEvent() { return false; } ++ }), ++ fetch: async () => { ++ throw new Error('Unexpected network request from authentication configuration test'); ++ } ++ }); ++ window.btoa = btoaPolyfill; ++ window.atob = atobPolyfill; ++ window.matchMedia = globalThis.matchMedia; ++ window.scrollTo = () => {}; ++ Element.prototype.scrollIntoView = function scrollIntoView() {}; ++ return dom; ++} ++ ++test.before(async () => { ++ ++ ({ JSDOM } = await import('/opt/stage4-jsdom/node_modules/jsdom/lib/api.js')); ++ installDom(); ++ OpenApiExplorer = (await import('../src/openapi-explorer.js')).default; ++}); ++ ++test.beforeEach(() => { ++ installDom(); ++}); ++ ++function createExplorer() { ++ const explorer = new OpenApiExplorer(); ++ document.body.appendChild(explorer); ++ explorer.renderStyle = 'view'; ++ explorer.hideInfo = true; ++ explorer.hideServerSelection = true; ++ explorer.hideAuthentication = true; ++ return explorer; ++} ++ ++async function loadedExplorer(spec = SPEC) { ++ const explorer = createExplorer(); ++ await explorer.loadSpec(structuredClone(spec)); ++ await explorer.updateComplete; ++ return explorer; ++} ++ ++function scheme(explorer, securitySchemeId) { ++ const found = explorer.resolvedSpec.securitySchemes.find(s => s.apiKeyId === securitySchemeId); ++ expect(found, `expected loaded security scheme ${securitySchemeId}`).to.exist; ++ return found; ++} ++ ++function operation(explorer, path) { ++ return explorer.resolvedSpec.tags.flatMap(tag => tag.paths).find(p => p.path === path); ++} ++ ++test.serial('applies bearer credentials and does not duplicate an existing bearer prefix', async t => { ++ ++ ++ ++ ++ const explorer = await loadedExplorer(); ++ ++ ++ expect(scheme(explorer, 'bearerAuth').finalKeyValue).to.not.equal('Bearer abc123'); ++ expect(operation(explorer, '/pets').security).to.eql([{ bearerAuth: [] }]); ++ ++ await explorer.setAuthenticationConfiguration('bearerAuth', { token: 'abc123' }); ++ await explorer.updateComplete; ++ ++ ++ expect(scheme(explorer, 'bearerAuth').finalKeyValue).to.equal('Bearer abc123'); ++ ++ const petOperation = operation(explorer, '/pets'); ++ const bearerKeysForRequest = explorer.resolvedSpec.securitySchemes ++ .filter(v => v.finalKeyValue && petOperation.security?.some(ps => ps[v.apiKeyId])) ++ .map(v => ({ apiKeyId: v.apiKeyId, name: v.name, finalKeyValue: v.finalKeyValue })); ++ expect(bearerKeysForRequest).to.eql([ ++ { apiKeyId: 'bearerAuth', name: 'Authorization', finalKeyValue: 'Bearer abc123' } ++ ]); ++ ++ await explorer.setAuthenticationConfiguration('bearerAuth', { token: 'Bearer xyz789' }); ++ await explorer.updateComplete; ++ ++ ++ expect(scheme(explorer, 'bearerAuth').finalKeyValue).to.equal('Bearer xyz789'); ++ t.pass(); ++}); ++ ++test.serial('applies basic credentials as a Basic Authorization value', async t => { ++ ++ ++ ++ ++ const explorer = await loadedExplorer(); ++ ++ await explorer.setAuthenticationConfiguration('basicAuth', { token: 'user:password' }); ++ await explorer.updateComplete; ++ ++ ++ expect(scheme(explorer, 'basicAuth').finalKeyValue).to.equal('Basic dXNlcjpwYXNzd29yZA=='); ++ ++ const reportsOperation = operation(explorer, '/reports'); ++ const basicKeysForRequest = explorer.resolvedSpec.securitySchemes ++ .filter(v => v.finalKeyValue && reportsOperation.security?.some(ps => ps[v.apiKeyId])) ++ .map(v => ({ apiKeyId: v.apiKeyId, name: v.name, finalKeyValue: v.finalKeyValue })); ++ expect(basicKeysForRequest).to.eql([ ++ { apiKeyId: 'basicAuth', name: 'Authorization', finalKeyValue: 'Basic dXNlcjpwYXNzd29yZA==' } ++ ]); ++ t.pass(); ++}); ++ ++test.serial('trims OAuth client configuration, resolves redirect URI, checks URL response, and requests render update', async t => { ++ ++ ++ ++ ++ const state = base64url.encode(JSON.stringify({ ++ apiKeyId: 'oauthAuth', ++ flowId: 'implicit', ++ url: 'https://docs.example.test/root/page.html' ++ })); ++ installDom(`https://docs.example.test/root/page.html?state=${state}&access_token=urlToken&token_type=Bearer&expires_in=3600`); ++ const explorer = createExplorer(); ++ let updateCount = 0; ++ const originalRequestUpdate = explorer.requestUpdate.bind(explorer); ++ explorer.requestUpdate = (...args) => { ++ updateCount += 1; ++ return originalRequestUpdate(...args); ++ }; ++ ++ await explorer.loadSpec(structuredClone(SPEC)); ++ await explorer.updateComplete; ++ ++ ++ expect(scheme(explorer, 'oauthAuth').finalKeyValue).to.equal('Bearer urlToken'); ++ expect(window.location.href).to.equal('https://docs.example.test/root/page.html'); ++ updateCount = 0; ++ ++ await explorer.setAuthenticationConfiguration('oauthAuth', { ++ token: 'oauth-token', ++ clientId: ' client-one ', ++ clientSecret: ' secret-one ', ++ redirectUri: ' callbacks/oauth ' ++ }); ++ await explorer.updateComplete; ++ ++ ++ expect(scheme(explorer, 'oauthAuth')).to.include({ ++ finalKeyValue: 'oauth-token', ++ clientId: 'client-one', ++ clientSecret: 'secret-one', ++ redirectUri: 'https://docs.example.test/root/callbacks/oauth' ++ }); ++ expect(updateCount).to.equal(1); ++ t.pass(); ++}); ++ ++test.serial('rejects unknown security scheme ids with the exact Error message', async t => { ++ ++ ++ ++ ++ const explorer = await loadedExplorer(); ++ ++ const err = await t.throwsAsync( ++ () => explorer.setAuthenticationConfiguration('missingAuth', { token: 'nope' }), ++ { instanceOf: Error } ++ ); ++ expect(err.message).to.equal('SecuritySchemeNotFound'); ++}); ++ ++test.serial('calling authentication configuration before a spec is loaded rejects like a missing scheme', async t => { ++ ++ ++ ++ ++ const explorer = createExplorer(); ++ ++ const err = await t.throwsAsync( ++ () => explorer.setAuthenticationConfiguration('bearerAuth', { token: 'abc123' }), ++ { instanceOf: Error } ++ ); ++ expect(err.message).to.equal('SecuritySchemeNotFound'); ++}); ++ ++test.serial('repeated configuration calls are idempotent for the same token value', async t => { ++ ++ ++ ++ ++ const explorer = await loadedExplorer(); ++ ++ await explorer.setAuthenticationConfiguration('basicAuth', { token: 'new:secret' }); ++ await explorer.setAuthenticationConfiguration('basicAuth', { token: 'new:secret' }); ++ await explorer.updateComplete; ++ ++ ++ expect(scheme(explorer, 'basicAuth').finalKeyValue).to.equal('Basic bmV3OnNlY3JldA=='); ++ t.pass(); ++}); ++ ++test.serial('two explorer instances keep independent applied credentials', async t => { ++ ++ ++ ++ ++ const a = await loadedExplorer(); ++ const b = await loadedExplorer(); ++ ++ await a.setAuthenticationConfiguration('bearerAuth', { token: 'aaa' }); ++ await a.updateComplete; ++ await b.updateComplete; ++ ++ ++ expect(scheme(a, 'bearerAuth').finalKeyValue).to.equal('Bearer aaa'); ++ expect(scheme(b, 'bearerAuth').finalKeyValue).to.not.equal('Bearer aaa'); ++ t.pass(); ++}); ++ ++test.serial('attach configure detach cycles keep authentication configuration usable', async t => { ++ ++ ++ ++ ++ ++ for (let i = 0; i < 25; i += 1) { ++ const explorer = await loadedExplorer(); ++ await explorer.setAuthenticationConfiguration('bearerAuth', { token: 'abc123' }); ++ expect(scheme(explorer, 'bearerAuth').finalKeyValue).to.equal('Bearer abc123'); ++ explorer.remove(); ++ } ++ t.pass(); ++}); +diff --git 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 ++ ++ ++ ++ ++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/ava ]; then ++ echo "Missing local ava binary; dependencies must be preinstalled before offline test execution." >&2 ++ exit 1 ++fi ++ ++if [ ! -f /opt/stage4-jsdom/node_modules/jsdom/lib/api.js ]; then ++ echo "Missing local jsdom package; dependencies must be preinstalled before offline test execution." >&2 ++ exit 1 ++fi ++ ++exec ./node_modules/.bin/ava /workspace/repo/usercase-test-coderl/authentication-configuration.test.js --verbose diff --git a/tasks/format-code-task-000481/tests/test.sh b/tasks/format-code-task-000481/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5c0500b4db0ea0a00b3bde984f73954bc3f38dc5 --- /dev/null +++ b/tasks/format-code-task-000481/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/authentication-configuration.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-000481/tests/test_command.sh b/tasks/format-code-task-000481/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000481/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-000486/environment/Dockerfile b/tasks/format-code-task-000486/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2a29ea6e5ef3e78288b9ba929b640e995dbfddfc --- /dev/null +++ b/tasks/format-code-task-000486/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3997e554aacca7de43f57dfcd0dc79c7f7f61736ac3b1cb715084cc13561d100 diff --git a/tasks/format-code-task-000486/environment/setup/files/blocklist b/tasks/format-code-task-000486/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000486/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000486/environment/setup/setup.sh b/tasks/format-code-task-000486/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000486/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000486/tests/test.patch b/tasks/format-code-task-000486/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..24b1d86616ef478ec641444127cbbfd7ef9cc124 --- /dev/null +++ b/tasks/format-code-task-000486/tests/test.patch @@ -0,0 +1,166 @@ +diff --git a/usercase-test-coderl/fixtures/repos-absent.json b/usercase-test-coderl/fixtures/repos-absent.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/repos-absent.json +@@ -0,0 +1,3 @@ ++{ ++ "CACHE_DIR": "/tmp/autopkg-cache" ++} +diff --git a/usercase-test-coderl/fixtures/repos-empty.json b/usercase-test-coderl/fixtures/repos-empty.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/repos-empty.json +@@ -0,0 +1,3 @@ ++{ ++ "RECIPE_REPOS": {} ++} +diff --git a/usercase-test-coderl/fixtures/repos-multiple.json b/usercase-test-coderl/fixtures/repos-multiple.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/repos-multiple.json +@@ -0,0 +1,13 @@ ++{ ++ "RECIPE_REPOS": { ++ "/var/tmp/zeta-recipes": { ++ "URL": "https://github.com/example/zeta-recipes" ++ }, ++ "/tmp/alpha-recipes": { ++ "URL": "https://github.com/example/alpha-recipes" ++ }, ++ "/tmp/beta-recipes": { ++ "URL": "ssh://git@example.com/team/beta-recipes.git" ++ } ++ } ++} +diff --git a/usercase-test-coderl/fixtures/repos-single.json b/usercase-test-coderl/fixtures/repos-single.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/repos-single.json +@@ -0,0 +1,7 @@ ++{ ++ "RECIPE_REPOS": { ++ "/opt/recipes": { ++ "URL": "git@example.com:team/recipes.git" ++ } ++ } ++} +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,98 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++export PYTHONDONTWRITEBYTECODE=1 ++ ++REPO=/workspace/repo ++FIXTURES="$REPO/usercase-test-coderl/fixtures" ++BIN="$REPO/Code/autopkg" ++export PYTHONPATH="$REPO/Code${PYTHONPATH:+:$PYTHONPATH}" ++ ++[ -x "$BIN" ] || { echo "FAIL: autopkg entry point is not executable" >&2; exit 1; } ++python3 - <<'PY' || { echo "FAIL: missing Python runtime dependencies" >&2; exit 1; } ++import appdirs ++import yaml ++PY ++ ++TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || exit 1 ++fail() { echo "FAIL: $*" >&2; exit 1; } ++run_autopkg() { python3 "$BIN" "$@"; } ++ ++ ++ ++ ++run_autopkg repo-list --prefs "$FIXTURES/repos-multiple.json" >out 2>err; ec=$? ++cat >expected <<'EOF' ++/tmp/alpha-recipes (https://github.com/example/alpha-recipes) ++/tmp/beta-recipes (ssh://git@example.com/team/beta-recipes.git) ++/var/tmp/zeta-recipes (https://github.com/example/zeta-recipes) ++ ++EOF ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++cmp -s out expected || fail "F1 stdout: $(cat out)" ++[ ! -s err ] || fail "F1 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_autopkg repo-list --prefs "$FIXTURES/repos-empty.json" >out 2>err; ec=$? ++printf 'No recipe repos.\n' >expected ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++cmp -s out expected || fail "F2 stdout: $(cat out)" ++[ ! -s err ] || fail "F2 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_autopkg repo-list --prefs "$FIXTURES/repos-absent.json" >out 2>err; ec=$? ++printf 'No recipe repos.\n' >expected ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++cmp -s out expected || fail "F3 stdout: $(cat out)" ++[ ! -s err ] || fail "F3 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_autopkg list-repos --prefs "$FIXTURES/repos-single.json" >out 2>err; ec=$? ++cat >expected <<'EOF' ++/opt/recipes (git@example.com:team/recipes.git) ++ ++EOF ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++cmp -s out expected || fail "F4 stdout: $(cat out)" ++[ ! -s err ] || fail "F4 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_autopkg repo-list --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++ ++grep -Fxq 'Usage: autopkg repo-list' out || fail "F5 missing usage line: $(cat out)" ++grep -Eiq 'list(s)? all installed recipe repos|list(s)? installed recipe repos' out || fail "F5 missing repository-listing description: $(cat out)" ++[ ! -s err ] || fail "F5 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_autopkg help >out 2>err; ec=$? ++ ++[ "$ec" -eq 0 ] || [ "$ec" -eq 1 ] || fail "F6 exit $ec; want successful/help-style exit" ++grep -Eq '(^|[[:space:]])repo-list([[:space:]]|$).*List installed recipe repos' out || fail "F6 missing repo-list help entry" ++grep -Eq '(^|[[:space:]])list-repos([[:space:]]|$).*see repo-list' out || fail "F6 missing list-repos help entry" ++[ ! -s err ] || fail "F6 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++run_autopkg repo-list --prefs >out 2>err; ec=$? ++ ++[ "$ec" -ne 0 ] || fail "F7 exit $ec; want non-zero" ++[ ! -s out ] || fail "F7 unexpected stdout: $(cat out)" ++[ -s err ] || fail "F7 expected an error message for missing --prefs path" ++grep -Eq -- '--prefs|Usage: autopkg repo-list' err || fail "F7 stderr should identify the invalid option or usage: $(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-000486/tests/test.sh b/tasks/format-code-task-000486/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ec07e7433ecbe267aef7e770cec1de70c6e547a --- /dev/null +++ b/tasks/format-code-task-000486/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/repos-absent.json +usercase-test-coderl/fixtures/repos-empty.json +usercase-test-coderl/fixtures/repos-multiple.json +usercase-test-coderl/fixtures/repos-single.json +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-000486/tests/test_command.sh b/tasks/format-code-task-000486/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000486/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-000488/environment/Dockerfile b/tasks/format-code-task-000488/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..38a917803abad898f1b559bff6f704d9d5ec87fd --- /dev/null +++ b/tasks/format-code-task-000488/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:73160ba415256bbc61a274e55d98cb036434da8ca1d74aff2aa89642bc5c2cb6 diff --git a/tasks/format-code-task-000488/environment/setup/files/blocklist b/tasks/format-code-task-000488/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000488/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000488/environment/setup/setup.sh b/tasks/format-code-task-000488/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000488/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000488/tests/test.patch b/tasks/format-code-task-000488/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c31bc3cac06792b11d3b03e1d8902b7d49f2d0a9 --- /dev/null +++ b/tasks/format-code-task-000488/tests/test.patch @@ -0,0 +1,631 @@ +diff --git a/usercase-test-coderl/test_create_scenario.py b/usercase-test-coderl/test_create_scenario.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_create_scenario.py +@@ -0,0 +1,603 @@ ++import json ++import os ++import subprocess ++import sys ++import textwrap ++ ++ ++ ++ ++ ++ ++ ++ ++REPO = "/workspace/repo" ++RESULT_PREFIX = "__USERCASE_RESULT__" ++ ++ ++COMMON = r""" ++import json ++from datetime import datetime ++ ++import taipy as tp ++from taipy import Config, Frequency ++ ++ ++def identity(x): ++ return x ++ ++ ++def emit(value): ++ print("__USERCASE_RESULT__" + json.dumps(value, sort_keys=True)) ++ ++ ++def configure_storage(suffix): ++ Config.configure_core(storage_folder=f".declared_data_{suffix}", taipy_storage_folder=f".declared_taipy_{suffix}") ++ ++ ++def sequence_task_ids(sequence): ++ return list(sequence.tasks.keys()) ++ ++ ++def scenario_summary(scenario): ++ return { ++ "config_id": scenario.config_id, ++ "task_config_ids": sorted(scenario.tasks.keys()), ++ "data_node_config_ids": sorted(scenario.data_nodes.keys()), ++ "additional_data_node_config_ids": sorted(scenario.additional_data_nodes.keys()), ++ "task_data_nodes": {k: sorted(v.data_nodes.keys()) for k, v in sorted(scenario.tasks.items())}, ++ "name": scenario.name, ++ "creation_date": scenario.creation_date.isoformat(), ++ "cycle": None if scenario.cycle is None else { ++ "frequency": scenario.cycle.frequency.name, ++ "creation_date": scenario.cycle.creation_date.isoformat(), ++ "start_date": scenario.cycle.start_date.isoformat(), ++ "end_date": scenario.cycle.end_date.isoformat(), ++ "name": scenario.cycle.name, ++ }, ++ "owner_id_matches_cycle": scenario.owner_id == (scenario.cycle.id if scenario.cycle else None), ++ "is_primary": scenario.is_primary, ++ "sequences": {name: sequence_task_ids(seq) for name, seq in sorted(scenario.sequences.items())}, ++ } ++""" ++ ++ ++def run_python(code, cwd): ++ env = os.environ.copy() ++ env["PYTHONPATH"] = REPO + os.pathsep + env.get("PYTHONPATH", "") ++ proc = subprocess.run( ++ [sys.executable, "-c", COMMON + "\n" + textwrap.dedent(code)], ++ cwd=cwd, ++ env=env, ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.STDOUT, ++ ) ++ if proc.returncode != 0: ++ raise AssertionError(proc.stdout) ++ for line in reversed(proc.stdout.splitlines()): ++ if line.startswith(RESULT_PREFIX): ++ return json.loads(line[len(RESULT_PREFIX) :]) ++ raise AssertionError(proc.stdout) ++ ++ ++def assert_scenario_summary( ++ summary, ++ *, ++ config_id, ++ task_config_ids, ++ data_node_config_ids, ++ task_data_nodes, ++ additional_data_node_config_ids=None, ++ name=None, ++ creation_date="2026-07-22T10:30:00", ++ cycle=None, ++ is_primary=False, ++ sequences=None, ++): ++ additional_data_node_config_ids = additional_data_node_config_ids or [] ++ sequences = sequences or {} ++ ++ assert summary["config_id"] == config_id ++ assert sorted(summary["task_config_ids"]) == sorted(task_config_ids) ++ assert sorted(summary["data_node_config_ids"]) == sorted(data_node_config_ids) ++ assert sorted(summary["additional_data_node_config_ids"]) == sorted(additional_data_node_config_ids) ++ assert summary["task_data_nodes"] == {k: sorted(v) for k, v in task_data_nodes.items()} ++ assert summary["name"] == name ++ assert summary["creation_date"] == creation_date ++ assert summary["is_primary"] is is_primary ++ assert summary["sequences"] == sequences ++ if cycle is None: ++ assert summary["cycle"] is None ++ else: ++ assert summary["cycle"]["frequency"] == cycle["frequency"] ++ assert summary["cycle"]["creation_date"] == cycle["creation_date"] ++ assert summary["cycle"]["start_date"] == cycle["start_date"] ++ assert summary["cycle"]["end_date"] == cycle["end_date"] ++ ++ ++ ++def test_one_task_graph_is_materialized_and_persisted(tmp_path): ++ ++ ++ ++ ++ result = run_python( ++ """ ++ configure_storage("basic") ++ input_cfg = Config.configure_data_node("input_cfg", storage_type="in_memory") ++ output_cfg = Config.configure_data_node("output_cfg", storage_type="in_memory") ++ task_cfg = Config.configure_task("forecast_task", identity, input_cfg, output_cfg) ++ scenario_cfg = Config.configure_scenario("forecast_scenario", task_configs=[task_cfg]) ++ creation_date = datetime(2026, 7, 22, 10, 30) ++ ++ scenario = tp.create_scenario(scenario_cfg, creation_date) ++ emit({ ++ "returned": scenario_summary(scenario), ++ "retrieved": scenario_summary(tp.get(scenario.id)), ++ "scenario_count": len(tp.get_scenarios()), ++ }) ++ """, ++ tmp_path, ++ ) ++ ++ ++ assert_scenario_summary( ++ result["returned"], ++ config_id="forecast_scenario", ++ task_config_ids=["forecast_task"], ++ data_node_config_ids=["input_cfg", "output_cfg"], ++ task_data_nodes={"forecast_task": ["input_cfg", "output_cfg"]}, ++ ) ++ assert result["retrieved"] == result["returned"] ++ assert result["scenario_count"] == 1 ++ ++ ++def test_name_argument_sets_display_name(tmp_path): ++ ++ ++ ++ ++ result = run_python( ++ """ ++ configure_storage("named") ++ input_cfg = Config.configure_data_node("input_cfg", storage_type="in_memory") ++ output_cfg = Config.configure_data_node("output_cfg", storage_type="in_memory") ++ task_cfg = Config.configure_task("forecast_task", identity, input_cfg, output_cfg) ++ scenario_cfg = Config.configure_scenario("forecast_scenario", task_configs=[task_cfg]) ++ ++ scenario = tp.create_scenario(scenario_cfg, datetime(2026, 7, 22, 10, 30), name="Forecast run") ++ emit(scenario_summary(scenario)) ++ """, ++ tmp_path, ++ ) ++ ++ ++ assert_scenario_summary( ++ result, ++ config_id="forecast_scenario", ++ task_config_ids=["forecast_task"], ++ data_node_config_ids=["input_cfg", "output_cfg"], ++ task_data_nodes={"forecast_task": ["input_cfg", "output_cfg"]}, ++ name="Forecast run", ++ ) ++ ++ ++def test_additional_data_nodes_are_included_when_unconnected(tmp_path): ++ ++ ++ ++ ++ result = run_python( ++ """ ++ configure_storage("extra") ++ input_cfg = Config.configure_data_node("input_cfg", storage_type="in_memory") ++ output_cfg = Config.configure_data_node("output_cfg", storage_type="in_memory") ++ extra_cfg = Config.configure_data_node("audit_notes", storage_type="in_memory") ++ task_cfg = Config.configure_task("forecast_task", identity, input_cfg, output_cfg) ++ scenario_cfg = Config.configure_scenario( ++ "extra_scenario", task_configs=[task_cfg], additional_data_node_configs=[extra_cfg] ++ ) ++ ++ scenario = tp.create_scenario(scenario_cfg, datetime(2026, 7, 22, 10, 30)) ++ emit(scenario_summary(scenario)) ++ """, ++ tmp_path, ++ ) ++ ++ ++ assert_scenario_summary( ++ result, ++ config_id="extra_scenario", ++ task_config_ids=["forecast_task"], ++ data_node_config_ids=["audit_notes", "input_cfg", "output_cfg"], ++ additional_data_node_config_ids=["audit_notes"], ++ task_data_nodes={"forecast_task": ["input_cfg", "output_cfg"]}, ++ ) ++ ++ ++def test_daily_frequency_attaches_cycle_and_marks_only_first_primary(tmp_path): ++ ++ ++ ++ ++ result = run_python( ++ """ ++ configure_storage("daily") ++ input_cfg = Config.configure_data_node("input_cfg", storage_type="in_memory") ++ output_cfg = Config.configure_data_node("output_cfg", storage_type="in_memory") ++ task_cfg = Config.configure_task("forecast_task", identity, input_cfg, output_cfg) ++ scenario_cfg = Config.configure_scenario("daily_forecast", task_configs=[task_cfg], frequency=Frequency.DAILY) ++ creation_date = datetime(2026, 7, 22, 10, 30) ++ ++ first = tp.create_scenario(scenario_cfg, creation_date) ++ second = tp.create_scenario(scenario_cfg, creation_date) ++ emit({ ++ "first": scenario_summary(first), ++ "second": scenario_summary(second), ++ "same_cycle": first.cycle.id == second.cycle.id, ++ "cycle_count": len(tp.get_cycles()), ++ }) ++ """, ++ tmp_path, ++ ) ++ ++ cycle = { ++ "frequency": "DAILY", ++ "creation_date": "2026-07-22T10:30:00", ++ "start_date": "2026-07-22T00:00:00", ++ "end_date": "2026-07-22T23:59:59.999999", ++ } ++ ++ assert_scenario_summary( ++ result["first"], ++ config_id="daily_forecast", ++ task_config_ids=["forecast_task"], ++ data_node_config_ids=["input_cfg", "output_cfg"], ++ task_data_nodes={"forecast_task": ["input_cfg", "output_cfg"]}, ++ cycle=cycle, ++ is_primary=True, ++ ) ++ assert_scenario_summary( ++ result["second"], ++ config_id="daily_forecast", ++ task_config_ids=["forecast_task"], ++ data_node_config_ids=["input_cfg", "output_cfg"], ++ task_data_nodes={"forecast_task": ["input_cfg", "output_cfg"]}, ++ cycle=cycle, ++ is_primary=False, ++ ) ++ assert result["same_cycle"] is True ++ assert result["cycle_count"] == 1 ++ ++ ++def test_no_frequency_has_no_cycle_and_is_not_primary(tmp_path): ++ ++ ++ ++ ++ result = run_python( ++ """ ++ configure_storage("nofrequency") ++ input_cfg = Config.configure_data_node("input_cfg", storage_type="in_memory") ++ output_cfg = Config.configure_data_node("output_cfg", storage_type="in_memory") ++ task_cfg = Config.configure_task("forecast_task", identity, input_cfg, output_cfg) ++ scenario_cfg = Config.configure_scenario("ad_hoc_forecast", task_configs=[task_cfg]) ++ ++ scenario = tp.create_scenario(scenario_cfg, datetime(2026, 7, 22, 10, 30)) ++ emit(scenario_summary(scenario)) ++ """, ++ tmp_path, ++ ) ++ ++ ++ assert_scenario_summary( ++ result, ++ config_id="ad_hoc_forecast", ++ task_config_ids=["forecast_task"], ++ data_node_config_ids=["input_cfg", "output_cfg"], ++ task_data_nodes={"forecast_task": ["input_cfg", "output_cfg"]}, ++ ) ++ ++ ++def test_sequence_definitions_create_ordered_sequence_views(tmp_path): ++ ++ ++ ++ ++ result = run_python( ++ """ ++ configure_storage("sequence") ++ raw_sales = Config.configure_data_node("raw_sales", storage_type="in_memory") ++ features = Config.configure_data_node("features", storage_type="in_memory") ++ trained_model = Config.configure_data_node("trained_model", storage_type="in_memory") ++ extract = Config.configure_task("extract", identity, raw_sales, features) ++ train = Config.configure_task("train", identity, features, trained_model) ++ scenario_cfg = Config.configure_scenario( ++ "training_pipeline", [extract, train], sequences={"pipeline": [extract, train]} ++ ) ++ ++ scenario = tp.create_scenario(scenario_cfg, datetime(2026, 7, 22, 10, 30)) ++ emit(scenario_summary(scenario)) ++ """, ++ tmp_path, ++ ) ++ ++ ++ assert_scenario_summary( ++ result, ++ config_id="training_pipeline", ++ task_config_ids=["extract", "train"], ++ data_node_config_ids=["features", "raw_sales", "trained_model"], ++ task_data_nodes={"extract": ["features", "raw_sales"], "train": ["features", "trained_model"]}, ++ sequences={"pipeline": ["extract", "train"]}, ++ ) ++ ++ ++def test_sequence_reference_to_foreign_task_raises_specific_exception(tmp_path): ++ ++ ++ ++ ++ result = run_python( ++ """ ++ from taipy.core.config import ScenarioConfig ++ from taipy.core.exceptions.exceptions import SequenceTaskConfigDoesNotExistInSameScenarioConfig ++ ++ configure_storage("badsequence") ++ a = Config.configure_data_node("a", storage_type="in_memory") ++ b = Config.configure_data_node("b", storage_type="in_memory") ++ t1 = Config.configure_task("t1", identity, a, b) ++ foreign_task = Config.configure_task("foreign_task", identity, b, None) ++ scenario_cfg = ScenarioConfig("bad_sequence", [t1], sequences={"pipeline": [t1, foreign_task]}) ++ ++ try: ++ tp.create_scenario(scenario_cfg) ++ except BaseException as exc: ++ emit({ ++ "matches_specific_exception": isinstance(exc, SequenceTaskConfigDoesNotExistInSameScenarioConfig), ++ }) ++ """, ++ tmp_path, ++ ) ++ ++ ++ assert result == {"matches_specific_exception": True} ++ ++ ++def test_configuration_is_locked_before_entities_are_created(tmp_path): ++ ++ ++ ++ ++ result = run_python( ++ """ ++ from taipy.common.config.exceptions.exceptions import ConfigurationUpdateBlocked ++ ++ configure_storage("lock") ++ input_cfg = Config.configure_data_node("input_cfg", storage_type="in_memory") ++ output_cfg = Config.configure_data_node("output_cfg", storage_type="in_memory") ++ task_cfg = Config.configure_task("forecast_task", identity, input_cfg, output_cfg) ++ scenario_cfg = Config.configure_scenario("forecast_scenario", task_configs=[task_cfg]) ++ ++ tp.create_scenario(scenario_cfg, datetime(2026, 7, 22, 10, 30)) ++ try: ++ Config.configure_data_node("after_lock", storage_type="in_memory") ++ except BaseException as exc: ++ emit({ ++ "configuration_update_blocked": isinstance(exc, ConfigurationUpdateBlocked), ++ }) ++ """, ++ tmp_path, ++ ) ++ ++ ++ assert result == {"configuration_update_blocked": True} ++ ++ ++def test_scenario_creation_event_is_published(tmp_path): ++ ++ ++ ++ ++ result = run_python( ++ """ ++ from taipy.core.notification import EventEntityType, EventOperation, Notifier ++ ++ configure_storage("event") ++ input_cfg = Config.configure_data_node("input_cfg", storage_type="in_memory") ++ output_cfg = Config.configure_data_node("output_cfg", storage_type="in_memory") ++ task_cfg = Config.configure_task("forecast_task", identity, input_cfg, output_cfg) ++ scenario_cfg = Config.configure_scenario("forecast_scenario", task_configs=[task_cfg]) ++ register_id, queue = Notifier.register(entity_type=EventEntityType.SCENARIO, operation=EventOperation.CREATION) ++ ++ scenario = tp.create_scenario(scenario_cfg, datetime(2026, 7, 22, 10, 30)) ++ event = queue.get_nowait() ++ Notifier.unregister(register_id) ++ emit({ ++ "entity_type": event.entity_type.name, ++ "operation": event.operation.name, ++ "entity_id_matches": event.entity_id == scenario.id, ++ "attribute_name": event.attribute_name, ++ "attribute_value": event.attribute_value, ++ "metadata_config_id": event.metadata.get("config_id"), ++ "metadata_keys": sorted(event.metadata.keys()), ++ }) ++ """, ++ tmp_path, ++ ) ++ ++ ++ assert result["entity_type"] == "SCENARIO" ++ assert result["operation"] == "CREATION" ++ assert result["entity_id_matches"] is True ++ ++ ++def test_referential_transparency_same_config_summary(tmp_path): ++ result = run_python( ++ """ ++ configure_storage("referential") ++ input_cfg = Config.configure_data_node("input_cfg", storage_type="in_memory") ++ output_cfg = Config.configure_data_node("output_cfg", storage_type="in_memory") ++ task_cfg = Config.configure_task("forecast_task", identity, input_cfg, output_cfg) ++ scenario_cfg = Config.configure_scenario("forecast_scenario", task_configs=[task_cfg]) ++ creation_date = datetime(2026, 7, 22, 10, 30) ++ ++ first = scenario_summary(tp.create_scenario(scenario_cfg, creation_date)) ++ second = scenario_summary(tp.create_scenario(scenario_cfg, creation_date)) ++ emit({"first": first, "second": second}) ++ """, ++ tmp_path, ++ ) ++ ++ ++ for key in ("first", "second"): ++ assert_scenario_summary( ++ result[key], ++ config_id="forecast_scenario", ++ task_config_ids=["forecast_task"], ++ data_node_config_ids=["input_cfg", "output_cfg"], ++ task_data_nodes={"forecast_task": ["input_cfg", "output_cfg"]}, ++ ) ++ ++ ++def test_create_scenario_does_not_mutate_caller_config(tmp_path): ++ result = run_python( ++ """ ++ configure_storage("mutation") ++ input_cfg = Config.configure_data_node("input_cfg", storage_type="in_memory") ++ output_cfg = Config.configure_data_node("output_cfg", storage_type="in_memory") ++ extra_cfg = Config.configure_data_node("audit_notes", storage_type="in_memory") ++ task_cfg = Config.configure_task("forecast_task", identity, input_cfg, output_cfg) ++ scenario_cfg = Config.configure_scenario( ++ "extra_scenario", task_configs=[task_cfg], additional_data_node_configs=[extra_cfg] ++ ) ++ ++ emit(scenario_summary(tp.create_scenario(scenario_cfg, datetime(2026, 7, 22, 10, 30)))) ++ """, ++ tmp_path, ++ ) ++ ++ ++ assert_scenario_summary( ++ result, ++ config_id="extra_scenario", ++ task_config_ids=["forecast_task"], ++ data_node_config_ids=["audit_notes", "input_cfg", "output_cfg"], ++ additional_data_node_config_ids=["audit_notes"], ++ task_data_nodes={"forecast_task": ["input_cfg", "output_cfg"]}, ++ ) ++ ++ ++def test_no_global_state_across_fresh_python_process(tmp_path): ++ result = run_python( ++ """ ++ import os ++ import subprocess ++ import sys ++ ++ configure_storage("global_parent") ++ input_cfg = Config.configure_data_node("input_cfg", storage_type="in_memory") ++ output_cfg = Config.configure_data_node("output_cfg", storage_type="in_memory") ++ task_cfg = Config.configure_task("forecast_task", identity, input_cfg, output_cfg) ++ scenario_cfg = Config.configure_scenario("forecast_scenario", task_configs=[task_cfg]) ++ in_process = scenario_summary(tp.create_scenario(scenario_cfg, datetime(2026, 7, 22, 10, 30))) ++ ++ child_code = "\\n".join([ ++ "import json", ++ "from datetime import datetime", ++ "import taipy as tp", ++ "from taipy import Config", ++ "", ++ "def identity(x):", ++ " return x", ++ "", ++ "def sequence_task_ids(sequence):", ++ " return list(sequence.tasks.keys())", ++ "", ++ "def scenario_summary(scenario):", ++ " return {", ++ " 'config_id': scenario.config_id,", ++ " 'task_config_ids': sorted(scenario.tasks.keys()),", ++ " 'data_node_config_ids': sorted(scenario.data_nodes.keys()),", ++ " 'additional_data_node_config_ids': sorted(scenario.additional_data_nodes.keys()),", ++ " 'task_data_nodes': {k: sorted(v.data_nodes.keys()) for k, v in sorted(scenario.tasks.items())},", ++ " 'name': scenario.name,", ++ " 'creation_date': scenario.creation_date.isoformat(),", ++ " 'cycle': None if scenario.cycle is None else {", ++ " 'frequency': scenario.cycle.frequency.name,", ++ " 'creation_date': scenario.cycle.creation_date.isoformat(),", ++ " 'start_date': scenario.cycle.start_date.isoformat(),", ++ " 'end_date': scenario.cycle.end_date.isoformat(),", ++ " 'name': scenario.cycle.name,", ++ " },", ++ " 'owner_id_matches_cycle': scenario.owner_id == (scenario.cycle.id if scenario.cycle else None),", ++ " 'is_primary': scenario.is_primary,", ++ " 'sequences': {name: sequence_task_ids(seq) for name, seq in sorted(scenario.sequences.items())},", ++ " }", ++ "", ++ "Config.configure_core(storage_folder='.declared_data_global_child', taipy_storage_folder='.declared_taipy_global_child')", ++ "input_cfg = Config.configure_data_node('input_cfg', storage_type='in_memory')", ++ "output_cfg = Config.configure_data_node('output_cfg', storage_type='in_memory')", ++ "task_cfg = Config.configure_task('forecast_task', identity, input_cfg, output_cfg)", ++ "scenario_cfg = Config.configure_scenario('forecast_scenario', task_configs=[task_cfg])", ++ "result = scenario_summary(tp.create_scenario(scenario_cfg, datetime(2026, 7, 22, 10, 30)))", ++ "print('__CHILD_RESULT__' + json.dumps(result, sort_keys=True))", ++ ]) ++ env = os.environ.copy() ++ proc = subprocess.run( ++ [sys.executable, "-c", child_code], ++ cwd=os.getcwd(), ++ env=env, ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.STDOUT, ++ check=True, ++ ) ++ fresh_process = None ++ for line in reversed(proc.stdout.splitlines()): ++ if line.startswith("__CHILD_RESULT__"): ++ fresh_process = json.loads(line[len("__CHILD_RESULT__"):]) ++ break ++ emit({"in_process": in_process, "fresh_process": fresh_process}) ++ """, ++ tmp_path, ++ ) ++ ++ ++ for key in ("in_process", "fresh_process"): ++ assert_scenario_summary( ++ result[key], ++ config_id="forecast_scenario", ++ task_config_ids=["forecast_task"], ++ data_node_config_ids=["input_cfg", "output_cfg"], ++ task_data_nodes={"forecast_task": ["input_cfg", "output_cfg"]}, ++ ) ++ ++ ++def test_no_undeclared_network_or_cwd_file_side_effects(tmp_path): ++ result = run_python( ++ """ ++ import os ++ import socket ++ ++ def blocked_socket(*args, **kwargs): ++ raise AssertionError("network access is not declared") ++ ++ socket.socket = blocked_socket ++ before = set(os.listdir(".")) ++ configure_storage("sideeffects") ++ input_cfg = Config.configure_data_node("input_cfg", storage_type="in_memory") ++ output_cfg = Config.configure_data_node("output_cfg", storage_type="in_memory") ++ task_cfg = Config.configure_task("forecast_task", identity, input_cfg, output_cfg) ++ scenario_cfg = Config.configure_scenario("forecast_scenario", task_configs=[task_cfg]) ++ ++ tp.create_scenario(scenario_cfg, datetime(2026, 7, 22, 10, 30)) ++ after = set(os.listdir(".")) ++ emit({"created_entries": sorted(after - before)}) ++ """, ++ tmp_path, ++ ) ++ ++ ++ assert ".declared_taipy_sideeffects" in result["created_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,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++exec /workspace/repo/.venv/bin/python -m pytest /workspace/repo/usercase-test-coderl/test_create_scenario.py -v diff --git a/tasks/format-code-task-000488/tests/test.sh b/tasks/format-code-task-000488/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..16d4d39550fa98f94bcfff5e9e5058cf8a7f8f66 --- /dev/null +++ b/tasks/format-code-task-000488/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_create_scenario.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-000488/tests/test_command.sh b/tasks/format-code-task-000488/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000488/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-000613/environment/Dockerfile b/tasks/format-code-task-000613/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b280bbc0a2b71b33c1e0b6f33b52f9c642c7bfcb --- /dev/null +++ b/tasks/format-code-task-000613/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:655b2c7aa9681d1ddb7c9acea0344ccd689e9dc0fd258204c782e4bc1741b3b2 diff --git a/tasks/format-code-task-000613/environment/setup/files/blocklist b/tasks/format-code-task-000613/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000613/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000613/environment/setup/setup.sh b/tasks/format-code-task-000613/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000613/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000613/tests/test.patch b/tasks/format-code-task-000613/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f5a9832010a04db0c3e0628095df8d1397de85a0 --- /dev/null +++ b/tasks/format-code-task-000613/tests/test.patch @@ -0,0 +1,574 @@ +diff --git a/usercase-test-coderl/test_table_exports.py b/usercase-test-coderl/test_table_exports.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_table_exports.py +@@ -0,0 +1,541 @@ ++ ++ ++ ++ ++ ++ ++ ++from __future__ import annotations ++ ++import json ++import os ++import socket ++import sqlite3 ++import subprocess ++import sys ++import zipfile ++from html.parser import HTMLParser ++from pathlib import Path ++ ++import pandas as pd ++import pytest ++from openpyxl import load_workbook ++ ++from camelot.core import Table ++from camelot.core import TableList ++ ++ ++CSV_AB = '"A","B"\n"1","2"\n' ++CSV_CD = '"C","D"\n"3","4"\n' ++RECORDS_AB = [{"0": "A", "1": "B"}, {"0": "1", "1": "2"}] ++RECORDS_CD = [{"0": "C", "1": "D"}, {"0": "3", "1": "4"}] ++ ++ ++class _HTMLTextCollector(HTMLParser): ++ def __init__(self): ++ super().__init__() ++ self.text = [] ++ ++ def handle_data(self, data): ++ value = data.strip() ++ if value: ++ self.text.append(value) ++ ++ ++def make_table(data=None, page=1, order=2): ++ table = Table(cols=[(0, 50), (50, 100)], rows=[(100, 50), (50, 0)]) ++ table.df = pd.DataFrame(data or [["A", "B"], ["1", "2"]]) ++ table.shape = table.df.shape ++ table.page = page ++ table.order = order ++ return table ++ ++ ++def make_table_list(): ++ return TableList( ++ [ ++ make_table([["A", "B"], ["1", "2"]], page=1, order=1), ++ make_table([["C", "D"], ["3", "4"]], page=2, order=1), ++ ] ++ ) ++ ++ ++def worksheet_matrix(path, sheet_name): ++ workbook = load_workbook(path) ++ sheet = workbook[sheet_name] ++ return [ ++ [sheet.cell(row=row, column=col).value for col in range(1, sheet.max_column + 1)] ++ for row in range(1, sheet.max_row + 1) ++ ] ++ ++ ++def assert_records_json(text, expected): ++ ++ assert json.loads(text) == expected ++ ++ ++def assert_html_table_text(text, expected_values): ++ ++ assert "" in text.lower() ++ parser = _HTMLTextCollector() ++ parser.feed(text) ++ for value in expected_values: ++ assert value in parser.text ++ ++ ++def assert_markdown_table_text(text, expected_values): ++ ++ table_lines = [line for line in text.splitlines() if "|" in line] ++ assert len(table_lines) >= 3 ++ for value in expected_values: ++ assert value in text ++ ++ ++def assert_sheet_contains_values(path, sheet_name, expected_values): ++ ++ matrix = worksheet_matrix(path, sheet_name) ++ flat = [value for row in matrix for value in row] ++ for value in expected_values: ++ assert value in flat ++ ++ ++def assert_zip_member_content(archive, fmt, members): ++ ++ first, second = members ++ if fmt == "csv": ++ assert archive.read(first).decode("utf-8") == CSV_AB ++ assert archive.read(second).decode("utf-8") == CSV_CD ++ elif fmt == "json": ++ assert_records_json(archive.read(first).decode("utf-8"), RECORDS_AB) ++ assert_records_json(archive.read(second).decode("utf-8"), RECORDS_CD) ++ elif fmt == "html": ++ assert_html_table_text(archive.read(first).decode("utf-8"), ["A", "B", "1", "2"]) ++ assert_html_table_text(archive.read(second).decode("utf-8"), ["C", "D", "3", "4"]) ++ elif fmt == "markdown": ++ assert_markdown_table_text(archive.read(first).decode("utf-8"), ["A", "B", "1", "2"]) ++ assert_markdown_table_text(archive.read(second).decode("utf-8"), ["C", "D", "3", "4"]) ++ else: ++ raise AssertionError(f"unexpected compressed export format: {fmt}") ++ ++ ++def assert_zipped_single_artifact(tmp_path, archive, fmt, expected_member): ++ ++ extract_dir = tmp_path / "zipcheck" ++ extract_dir.mkdir() ++ extracted = extract_dir / expected_member ++ extracted.write_bytes(archive.read(expected_member)) ++ if fmt == "excel": ++ assert load_workbook(extracted).sheetnames == ["page-1-table-1", "page-2-table-1"] ++ assert_sheet_contains_values(extracted, "page-1-table-1", ["A", "B", "1", "2"]) ++ assert_sheet_contains_values(extracted, "page-2-table-1", ["C", "D", "3", "4"]) ++ elif fmt == "sqlite": ++ assert sqlite_table_names(extracted) == [("page-1-table-1",), ("page-2-table-1",)] ++ assert sqlite_rows(extracted, "page-1-table-1") == [("A", "B"), ("1", "2")] ++ assert sqlite_rows(extracted, "page-2-table-1") == [("C", "D"), ("3", "4")] ++ else: ++ raise AssertionError(f"unexpected compressed export format: {fmt}") ++ ++ ++def sqlite_rows(path, table_name): ++ connection = sqlite3.connect(path) ++ try: ++ return connection.execute(f'select * from "{table_name}"').fetchall() ++ finally: ++ connection.close() ++ ++ ++def sqlite_table_names(path): ++ connection = sqlite3.connect(path) ++ try: ++ return connection.execute( ++ "select name from sqlite_master where type='table' order by name" ++ ).fetchall() ++ finally: ++ connection.close() ++ ++ ++def test_table_to_csv_writes_utf8_csv_without_index_or_header(tmp_path): ++ ++ ++ ++ ++ path = tmp_path / "out.csv" ++ ++ result = make_table().to_csv(path) ++ ++ assert result is None ++ assert path.read_bytes() == b'"A","B"\n"1","2"\n' ++ assert path.read_text(encoding="utf-8") == CSV_AB ++ ++ ++def test_table_to_json_writes_records_oriented_json(tmp_path): ++ ++ ++ ++ ++ path = tmp_path / "out.json" ++ ++ result = make_table().to_json(path) ++ ++ assert result is None ++ assert_records_json(path.read_text(encoding="utf-8"), RECORDS_AB) ++ ++ ++def test_table_to_json_mode_append_consumed_by_file_open(tmp_path): ++ ++ ++ ++ ++ path = tmp_path / "out.json" ++ path.write_text("prefix|", encoding="utf-8") ++ ++ result = make_table().to_json(path, mode="a") ++ ++ assert result is None ++ text = path.read_text(encoding="utf-8") ++ assert text.startswith("prefix|") ++ assert_records_json(text.removeprefix("prefix|"), RECORDS_AB) ++ ++ ++def test_table_to_excel_writes_named_sheet_without_index_or_headers(tmp_path): ++ ++ ++ ++ ++ path = tmp_path / "out.xlsx" ++ ++ result = make_table().to_excel(path) ++ ++ assert result is None ++ assert load_workbook(path).sheetnames == ["page-1-table-2"] ++ ++ assert worksheet_matrix(path, "page-1-table-2") == [["A", "B"], ["1", "2"]] ++ ++ ++def test_table_to_excel_allows_index_and_header_kwargs_to_override_defaults(tmp_path): ++ ++ ++ ++ ++ path = tmp_path / "out.xlsx" ++ ++ result = make_table().to_excel(path, index=True, header=True) ++ ++ assert result is None ++ ++ assert worksheet_matrix(path, "page-1-table-2") == [ ++ [None, 0, 1], ++ [0, "A", "B"], ++ [1, "1", "2"], ++ ] ++ ++ ++def test_table_to_html_writes_pandas_html_and_appends_with_mode(tmp_path): ++ ++ ++ ++ ++ path = tmp_path / "out.html" ++ path.write_text("prefix|", encoding="utf-8") ++ ++ result = make_table().to_html(path, mode="a") ++ ++ assert result is None ++ text = path.read_text(encoding="utf-8") ++ assert text.startswith("prefix|") ++ assert_html_table_text(text.removeprefix("prefix|"), ["A", "B", "1", "2"]) ++ ++ ++def test_table_to_markdown_writes_pandas_markdown_and_appends_with_mode(tmp_path): ++ ++ ++ ++ ++ path = tmp_path / "out.md" ++ path.write_text("prefix|", encoding="utf-8") ++ ++ result = make_table().to_markdown(path, mode="a") ++ ++ assert result is None ++ text = path.read_text(encoding="utf-8") ++ assert text.startswith("prefix|") ++ assert_markdown_table_text(text.removeprefix("prefix|"), ["A", "B", "1", "2"]) ++ ++ ++def test_table_to_sqlite_replaces_named_table_without_index_column(tmp_path): ++ ++ ++ ++ ++ path = tmp_path / "out.sqlite" ++ ++ result = make_table().to_sqlite(path) ++ ++ assert result is None ++ assert sqlite_table_names(path) == [("page-1-table-2",)] ++ assert sqlite_rows(path, "page-1-table-2") == [("A", "B"), ("1", "2")] ++ ++ ++def test_tablelist_export_csv_writes_one_named_file_per_table(tmp_path): ++ ++ ++ ++ ++ result = make_table_list().export(str(tmp_path / "out.csv"), f="csv") ++ ++ assert result is None ++ assert sorted(path.name for path in tmp_path.iterdir()) == [ ++ "out-page-1-table-1.csv", ++ "out-page-2-table-1.csv", ++ ] ++ assert (tmp_path / "out-page-1-table-1.csv").read_text(encoding="utf-8") == CSV_AB ++ assert (tmp_path / "out-page-2-table-1.csv").read_text(encoding="utf-8") == CSV_CD ++ ++ ++def test_tablelist_export_json_writes_one_named_file_per_table(tmp_path): ++ ++ ++ ++ ++ result = make_table_list().export(str(tmp_path / "out.json"), f="json") ++ ++ assert result is None ++ assert sorted(path.name for path in tmp_path.iterdir()) == [ ++ "out-page-1-table-1.json", ++ "out-page-2-table-1.json", ++ ] ++ assert_records_json( ++ (tmp_path / "out-page-1-table-1.json").read_text(encoding="utf-8"), ++ RECORDS_AB, ++ ) ++ assert_records_json( ++ (tmp_path / "out-page-2-table-1.json").read_text(encoding="utf-8"), ++ RECORDS_CD, ++ ) ++ ++ ++def test_tablelist_export_html_writes_one_named_file_per_table(tmp_path): ++ ++ ++ ++ ++ result = make_table_list().export(str(tmp_path / "out.html"), f="html") ++ ++ assert result is None ++ assert sorted(path.name for path in tmp_path.iterdir()) == [ ++ "out-page-1-table-1.html", ++ "out-page-2-table-1.html", ++ ] ++ assert_html_table_text( ++ (tmp_path / "out-page-1-table-1.html").read_text(encoding="utf-8"), ++ ["A", "B", "1", "2"], ++ ) ++ assert_html_table_text( ++ (tmp_path / "out-page-2-table-1.html").read_text(encoding="utf-8"), ++ ["C", "D", "3", "4"], ++ ) ++ ++ ++def test_tablelist_export_markdown_writes_one_named_file_per_table(tmp_path): ++ ++ ++ ++ ++ result = make_table_list().export(str(tmp_path / "out.md"), f="markdown") ++ ++ assert result is None ++ assert sorted(path.name for path in tmp_path.iterdir()) == [ ++ "out-page-1-table-1.md", ++ "out-page-2-table-1.md", ++ ] ++ assert_markdown_table_text( ++ (tmp_path / "out-page-1-table-1.md").read_text(encoding="utf-8"), ++ ["A", "B", "1", "2"], ++ ) ++ assert_markdown_table_text( ++ (tmp_path / "out-page-2-table-1.md").read_text(encoding="utf-8"), ++ ["C", "D", "3", "4"], ++ ) ++ ++ ++def test_tablelist_export_excel_creates_single_workbook_at_exact_path(tmp_path): ++ ++ ++ ++ ++ path = tmp_path / "book.xlsx" ++ ++ result = make_table_list().export(str(path), f="excel") ++ ++ assert result is None ++ assert sorted(child.name for child in tmp_path.iterdir()) == ["book.xlsx"] ++ assert load_workbook(path).sheetnames == ["page-1-table-1", "page-2-table-1"] ++ assert_sheet_contains_values(path, "page-1-table-1", ["A", "B", "1", "2"]) ++ assert_sheet_contains_values(path, "page-2-table-1", ["C", "D", "3", "4"]) ++ ++ ++def test_tablelist_export_sqlite_creates_single_database_at_exact_path(tmp_path): ++ ++ ++ ++ ++ path = tmp_path / "db.sqlite" ++ ++ result = make_table_list().export(str(path), f="sqlite") ++ ++ assert result is None ++ assert sorted(child.name for child in tmp_path.iterdir()) == ["db.sqlite"] ++ assert sqlite_table_names(path) == [("page-1-table-1",), ("page-2-table-1",)] ++ assert sqlite_rows(path, "page-1-table-1") == [("A", "B"), ("1", "2")] ++ assert sqlite_rows(path, "page-2-table-1") == [("C", "D"), ("3", "4")] ++ ++ ++@pytest.mark.parametrize( ++ ("fmt", "extension", "expected_members"), ++ [ ++ ("csv", ".csv", ["zipout-page-1-table-1.csv", "zipout-page-2-table-1.csv"]), ++ ( ++ "html", ++ ".html", ++ ["zipout-page-1-table-1.html", "zipout-page-2-table-1.html"], ++ ), ++ ( ++ "json", ++ ".json", ++ ["zipout-page-1-table-1.json", "zipout-page-2-table-1.json"], ++ ), ++ ( ++ "markdown", ++ ".md", ++ ["zipout-page-1-table-1.md", "zipout-page-2-table-1.md"], ++ ), ++ ], ++) ++def test_tablelist_export_compresses_multi_file_formats_into_zip( ++ tmp_path, fmt, extension, expected_members ++): ++ ++ ++ ++ ++ result = make_table_list().export(str(tmp_path / f"zipout{extension}"), f=fmt, compress=True) ++ ++ assert result is None ++ assert sorted(child.name for child in tmp_path.iterdir()) == ["zipout.zip"] ++ with zipfile.ZipFile(tmp_path / "zipout.zip") as archive: ++ assert sorted(archive.namelist()) == expected_members ++ assert_zip_member_content(archive, fmt, expected_members) ++ ++ ++@pytest.mark.parametrize( ++ ("fmt", "extension", "expected_member"), ++ [("excel", ".xlsx", "zipout.xlsx"), ("sqlite", ".sqlite", "zipout.sqlite")], ++) ++def test_tablelist_export_compresses_single_artifact_formats_into_zip( ++ tmp_path, fmt, extension, expected_member ++): ++ ++ ++ ++ ++ result = make_table_list().export(str(tmp_path / f"zipout{extension}"), f=fmt, compress=True) ++ ++ assert result is None ++ assert sorted(child.name for child in tmp_path.iterdir()) == ["zipout.zip"] ++ with zipfile.ZipFile(tmp_path / "zipout.zip") as archive: ++ assert sorted(archive.namelist()) == [expected_member] ++ assert_zipped_single_artifact(tmp_path, archive, fmt, expected_member) ++ ++ ++def test_table_to_json_writes_to_requested_path(tmp_path): ++ ++ path = tmp_path / "out.json" ++ ++ result = make_table().to_json(path) ++ ++ assert result is None ++ assert path.exists() ++ assert_records_json(path.read_text(encoding="utf-8"), RECORDS_AB) ++ ++ ++def test_referential_transparency_for_same_table_export_result(tmp_path): ++ first_path = tmp_path / "first.json" ++ second_path = tmp_path / "second.json" ++ table = make_table() ++ ++ first = table.to_json(first_path) ++ second = table.to_json(second_path) ++ ++ assert first == second == None ++ assert_records_json(first_path.read_text(encoding="utf-8"), RECORDS_AB) ++ assert_records_json(second_path.read_text(encoding="utf-8"), RECORDS_AB) ++ ++ ++def test_table_export_does_not_mutate_caller_table(tmp_path): ++ table = make_table() ++ before_df = table.df.copy(deep=True) ++ before_page = table.page ++ before_order = table.order ++ ++ table.to_csv(tmp_path / "out.csv") ++ ++ assert table.df.equals(before_df) ++ ++ assert table.page == before_page ++ assert table.order == before_order ++ ++ ++def test_no_global_state_matches_fresh_process_for_same_input(tmp_path): ++ in_process_path = tmp_path / "in_process.json" ++ make_table().to_json(in_process_path) ++ in_process = in_process_path.read_text(encoding="utf-8") ++ child_path = tmp_path / "child.json" ++ script = f""" ++import sys ++from pathlib import Path ++sys.path.insert(0, {str(Path('/workspace/repo'))!r}) ++import pandas as pd ++from camelot.core import Table ++t = Table(cols=[(0, 50), (50, 100)], rows=[(100, 50), (50, 0)]) ++t.df = pd.DataFrame([["A", "B"], ["1", "2"]]) ++t.shape = t.df.shape ++t.page = 1 ++t.order = 2 ++t.to_json(Path({str(child_path)!r})) ++sys.stdout.write(Path({str(child_path)!r}).read_text(encoding="utf-8")) ++""" ++ ++ fresh_process = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ ).stdout ++ ++ assert_records_json(in_process, RECORDS_AB) ++ assert_records_json(fresh_process, RECORDS_AB) ++ ++ ++def test_export_writes_only_declared_output_files_and_never_uses_network( ++ tmp_path, monkeypatch ++): ++ def fail_socket(*args, **kwargs): ++ raise AssertionError("network access is not declared by the export contract") ++ ++ monkeypatch.setattr(socket, "socket", fail_socket) ++ previous_cwd = Path.cwd() ++ try: ++ os.chdir(tmp_path) ++ before = sorted(path.name for path in tmp_path.iterdir()) ++ result = make_table_list().export("reports.csv", f="csv") ++ after = sorted(path.name for path in tmp_path.iterdir()) ++ finally: ++ os.chdir(previous_cwd) ++ ++ assert before == [] ++ assert result is None ++ assert after == ["reports-page-1-table-1.csv", "reports-page-2-table-1.csv"] ++ assert (tmp_path / "reports-page-1-table-1.csv").read_text(encoding="utf-8") == CSV_AB ++ assert (tmp_path / "reports-page-2-table-1.csv").read_text(encoding="utf-8") == CSV_CD +diff --git 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 ++PYTHON=/workspace/repo/.venv/bin/python ++if [ ! -x "$PYTHON" ]; then ++ echo "Expected offline test venv missing at $PYTHON" >&2 ++ exit 1 ++fi ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:$PYTHONPATH}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++exec "$PYTHON" -m pytest /workspace/repo/usercase-test-coderl/test_table_exports.py -v diff --git a/tasks/format-code-task-000613/tests/test.sh b/tasks/format-code-task-000613/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c0333f236d1cb0f20625b1495d68498f45537462 --- /dev/null +++ b/tasks/format-code-task-000613/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_table_exports.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-000613/tests/test_command.sh b/tasks/format-code-task-000613/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000613/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-000614/environment/Dockerfile b/tasks/format-code-task-000614/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..126c62cce0a4f8b16d83db542a768a7f520bae6f --- /dev/null +++ b/tasks/format-code-task-000614/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2d3e3e6c602a2d5acb6a6e8948458f8c5905e93babab71b8ad1219ec51a788c8 diff --git a/tasks/format-code-task-000614/environment/setup/files/blocklist b/tasks/format-code-task-000614/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000614/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000614/environment/setup/setup.sh b/tasks/format-code-task-000614/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000614/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000614/tests/test.patch b/tasks/format-code-task-000614/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ab7cb41fd088857bb6cec420d9b7168c80c93309 --- /dev/null +++ b/tasks/format-code-task-000614/tests/test.patch @@ -0,0 +1,789 @@ +diff --git a/usercase-test-coderl/test_stack_contiguous_acceptance.py b/usercase-test-coderl/test_stack_contiguous_acceptance.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_stack_contiguous_acceptance.py +@@ -0,0 +1,753 @@ ++ ++ ++ ++ ++ ++ ++ ++from __future__ import annotations ++ ++import copy ++import json ++import os ++import socket ++import subprocess ++import sys ++ ++import pandas as pd ++import pytest ++ ++from camelot.core import Table ++from camelot.core import TableList ++ ++ ++def make_table( ++ values, ++ page=1, ++ order=1, ++ accuracy=95.0, ++ whitespace=5.0, ++ x_step=100, ++ top=300, ++ row_height=20, ++): ++ ncols = len(values[0]) if values else 0 ++ xs = [i * x_step for i in range(ncols + 1)] ++ ys = [top - i * row_height for i in range(len(values) + 1)] ++ cols = list(zip(xs[:-1], xs[1:])) ++ rows = list(zip(ys[:-1], ys[1:])) ++ table = Table(cols=cols, rows=rows) ++ table.df = pd.DataFrame(values) ++ table.shape = table.df.shape ++ table.page = page ++ table.order = order ++ table.accuracy = accuracy ++ table.whitespace = whitespace ++ table._bbox = (min(xs), min(ys), max(xs), max(ys)) if xs and ys else None ++ return table ++ ++ ++def table_summary(table): ++ return { ++ "df": table.df.values.tolist(), ++ "shape": list(table.df.shape), ++ "page": table.page, ++ "order": table.order, ++ "accuracy": table.accuracy, ++ "whitespace": table.whitespace, ++ "confidence": table.confidence, ++ "parsing_report": table.parsing_report, ++ "rows": [list(row) for row in table.rows], ++ "first_cell": [ ++ table.cells[0][0].x1, ++ table.cells[0][0].y1, ++ table.cells[0][0].x2, ++ table.cells[0][0].y2, ++ ], ++ "last_cell": [ ++ table.cells[-1][-1].x1, ++ table.cells[-1][-1].y1, ++ table.cells[-1][-1].x2, ++ table.cells[-1][-1].y2, ++ ], ++ } ++ ++ ++def table_list_summary(table_list): ++ return [table_summary(table) for table in table_list] ++ ++ ++GEOMETRY_KEYS = {"rows", "first_cell", "last_cell"} ++ ++ ++def assert_spec_value(actual, expected): ++ if isinstance(expected, float): ++ ++ assert actual == pytest.approx(expected) ++ elif isinstance(expected, dict): ++ assert actual.keys() == expected.keys() ++ for key, expected_value in expected.items(): ++ assert_spec_value(actual[key], expected_value) ++ elif isinstance(expected, list): ++ assert len(actual) == len(expected) ++ for actual_value, expected_value in zip(actual, expected): ++ assert_spec_value(actual_value, expected_value) ++ else: ++ assert actual == expected ++ ++ ++def assert_summary_matches_spec(actual, expected): ++ ++ ++ ++ assert len(actual) == len(expected) ++ for table, expected_table in zip(actual, expected): ++ actual_non_geometry = { ++ key: value for key, value in table.items() if key not in GEOMETRY_KEYS ++ } ++ expected_non_geometry = { ++ key: value ++ for key, value in expected_table.items() ++ if key not in GEOMETRY_KEYS ++ } ++ assert_spec_value(actual_non_geometry, expected_non_geometry) ++ assert len(table["rows"]) >= len(table["df"]) ++ assert len(table["first_cell"]) == 4 ++ assert len(table["last_cell"]) == 4 ++ assert table["first_cell"][1] == table["rows"][0][1] ++ assert table["first_cell"][3] == table["rows"][0][0] ++ assert table["last_cell"][1] == table["rows"][-1][1] ++ assert table["last_cell"][3] == table["rows"][-1][0] ++ for top, bottom in table["rows"]: ++ assert top >= bottom ++ for previous, current in zip(table["rows"], table["rows"][1:]): ++ assert previous[1] >= current[0] ++ ++ ++def test_default_column_count_stacks_two_adjacent_tables(): ++ ++ ++ ++ result = TableList( ++ [ ++ make_table( ++ [["1", "Alice"], ["2", "Bob"]], ++ page=5, ++ order=2, ++ accuracy=88.0, ++ whitespace=4.0, ++ ), ++ make_table( ++ [["3", "Charlie"], ["4", "Diana"]], ++ page=6, ++ order=1, ++ accuracy=92.0, ++ whitespace=8.0, ++ ), ++ ] ++ ).stack_contiguous() ++ ++ assert_summary_matches_spec(table_list_summary(result), [ ++ { ++ "df": [["1", "Alice"], ["2", "Bob"], ["3", "Charlie"], ["4", "Diana"]], ++ "shape": [4, 2], ++ "page": 5, ++ "order": 2, ++ "accuracy": 90.0, ++ "whitespace": 6.0, ++ "confidence": 0.846, ++ "parsing_report": { ++ "accuracy": 90.0, ++ "whitespace": 6.0, ++ "order": 2, ++ "page": 5, ++ "confidence": 0.846, ++ }, ++ "rows": [[300, 280], [280, 260], [260, 240], [240, 220]], ++ "first_cell": [0, 280, 100, 300], ++ "last_cell": [100, 220, 200, 240], ++ } ++ ]) ++ ++ ++def test_default_column_count_keeps_different_width_tables_separate(): ++ ++ ++ ++ result = TableList( ++ [ ++ make_table([["1", "Alice"], ["2", "Bob"]], page=1, order=1), ++ make_table( ++ [["3", "Charlie", "NY"], ["4", "Diana", "LA"]], ++ page=2, ++ order=1, ++ x_step=80, ++ ), ++ ] ++ ).stack_contiguous() ++ ++ assert_summary_matches_spec(table_list_summary(result), [ ++ { ++ "df": [["1", "Alice"], ["2", "Bob"]], ++ "shape": [2, 2], ++ "page": 1, ++ "order": 1, ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "confidence": 0.9025, ++ "parsing_report": { ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "order": 1, ++ "page": 1, ++ "confidence": 0.9025, ++ }, ++ "rows": [[300, 280], [280, 260]], ++ "first_cell": [0, 280, 100, 300], ++ "last_cell": [100, 260, 200, 280], ++ }, ++ { ++ "df": [["3", "Charlie", "NY"], ["4", "Diana", "LA"]], ++ "shape": [2, 3], ++ "page": 2, ++ "order": 1, ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "confidence": 0.9025, ++ "parsing_report": { ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "order": 1, ++ "page": 2, ++ "confidence": 0.9025, ++ }, ++ "rows": [[300, 280], [280, 260]], ++ "first_cell": [0, 280, 80, 300], ++ "last_cell": [160, 260, 240, 280], ++ }, ++ ]) ++ ++ ++def test_column_count_stacks_only_each_contiguous_compatible_run(): ++ ++ ++ ++ result = TableList( ++ [ ++ make_table( ++ [["1", "Alice"]], ++ page=7, ++ order=1, ++ accuracy=80.0, ++ whitespace=10.0, ++ ), ++ make_table( ++ [["2", "Bob"]], ++ page=8, ++ order=1, ++ accuracy=90.0, ++ whitespace=20.0, ++ ), ++ make_table( ++ [["code", "name", "city"]], ++ page=9, ++ order=1, ++ accuracy=100.0, ++ whitespace=0.0, ++ x_step=75, ++ ), ++ ] ++ ).stack_contiguous() ++ ++ summary = table_list_summary(result) ++ assert_summary_matches_spec( ++ summary, ++ [ ++ { ++ "df": [["1", "Alice"], ["2", "Bob"]], ++ "shape": [2, 2], ++ "page": 7, ++ "order": 1, ++ "accuracy": 85.0, ++ "whitespace": 15.0, ++ "confidence": 0.7225, ++ "parsing_report": { ++ "accuracy": 85.0, ++ "whitespace": 15.0, ++ "order": 1, ++ "page": 7, ++ "confidence": 0.7225, ++ }, ++ "rows": [[300, 280], [280, 260]], ++ "first_cell": [0, 280, 100, 300], ++ "last_cell": [100, 260, 200, 280], ++ }, ++ { ++ "df": [["code", "name", "city"]], ++ "shape": [1, 3], ++ "page": 9, ++ "order": 1, ++ "accuracy": 100.0, ++ "whitespace": 0.0, ++ "confidence": 1.0, ++ "parsing_report": { ++ "accuracy": 100.0, ++ "whitespace": 0.0, ++ "order": 1, ++ "page": 9, ++ "confidence": 1.0, ++ }, ++ "rows": [[300, 280]], ++ "first_cell": [0, 280, 75, 300], ++ "last_cell": [150, 280, 225, 300], ++ }, ++ ], ++ ) ++ ++ ++def test_first_row_match_drops_continuation_header_by_default(): ++ ++ ++ ++ result = TableList( ++ [ ++ make_table( ++ [["ID", "Name"], ["1", "Alice"], ["2", "Bob"]], ++ page=10, ++ order=3, ++ accuracy=81.0, ++ whitespace=11.0, ++ ), ++ make_table( ++ [["ID", "Name"], ["3", "Charlie"]], ++ page=11, ++ order=1, ++ accuracy=99.0, ++ whitespace=1.0, ++ ), ++ ] ++ ).stack_contiguous(match="first_row") ++ ++ assert_summary_matches_spec(table_list_summary(result), [ ++ { ++ "df": [["ID", "Name"], ["1", "Alice"], ["2", "Bob"], ["3", "Charlie"]], ++ "shape": [4, 2], ++ "page": 10, ++ "order": 3, ++ "accuracy": 90.0, ++ "whitespace": 6.0, ++ "confidence": 0.846, ++ "parsing_report": { ++ "accuracy": 90.0, ++ "whitespace": 6.0, ++ "order": 3, ++ "page": 10, ++ "confidence": 0.846, ++ }, ++ "rows": [[300, 280], [280, 260], [260, 240], [240, 220], [220, 200]], ++ "first_cell": [0, 280, 100, 300], ++ "last_cell": [100, 200, 200, 220], ++ } ++ ]) ++ ++ ++def test_first_row_match_can_keep_repeated_headers(): ++ ++ ++ ++ result = TableList( ++ [ ++ make_table([["ID", "Name"], ["1", "Alice"]], page=12, order=4), ++ make_table([["ID", "Name"], ["2", "Bob"]], page=13, order=1), ++ ] ++ ).stack_contiguous(match="first_row", keep_first_header=True) ++ ++ assert_summary_matches_spec(table_list_summary(result), [ ++ { ++ "df": [["ID", "Name"], ["1", "Alice"], ["ID", "Name"], ["2", "Bob"]], ++ "shape": [4, 2], ++ "page": 12, ++ "order": 4, ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "confidence": 0.9025, ++ "parsing_report": { ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "order": 4, ++ "page": 12, ++ "confidence": 0.9025, ++ }, ++ "rows": [[300, 280], [280, 260], [260, 240], [240, 220]], ++ "first_cell": [0, 280, 100, 300], ++ "last_cell": [100, 220, 200, 240], ++ } ++ ]) ++ ++ ++def test_first_row_match_rejects_different_header_text(): ++ ++ ++ ++ result = TableList( ++ [ ++ make_table([["ID", "Name"], ["1", "Alice"]], page=14, order=1), ++ make_table([["Number", "Name"], ["2", "Bob"]], page=15, order=1), ++ ] ++ ).stack_contiguous(match="first_row") ++ ++ assert [table.df.values.tolist() for table in result] == [ ++ [["ID", "Name"], ["1", "Alice"]], ++ [["Number", "Name"], ["2", "Bob"]], ++ ] ++ assert [table.parsing_report for table in result] == [ ++ { ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "order": 1, ++ "page": 14, ++ "confidence": 0.9025, ++ }, ++ { ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "order": 1, ++ "page": 15, ++ "confidence": 0.9025, ++ }, ++ ] ++ ++ ++def test_first_row_match_rejects_different_column_count(): ++ ++ ++ ++ result = TableList( ++ [ ++ make_table([["ID", "Name"], ["1", "Alice"]], page=16, order=1), ++ make_table( ++ [["ID", "Name", "City"], ["2", "Bob", "Rome"]], ++ page=17, ++ order=1, ++ x_step=70, ++ ), ++ ] ++ ).stack_contiguous(match="first_row") ++ ++ assert [table.df.values.tolist() for table in result] == [ ++ [["ID", "Name"], ["1", "Alice"]], ++ [["ID", "Name", "City"], ["2", "Bob", "Rome"]], ++ ] ++ assert [[list(row) for row in table.rows] for table in result] == [ ++ [[300, 280], [280, 260]], ++ [[300, 280], [280, 260]], ++ ] ++ assert [ ++ [ ++ table.cells[-1][-1].x1, ++ table.cells[-1][-1].y1, ++ table.cells[-1][-1].x2, ++ table.cells[-1][-1].y2, ++ ] ++ for table in result ++ ] == [ ++ [100, 260, 200, 280], ++ [140, 260, 210, 280], ++ ] ++ ++ ++def test_stacked_run_preserves_first_page_order_and_averages_quality(): ++ ++ ++ ++ result = TableList( ++ [ ++ make_table( ++ [["A", "B"]], ++ page=21, ++ order=5, ++ accuracy=80.0, ++ whitespace=10.0, ++ ), ++ make_table( ++ [["C", "D"]], ++ page=22, ++ order=1, ++ accuracy=100.0, ++ whitespace=0.0, ++ ), ++ ] ++ ).stack_contiguous() ++ ++ assert_summary_matches_spec(table_list_summary(result), [ ++ { ++ "df": [["A", "B"], ["C", "D"]], ++ "shape": [2, 2], ++ "page": 21, ++ "order": 5, ++ "accuracy": 90.0, ++ "whitespace": 5.0, ++ "confidence": 0.855, ++ "parsing_report": { ++ "accuracy": 90.0, ++ "whitespace": 5.0, ++ "order": 5, ++ "page": 21, ++ "confidence": 0.855, ++ }, ++ "rows": [[300, 280], [280, 260]], ++ "first_cell": [0, 280, 100, 300], ++ "last_cell": [100, 260, 200, 280], ++ } ++ ]) ++ ++ ++def test_continuation_geometry_is_shifted_into_one_coherent_stack(): ++ ++ ++ ++ result = TableList( ++ [ ++ make_table( ++ [["1", "Alice"], ["2", "Bob"]], ++ page=31, ++ order=1, ++ top=400, ++ row_height=30, ++ ), ++ make_table( ++ [["3", "Charlie"], ["4", "Diana"]], ++ page=32, ++ order=1, ++ top=250, ++ row_height=25, ++ ), ++ ] ++ ).stack_contiguous() ++ ++ summary = table_list_summary(result) ++ assert_summary_matches_spec(summary, [ ++ { ++ "df": [["1", "Alice"], ["2", "Bob"], ["3", "Charlie"], ["4", "Diana"]], ++ "shape": [4, 2], ++ "page": 31, ++ "order": 1, ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "confidence": 0.9025, ++ "parsing_report": { ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "order": 1, ++ "page": 31, ++ "confidence": 0.9025, ++ }, ++ "rows": [[400, 370], [370, 340], [340, 315], [315, 290]], ++ "first_cell": [0, 370, 100, 400], ++ "last_cell": [100, 290, 200, 315], ++ } ++ ]) ++ ++ ++ assert summary[0]["rows"][2] != [250, 225] ++ assert summary[0]["last_cell"] != [100, 200, 200, 225] ++ ++ ++def test_invalid_match_raises_specific_value_error(): ++ ++ with pytest.raises(ValueError): ++ TableList([]).stack_contiguous(match="bogus") ++ ++ ++def test_referential_transparency_for_equivalent_input(): ++ tables = TableList( ++ [ ++ make_table([["1", "Alice"], ["2", "Bob"]], page=51, order=1), ++ make_table([["3", "Charlie"]], page=52, order=1), ++ ] ++ ) ++ ++ assert table_list_summary(tables.stack_contiguous()) == table_list_summary( ++ tables.stack_contiguous() ++ ) ++ ++ ++def test_does_not_mutate_input_tables_or_alias_returned_tables(): ++ tables = TableList( ++ [ ++ make_table([["1", "Alice"], ["2", "Bob"]], page=61, order=1), ++ make_table([["3", "Charlie"], ["4", "Diana"]], page=62, order=1), ++ ] ++ ) ++ before = copy.deepcopy(table_list_summary(tables)) ++ ++ result = tables.stack_contiguous() ++ result[0].df.iloc[0, 0] = "changed" ++ result[0].cells[0][0].x1 = -999 ++ ++ assert before == [ ++ { ++ "df": [["1", "Alice"], ["2", "Bob"]], ++ "shape": [2, 2], ++ "page": 61, ++ "order": 1, ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "confidence": 0.9025, ++ "parsing_report": { ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "order": 1, ++ "page": 61, ++ "confidence": 0.9025, ++ }, ++ "rows": [[300, 280], [280, 260]], ++ "first_cell": [0, 280, 100, 300], ++ "last_cell": [100, 260, 200, 280], ++ }, ++ { ++ "df": [["3", "Charlie"], ["4", "Diana"]], ++ "shape": [2, 2], ++ "page": 62, ++ "order": 1, ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "confidence": 0.9025, ++ "parsing_report": { ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "order": 1, ++ "page": 62, ++ "confidence": 0.9025, ++ }, ++ "rows": [[300, 280], [280, 260]], ++ "first_cell": [0, 280, 100, 300], ++ "last_cell": [100, 260, 200, 280], ++ }, ++ ] ++ assert table_list_summary(tables) == before ++ ++ ++def test_no_global_state_across_fresh_python_process(): ++ in_process = table_list_summary( ++ TableList( ++ [ ++ make_table([["ID", "Name"], ["1", "Alice"]], page=71, order=1), ++ make_table([["ID", "Name"], ["2", "Bob"]], page=72, order=1), ++ ] ++ ).stack_contiguous(match="first_row") ++ ) ++ script = r""" ++import json ++import pandas as pd ++import sys ++sys.path.insert(0, "/workspace/repo") ++from camelot.core import Table, TableList ++ ++def make_table(values, page=1, order=1, accuracy=95.0, whitespace=5.0): ++ xs = [i * 100 for i in range(len(values[0]) + 1)] ++ ys = [300 - i * 20 for i in range(len(values) + 1)] ++ table = Table(cols=list(zip(xs[:-1], xs[1:])), rows=list(zip(ys[:-1], ys[1:]))) ++ table.df = pd.DataFrame(values) ++ table.shape = table.df.shape ++ table.page = page ++ table.order = order ++ table.accuracy = accuracy ++ table.whitespace = whitespace ++ table._bbox = (min(xs), min(ys), max(xs), max(ys)) ++ return table ++ ++def table_summary(table): ++ return { ++ "df": table.df.values.tolist(), ++ "shape": list(table.df.shape), ++ "page": table.page, ++ "order": table.order, ++ "accuracy": table.accuracy, ++ "whitespace": table.whitespace, ++ "confidence": table.confidence, ++ "parsing_report": table.parsing_report, ++ "rows": [list(row) for row in table.rows], ++ "first_cell": [table.cells[0][0].x1, table.cells[0][0].y1, table.cells[0][0].x2, table.cells[0][0].y2], ++ "last_cell": [table.cells[-1][-1].x1, table.cells[-1][-1].y1, table.cells[-1][-1].x2, table.cells[-1][-1].y2], ++ } ++ ++out = TableList([ ++ make_table([["ID", "Name"], ["1", "Alice"]], page=71, order=1), ++ make_table([["ID", "Name"], ["2", "Bob"]], page=72, order=1), ++]).stack_contiguous(match="first_row") ++print(json.dumps([table_summary(table) for table in out], sort_keys=True)) ++""" ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ capture_output=True, ++ text=True, ++ ) ++ ++ assert in_process == json.loads(completed.stdout) ++ assert_summary_matches_spec(in_process, [ ++ { ++ "df": [["ID", "Name"], ["1", "Alice"], ["2", "Bob"]], ++ "shape": [3, 2], ++ "page": 71, ++ "order": 1, ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "confidence": 0.9025, ++ "parsing_report": { ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "order": 1, ++ "page": 71, ++ "confidence": 0.9025, ++ }, ++ "rows": [[300, 280], [280, 260], [260, 240], [240, 220]], ++ "first_cell": [0, 280, 100, 300], ++ "last_cell": [100, 220, 200, 240], ++ } ++ ]) ++ ++ ++def test_no_undeclared_filesystem_or_network_side_effects(tmp_path, monkeypatch): ++ def fail_socket(*args, **kwargs): ++ raise AssertionError("stack_contiguous must not open network sockets") ++ ++ monkeypatch.setattr(socket, "socket", fail_socket) ++ old_cwd = os.getcwd() ++ os.chdir(tmp_path) ++ try: ++ before = sorted(os.listdir(tmp_path)) ++ result = TableList( ++ [ ++ make_table([["1", "Alice"]], page=81, order=1), ++ make_table([["2", "Bob"]], page=82, order=1), ++ ] ++ ).stack_contiguous() ++ after = sorted(os.listdir(tmp_path)) ++ finally: ++ os.chdir(old_cwd) ++ ++ assert before == [] ++ assert after == [] ++ assert_summary_matches_spec(table_list_summary(result), [ ++ { ++ "df": [["1", "Alice"], ["2", "Bob"]], ++ "shape": [2, 2], ++ "page": 81, ++ "order": 1, ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "confidence": 0.9025, ++ "parsing_report": { ++ "accuracy": 95.0, ++ "whitespace": 5.0, ++ "order": 1, ++ "page": 81, ++ "confidence": 0.9025, ++ }, ++ "rows": [[300, 280], [280, 260]], ++ "first_cell": [0, 280, 100, 300], ++ "last_cell": [100, 260, 200, 280], ++ } ++ ]) +diff --git 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 ++ ++ ++ ++ ++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 PYTHONNOUSERSITE=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export HF_HUB_OFFLINE=1 ++export TRANSFORMERS_OFFLINE=1 ++PYTHON=/opt/stage4a-venv/bin/python ++if [[ ! -x "$PYTHON" ]]; then ++ echo "local offline venv missing at $PYTHON" >&2 ++ exit 127 ++fi ++exec "$PYTHON" -m pytest /workspace/repo/usercase-test-coderl/test_stack_contiguous_acceptance.py -v diff --git a/tasks/format-code-task-000614/tests/test.sh b/tasks/format-code-task-000614/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..51ca518bd3751af60acdf82a50c990a88e5896d3 --- /dev/null +++ b/tasks/format-code-task-000614/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_stack_contiguous_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-000614/tests/test_command.sh b/tasks/format-code-task-000614/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000614/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-000625/environment/Dockerfile b/tasks/format-code-task-000625/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..33f0d3452557bcec4a4d481667f8b258458a04f3 --- /dev/null +++ b/tasks/format-code-task-000625/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ecc7de8ea3f4a35a710c75416ab99f551404fc049ee457bb071d80174b9c5c19 diff --git a/tasks/format-code-task-000625/environment/setup/files/blocklist b/tasks/format-code-task-000625/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000625/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000625/environment/setup/setup.sh b/tasks/format-code-task-000625/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000625/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000625/tests/test.patch b/tasks/format-code-task-000625/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9c484687f81cbed01461d854bb01f562e0cfc5a --- /dev/null +++ b/tasks/format-code-task-000625/tests/test.patch @@ -0,0 +1,349 @@ +diff --git a/test/test_plugin_pagertree.py b/test/test_plugin_pagertree.py +new file mode 100644 +index 0000000..81ce81f +--- /dev/null ++++ b/test/test_plugin_pagertree.py +@@ -0,0 +1,319 @@ ++# -*- coding: utf-8 -*- ++ ++ ++ ++import json ++import requests ++from unittest import mock ++ ++from apprise import Apprise ++from apprise.plugins.NotifyPagerTree import NotifyPagerTree ++from helpers import AppriseURLTester ++ ++ ++import logging ++logging.disable(logging.CRITICAL) ++ ++ ++def _posted_body(call): ++ ++ ++ ++ ++ kwargs = call[1] ++ if 'json' in kwargs and kwargs['json'] is not None: ++ return kwargs['json'] ++ return json.loads(kwargs['data']) ++ ++ ++ ++apprise_url_tests = ( ++ ('pagertree://', { ++ ++ 'instance': TypeError, ++ }), ++ ('pagertree://%20', { ++ ++ 'instance': TypeError, ++ }), ++ ('pagertree://int_123', { ++ ++ 'instance': TypeError, ++ }), ++ ('pagertree://int_012345678901234567890', { ++ ++ 'instance': TypeError, ++ }), ++ ('pagertree://int_1234567', { ++ ++ 'instance': NotifyPagerTree, ++ }), ++ ('pagertree://int_123456789?thirdparty=', { ++ ++ 'instance': NotifyPagerTree, ++ }), ++ ('pagertree://int_123456789?action=invalid', { ++ ++ 'instance': NotifyPagerTree, ++ }), ++ ('pagertree://int_123456789?action=resolve&thirdparty=abc123', { ++ ++ 'instance': NotifyPagerTree, ++ }), ++ ('pagertree://int_123456789?urgency=critical&tags=a,b,c', { ++ ++ 'instance': NotifyPagerTree, ++ }), ++ ('pagertree://int_123456789?urgency=bogus', { ++ ++ 'instance': NotifyPagerTree, ++ }), ++ ('pagertree://int_123456789?+x-token=abc&:server=blue&-incident=true', { ++ ++ 'instance': NotifyPagerTree, ++ }), ++ ('pagertree://int_123456789', { ++ 'instance': NotifyPagerTree, ++ ++ 'response': False, ++ 'requests_response_code': requests.codes.internal_server_error, ++ }), ++ ('pagertree://int_123456789', { ++ 'instance': NotifyPagerTree, ++ ++ 'response': False, ++ 'requests_response_code': 999, ++ }), ++ ('pagertree://int_123456789', { ++ 'instance': NotifyPagerTree, ++ ++ 'test_requests_exceptions': True, ++ }), ++) ++ ++ ++def test_plugin_pagertree_urls(): ++ ++ ++ ++ AppriseURLTester(tests=apprise_url_tests).run_all() ++ ++ ++@mock.patch('requests.post') ++def test_plugin_pagertree_default_payload(mock_post): ++ ++ ++ ++ response = mock.Mock() ++ response.status_code = requests.codes.ok ++ response.content = b'' ++ mock_post.return_value = response ++ ++ obj = Apprise.instantiate('pagertree://int_1234567') ++ assert isinstance(obj, NotifyPagerTree) ++ ++ assert obj.notify(body='my body', title='my title') is True ++ assert mock_post.call_count == 1 ++ ++ call = mock_post.call_args_list[0] ++ ++ assert call[0][0] == 'https://api.pagertree.com/integration/int_1234567' ++ ++ ++ assert call[1]['headers']['Content-Type'] == 'application/json' ++ ++ payload = _posted_body(call) ++ assert payload['event_type'] == 'create' ++ assert payload['title'] == 'my title' ++ assert payload['description'] == 'my body' ++ ++ assert isinstance(payload['id'], str) ++ assert len(payload['id']) > 0 ++ ++ assert payload['meta'] == {} ++ assert payload['tags'] == [] ++ ++ assert 'urgency' not in payload ++ ++ ++@mock.patch('requests.post') ++def test_plugin_pagertree_generated_ids_unique(mock_post): ++ ++ ++ ++ response = mock.Mock() ++ response.status_code = requests.codes.ok ++ response.content = b'' ++ mock_post.return_value = response ++ ++ obj = Apprise.instantiate('pagertree://int_1234567') ++ assert obj.notify(body='a') is True ++ assert obj.notify(body='b') is True ++ ++ first = _posted_body(mock_post.call_args_list[0])['id'] ++ second = _posted_body(mock_post.call_args_list[1])['id'] ++ assert first != second ++ ++ ++@mock.patch('requests.post') ++def test_plugin_pagertree_tags_and_urgency(mock_post): ++ ++ ++ ++ response = mock.Mock() ++ response.status_code = requests.codes.ok ++ response.content = b'' ++ mock_post.return_value = response ++ ++ obj = Apprise.instantiate( ++ 'pagertree://int_1234567?tags=prod,server,outage&urgency=high') ++ assert obj.notify(body='b', title='t') is True ++ ++ payload = _posted_body(mock_post.call_args_list[0]) ++ assert sorted(payload['tags']) == ['outage', 'prod', 'server'] ++ assert payload['urgency'] == 'high' ++ ++ ++@mock.patch('requests.post') ++def test_plugin_pagertree_invalid_urgency_omitted(mock_post): ++ ++ ++ ++ response = mock.Mock() ++ response.status_code = requests.codes.ok ++ response.content = b'' ++ mock_post.return_value = response ++ ++ obj = Apprise.instantiate('pagertree://int_1234567?urgency=nope') ++ assert obj.notify(body='b', title='t') is True ++ ++ payload = _posted_body(mock_post.call_args_list[0]) ++ assert 'urgency' not in payload ++ ++ ++@mock.patch('requests.post') ++def test_plugin_pagertree_thirdparty_id(mock_post): ++ ++ ++ ++ response = mock.Mock() ++ response.status_code = requests.codes.ok ++ response.content = b'' ++ mock_post.return_value = response ++ ++ obj = Apprise.instantiate('pagertree://int_1234567?thirdparty=abc123') ++ assert obj.notify(body='b', title='t') is True ++ ++ payload = _posted_body(mock_post.call_args_list[0]) ++ assert payload['id'] == 'abc123' ++ ++ ++@mock.patch('requests.post') ++def test_plugin_pagertree_resolve_action(mock_post): ++ ++ ++ ++ response = mock.Mock() ++ response.status_code = requests.codes.ok ++ response.content = b'' ++ mock_post.return_value = response ++ ++ for action in ('resolve', 'acknowledge'): ++ mock_post.reset_mock() ++ obj = Apprise.instantiate( ++ 'pagertree://int_1234567?action={}&thirdparty=abc123' ++ '&tags=x,y&urgency=high'.format(action)) ++ assert obj.notify(body='b', title='t') is True ++ ++ payload = _posted_body(mock_post.call_args_list[0]) ++ assert payload['event_type'] == action ++ assert payload['id'] == 'abc123' ++ ++ assert 'title' not in payload ++ assert 'description' not in payload ++ assert 'meta' not in payload ++ assert 'tags' not in payload ++ assert 'urgency' not in payload ++ ++ ++@mock.patch('requests.post') ++def test_plugin_pagertree_invalid_action_defaults_create(mock_post): ++ ++ ++ ++ response = mock.Mock() ++ response.status_code = requests.codes.ok ++ response.content = b'' ++ mock_post.return_value = response ++ ++ obj = Apprise.instantiate('pagertree://int_1234567?action=bogus') ++ assert obj.notify(body='b', title='t') is True ++ ++ payload = _posted_body(mock_post.call_args_list[0]) ++ assert payload['event_type'] == 'create' ++ assert payload['title'] == 't' ++ assert payload['description'] == 'b' ++ ++ ++@mock.patch('requests.post') ++def test_plugin_pagertree_prefixed_arguments(mock_post): ++ ++ ++ ++ response = mock.Mock() ++ response.status_code = requests.codes.ok ++ response.content = b'' ++ mock_post.return_value = response ++ ++ obj = Apprise.instantiate( ++ 'pagertree://int_1234567' ++ '?+my-token=secret&:server=blue-ranger&-incident=true') ++ assert obj.notify(body='b', title='t') is True ++ ++ call = mock_post.call_args_list[0] ++ ++ ++ assert call[1]['headers']['my-token'] == 'secret' ++ ++ payload = _posted_body(call) ++ ++ assert payload['server'] == 'blue-ranger' ++ ++ assert payload['meta']['incident'] == 'true' ++ ++ ++@mock.patch('requests.post') ++def test_plugin_pagertree_payload_override(mock_post): ++ ++ ++ ++ response = mock.Mock() ++ response.status_code = requests.codes.ok ++ response.content = b'' ++ mock_post.return_value = response ++ ++ obj = Apprise.instantiate('pagertree://int_1234567?:title=overridden') ++ assert obj.notify(body='b', title='original') is True ++ ++ payload = _posted_body(mock_post.call_args_list[0]) ++ assert payload['title'] == 'overridden' ++ ++ ++@mock.patch('requests.post') ++def test_plugin_pagertree_failure_codes(mock_post): ++ ++ ++ ++ response = mock.Mock() ++ response.content = b'' ++ mock_post.return_value = response ++ ++ obj = Apprise.instantiate('pagertree://int_1234567') ++ ++ for code in (200, 201, 202): ++ response.status_code = code ++ assert obj.notify(body='b', title='t') is True ++ ++ for code in (402, 403, 404, 405, 429, 500): ++ response.status_code = code ++ assert obj.notify(body='b', title='t') is 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,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++PYTEST="/testbed/.venv/bin/pytest" ++ ++ ++"$PYTEST" test/test_api.py test/test_rest_plugins.py ++ ++ ++"$PYTEST" test/test_plugin_pagertree.py diff --git a/tasks/format-code-task-000625/tests/test.sh b/tasks/format-code-task-000625/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..51e2679b83cd921033a124c751c5dc58bdeca7b4 --- /dev/null +++ b/tasks/format-code-task-000625/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/test_plugin_pagertree.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-000625/tests/test_command.sh b/tasks/format-code-task-000625/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000625/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000640/environment/Dockerfile b/tasks/format-code-task-000640/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a04fa1802c0c2bfa37f477201391e65e4f6d6679 --- /dev/null +++ b/tasks/format-code-task-000640/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:127245b11fb8d15a75600c68ababd60247971e4eb32e395075728bb7a08cdddc diff --git a/tasks/format-code-task-000640/environment/setup/files/blocklist b/tasks/format-code-task-000640/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000640/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000640/environment/setup/setup.sh b/tasks/format-code-task-000640/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000640/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000640/tests/test.patch b/tasks/format-code-task-000640/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cc805c7982f1981ec31a57be12ad998aa0403baa --- /dev/null +++ b/tasks/format-code-task-000640/tests/test.patch @@ -0,0 +1,102 @@ +diff --git a/client_test.go b/client_test.go +index 0d76dc24..85438ae0 100644 +--- a/client_test.go ++++ b/client_test.go +@@ -3550,6 +3550,62 @@ func TestClient_HandleCommandV2_NonAuthenticated(t *testing.T) { + require.False(t, ok) + } + ++func TestClientLevelPing(t *testing.T) { ++ t.Parallel() ++ node := defaultTestNode() ++ defer func() { _ = node.Shutdown(context.Background()) }() ++ done := make(chan struct{}) ++ node.OnConnecting(func(context.Context, ConnectEvent) (ConnectReply, error) { ++ return ConnectReply{ ++ PingPongConfig: &PingPongConfig{ ++ PingInterval: 5 * time.Second, ++ PongTimeout: 3 * time.Second, ++ }, ++ }, nil ++ }) ++ node.OnConnect(func(client *Client) { ++ client.OnDisconnect(func(event DisconnectEvent) { ++ require.Equal(t, DisconnectNoPong.Code, event.Disconnect.Code) ++ close(done) ++ }) ++ }) ++ ctx, cancelFn := context.WithCancel(context.Background()) ++ transport := newTestTransport(cancelFn) ++ transport.setProtocolVersion(ProtocolVersion2) ++ transport.setPing(0, 0) ++ client := newTestClientCustomTransport(t, ctx, node, transport, "42") ++ connectClientV2(t, client) ++ select { ++ case <-done: ++ case <-time.After(9 * time.Second): ++ t.Fatal("no disconnect in timeout") ++ } ++} ++ ++func TestNoClientLevelPing(t *testing.T) { ++ t.Parallel() ++ node := defaultTestNode() ++ defer func() { _ = node.Shutdown(context.Background()) }() ++ done := make(chan struct{}) ++ node.OnConnect(func(client *Client) { ++ client.OnDisconnect(func(event DisconnectEvent) { ++ require.NotEqual(t, DisconnectNoPong.Code, event.Disconnect.Code) ++ close(done) ++ }) ++ }) ++ ctx, cancelFn := context.WithCancel(context.Background()) ++ transport := newTestTransport(cancelFn) ++ transport.setProtocolVersion(ProtocolVersion2) ++ transport.setPing(-1, 0) ++ client := newTestClientCustomTransport(t, ctx, node, transport, "42") ++ connectClientV2(t, client) ++ select { ++ case <-done: ++ t.Fatal("should not disconnect when no timeout") ++ case <-time.After(36 * time.Second): ++ } ++} ++ + func TestClient_HandleCommandV2(t *testing.T) { + node := defaultNodeNoHandlers() + defer func() { _ = node.Shutdown(context.Background()) }() +diff --git a/hub_test.go b/hub_test.go +index 38d0e3e5..bc6677ab 100644 +--- a/hub_test.go ++++ b/hub_test.go +@@ -127,8 +127,8 @@ func (t *testTransport) DisabledPushFlags() uint64 { + return PushFlagDisconnect + } + +-func (t *testTransport) AppLevelPing() AppLevelPing { +- return AppLevelPing{ ++func (t *testTransport) PingPongConfig() PingPongConfig { ++ return PingPongConfig{ + PingInterval: t.pingInterval, + PongTimeout: t.pongTimeout, + } +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+3RzQqCQBSGYddexbkBbWbyZ9W1iH9UkA7k6PVnLioCc6NE9D6bc2AOzAdfWPTn ++S5XV7bDztqJGaRxPc/Q+p13HRhuTap2Od1onKvIk3izRi75z+VXEu1rrPt0tvf+o8Nm/qzuXlbZp ++8rYKu9N6fyz2H5lH/yrZj/1HiVaeqPUizPvz/stKpuKLuvKPVu6rBIMEpe1bd9AS+t9OCAAAAAAA ++AAAAAAAAAGDODbiSot4AKAAA +diff --git 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-000640/tests/test.sh b/tasks/format-code-task-000640/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a12cec51f6432df244979bb65236c4d730e370ad --- /dev/null +++ b/tasks/format-code-task-000640/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' +client_test.go +hub_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-000640/tests/test_command.sh b/tasks/format-code-task-000640/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000640/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000647/environment/Dockerfile b/tasks/format-code-task-000647/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8ed0208ccac64eb01683925d0561062602fe13eb --- /dev/null +++ b/tasks/format-code-task-000647/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fa1eabf23e5b2fb2b67636af2be441a6a3a1f08d236b1cb0ff2f9ab097829075 diff --git a/tasks/format-code-task-000647/environment/setup/files/blocklist b/tasks/format-code-task-000647/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000647/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000647/environment/setup/setup.sh b/tasks/format-code-task-000647/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000647/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000647/tests/test.patch b/tasks/format-code-task-000647/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a16a1bcf43810e5e81afa64797f88559f58d15f7 --- /dev/null +++ b/tasks/format-code-task-000647/tests/test.patch @@ -0,0 +1,2620 @@ +diff --git a/test/unit_tests/apps/paying-for-college/disclosures/fixtures/index.js b/test/unit_tests/apps/paying-for-college/disclosures/fixtures/index.js +new file mode 100644 +index 00000000000..46af3bcc21e +--- /dev/null ++++ b/test/unit_tests/apps/paying-for-college/disclosures/fixtures/index.js +@@ -0,0 +1,5 @@ ++export const constants = {"apiYear": 2016, "constantsYear": "2020-21", "militaryAssistanceCap": 4500, "pellCap": 9293, "perkinsGradCap": 8000, "perkinsUnderCap": 5500, "salaryYear": 2014, "subsidizedCapYearOne": 3500, "subsidizedCapYearThree": 5500, "subsidizedCapYearTwo": 4500, "unsubsidizedCapGrad": 47167, "unsubsidizedCapIndepYearOne": 9500, "unsubsidizedCapIndepYearThree": 12500, "unsubsidizedCapIndepYearTwo": 10500, "unsubsidizedCapYearOne": 5500, "unsubsidizedCapYearThree": 7500, "unsubsidizedCapYearTwo": 6500, "DLOriginationFee": "0.01057", "existingDebtRate": "0.05000", "gradPlusRate": "0.07540", "homeEquityLoanRate": "0.07900", "institutionalLoanRate": "0.07900", "loanDefaultRateHigh": "0.14500", "loanDefaultRateLow": "0.13500", "nationalLoanDefaultRate": "0.13700", "parentplusRate": "0.07540", "perkinsRate": "0.05000", "plusOriginationFee": "0.04228", "privateLoanFee": "0.00000", "privateLoanRate": "0.07900", "subsidizedRate": "0.04990", "unsubsidizedRate": "0.04990", "unsubsidizedRateGrad": "0.06540", "unsubsidizedRateUndergrad": "0.04990"} ++export const expenses = {"Other":{"note":"Other expeditures","MW":{"less_than_5000":3206,"50000_to_69999":4432,"20000_to_29999":3352,"5000_to_9999":2490,"10000_to_14999":2364,"15000_to_19999":3288,"70000_or_more":9455,"40000_to_49999":3697,"30000_to_39999":3092},"WE":{"less_than_5000":3803,"50000_to_69999":4565,"20000_to_29999":3289,"5000_to_9999":2776,"10000_to_14999":2711,"15000_to_19999":3060,"70000_or_more":9245,"40000_to_49999":3941,"30000_to_39999":3460},"SO":{"less_than_5000":1700,"50000_to_69999":4443,"20000_to_29999":2589,"5000_to_9999":1745,"10000_to_14999":1582,"15000_to_19999":2231,"70000_or_more":8383,"40000_to_49999":3379,"30000_to_39999":3023},"NE":{"less_than_5000":4621,"50000_to_69999":4928,"20000_to_29999":3207,"5000_to_9999":3133,"10000_to_14999":2993,"15000_to_19999":2073,"70000_or_more":9752,"40000_to_49999":3926,"30000_to_39999":4327}},"Year":2014,"Retirement":{"note":"Pensions and personal insurance","MW":{"less_than_5000":162,"50000_to_69999":4850,"20000_to_29999":1271,"5000_to_9999":340,"10000_to_14999":643,"15000_to_19999":715,"70000_or_more":12491,"40000_to_49999":3301,"30000_to_39999":2351},"WE":{"less_than_5000":464,"50000_to_69999":4975,"20000_to_29999":1378,"5000_to_9999":396,"10000_to_14999":400,"15000_to_19999":708,"70000_or_more":12651,"40000_to_49999":3382,"30000_to_39999":2505},"SO":{"less_than_5000":165,"50000_to_69999":4714,"20000_to_29999":1687,"5000_to_9999":291,"10000_to_14999":671,"15000_to_19999":867,"70000_or_more":12128,"40000_to_49999":3341,"30000_to_39999":2298},"NE":{"less_than_5000":264,"50000_to_69999":4632,"20000_to_29999":1482,"5000_to_9999":297,"10000_to_14999":465,"15000_to_19999":766,"70000_or_more":13400,"40000_to_49999":3067,"30000_to_39999":2186}},"Transportation":{"note":"Cars, public transit, insurance","MW":{"less_than_5000":2353,"50000_to_69999":9174,"20000_to_29999":6112,"5000_to_9999":3239,"10000_to_14999":3373,"15000_to_19999":3423,"70000_or_more":14794,"40000_to_49999":7640,"30000_to_39999":6833},"WE":{"less_than_5000":4783,"50000_to_69999":9047,"20000_to_29999":5710,"5000_to_9999":4180,"10000_to_14999":3731,"15000_to_19999":3258,"70000_or_more":14144,"40000_to_49999":9000,"30000_to_39999":6419},"SO":{"less_than_5000":3051,"50000_to_69999":10291,"20000_to_29999":6056,"5000_to_9999":2612,"10000_to_14999":3248,"15000_to_19999":4570,"70000_or_more":14894,"40000_to_49999":8234,"30000_to_39999":6603},"NE":{"less_than_5000":3883,"50000_to_69999":9447,"20000_to_29999":5094,"5000_to_9999":2598,"10000_to_14999":2942,"15000_to_19999":4231,"70000_or_more":14860,"40000_to_49999":6906,"30000_to_39999":6727}},"Healthcare":{"note":"Including insurance","MW":{"less_than_5000":1923,"50000_to_69999":4761,"20000_to_29999":3204,"5000_to_9999":1020,"10000_to_14999":1820,"15000_to_19999":2827,"70000_or_more":6155,"40000_to_49999":3935,"30000_to_39999":3588},"WE":{"less_than_5000":1877,"50000_to_69999":4429,"20000_to_29999":2937,"5000_to_9999":1194,"10000_to_14999":2274,"15000_to_19999":2512,"70000_or_more":5675,"40000_to_49999":3181,"30000_to_39999":3018},"SO":{"less_than_5000":1365,"50000_to_69999":3941,"20000_to_29999":2885,"5000_to_9999":1374,"10000_to_14999":1673,"15000_to_19999":2415,"70000_or_more":5672,"40000_to_49999":3361,"30000_to_39999":3175},"NE":{"less_than_5000":1448,"50000_to_69999":4349,"20000_to_29999":3004,"5000_to_9999":1227,"10000_to_14999":1899,"15000_to_19999":2972,"70000_or_more":5806,"40000_to_49999":3542,"30000_to_39999":3419}},"Food":{"note":"Dining out and in; all food costs","MW":{"less_than_5000":3488,"50000_to_69999":6620,"20000_to_29999":4443,"5000_to_9999":3781,"10000_to_14999":3301,"15000_to_19999":4369,"70000_or_more":10033,"40000_to_49999":5812,"30000_to_39999":5001},"WE":{"less_than_5000":3830,"50000_to_69999":6940,"20000_to_29999":4959,"5000_to_9999":4314,"10000_to_14999":4226,"15000_to_19999":4421,"70000_or_more":10395,"40000_to_49999":5972,"30000_to_39999":5220},"SO":{"less_than_5000":3390,"50000_to_69999":6441,"20000_to_29999":4365,"5000_to_9999":2974,"10000_to_14999":3107,"15000_to_19999":3617,"70000_or_more":9732,"40000_to_49999":5828,"30000_to_39999":5019},"NE":{"less_than_5000":4074,"50000_to_69999":6501,"20000_to_29999":4660,"5000_to_9999":3121,"10000_to_14999":3168,"15000_to_19999":4121,"70000_or_more":10194,"40000_to_49999":5725,"30000_to_39999":5507}},"Housing":{"note":"Mortgage, rent, utilities, insurance","MW":{"less_than_5000":7911,"50000_to_69999":15741,"20000_to_29999":10907,"5000_to_9999":7646,"10000_to_14999":8397,"15000_to_19999":9832,"70000_or_more":24891,"40000_to_49999":13980,"30000_to_39999":12159},"WE":{"less_than_5000":11397,"50000_to_69999":19081,"20000_to_29999":12979,"5000_to_9999":9979,"10000_to_14999":10846,"15000_to_19999":11527,"70000_or_more":28761,"40000_to_49999":16734,"30000_to_39999":14411},"SO":{"less_than_5000":9363,"50000_to_69999":15185,"20000_to_29999":10949,"5000_to_9999":7611,"10000_to_14999":7981,"15000_to_19999":9317,"70000_or_more":25172,"40000_to_49999":13653,"30000_to_39999":12441},"NE":{"less_than_5000":9908,"50000_to_69999":19468,"20000_to_29999":14328,"5000_to_9999":10382,"10000_to_14999":10472,"15000_to_19999":12619,"70000_or_more":30244,"40000_to_49999":17163,"30000_to_39999":15656}},"Entertainment":{"note":"Events, pets, hobbies, equipment","MW":{"less_than_5000":896,"50000_to_69999":2523,"20000_to_29999":1269,"5000_to_9999":791,"10000_to_14999":844,"15000_to_19999":1084,"70000_or_more":4646,"40000_to_49999":1904,"30000_to_39999":1811},"WE":{"less_than_5000":1415,"50000_to_69999":2696,"20000_to_29999":1607,"5000_to_9999":1444,"10000_to_14999":1022,"15000_to_19999":1436,"70000_or_more":5007,"40000_to_49999":2221,"30000_to_39999":1776},"SO":{"less_than_5000":911,"50000_to_69999":2315,"20000_to_29999":1349,"5000_to_9999":921,"10000_to_14999":946,"15000_to_19999":1223,"70000_or_more":4282,"40000_to_49999":1814,"30000_to_39999":1676},"NE":{"less_than_5000":1122,"50000_to_69999":2481,"20000_to_29999":1615,"5000_to_9999":1117,"10000_to_14999":1058,"15000_to_19999":1235,"70000_or_more":4222,"40000_to_49999":2174,"30000_to_39999":1789}},"Clothing":{"note":"Apparel and services","MW":{"less_than_5000":679,"50000_to_69999":1364,"20000_to_29999":780,"5000_to_9999":579,"10000_to_14999":736,"15000_to_19999":797,"70000_or_more":3001,"40000_to_49999":1268,"30000_to_39999":1035},"WE":{"less_than_5000":1363,"50000_to_69999":1871,"20000_to_29999":1217,"5000_to_9999":901,"10000_to_14999":804,"15000_to_19999":923,"70000_or_more":2806,"40000_to_49999":1526,"30000_to_39999":1088},"SO":{"less_than_5000":651,"50000_to_69999":1566,"20000_to_29999":908,"5000_to_9999":557,"10000_to_14999":728,"15000_to_19999":621,"70000_or_more":2657,"40000_to_49999":1327,"30000_to_39999":1200},"NE":{"less_than_5000":1047,"50000_to_69999":1534,"20000_to_29999":1129,"5000_to_9999":722,"10000_to_14999":495,"15000_to_19999":1049,"70000_or_more":2885,"40000_to_49999":1442,"30000_to_39999":1845}},"Taxes":{"note":"Personal federal, state, and local taxes; contains some imputed values","MW":{"less_than_5000":-415,"50000_to_69999":5027,"20000_to_29999":-583,"5000_to_9999":-608,"10000_to_14999":-248,"15000_to_19999":-832,"70000_or_more":23092,"40000_to_49999":2030,"30000_to_39999":918},"WE":{"less_than_5000":-154,"50000_to_69999":4303,"20000_to_29999":-716,"5000_to_9999":-406,"10000_to_14999":-581,"15000_to_19999":-722,"70000_or_more":21459,"40000_to_49999":1716,"30000_to_39999":-38},"SO":{"less_than_5000":-90,"50000_to_69999":4127,"20000_to_29999":-922,"5000_to_9999":-327,"10000_to_14999":-571,"15000_to_19999":-832,"70000_or_more":20382,"40000_to_49999":1763,"30000_to_39999":273},"NE":{"less_than_5000":-72,"50000_to_69999":4771,"20000_to_29999":-809,"5000_to_9999":-26,"10000_to_14999":-433,"15000_to_19999":-446,"70000_or_more":25821,"40000_to_49999":2529,"30000_to_39999":322}}} ++export const national = {"completionRateMedian":0.4778,"completionRateMedianHigh":0.5608,"completionRateMedianLow":0.3781,"monthlyLoanMedian":238.27,"nationalSalary":42051,"nationalSalaryAvgHigh":40700,"nationalSalaryAvgLow":37100,"netPriceMedian":16190,"repaymentRateMedian":0.67900875,"retentionRateMedian":0.67769998} ++export const program = {"accreditor":"","books":5425,"campus":"South University South University West Palm Beach","cipCode":"51.0912","completers":null,"completionCohort":null,"completionRate":"None","defaultRate":"0.00","fees":null,"housing":null,"institution":"South University-West Palm Beach","institutionalDebt":null,"jobNote":"","jobRate":null,"level":"4","levelName":"Post-baccalaureate certificate","meanStudentLoanCompleters":null,"medianMonthlyDebt":null,"medianStudentLoanCompleters":138404,"privateDebt":null,"programCode":"5287","programLength":30,"programName":"Physician Assistant","programSalary":null,"schoolID":133465,"socCodes":"","timeToComplete":null,"titleIVDebt":null,"totalCost":104680,"transportation":null,"tuition":99255} ++export const school = {"books":"1500","city":"Royal Palm Beach","cohortRankByControl":{"grad_rate":{"cohort_count":1100,"percentile_rank":15},"repay_3yr":{"cohort_count":1285,"percentile_rank":17},"median_total_debt":{"cohort_count":1283,"percentile_rank":30}},"cohortRankByHighestDegree":{"grad_rate":{"cohort_count":1621,"percentile_rank":12},"repay_3yr":{"cohort_count":1850,"percentile_rank":13},"median_total_debt":{"cohort_count":1851,"percentile_rank":29}},"cohortRankByState":{"grad_rate":{"cohort_count":66,"percentile_rank":20},"repay_3yr":{"cohort_count":72,"percentile_rank":21},"median_total_debt":{"cohort_count":74,"percentile_rank":38}},"control":"For-profit","defaultRate":"0.145","enrollment":554,"gradRate":"0.256","highestDegree":"Graduate degree","medianAnnualPay":33400,"medianAnnualPay6Yr":26900,"medianMonthlyDebt":"260.33","medianTotalDebt":"12667.0","netPriceAvg":21471,"netPriceAvgSlices":{"0_30k":19799,"30k_48k":22473,"48k_75k":null,"75k_110k":null,"110k_plus":24483},"nicknames":"","offersPerkins":false,"onCampusAvail":"No","online":false,"otherOffCampus":"5899","otherOnCampus":null,"otherWFamily":"4129","predominantDegree":"Bachelor's degree","programCodes":{"graduate":[],"undergrad":[]},"programCount":6,"programsPopular":["Health Professions and Related Programs","Legal Professions and Studies","Psychology","Business, Management, Marketing, and Related Support Services","Homeland Security, Law Enforcement, Firefighting and Related Protective Services","Computer and Information Sciences and Support Services"],"rateAssociateTransfer":null,"rateDefault":"0.145","rateGraduation":"0.256","rateRepay3yr":"0.2547585840","region":"SO","repay3yr":"0.2547585840","roomBrdOffCampus":"6652","roomBrdOnCampus":null,"school":"South University-West Palm Beach","schoolID":133465,"schoolSalary":33400,"settlementSchool":"edmc","state":"FL","tuitionGradInDis":"16620","tuitionGradInS":"16620","tuitionGradOss":"16620","tuitionUnderInDis":"16920","tuitionUnderInS":17014,"tuitionUnderOoss":17014,"underInvestigation":false,"url":"www.southuniversity.edu/west-palm-beach#location=West%20Palm%20Beach,%20FL","zip5":"33411"} +diff --git a/test/unit_tests/apps/paying-for-college/disclosures/fixtures/overview.js b/test/unit_tests/apps/paying-for-college/disclosures/fixtures/overview.js +new file mode 100644 +index 00000000000..94a4135b377 +--- /dev/null ++++ b/test/unit_tests/apps/paying-for-college/disclosures/fixtures/overview.js +@@ -0,0 +1,2515 @@ ++export default ` ++
++
++
++
++
++

++ Understanding your financial aid offer ++

++

++ This personalized summary will help you evaluate your ++ financial aid offer from your school to see how ++ student debt may impact your future finances.

++
++
++
++
++
++
++
++
++
++ ++
++ ++
++
Error!
++

++ The information your school provided is missing the school ID, which is vital information for this tool to work. Please contact your school and ask them to ensure they are sending us the right school ID and it's in the correct format. ++

++ ++

++ Once your school provides you with an updated URL link, you will be able to return here so you can continue reviewing the information in the tool. ++

++
++
++ ++
++ ++
++
Error!
++

++ The information your school provided is missing the program ID, which is vital information for this tool to work. Please contact your school and ask them to ensure they are sending us the right program ID and it's in the correct format. ++

++ ++

++ Once your school provides you with an updated URL link, you will be able to return here so you can continue reviewing the information in the tool. ++

++
++
++
++ ++
++
Error!
++

++ The information your school provided is missing the offer ID, which is vital information for this tool to work. Please contact your school and ask them to ensure they are sending us the right offer ID and it's in the correct format. ++

++ ++

++ Once your school provides you with an updated URL link, you will be able to return here so you can continue reviewing the information in the tool. ++

++
++
++
++
++

++ Make sure that the information below is correct ++ before reviewing your offer. ++

++
++
++ South University-West Palm Beach ++
++
++ Royal Palm Beach, FL ++
++
++ For-profit school ++
++
++
++ Program ++
++
++ Physician Assistant ++
++
++ Program type ++
++
++ Graduate degree ++
++
++ Estimated total cost of program ++
++
++ $45,000 (tuition, fees, books, and supplies) ++
++
++ Estimated years to complete your program ++
++
++

++ Select how long you expect it to take to ++ complete your program. This may be ++ shorter than the program length below if ++ you transferred in with credits that the ++ school accepts. For example, it may be ++ longer if you plan to attend part time ++ or do not successfully complete your ++ courses. We’ll use this to help ++ calculate your total debt after ++ graduation. ++

++
++ ++
++
++
++ Offer ID ++
++
++ ABCDEAB ++
++
++ ++
++
++
++
++
++
++
++
++
++
++
++

++ As you go through the three sections of this ++ tool, you’ll: ++

++
    ++
  1. Review your first-year financial aid ++ offer,
  2. ++
  3. Evaluate the financial impact of accepting ++ your financial aid offer by reviewing ++ graduation rates, expected salaries, ++ affordability, the program’s loan default ++ rates, and other factors specific to your ++ school and program, and
  4. ++
  5. Learn about your options ++ to reduce student debt.
  6. ++
++

++ You must complete steps 1 and 2 of this tool ++ before you can enroll. ++

++
++
++

++ About this tool ++

++
++

This tool uses data, financial terms and ++ estimations that may need additional ++ explanation. Learn more about the financial ++ language, how calculations are created, and ++ where the data comes from. ++

++

++ Get details ++ about how this tool works ++

++
++
++
++
++
++
++
++
++
++
++

++ Step 1: Review your first year offer ++

++

++ Here is your financial aid offer from ++ South University-West Palm Beach. Please review the amounts provided by ++ your school below and make any necessary changes ++ or add any missing information. Please note any ++ changes you make here will not change your ++ financial aid offer or your eligibility for ++ grants or loans. You will need to contact your ++ school’s financial aid representative and work ++ with them to update your financial aid package. ++

++
++
++ ++
++
++
++
++

++ How much does it cost to attend this ++ school? ++

++
++
++
++
++
++
++
++ ++

++ Includes the annual cost of the program ++ (tuition, fees, books, and supplies) ++ as well as ordinary living expenses ++ that may be incurred regardless of ++ enrollment (housing, meals, ++ transportation, and other personal ++ expenses) ++

++
++
++
++ ++
++
++ ++
++
++
++
++ ++
++
++ ++
++
++
++
++ ++
++
++ ++
++
++
++
++ ++
++
++ ++
++
++
++
++ ++

++ Personal expenses like ++ computers, daycare, ++ entertainment, laundry, etc. ++

++
++
++ ++
++
++
++
++
++
++ Total cost of attendance ++
++
++ ++ $ ++ ++ 43,626 ++
++
++
++
++
++
++ ++

++ Money you don’t have to pay back ++

++
++ ++
++
++ ++

++ Total amount awarded from your ++ school ++

++
++
++ ++
++
++
++
++ ++

++ Total amount awarded from your ++ state ++

++
++
++ ++
++
++
++
++ ++

++ Such as academic scholarships ++ or grants from a foundation ++

++
++
++ ++
++
++
++
++ ++

++ Money for active or reserve ++ servicemembers that you don’t ++ have to pay back ++

++
++
++ ++ ++
++
++
++
++ ++

++ Money for service members or ++ veterans that you don’t have ++ to pay back; see how much the ++ GI Bill pays ++

++
++
++ ++
++
++
++
++
++
++ Total grants and scholarships ++
++
++ ++ $ ++ ++ 10,100 ++
++
++
++
++
++
++
++
++

++ Cost summary ++

++
++
++ Cost of attendance ++
++
++ ++ $ ++ ++ 43,626 ++
++
++
++
++ Grants and scholarships ++
++
++ ++ ++ ( − ) ++ ++ $ ++ ++ 10,100 ++
++
++
++
++
++
++ Your out-of-pocket cost ++
++
++ ++ $ ++ ++ 33,526 ++
++
++
++
++
++
++
++
++
++

++ How much can you contribute without ++ going into debt? ++

++

++ This section includes loans that your ++ family has to repay, but those loans are ++ not included in your personal ++ debt or student loan payments summary. ++

++
++
++
++
++
++
++
++ ++
++
++
++ ++

++ Includes money that you can ++ pay now or will earn during ++ the school year ++

++
++
++ ++
++
++
++
++ ++

++ Includes money given to you from ++ family or others, private loans ++ your parents take out, etc. ++

++
++
++ ++
++
++
++
++ ++

++ Federal loans your parents take out and repay; ++ does not count toward your total student loan debt ++ shown in this tool ++

++
++
++ ++
++
++
++
++ ++

++ Money you earn per year from ++ an eligible Federal Work-Study ++ job while in school; awarded ++ based on financial need ++

++
++
++ ++
++
++
++
++
++
++
++

++ Contributions summary ++

++
++
++ Cash you will pay ++
++
++ ++ $ ++ ++ 0 ++
++
++
++
++ Money your family/others will pay ++
++
++ ++ ++ ( + ) ++ ++ $ ++ ++ 14,000 ++
++
++
++
++ Parent PLUS loans ++
++
++ ++ ++ ( + ) ++ ++ $ ++ ++ 1,000 ++
++
++
++
++ Federal Work-Study ++
++
++ ++ ++ ( + ) ++ ++ $ ++ ++ 3,000 ++
++
++
++
++
++
++ Your personal and family/others ++ contributions ++
++
++ ++ $ ++ ++ 18,000 ++
++
++
++
++

++ Big picture ++

++
++
++ Your out-of-pocket cost ++
++
++ ++ $ ++ ++ 33,526 ++
++
++
++
++ Your contributions ++
++
++ ++ ++ ( − ) ++ ++ $ ++ ++ 18,000 ++
++
++
++
++
++
++ Remaining cost ++
++
++ ++ $ ++ ++ 15,526 ++
++
++

++ This is an estimate of the remaining costs ++ of studying your program at ++ South University-West Palm Beach for one year. ++

++
++
++
++
++
++
++
++

++ How much would you have to borrow to ++ cover the remaining cost? ++

++
++
++
++
++
++
++
++ ++

++ Money you borrow from the federal ++ government this year and have to ++ pay back over time. Interest rates ++ and loan fees on future federal ++ loans may increase or decrease ++ year to year. ++

++
++ ++ ++ ++ ++
++
++ ++
++
++ ++ ++
++
++

++ 6.54% interest ++

++

++ Interest starts accumulating ++ when the money is sent to your ++ school ++

++

++ 1.06% loan fee ++

++

++ Fee is deducted immediately from ++ your loan amount, lowering the ++ total you receive (for example, ++ if the loan fee is 1%, then $10 ++ will be subtracted from a $1,000 ++ loan, so you or your school will ++ only receive $990 but you would ++ have to repay $1,000) ++

++
++
++
++
++
++
++ ++
++
++ ++
++
++

++ 7.54% interest ++

++

++ Interest starts accumulating ++ when the money is sent to your ++ school ++

++

++ 4.23% loan fee ++

++

++ Fee is deducted immediately from ++ your loan amount, lowering the ++ total you receive (for example, ++ if the loan fee is 4%, then $40 ++ will be subtracted from a $1,000 ++ loan, so you or your school will ++ only receive $960 but you would ++ have to repay $1,000) ++

++
++
++
++
++
++
++
++ Total federal loans ++
++
++ ++ $ ++ ++ 3,000 ++
++
++
++
++
++
++ ++

++ Money from banks, schools, or others ++ you have to pay back ++

++
++
++
++
++
++ Private loan ++
++ ++
++
++
++ ++
++
++ ++
++
++
++
++ ++

++ Interest starts ++ accumulating when you ++ sign the loan; may be a ++ variable rate and ++ increase or decrease in ++ the future ++

++
++
++ ++ ++ % ++ ++
++
++
++
++ ++

++ Fee is added to the ++ total loan amount (for ++ example if the loan ++ fee is 3%, then $30 ++ would be added to a ++ $1,000 loan, so you or ++ your school receive ++ $1,000 but you would ++ have to repay $1,030) ++

++
++
++ ++ ++ % ++ ++
++
++
++ ++ ++ ++
++
++
++
++
++ Total private loans ++
++
++ ++ $ ++ ++ 3,000 ++
++
++
++
++
++
++ ++

++ A loan arrangement with your school ++ that you pay back within a certain ++ amount of time. The amount of the ++ tuition payment plan shown here is ++ the total awarded for the length of ++ your entire program, not per year. ++

++
++
++
++ ++
++
++ ++
++
++
++
++ ++

++ Full tuition payment plan amount ++ divided by the estimated years ++ to complete your program ++

++
++
++ ++
++
++
++
++

++ 4.55% interest ++

++

++ Interest starts accumulating ++ when you leave or finish school ++

++

++ Payments start while you are in ++ school and the loan must be paid ++ back within 8 months ++

++
++
++
++
++
++
++ Total payment plans ++
++
++ ++ $ ++ ++ 3,000 ++
++
++
++
++
++
++
++
++

++ Loans summary ++

++
++
++ Federal loans ++
++
++ ++ $ ++ ++ 3,000 ++
++
++
++
++ Private loans ++
++
++ ++ ++ ( + ) ++ ++ $ ++ ++ 3,000 ++
++
++
++
++ Tuition payment plan for one year ++
++
++ ++ ++ ( + ) ++ ++ $ ++ ++ 1,200 ++
++
++
++
++
++
++ Total student loan debt ++
++
++ ++ $ ++ ++ 7,200 ++
++
++
++
++

++ Big picture ++

++
++
++ Your out-of-pocket cost ++
++
++ ++ $ ++ ++ 33,526 ++
++
++
++
++ Your contributions ++
++
++ ++ ++ ( − ) ++ ++ $ ++ ++ 18,000 ++
++
++
++
++ Your debt ++
++
++ ++ ++ ( − ) ++ ++ $ ++ ++ 7,200 ++
++
++
++
++
++
++ Remaining cost ++
++
++ ++ $ ++ ++ 8,326 ++
++
++

++ This is an estimate of the remaining costs ++ of studying your program at ++ South University-West Palm Beach for one year based ++ on your inputs above. ++

++
++
++
++
++
++
++
++

++ What does this mean for your future? ++

++
++
++
++
++

++ It looks like you still have a remaining cost ++ of $8,326 to pay for ++ the first year of school. You’ll either need ++ to lower your cost of attendance, pay more ++ upfront, or increase your loan amount to cover ++ these costs. ++

++ ++

++ Think about how borrowing $7,200 this ++ year will affect your future finances. As you ++ can see in the summary, the ++ total cost of these loans after two and a half years ++ plus interest and fees equals $25,412. ++

++

++ Some students find themselves struggling to ++ repay student debt once they leave school. In ++ Step 2, learn how factors like graduation rates ++ and expected salary can affect your ability to ++ repay your student debt. ++

++
++
++
++

++ Big picture ++

++
++
++ Your out-of-pocket cost ++
++
++ ++ $ ++ ++ 33,526 ++
++
++
++
++ Your contributions ++
++
++ ++ ++ ( − ) ++ ++ $ ++ ++ 18,000 ++
++
++
++
++ Your debt ++
++
++ ++ ++ ( − ) ++ ++ $ ++ ++ 7,200 ++
++
++
++
++
++
++ Remaining cost ++
++
++ ++ $ ++ ++ 8,326 ++
++
++

++ After all the grants, scholarships, loans, ++ and personal contributions, this is how ++ much you still need to pay to attend ++ South University-West Palm Beach for one year. ++

++
++
++

++ Debt summary ++

++
++
++ Loans for first year ++
++
++ ++ $ ++ ++ 7,200 ++
++
++
++ ++
++ Loans for two and a half years (program length) ++
++
++ ++ $ ++ ++ 18,000 ++
++
++
++
++ Total cost of repayment with interest ++ and fees ++ ++ Assuming all interest rates and loan ++ amounts remain the same for the ++ entire program and a standard ++ 10-year repayment plan ++ ++
++
++ ++ $ ++ ++ 25,412 ++
++
++

++ You may be eligible for a ++ repayment plan that allows you to pay your ++ loans over a period greater than 10 ++ years. ++

++
++
++
++
++
++
++
++
++
++
++

++ Don’t forget you can edit amounts in your ++ offer. These loan numbers will be used in ++ Step 2 to help you evaluate your offer. ++

++

++ Editing amounts does not change your offer ++ or your eligibility for grants or loans. If ++ you want to change your financial aid ++ package, you will need to contact your ++ school’s financial aid representative and ++ work with them to determine your ++ eligibility. ++

++
++ ++
++
++
++
++
++
++
++
++
++
++

++ Step 2: Weigh the financial impact of your offer ++

++

++ The information in this section will help you ++ understand how accepting this offer could ++ affect your ability to pay back your student ++ debt and impact your financial future. ++

++
++
++
++

++ How many students graduate? ++

++
++
++ ++

++ Remember, whether you get your ++ diploma or not, you’ll still have to repay ++ federal and private loans (and possibly ++ even some grants). If you don’t graduate, ++ you won’t have the added benefit of your ++ degree to help earn more money to put ++ toward paying off student loans. ++

++
++
++
++

++ Graduation rate ++

++

++ Percentage of first-time, full-time ++ students who graduate from ++ this school ++

++
++
++
++
This school
++
++
++
26%
++
++
++ ++
++ ++ ++
++
++
++
++
++

++ How do I know if I'm about to take on too much debt? ++

++
++
++

++ The typical salary for students who started attending this school 10 years ago is $33,400 ++ per year. In reality, you could end up ++ making more or less than the salary ++ shown here. ++

++

++ If your total debt is too high, it ++ increases the chances of not being able to ++ repay your loan on time and incurring late ++ fees and more interest, or not being able ++ to pay for other necessities, like rent or ++ groceries. Since it’s difficult to predict ++ your future salary, one way to lower your ++ debt is to reduce the amount of student ++ loans you take out. ++

++
++
++
++

++ Your salary and total student debt ++

++

++ A general rule of thumb for ++ undergraduates is that you should ++ avoid borrowing more for school than ++ you’ll earn your first year out of ++ school. ++

++

++ For graduate students, especially in ++ medical residency programs, this rule of ++ thumb may not apply. ++

++
++
Typical salary for this school
++
++ $33,400 ++
++
++
++
++ Estimated debt when repayment begins ++ ++ Includes interest and fees ++ accrued while in school ++ ++
++
++ $17,011 ++
++
++
++

++ Projected first-year salary is ++ higher than total student debt ++

++

++ Projected first-year salary is ++ about the same as total student debt ++

++

++ ++ ++ ++ Projected first-year salary is ++ lower than total student debt ++

++

++ We currently don’t have salary data ++ to display for your school ++

++

++ We currently don’t have salary data ++ to display ++

++
++
++
++
++
++
++

++ How much will I pay per month for all of my student loans? ++

++
++
++

++ Currently, your projected monthly student loan ++ payment is $562, ++ based on standard loan terms of 10 years. Once ++ you leave school, you are able to choose one ++ of several ++ different repayment options for your federal ++ loans that may help reduce your monthly ++ student loan payment. ++

++

++ Tuition, certain other educational expenses, ++ and interest paid on federal loans may ++ qualify for a federal tax credit or ++ deduction. As a result, when you start ++ repaying your loans, you may be able to ++ reduce your ++ federal tax burden . Please consult with ++ your tax advisor. ++

++

++ Many of these alternative repayment plans are ++ based on income and family size, which means ++ the lower your salary, the lower your student ++ loan payment. For instance, if you have a ++ family of four with an annual income of ++ $50,000, a monthly student loan payment would ++ be set at $114. Depending on your income ++ and family size it could be as low as $0. If ++ you select one of these income based repayment ++ plans you may be paying off your loans for up ++ to of 20 to 25 years. ++

++

++ Another payment option extends your ++ repayment over 25 years, which means you ++ would have a lower monthly student loan ++ payment but a higher total cost of interest ++ over the life of the loan. ++

++

++ These repayment plans typically aren’t ++ available for private student loans. If ++ you’re still not able to make payments on ++ your loans, you could go into default. ++

++
++
++
++

++ Your estimated monthly payment ++

++

++ Based on a standard loan term of 10 ++ years ++

++ ++

++ Once you leave school, you can choose ++ one of several available repayment ++ options. ++

++
++
++ Your projected loan payment ++
++
++ $562 ++
++
++
++
++ Total cost of repayment with interest ++ and fees ++
++
++ $25,412 ++
++
++
++

++ See how loan length affects your ++ payments ++

++
++ ++ ++
++
++ ++
++
++
++
++
++

++ How will I afford my loan payment? ++

++
++
++

++ Think about how much money you can expect to ++ make if you graduate and get a job in your ++ field, and then evaluate how much of that ++ will go toward living expenses and loan ++ payments. In reality, you could end up ++ making more or less than the salaries shown here. ++

++ ++
++
++
++

++ Your estimated debt burden ++

++

++ We calculate your debt burden by ++ dividing your monthly loan payment by ++ the average salary ++ for students who attended your ++ school. ++

++
++
++ Your projected loan payment ++
++
++ $562 ++ / mo. ++
++
++
++
++ Average salary ++
++
++ $33,400 ++ / yr.
++ $2,783 ++ / mo. ++
++
++
++
++
++ $562 ++
++
++ loan payment ++
++
++
++ / ++
++
++
++ $2,783 ++
++
++ monthly salary ++
++
++
++ = ++
++
++
++ 20% ++
++
++ of your income ++
++
++
++ ++ ++
++
++
++
++
++

++ Estimated budget after you leave ++ school (adjust as needed) ++

++

++ Average monthly living expenses for ++ someone and their family making ++ $33,400/year ++ (the average national salary for all ++ students who attended ++ college) in the region you ++ plan to live (Source: Bureau of Labor ++ Statistics ). Your expenses may ++ be higher or lower. ++

++
++
++ ++
++
++
++
++
++ Average monthly salary ++ ++ Before taxes ++ ++
++
++ ++ $ ++ ++ 2,783 ++
++
++
++
++ Monthly student loan payment ++ ++ Based on 10-year repayment plan ++ ++
++
++ ++ ( − ) ++ ++ ++ $ ++ ++ 562 ++
++
++
++ ++
++
++ ++
++
++ ++
++
++ ++
++
++ ++
++
++ ++
++
++ ++
++
++ ++
++
++ ++
++
++
++
++
++
++ Total left at the end of the month ++
++
++ -$756 ++
++
++
++ Your total expenses are higher than your ++ estimated monthly salary ++
++
++
++
++
++
++

++ What if I can’t afford my student loan payments? ++

++
++
++

++ Defaulting on a loan can happen when you ++ fail to make scheduled payments over a ++ certain period of time. This length of time ++ can vary based on the type of loan. It can ++ also mean added fees and interest because ++ the debt isn’t paid off in time. Defaulting ++ on a loan can negatively impact your credit ++ rating, which could make it more difficult ++ in the future to borrow money to purchase a ++ car or a home. Defaulting could also result ++ in wage garnishment. ++

++
++
++
++

++ Loan default rates ++

++

++ Percentage of students from this ++ program ++ who default on loans after ++ entering repayment ++

++
++
++ 40% ++
++
++
++
This program
++
++
++
0%
++
++
++ ++
++ ++ ++
++
++
++
++
++
++
++
++
++
++
++

++ It's estimated you'll owe $25,412 ++ to complete this program in Physician Assistant at ++ South University-West Palm Beach. Do you better ++ understand how this may impact your future ++ finances? ++

++ ++
++ ++ ++ ++
++

++ Your response will not be shared with your ++ school and does not affect your ability to ++ accept or reject the actual offer from your ++ school. ++

++
++
++
++
++
++
++
++
++
++

++ Step 3: Consider your options ++

++

++ If you are interested in lowering your amount of ++ debt, there are things you can do. Here are some ++ choices you can make that may help you improve ++ your financial future. ++

++
++
++

++ Step 3: A few more things to consider ++

++

++ It’s important to feel confident in the ++ financial decisions you are making. Here are ++ some additional choices you can make that may ++ help you improve your financial future even ++ more. ++

++
++
++

++ Step 3: Consider your options ++

++

++ If you are interested in lowering your amount of ++ debt, there are things you can do. ++

++

++ Here are some choices you can make that may help ++ you improve your financial future. ++

++
++
++
++
++
++

++ Maximize all available grants and scholarships. ++

++

++ Consider applying for additional ++ scholarships and grants , ++ which provide money you don’t have to repay. ++ By increasing the amount of this type of ++ aid, you can decrease the overall amount of ++ debt you have to borrow—and ++ consequently pay back. ++

++
++
++

++ Reduce your living costs. ++

++

++ Living at home or finding cheaper off-campus ++ housing can ++ reduce the ++ cost of attendance , meaning you can ++ borrow less money overall. ++

++
++
++

++ Consider a different program with better ++ outcomes. ++

++

++ Salaries are often influenced by the degree ++ you earn. If the projected salary of your ++ program is far below the national average or ++ the job placement rate seems low, you might ++ consider a different program with a higher ++ projected earning potential. Ask your ++ admission representative or search for ++ gainful employment information on your school’s website ++ to learn more about job placement rates and ++ the average salaries of graduates. ++

++
++ ++ ++
++

++ Think about working while you study. ++

++

++ Nearly two-thirds of college students work ++ while they are enrolled in school. While not ++ for everyone, earning money from a job, even ++ if it’s not related to your field of study, ++ can help reduce the amount of money you need ++ to borrow to pay for school, resulting in ++ long-term benefits of reducing overall debt. ++ Check out resources for finding a ++ job , including links to job search ++ sites, tips for writing a ++ résumé, and more. ++

++
++
++ ++
++
++
++
++
++
++
++
++

++ Next steps ++

++

++ We have notified your school that you have ++ reviewed your personalized offer. You can now ++ move forward in the enrollment process. ++

++
++
++
    ++
  1. ++

    ++ Review any changes you made to your offer. If ++ you decide to move forward using any adjusted ++ amount of aid, you need to contact your ++ financial aid representative and work with them ++ to update your financial aid plan. ++

    ++

    ++ Changes you make using this tool are meant for ++ your guidance only. They are not sent to your ++ school and do not affect your actual financial ++ aid offer. ++

    ++

    ++ If you want to change your offer in any way, ++ contact your school’s financial aid ++ representative to have your financial aid offer ++ updated. ++

    ++
  2. ++
  3. ++

    ++ Keep a copy of this personalized aid ++ information. ++

    ++

    ++ You can print a summary of the aid information ++ in this tool or save it as a PDF. Use this as a ++ reference while talking with your school. ++

    ++
    ++ ++
    ++
  4. ++
++
++
++
++
++
++
++
++
++

++ If the information provided is not correct, ++ please contact your school and ask them to fix ++ it. Once your school provides you with an ++ updated link, you will be able to return so you ++ can continue reviewing the information in the ++ tool. ++

++
++
++
++
++
++
++
` +diff --git a/test/unit_tests/apps/paying-for-college/disclosures/js/overview-spec.js b/test/unit_tests/apps/paying-for-college/disclosures/js/overview-spec.js +new file mode 100644 +index 00000000000..90a8695cfa8 +--- /dev/null ++++ b/test/unit_tests/apps/paying-for-college/disclosures/js/overview-spec.js +@@ -0,0 +1,57 @@ ++import financialView from '../../../../../../cfgov/unprocessed/apps/paying-for-college/js/disclosures/views/financial-view.js'; ++import financialModel from '../../../../../../cfgov/unprocessed/apps/paying-for-college/js/disclosures/models/financial-model.js'; ++import expensesModel from '../../../../../../cfgov/unprocessed/apps/paying-for-college/js/disclosures/models/expenses-model.js'; ++import schoolModel from '../../../../../../cfgov/unprocessed/apps/paying-for-college/js/disclosures/models/school-model.js'; ++import { getUrlValues } from '../../../../../../cfgov/unprocessed/apps/paying-for-college/js/disclosures/dispatchers/get-url-values.js'; ++import publishUpdate from '../../../../../../cfgov/unprocessed/apps/paying-for-college/js/disclosures/dispatchers/publish-update.js'; ++import HTML_SNIPPET from '../fixtures/overview.js'; ++import { ++ constants, ++ expenses, ++ national, ++ school, ++ program, ++} from '../fixtures/index.js'; ++ ++describe('Disclosures', () => { ++ beforeEach(() => { ++ document.body.innerHTML = HTML_SNIPPET; ++ delete global.location; ++ global.location = { ++ search: ++ '?iped=133465&pid=5287&oid=ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE&totl=45000&tuit=38976&hous=3000&book=650&tran=500&othr=500&pelg=1500&schg=2000&stag=2000&othg=100&ta=3000&mta=3000&gib=3000&wkst=3000&parl=14000&perl=3000&subl=15000&unsl=2000&ppl=1000&gpl=1000&prvl=3000&prvi=4.55&prvf=1.01&insl=3000&insi=4.55&inst=8&leng=30%27;#info-right', ++ }; ++ }); ++ ++ it('renders data into the financial model', () => { ++ financialModel.init(constants); ++ expect(financialModel.values).toBeTruthy(); ++ }); ++ ++ it('initializes the expenses model', () => { ++ expensesModel.init(expenses); ++ expect(expensesModel.values.stored).toBeTruthy(); ++ }); ++ ++ it('extracts url values into an expected object', () => { ++ expect(getUrlValues().tuitionFees).toBe(38976); ++ }); ++ ++ it('initializes the school model', () => { ++ schoolModel.init(national, school, program); ++ expect(schoolModel.values.medianSalary).toBe(33400); ++ }); ++ ++ it('extends the financial model with url values', () => { ++ publishUpdate.extendFinancialData(getUrlValues()); ++ expect(financialModel.values.totalCost).toBe(45000); ++ expect(financialModel.values.costOfAttendance).toBe(43626); ++ }); ++ ++ it('updates financial data on input change', () => { ++ const tuitionInput = document.getElementById('costs__tuition'); ++ tuitionInput.value = 40000; ++ financialView.inputHandler('costs__tuition'); ++ expect(financialModel.values.costOfAttendance).toBe(44650); ++ }); ++}); +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+3SQYvUMBQH8Dn3UzwriCJp2jrdAUVve/AgiB5lGTLN6zRjmpQkrTuyH960M86u ++sutedhHx/aA0NE3fv3nJNoPSco1m5IvHkkerqprv0e/3eVxUZVEWRfmqPFvkRVGtlguoHi3RDYMP ++wgEsnLXhT+/dN/+Pyq77H9CHdW27ThiZ+fbhatzT/yJfVqf+l6si9n95lq8WkD9chLv95/2vJcyN ++36BMkqdwbvzgEPbCGVAexCiUFhuNiWrgCRwPB7Dx8Mazd1ziyM2g9RsILZoEQBtgvgFu+8CNlcjK ++kmu1mcfrzspBo+fTar5RZh5kOw988I5rWwt9ehy/VbdxAby8vHW6UVPg9yb2T2uQ2KORaGqFHmJY ++gyjjL8XRlxicSbhZHy7g6uq2CZ7Vom4RLk6/c9iJYxHGGme/o2ExytdGaYTyegeOgT4NZloL8VRt ++McC0tx6+qdDC+ecP4Ie+ty7A897ZHdYBBh/jpGHfY/oa0kOM9EUyhYrl8LJHpzo0sTwbO/Yzf/br ++dmbTpuxipbhkKvhRhDZeAZ15m04P+GBUWM9ZuOh7z3uxV2bLGutYbbXGLXKpfK3t1H6fxu8YG2dG ++dGKLyd8+pIQQQgghhBBCCCGEEEIIIYQQQggh5E4/AOwBCzEAKAAA +diff --git 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-000647/tests/test.sh b/tasks/format-code-task-000647/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..751b771a5a99d0848c1b799b57a9db3fd54ff0ec --- /dev/null +++ b/tasks/format-code-task-000647/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/unit_tests/apps/paying-for-college/disclosures/fixtures/index.js +test/unit_tests/apps/paying-for-college/disclosures/fixtures/overview.js +test/unit_tests/apps/paying-for-college/disclosures/js/overview-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-000647/tests/test_command.sh b/tasks/format-code-task-000647/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000647/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000676/environment/Dockerfile b/tasks/format-code-task-000676/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0c6e0be79a0cbd54328bb36f5da4cad9d57ba2d6 --- /dev/null +++ b/tasks/format-code-task-000676/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:da9791a2c317987b8bc7933892e51796d13d251244306cd47ef50d54f41c5fda diff --git a/tasks/format-code-task-000676/environment/setup/files/blocklist b/tasks/format-code-task-000676/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000676/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000676/environment/setup/setup.sh b/tasks/format-code-task-000676/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000676/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000676/tests/test.patch b/tasks/format-code-task-000676/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..48cbadd04ef0ebe86aa2ac211fc78b2aec3a3850 --- /dev/null +++ b/tasks/format-code-task-000676/tests/test.patch @@ -0,0 +1,223 @@ +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,201 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC LRZIP=NOCONFIG ++ ++fail() { ++ echo "FAIL: $*" >&2 ++ exit 1 ++} ++ ++( ++ cd /workspace/repo || exit 1 ++ ./autogen.sh >/dev/null || exit 1 ++ ++ make -C lzma/C liblzma.la >/dev/null || exit 1 ++ make lrzip >/dev/null || exit 1 ++) || fail "build" ++BIN=/workspace/repo/lrzip ++[ -x "$BIN" ] || fail "missing lrzip binary at $BIN" ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || fail "cd tmp" ++ ++make_lines_fixture() { ++ local out=$1 ++ local i ++ : > "$out" ++ for i in $(seq 1 10000); do ++ printf 'line-%05d abcdefghijklmnopqrstuvwxyz\n' "$i" >> "$out" ++ done ++} ++ ++make_randomish_fixture() { ++ local out=$1 ++ perl -e 'my $x=1; for (1..200000) { $x = (1103515245 * $x + 12345) & 0x7fffffff; print chr(($x >> 8) & 255); }' > "$out" ++} ++ ++assert_same_file() { ++ local expected=$1 ++ local actual=$2 ++ cmp -s "$expected" "$actual" || fail "$actual differs from $expected" ++} ++ ++gzip_block_info() { ++ local info_file=$1 ++ awk '$2 == "gzip" { print $7, $9, $4, $7 + 10 }' "$info_file" | head -n 1 ++} ++ ++patch_byte() { ++ local file=$1 ++ local offset=$2 ++ local octal=$3 ++ printf "$octal" | dd of="$file" bs=1 seek="$offset" count=1 conv=notrunc status=none ++} ++ ++ ++ ++ ++"$BIN" --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++cat out err >help.all ++grep -Fq $'\t-g, --gzip\t\tgzip compression using zlib' help.all || fail "F1 help missing gzip option text" ++ ++ ++ ++ ++ ++make_lines_fixture lines.txt ++"$BIN" -g -L 6 -v -o lines.lrz lines.txt >compress.out 2>compress.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 compress exit $ec; want 0" ++grep -Fq "Compression mode is: GZIP" compress.out || fail "F2 verbose summary missing GZIP" ++ ++[ -s lines.lrz ] || fail "F2 missing compressed archive" ++ ++"$BIN" -ivv lines.lrz >info.out 2>info.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 info exit $ec; want 0" ++ ++awk '$2 == "gzip" && $4 + 0 < $6 + 0 { found=1 } END { exit found ? 0 : 1 }' info.out || fail "F2 info missing smaller gzip block" ++grep -Fq " Compression Method: rzip + gzip" info.out || fail "F2 info summary missing rzip + gzip" ++ ++ ++ ++ ++ ++rm -f lines.restored ++"$BIN" -d -o lines.restored lines.lrz >decompress.out 2>decompress.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 decompress exit $ec; want 0" ++ ++assert_same_file lines.txt lines.restored ++ ++ ++ ++ ++make_lines_fixture longopt.txt ++"$BIN" --gzip -L 1 -v -o longopt.lrz longopt.txt >long.out 2>long.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 compress exit $ec; want 0" ++grep -Fq "Compression level 1" long.out || fail "F4 missing level 1 summary" ++grep -Fq "Compression mode is: GZIP" long.out || fail "F4 verbose summary missing GZIP" ++"$BIN" -ivv longopt.lrz >longinfo.out 2>longinfo.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 info exit $ec; want 0" ++ ++awk '$2 == "gzip" && $4 + 0 < $6 + 0 { found=1 } END { exit found ? 0 : 1 }' longinfo.out || fail "F4 info missing smaller gzip block" ++grep -Fq " Compression Method: rzip + gzip" longinfo.out || fail "F4 info summary missing rzip + gzip" ++ ++ ++ ++ ++mkdir confcase ++( ++ cd confcase || exit 1 ++ unset LRZIP ++ printf 'CompressionMethod = gzip\nCompressionLevel = 6\n' > lrzip.conf ++ make_lines_fixture conf-lines.txt ++ "$BIN" -v -o conf-lines.lrz conf-lines.txt >conf.out 2>conf.err ++ ec=$? ++ [ "$ec" -eq 0 ] || fail "F5 compress exit $ec; want 0" ++ grep -Fq "Compression mode is: GZIP" conf.out || fail "F5 verbose summary missing GZIP" ++ grep -Fq "Compression level 6" conf.out || fail "F5 config level missing" ++ "$BIN" -ivv conf-lines.lrz >confinfo.out 2>confinfo.err ++ ec=$? ++ [ "$ec" -eq 0 ] || fail "F5 info exit $ec; want 0" ++ ++ awk '$2 == "gzip" && $4 + 0 < $6 + 0 { found=1 } END { exit found ? 0 : 1 }' confinfo.out || fail "F5 info missing smaller gzip block" ++ grep -Fq " Compression Method: rzip + gzip" confinfo.out || fail "F5 info summary missing rzip + gzip" ++) ++ ++ ++ ++ ++mkdir badconf ++( ++ cd badconf || exit 1 ++ unset LRZIP ++ printf 'CompressionMethod = gzip\nCompressionMethod = bzip2\n' > lrzip.conf ++ printf 'x%.0s' $(seq 1 2000) > x.txt ++ "$BIN" -o x.lrz x.txt >out 2>err ++ ec=$? ++ [ "$ec" -ne 0 ] || fail "F6 want non-zero exit" ++ ++ cat out err >combined ++ grep -Eiq "compression method|one compression|only one" combined || fail "F6 missing config conflict diagnostic" ++) ++ ++ ++ ++ ++printf 'x%.0s' $(seq 1 2000) > conflict.txt ++"$BIN" -g -b -o conflict.lrz conflict.txt >conflict.out 2>conflict.err; ec=$? ++[ "$ec" -ne 0 ] || fail "F7 want non-zero exit" ++ ++cat conflict.out conflict.err >conflict.all ++grep -Eiq "compression method|one of|only one" conflict.all || fail "F7 missing method conflict diagnostic" ++ ++ ++ ++ ++make_randomish_fixture randomish.bin ++"$BIN" -g -L 6 -o randomish.lrz randomish.bin >rand.out 2>rand.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F8 compress exit $ec; want 0" ++"$BIN" -ivv randomish.lrz >randinfo.out 2>randinfo.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F8 info exit $ec; want 0" ++ ++awk '$2 == "none" && $4 + 0 >= $6 + 0 { found=1 } END { exit found ? 0 : 1 }' randinfo.out || fail "F8 info missing uncompressed data block" ++ ++awk '$2 == "gzip" { bad=1 } END { exit bad ? 1 : 0 }' randinfo.out || fail "F8 incompressible data should not be gzip-marked" ++rm -f randomish.restored ++"$BIN" -d -o randomish.restored randomish.lrz >randdec.out 2>randdec.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F8 decompress exit $ec; want 0" ++ ++assert_same_file randomish.bin randomish.restored ++ ++ ++ ++ ++cp lines.lrz corrupt-data.lrz ++ ++read -r first_gzip_offset first_gzip_head first_gzip_clen first_gzip_payload < <(gzip_block_info info.out) ++[ -n "${first_gzip_payload:-}" ] || fail "F9 could not locate gzip block" ++patch_byte corrupt-data.lrz "$first_gzip_payload" '\377' ++"$BIN" -d -o corrupt.out corrupt-data.lrz >corrupt.outlog 2>corrupt.err; ec=$? ++[ "$ec" -ne 0 ] || fail "F9 want non-zero exit" ++ ++cat corrupt.outlog corrupt.err >corrupt.all ++grep -Eiq "decompress|corrupt|fatal|error" corrupt.all || fail "F9 missing corruption diagnostic" ++ ++ ++ ++ ++cp lines.lrz lenmismatch.lrz ++ ++[ -n "${first_gzip_offset:-}" ] || fail "F10 could not locate gzip block" ++patch_byte lenmismatch.lrz "$((first_gzip_offset + 4))" '\102' ++"$BIN" -d -o lenmismatch.out lenmismatch.lrz >lenmismatch.outlog 2>lenmismatch.err; ec=$? ++[ "$ec" -ne 0 ] || fail "F10 want non-zero exit" ++ ++cat lenmismatch.outlog lenmismatch.err >lenmismatch.all ++grep -Eiq "length|decompress|fatal|error" lenmismatch.all || fail "F10 missing length mismatch diagnostic" ++ ++echo "PASS" +diff --git 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-000676/tests/test.sh b/tasks/format-code-task-000676/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000676/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-000676/tests/test_command.sh b/tasks/format-code-task-000676/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000676/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-000678/environment/Dockerfile b/tasks/format-code-task-000678/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d0192e235f75700940931d9242434d3dff03d727 --- /dev/null +++ b/tasks/format-code-task-000678/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:35c2bcb36c7d14b29a60a88ace1f3fa40a6e79d64ef6993a270ff868a529e6a0 diff --git a/tasks/format-code-task-000678/environment/setup/files/blocklist b/tasks/format-code-task-000678/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000678/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000678/environment/setup/setup.sh b/tasks/format-code-task-000678/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000678/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000678/tests/test.patch b/tasks/format-code-task-000678/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3420dc3e7202a72752148df4a71994f7829bac48 --- /dev/null +++ b/tasks/format-code-task-000678/tests/test.patch @@ -0,0 +1,137 @@ +diff --git a/pkg/cmd/browse/browse_test.go b/pkg/cmd/browse/browse_test.go +index bf3349c3ca3..0cb4df786f4 100644 +--- a/pkg/cmd/browse/browse_test.go ++++ b/pkg/cmd/browse/browse_test.go +@@ -213,7 +213,7 @@ func Test_runBrowse(t *testing.T) { + }, + baseRepo: ghrepo.New("ravocean", "angur"), + defaultBranch: "trunk", +- expectedURL: "https://github.com/ravocean/angur/tree/trunk/path/to/file.txt#L32", ++ expectedURL: "https://github.com/ravocean/angur/blob/trunk/path/to/file.txt?plain=1#L32", + }, + { + name: "file with line range", +@@ -222,16 +222,41 @@ func Test_runBrowse(t *testing.T) { + }, + baseRepo: ghrepo.New("ravocean", "angur"), + defaultBranch: "trunk", +- expectedURL: "https://github.com/ravocean/angur/tree/trunk/path/to/file.txt#L32-L40", ++ expectedURL: "https://github.com/ravocean/angur/blob/trunk/path/to/file.txt?plain=1#L32-L40", + }, + { +- name: "file with invalid line number", ++ name: "invalid default branch", ++ opts: BrowseOptions{ ++ SelectorArg: "chocolate-pecan-pie.txt", ++ }, ++ baseRepo: ghrepo.New("andrewhsu", "recipies"), ++ defaultBranch: "", ++ wantsErr: true, ++ }, ++ { ++ name: "file with invalid line number after colon", ++ opts: BrowseOptions{ ++ SelectorArg: "laptime-notes.txt:w-9", ++ }, ++ baseRepo: ghrepo.New("andrewhsu", "sonoma-raceway"), ++ wantsErr: true, ++ }, ++ { ++ name: "file with invalid file format", + opts: BrowseOptions{ + SelectorArg: "path/to/file.txt:32:32", + }, + baseRepo: ghrepo.New("ttran112", "ttrain211"), + wantsErr: true, + }, ++ { ++ name: "file with invalid line number", ++ opts: BrowseOptions{ ++ SelectorArg: "path/to/file.txt:32a", ++ }, ++ baseRepo: ghrepo.New("ttran112", "ttrain211"), ++ wantsErr: true, ++ }, + { + name: "file with invalid line range", + opts: BrowseOptions{ +@@ -258,7 +283,7 @@ func Test_runBrowse(t *testing.T) { + }, + baseRepo: ghrepo.New("github", "ThankYouGitHub"), + wantsErr: false, +- expectedURL: "https://github.com/github/ThankYouGitHub/tree/first-browse-pull/browse.go#L32", ++ expectedURL: "https://github.com/github/ThankYouGitHub/blob/first-browse-pull/browse.go?plain=1#L32", + }, + { + name: "no browser with branch file and line number", +@@ -269,7 +294,7 @@ func Test_runBrowse(t *testing.T) { + }, + baseRepo: ghrepo.New("mislav", "will_paginate"), + wantsErr: false, +- expectedURL: "https://github.com/mislav/will_paginate/tree/3-0-stable/init.rb#L6", ++ expectedURL: "https://github.com/mislav/will_paginate/blob/3-0-stable/init.rb?plain=1#L6", + }, + } + +@@ -313,41 +338,3 @@ func Test_runBrowse(t *testing.T) { + }) + } + } +- +-func Test_parseFileArg(t *testing.T) { +- tests := []struct { +- name string +- arg string +- errorExpected bool +- expectedFileArg string +- stderrExpected string +- }{ +- { +- name: "non line number", +- arg: "main.go", +- errorExpected: false, +- expectedFileArg: "main.go", +- }, +- { +- name: "line number", +- arg: "main.go:32", +- errorExpected: false, +- expectedFileArg: "main.go#L32", +- }, +- { +- name: "non line number error", +- arg: "ma:in.go", +- errorExpected: true, +- stderrExpected: "invalid line number after colon\nUse 'gh browse --help' for more information about browse\n", +- }, +- } +- for _, tt := range tests { +- fileArg, err := parseFileArg(tt.arg) +- if tt.errorExpected { +- assert.Equal(t, err.Error(), tt.stderrExpected) +- } else { +- assert.Equal(t, err, nil) +- assert.Equal(t, tt.expectedFileArg, fileArg) +- } +- } +-} +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+3SQY7CIBTGcdae4l2gBYzYlRvP4N7Y0qjRFtNSvf5gN04mGd1ojPH/W8ALkPDI ++R14O+6Nf1+1Zq1cxSeHcOCd/57G2bmqnJg1upoy1rpgrcS/r6Jehj5tORHUhxHvnHu1/qPyWf6z7 ++uK5C02xan/e7593xKH9r5rf8jU35z1xRKDHPa+F/X55/5WUMvqz9ZBvkWkquT4etrhqvyy5c+lpL ++1g2trK7/IxXLcVGys2RVGNq4sJN3vwIAAAAAAAAAAAAAAAD4Tj96BWGPACgAAA== +diff --git 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-000678/tests/test.sh b/tasks/format-code-task-000678/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..01fb6c5b18ee2bea2bfb4e9580705480d2707be5 --- /dev/null +++ b/tasks/format-code-task-000678/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/cmd/browse/browse_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-000678/tests/test_command.sh b/tasks/format-code-task-000678/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000678/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000682/environment/Dockerfile b/tasks/format-code-task-000682/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7b38487d8f84a36dd53e820f1039754970a2548a --- /dev/null +++ b/tasks/format-code-task-000682/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:841295b1106d2046ba7c991b2942bbb464308aaddd35de60fd3eef2a715617c7 diff --git a/tasks/format-code-task-000682/environment/setup/files/blocklist b/tasks/format-code-task-000682/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000682/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000682/environment/setup/setup.sh b/tasks/format-code-task-000682/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000682/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000682/tests/test.patch b/tasks/format-code-task-000682/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f20ae1c9df7715680e300d129f449d2e247f7f7f --- /dev/null +++ b/tasks/format-code-task-000682/tests/test.patch @@ -0,0 +1,880 @@ +diff --git a/tests/data/placebo/test_sns_kms_related_filter_test/kms.DescribeKey_1.json b/tests/data/placebo/test_sns_kms_related_filter_test/kms.DescribeKey_1.json +new file mode 100644 +index 00000000000..c9a10d1ea4c +--- /dev/null ++++ b/tests/data/placebo/test_sns_kms_related_filter_test/kms.DescribeKey_1.json +@@ -0,0 +1,36 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "KeyMetadata": { ++ "AWSAccountId": "644160558196", ++ "KeyId": "36812ccf-daaf-49b1-a24b-0eef254ffe41", ++ "Arn": "arn:aws:kms:us-east-1:644160558196:key/36812ccf-daaf-49b1-a24b-0eef254ffe41", ++ "CreationDate": { ++ "__class__": "datetime", ++ "year": 2016, ++ "month": 7, ++ "day": 24, ++ "hour": 4, ++ "minute": 51, ++ "second": 26, ++ "microsecond": 199000 ++ }, ++ "Enabled": true, ++ "Description": "Trails for the Skunk", ++ "KeyUsage": "ENCRYPT_DECRYPT", ++ "KeyState": "Enabled", ++ "Origin": "AWS_KMS", ++ "KeyManager": "CUSTOMER" ++ }, ++ "ResponseMetadata": { ++ "RequestId": "8f34128c-c503-4843-8bb5-35b979a6723a", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "8f34128c-c503-4843-8bb5-35b979a6723a", ++ "content-type": "application/x-amz-json-1.1", ++ "content-length": "355" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_kms_related_filter_test/kms.ListAliases_1.json b/tests/data/placebo/test_sns_kms_related_filter_test/kms.ListAliases_1.json +new file mode 100644 +index 00000000000..b3b68cc972b +--- /dev/null ++++ b/tests/data/placebo/test_sns_kms_related_filter_test/kms.ListAliases_1.json +@@ -0,0 +1,23 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Aliases": [ ++ { ++ "AliasName": "alias/skunk/trails", ++ "AliasArn": "arn:aws:kms:us-east-1:644160558196:alias/skunk/trails", ++ "TargetKeyId": "36812ccf-daaf-49b1-a24b-0eef254ffe41" ++ } ++ ], ++ "Truncated": false, ++ "ResponseMetadata": { ++ "RequestId": "fa0f9b9b-0d18-4fe2-b8f1-428284fce483", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "fa0f9b9b-0d18-4fe2-b8f1-428284fce483", ++ "content-type": "application/x-amz-json-1.1", ++ "content-length": "202" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_kms_related_filter_test/kms.ListAliases_2.json b/tests/data/placebo/test_sns_kms_related_filter_test/kms.ListAliases_2.json +new file mode 100644 +index 00000000000..3da568c8c3a +--- /dev/null ++++ b/tests/data/placebo/test_sns_kms_related_filter_test/kms.ListAliases_2.json +@@ -0,0 +1,23 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Aliases": [ ++ { ++ "AliasName": "alias/skunk/trails", ++ "AliasArn": "arn:aws:kms:us-east-1:644160558196:alias/skunk/trails", ++ "TargetKeyId": "36812ccf-daaf-49b1-a24b-0eef254ffe41" ++ } ++ ], ++ "Truncated": false, ++ "ResponseMetadata": { ++ "RequestId": "4b79e6f0-60e3-435a-acce-7f3cf255b4d0", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "4b79e6f0-60e3-435a-acce-7f3cf255b4d0", ++ "content-type": "application/x-amz-json-1.1", ++ "content-length": "202" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_kms_related_filter_test/kms.ListKeys_1.json b/tests/data/placebo/test_sns_kms_related_filter_test/kms.ListKeys_1.json +new file mode 100644 +index 00000000000..046459db3f7 +--- /dev/null ++++ b/tests/data/placebo/test_sns_kms_related_filter_test/kms.ListKeys_1.json +@@ -0,0 +1,126 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Keys": [ ++ { ++ "KeyId": "0c34a807-a390-4128-ba02-463ccd3d8850", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/0c34a807-a390-4128-ba02-463ccd3d8850" ++ }, ++ { ++ "KeyId": "13121aca-ffd6-45af-b640-4eb89f6d8fbd", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/13121aca-ffd6-45af-b640-4eb89f6d8fbd" ++ }, ++ { ++ "KeyId": "19135ee1-cd2b-4553-a719-a960edf22ae4", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/19135ee1-cd2b-4553-a719-a960edf22ae4" ++ }, ++ { ++ "KeyId": "36812ccf-daaf-49b1-a24b-0eef254ffe41", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/36812ccf-daaf-49b1-a24b-0eef254ffe41" ++ }, ++ { ++ "KeyId": "3f2ab3af-cc4e-427b-b96d-d4356f9764c4", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/3f2ab3af-cc4e-427b-b96d-d4356f9764c4" ++ }, ++ { ++ "KeyId": "6917a312-adce-4bbc-8202-958f2db490fa", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/6917a312-adce-4bbc-8202-958f2db490fa" ++ }, ++ { ++ "KeyId": "70b96f94-38b3-4a1f-96ad-7fe04b197e33", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/70b96f94-38b3-4a1f-96ad-7fe04b197e33" ++ }, ++ { ++ "KeyId": "7147f795-71ee-4b59-8dd1-2fa32a55423c", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/7147f795-71ee-4b59-8dd1-2fa32a55423c" ++ }, ++ { ++ "KeyId": "75d1e7ba-f9c5-46b9-97bc-28e6c834aa49", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/75d1e7ba-f9c5-46b9-97bc-28e6c834aa49" ++ }, ++ { ++ "KeyId": "798bc4bb-3079-4a9a-bc27-2c7f2b6c91d0", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/798bc4bb-3079-4a9a-bc27-2c7f2b6c91d0" ++ }, ++ { ++ "KeyId": "7d30a034-2787-478a-85e7-1a2b85205fbc", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/7d30a034-2787-478a-85e7-1a2b85205fbc" ++ }, ++ { ++ "KeyId": "7efe5f36-5599-4a81-97b9-4c4aa4b64f93", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/7efe5f36-5599-4a81-97b9-4c4aa4b64f93" ++ }, ++ { ++ "KeyId": "82645407-2faa-4d93-be71-7d6a8d59a5fc", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/82645407-2faa-4d93-be71-7d6a8d59a5fc" ++ }, ++ { ++ "KeyId": "845ab6f1-744c-4edc-b702-efae6836818a", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/845ab6f1-744c-4edc-b702-efae6836818a" ++ }, ++ { ++ "KeyId": "84c99eaf-7284-4645-bfe9-f627251e142d", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/84c99eaf-7284-4645-bfe9-f627251e142d" ++ }, ++ { ++ "KeyId": "8785aeb9-a616-4e2b-bbd3-df3cde76bcc5", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/8785aeb9-a616-4e2b-bbd3-df3cde76bcc5" ++ }, ++ { ++ "KeyId": "9835c962-ea8a-41ba-ab9e-32547228571d", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/9835c962-ea8a-41ba-ab9e-32547228571d" ++ }, ++ { ++ "KeyId": "a476e533-b970-4c74-a341-707420ecf59b", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/a476e533-b970-4c74-a341-707420ecf59b" ++ }, ++ { ++ "KeyId": "aaac6583-1d5f-44a2-b535-0823b47ed00e", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/aaac6583-1d5f-44a2-b535-0823b47ed00e" ++ }, ++ { ++ "KeyId": "b10f842a-feb7-4318-92d5-0640a75b7688", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/b10f842a-feb7-4318-92d5-0640a75b7688" ++ }, ++ { ++ "KeyId": "d1305425-4cde-46ee-be31-e2043dd4df39", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/d1305425-4cde-46ee-be31-e2043dd4df39" ++ }, ++ { ++ "KeyId": "d38e6df4-3a19-4516-9f4b-ab568e9bccc5", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/d38e6df4-3a19-4516-9f4b-ab568e9bccc5" ++ }, ++ { ++ "KeyId": "d551d66a-1396-4c94-a6b7-e2edf550510c", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/d551d66a-1396-4c94-a6b7-e2edf550510c" ++ }, ++ { ++ "KeyId": "e39ed135-2a46-4d5e-8c05-41b8d900d0c7", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/e39ed135-2a46-4d5e-8c05-41b8d900d0c7" ++ }, ++ { ++ "KeyId": "f0108d2e-e1df-4a94-b1b6-9144085093cb", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/f0108d2e-e1df-4a94-b1b6-9144085093cb" ++ }, ++ { ++ "KeyId": "f1f33a6b-91aa-4b0a-904c-f2a0378277f0", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/f1f33a6b-91aa-4b0a-904c-f2a0378277f0" ++ }, ++ { ++ "KeyId": "f4441361-1c8d-4710-8d6d-0b6d7cd0be11", ++ "KeyArn": "arn:aws:kms:us-east-1:644160558196:key/f4441361-1c8d-4710-8d6d-0b6d7cd0be11" ++ } ++ ], ++ "Truncated": false, ++ "ResponseMetadata": { ++ "RequestId": "d457e9d6-b9be-4722-b2b7-4536fa07afb3", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "d457e9d6-b9be-4722-b2b7-4536fa07afb3", ++ "content-type": "application/x-amz-json-1.1", ++ "content-length": "3714" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_kms_related_filter_test/sns.GetTopicAttributes_1.json b/tests/data/placebo/test_sns_kms_related_filter_test/sns.GetTopicAttributes_1.json +new file mode 100644 +index 00000000000..e6488b91b54 +--- /dev/null ++++ b/tests/data/placebo/test_sns_kms_related_filter_test/sns.GetTopicAttributes_1.json +@@ -0,0 +1,28 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Attributes": { ++ "Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__console_sub_0\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:Subscribe\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:us-east-1:644160558196:test\",\"Condition\":{\"StringLike\":{\"SNS:Endpoint\":\"alfredmarc.gamulo@capitalone.com\"}}}]}", ++ "Owner": "644160558196", ++ "SubscriptionsPending": "0", ++ "KmsMasterKeyId": "arn:aws:kms:us-east-1:644160558196:key/36812ccf-daaf-49b1-a24b-0eef254ffe41", ++ "TopicArn": "arn:aws:sns:us-east-1:644160558196:test", ++ "EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false}}", ++ "SubscriptionsConfirmed": "0", ++ "DisplayName": "test", ++ "SubscriptionsDeleted": "0" ++ }, ++ "ResponseMetadata": { ++ "RequestId": "32c871da-24a5-5f81-8f01-2553fdd3bc31", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "32c871da-24a5-5f81-8f01-2553fdd3bc31", ++ "content-type": "text/xml", ++ "content-length": "2080", ++ "vary": "Accept-Encoding", ++ "date": "Tue, 11 Dec 2018 15:26:45 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_kms_related_filter_test/sns.ListTopics_1.json b/tests/data/placebo/test_sns_kms_related_filter_test/sns.ListTopics_1.json +new file mode 100644 +index 00000000000..9a742c1edeb +--- /dev/null ++++ b/tests/data/placebo/test_sns_kms_related_filter_test/sns.ListTopics_1.json +@@ -0,0 +1,42 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Topics": [ ++ { ++ "TopicArn": "arn:aws:sns:us-east-1:644160558196:cof-guard-duty-archive-notify" ++ }, ++ { ++ "TopicArn": "arn:aws:sns:us-east-1:644160558196:cof-guard-duty-stream-notify" ++ }, ++ { ++ "TopicArn": "arn:aws:sns:us-east-1:644160558196:config-topic" ++ }, ++ { ++ "TopicArn": "arn:aws:sns:us-east-1:644160558196:custodian-test-data-22" ++ }, ++ { ++ "TopicArn": "arn:aws:sns:us-east-1:644160558196:dynamodb" ++ }, ++ { ++ "TopicArn": "arn:aws:sns:us-east-1:644160558196:sphere11-lock-notifications" ++ }, ++ { ++ "TopicArn": "arn:aws:sns:us-east-1:644160558196:sphere11-revert-notifications" ++ }, ++ { ++ "TopicArn": "arn:aws:sns:us-east-1:644160558196:test" ++ } ++ ], ++ "ResponseMetadata": { ++ "RequestId": "64be2466-3a4e-5a96-892a-70efe33b1ecf", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "64be2466-3a4e-5a96-892a-70efe33b1ecf", ++ "content-type": "text/xml", ++ "content-length": "1196", ++ "date": "Tue, 11 Dec 2018 15:26:44 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_kms_related_filter_test/tagging.GetResources_1.json b/tests/data/placebo/test_sns_kms_related_filter_test/tagging.GetResources_1.json +new file mode 100644 +index 00000000000..481d0be3d3d +--- /dev/null ++++ b/tests/data/placebo/test_sns_kms_related_filter_test/tagging.GetResources_1.json +@@ -0,0 +1,46 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "PaginationToken": "", ++ "ResourceTagMappingList": [ ++ { ++ "ResourceARN": "arn:aws:kms:us-east-1:644160558196:key/3f2ab3af-cc4e-427b-b96d-d4356f9764c4", ++ "Tags": [ ++ { ++ "Key": "Test", ++ "Value": "Test" ++ } ++ ] ++ }, ++ { ++ "ResourceARN": "arn:aws:kms:us-east-1:644160558196:key/75d1e7ba-f9c5-46b9-97bc-28e6c834aa49", ++ "Tags": [ ++ { ++ "Key": "Name", ++ "Value": "c7n/sagemaker" ++ } ++ ] ++ }, ++ { ++ "ResourceARN": "arn:aws:kms:us-east-1:644160558196:key/a476e533-b970-4c74-a341-707420ecf59b", ++ "Tags": [ ++ { ++ "Key": "Name", ++ "Value": "CMK-Rotation-Test" ++ } ++ ] ++ } ++ ], ++ "ResponseMetadata": { ++ "RequestId": "2c2d19d0-fd59-11e8-9948-ddbb0d432f71", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "2c2d19d0-fd59-11e8-9948-ddbb0d432f71", ++ "content-type": "application/x-amz-json-1.1", ++ "content-length": "470", ++ "date": "Tue, 11 Dec 2018 15:26:46 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_set_encryption/sns.GetTopicAttributes_1.json b/tests/data/placebo/test_sns_set_encryption/sns.GetTopicAttributes_1.json +new file mode 100644 +index 00000000000..e557fe78193 +--- /dev/null ++++ b/tests/data/placebo/test_sns_set_encryption/sns.GetTopicAttributes_1.json +@@ -0,0 +1,27 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Attributes": { ++ "Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:us-west-1:644160558196:test\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"644160558196\"}}}]}", ++ "Owner": "644160558196", ++ "SubscriptionsPending": "0", ++ "TopicArn": "arn:aws:sns:us-west-1:644160558196:test", ++ "EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false}}", ++ "SubscriptionsConfirmed": "0", ++ "DisplayName": "", ++ "SubscriptionsDeleted": "0" ++ }, ++ "ResponseMetadata": { ++ "RequestId": "ef73f15a-cdd9-5e23-b554-a5d1efbd5ff7", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "ef73f15a-cdd9-5e23-b554-a5d1efbd5ff7", ++ "content-type": "text/xml", ++ "content-length": "2125", ++ "vary": "Accept-Encoding", ++ "date": "Wed, 12 Dec 2018 14:50:12 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_set_encryption/sns.GetTopicAttributes_2.json b/tests/data/placebo/test_sns_set_encryption/sns.GetTopicAttributes_2.json +new file mode 100644 +index 00000000000..c992643e1c1 +--- /dev/null ++++ b/tests/data/placebo/test_sns_set_encryption/sns.GetTopicAttributes_2.json +@@ -0,0 +1,28 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Attributes": { ++ "Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:us-west-1:644160558196:test\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"644160558196\"}}}]}", ++ "Owner": "644160558196", ++ "SubscriptionsPending": "0", ++ "KmsMasterKeyId": "alias/aws/sns", ++ "TopicArn": "arn:aws:sns:us-west-1:644160558196:test", ++ "EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false}}", ++ "SubscriptionsConfirmed": "0", ++ "DisplayName": "", ++ "SubscriptionsDeleted": "0" ++ }, ++ "ResponseMetadata": { ++ "RequestId": "c67365a8-816e-566c-89c0-3123a30b33de", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "c67365a8-816e-566c-89c0-3123a30b33de", ++ "content-type": "text/xml", ++ "content-length": "2225", ++ "vary": "Accept-Encoding", ++ "date": "Wed, 12 Dec 2018 14:50:13 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_set_encryption/sns.ListTopics_1.json b/tests/data/placebo/test_sns_set_encryption/sns.ListTopics_1.json +new file mode 100644 +index 00000000000..05595448ea2 +--- /dev/null ++++ b/tests/data/placebo/test_sns_set_encryption/sns.ListTopics_1.json +@@ -0,0 +1,21 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Topics": [ ++ { ++ "TopicArn": "arn:aws:sns:us-west-1:644160558196:test" ++ } ++ ], ++ "ResponseMetadata": { ++ "RequestId": "94a75c6d-c845-5e33-851d-08e6ea21b78b", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "94a75c6d-c845-5e33-851d-08e6ea21b78b", ++ "content-type": "text/xml", ++ "content-length": "369", ++ "date": "Wed, 12 Dec 2018 14:50:12 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_set_encryption/sns.SetTopicAttributes_1.json b/tests/data/placebo/test_sns_set_encryption/sns.SetTopicAttributes_1.json +new file mode 100644 +index 00000000000..40b325ff4c7 +--- /dev/null ++++ b/tests/data/placebo/test_sns_set_encryption/sns.SetTopicAttributes_1.json +@@ -0,0 +1,16 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "ResponseMetadata": { ++ "RequestId": "cf6eca90-63f9-58f6-8cf3-9e1b419ceba5", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "cf6eca90-63f9-58f6-8cf3-9e1b419ceba5", ++ "content-type": "text/xml", ++ "content-length": "215", ++ "date": "Wed, 12 Dec 2018 14:50:13 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_set_encryption_custom_key/sns.GetTopicAttributes_1.json b/tests/data/placebo/test_sns_set_encryption_custom_key/sns.GetTopicAttributes_1.json +new file mode 100644 +index 00000000000..f91b1c7de6a +--- /dev/null ++++ b/tests/data/placebo/test_sns_set_encryption_custom_key/sns.GetTopicAttributes_1.json +@@ -0,0 +1,27 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Attributes": { ++ "Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:us-west-1:644160558196:test\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"644160558196\"}}}]}", ++ "Owner": "644160558196", ++ "SubscriptionsPending": "0", ++ "TopicArn": "arn:aws:sns:us-west-1:644160558196:test", ++ "EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false}}", ++ "SubscriptionsConfirmed": "0", ++ "DisplayName": "", ++ "SubscriptionsDeleted": "0" ++ }, ++ "ResponseMetadata": { ++ "RequestId": "10f95b1a-affe-543f-ab76-0f91c9658f90", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "10f95b1a-affe-543f-ab76-0f91c9658f90", ++ "content-type": "text/xml", ++ "content-length": "2125", ++ "vary": "Accept-Encoding", ++ "date": "Wed, 12 Dec 2018 19:41:15 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_set_encryption_custom_key/sns.GetTopicAttributes_2.json b/tests/data/placebo/test_sns_set_encryption_custom_key/sns.GetTopicAttributes_2.json +new file mode 100644 +index 00000000000..2d17bd752e8 +--- /dev/null ++++ b/tests/data/placebo/test_sns_set_encryption_custom_key/sns.GetTopicAttributes_2.json +@@ -0,0 +1,28 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Attributes": { ++ "Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:us-west-1:644160558196:test\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"644160558196\"}}}]}", ++ "Owner": "644160558196", ++ "SubscriptionsPending": "0", ++ "KmsMasterKeyId": "alias/alias/test/key", ++ "TopicArn": "arn:aws:sns:us-west-1:644160558196:test", ++ "EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false}}", ++ "SubscriptionsConfirmed": "0", ++ "DisplayName": "", ++ "SubscriptionsDeleted": "0" ++ }, ++ "ResponseMetadata": { ++ "RequestId": "97f8efe5-84bb-508d-a40c-bb6ee2274119", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "97f8efe5-84bb-508d-a40c-bb6ee2274119", ++ "content-type": "text/xml", ++ "content-length": "2232", ++ "vary": "Accept-Encoding", ++ "date": "Wed, 12 Dec 2018 19:41:16 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_set_encryption_custom_key/sns.ListTopics_1.json b/tests/data/placebo/test_sns_set_encryption_custom_key/sns.ListTopics_1.json +new file mode 100644 +index 00000000000..107d70f0e97 +--- /dev/null ++++ b/tests/data/placebo/test_sns_set_encryption_custom_key/sns.ListTopics_1.json +@@ -0,0 +1,21 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Topics": [ ++ { ++ "TopicArn": "arn:aws:sns:us-west-1:644160558196:test" ++ } ++ ], ++ "ResponseMetadata": { ++ "RequestId": "2883043d-9792-5928-9d73-50b6f108beb9", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "2883043d-9792-5928-9d73-50b6f108beb9", ++ "content-type": "text/xml", ++ "content-length": "369", ++ "date": "Wed, 12 Dec 2018 19:41:14 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_set_encryption_custom_key/sns.SetTopicAttributes_1.json b/tests/data/placebo/test_sns_set_encryption_custom_key/sns.SetTopicAttributes_1.json +new file mode 100644 +index 00000000000..dad21266014 +--- /dev/null ++++ b/tests/data/placebo/test_sns_set_encryption_custom_key/sns.SetTopicAttributes_1.json +@@ -0,0 +1,16 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "ResponseMetadata": { ++ "RequestId": "dd4beb4c-a469-5a7a-a19b-bfc7c2f21302", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "dd4beb4c-a469-5a7a-a19b-bfc7c2f21302", ++ "content-type": "text/xml", ++ "content-length": "215", ++ "date": "Wed, 12 Dec 2018 19:41:15 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_unset_encryption/sns.GetTopicAttributes_1.json b/tests/data/placebo/test_sns_unset_encryption/sns.GetTopicAttributes_1.json +new file mode 100644 +index 00000000000..3224743a352 +--- /dev/null ++++ b/tests/data/placebo/test_sns_unset_encryption/sns.GetTopicAttributes_1.json +@@ -0,0 +1,28 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Attributes": { ++ "Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:us-west-1:644160558196:test\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"644160558196\"}}}]}", ++ "Owner": "644160558196", ++ "SubscriptionsPending": "0", ++ "KmsMasterKeyId": "alias/aws/sns", ++ "TopicArn": "arn:aws:sns:us-west-1:644160558196:test", ++ "EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false}}", ++ "SubscriptionsConfirmed": "0", ++ "DisplayName": "", ++ "SubscriptionsDeleted": "0" ++ }, ++ "ResponseMetadata": { ++ "RequestId": "9e023ad3-afb9-54e8-a07f-6e588d158891", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "9e023ad3-afb9-54e8-a07f-6e588d158891", ++ "content-type": "text/xml", ++ "content-length": "2225", ++ "vary": "Accept-Encoding", ++ "date": "Wed, 12 Dec 2018 14:51:24 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_unset_encryption/sns.GetTopicAttributes_2.json b/tests/data/placebo/test_sns_unset_encryption/sns.GetTopicAttributes_2.json +new file mode 100644 +index 00000000000..b35eeb7727a +--- /dev/null ++++ b/tests/data/placebo/test_sns_unset_encryption/sns.GetTopicAttributes_2.json +@@ -0,0 +1,27 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Attributes": { ++ "Policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:us-west-1:644160558196:test\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"644160558196\"}}}]}", ++ "Owner": "644160558196", ++ "SubscriptionsPending": "0", ++ "TopicArn": "arn:aws:sns:us-west-1:644160558196:test", ++ "EffectiveDeliveryPolicy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false}}", ++ "SubscriptionsConfirmed": "0", ++ "DisplayName": "", ++ "SubscriptionsDeleted": "0" ++ }, ++ "ResponseMetadata": { ++ "RequestId": "8f5c27e2-584e-5ac8-8e44-73697ae320b2", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "8f5c27e2-584e-5ac8-8e44-73697ae320b2", ++ "content-type": "text/xml", ++ "content-length": "2125", ++ "vary": "Accept-Encoding", ++ "date": "Wed, 12 Dec 2018 14:51:25 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_unset_encryption/sns.ListTopics_1.json b/tests/data/placebo/test_sns_unset_encryption/sns.ListTopics_1.json +new file mode 100644 +index 00000000000..e12016682e2 +--- /dev/null ++++ b/tests/data/placebo/test_sns_unset_encryption/sns.ListTopics_1.json +@@ -0,0 +1,21 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Topics": [ ++ { ++ "TopicArn": "arn:aws:sns:us-west-1:644160558196:test" ++ } ++ ], ++ "ResponseMetadata": { ++ "RequestId": "2ec7d797-0074-5ff6-96c9-831c22d81982", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "2ec7d797-0074-5ff6-96c9-831c22d81982", ++ "content-type": "text/xml", ++ "content-length": "369", ++ "date": "Wed, 12 Dec 2018 14:51:24 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_sns_unset_encryption/sns.SetTopicAttributes_1.json b/tests/data/placebo/test_sns_unset_encryption/sns.SetTopicAttributes_1.json +new file mode 100644 +index 00000000000..2ae836ad4c7 +--- /dev/null ++++ b/tests/data/placebo/test_sns_unset_encryption/sns.SetTopicAttributes_1.json +@@ -0,0 +1,16 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "ResponseMetadata": { ++ "RequestId": "7c0bb506-f8cb-5148-80f9-e18dda66a33e", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "7c0bb506-f8cb-5148-80f9-e18dda66a33e", ++ "content-type": "text/xml", ++ "content-length": "215", ++ "date": "Wed, 12 Dec 2018 14:51:25 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/test_sns.py b/tests/test_sns.py +index 45660b758f8..2af89ebb67f 100644 +--- a/tests/test_sns.py ++++ b/tests/test_sns.py +@@ -475,3 +475,121 @@ def test_sns_modify_add_and_remove_policy(self): + self.assertTrue("AddMe" in statement_ids) + self.assertTrue("RemoveMe" not in statement_ids) + self.assertTrue("SpecificAllow" in statement_ids) ++ ++ def test_sns_topic_encryption(self): ++ session_factory = self.replay_flight_data('test_sns_kms_related_filter_test') ++ kms = session_factory().client('kms') ++ p = self.load_policy( ++ { ++ 'name': 'test-sns-kms-related-filter', ++ 'resource': 'sns', ++ 'filters': [ ++ { ++ 'TopicArn': 'arn:aws:sns:us-east-1:644160558196:test' ++ }, ++ { ++ 'type': 'kms-key', ++ 'key': 'c7n:AliasName', ++ 'value': 'alias/skunk/trails' ++ } ++ ] ++ }, ++ session_factory=session_factory ++ ) ++ resources = p.run() ++ self.assertTrue(len(resources), 1) ++ aliases = kms.list_aliases(KeyId=resources[0]['KmsMasterKeyId']) ++ self.assertEqual(aliases['Aliases'][0]['AliasName'], 'alias/skunk/trails') ++ ++ def test_set_sns_topic_encryption(self): ++ session_factory = self.replay_flight_data('test_sns_set_encryption') ++ topic = 'arn:aws:sns:us-west-1:644160558196:test' ++ p = self.load_policy( ++ { ++ 'name': 'test-sns-kms-related-filter', ++ 'resource': 'sns', ++ 'filters': [ ++ { ++ 'TopicArn': topic ++ }, ++ { ++ 'KmsMasterKeyId': 'absent' ++ } ++ ], ++ 'actions': [ ++ { ++ 'type': 'set-encryption' ++ } ++ ] ++ }, ++ session_factory=session_factory ++ ) ++ resources = p.run() ++ self.assertEquals(len(resources), 1) ++ sns = session_factory().client('sns') ++ attributes = sns.get_topic_attributes(TopicArn=topic) ++ self.assertTrue(attributes['Attributes']['KmsMasterKeyId'], 'alias/aws/sns') ++ ++ def test_sns_disable_encryption(self): ++ session_factory = self.replay_flight_data('test_sns_unset_encryption') ++ topic = 'arn:aws:sns:us-west-1:644160558196:test' ++ p = self.load_policy( ++ { ++ 'name': 'test-sns-kms-related-filter', ++ 'resource': 'sns', ++ 'filters': [ ++ { ++ 'TopicArn': topic ++ }, ++ { ++ 'KmsMasterKeyId': 'alias/aws/sns' ++ } ++ ], ++ 'actions': [ ++ { ++ 'type': 'set-encryption', ++ 'enabled': False ++ } ++ ] ++ }, ++ session_factory=session_factory ++ ) ++ ++ resources = p.run() ++ ++ self.assertEqual(len(resources), 1) ++ ++ sns = session_factory().client('sns') ++ attributes = sns.get_topic_attributes(TopicArn=topic)['Attributes'] ++ self.assertFalse(attributes.get('KmsMasterKeyId')) ++ ++ def test_sns_set_encryption_custom_key(self): ++ session_factory = self.replay_flight_data('test_sns_set_encryption_custom_key') ++ topic = 'arn:aws:sns:us-west-1:644160558196:test' ++ key_alias = 'alias/alias/test/key' ++ sns = session_factory().client('sns') ++ p = self.load_policy( ++ { ++ 'name': 'test-sns-kms-related-filter-alias', ++ 'resource': 'sns', ++ 'filters': [ ++ { ++ 'TopicArn': topic ++ }, ++ { ++ 'KmsMasterKeyId': 'absent' ++ } ++ ], ++ 'actions': [ ++ { ++ 'type': 'set-encryption', ++ 'key': key_alias ++ } ++ ] ++ }, ++ session_factory=session_factory ++ ) ++ resources = p.run() ++ self.assertEquals(len(resources), 1) ++ attributes = sns.get_topic_attributes(TopicArn=topic)['Attributes'] ++ self.assertEqual(attributes.get('KmsMasterKeyId'), key_alias) +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+3S0WrDIBgFYK/7FL5AM01iAnmI3nT3kqjQsEZDtIW8/f5mbB2DrVtpGWPnu4jG ++5KBwzLpDv7fa+eMDuxdBaqWWkXwcl7lUuczzWsmyYELKShSMq7ud6J1DTO3EOZtCSF/9d+n7H5Wd +++08uJm3CMLTeZnF3uz0u9V/Kt/6LWlTUf1lJxbi43RE+98/7N5YvxXfOrsY57YIv+HrgNKVFfnrE ++l4sRfczGuWke6WW72TbN66pOYewN3SAzzWPqg/9Gyl2dpJTtY9vt3Y9zp13PGW2o+TDoJzfz9XH1 ++2z0AAAAAAAAAAAAAAAAAAAAAAFzjGYH6YoQAKAAA +diff --git 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-000682/tests/test.sh b/tasks/format-code-task-000682/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..53a63f1f1ec41883d75da9bed567e59b64fd7625 --- /dev/null +++ b/tasks/format-code-task-000682/tests/test.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 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/data/placebo/test_sns_kms_related_filter_test/kms.DescribeKey_1.json +tests/data/placebo/test_sns_kms_related_filter_test/kms.ListAliases_1.json +tests/data/placebo/test_sns_kms_related_filter_test/kms.ListAliases_2.json +tests/data/placebo/test_sns_kms_related_filter_test/kms.ListKeys_1.json +tests/data/placebo/test_sns_kms_related_filter_test/sns.GetTopicAttributes_1.json +tests/data/placebo/test_sns_kms_related_filter_test/sns.ListTopics_1.json +tests/data/placebo/test_sns_kms_related_filter_test/tagging.GetResources_1.json +tests/data/placebo/test_sns_set_encryption/sns.GetTopicAttributes_1.json +tests/data/placebo/test_sns_set_encryption/sns.GetTopicAttributes_2.json +tests/data/placebo/test_sns_set_encryption/sns.ListTopics_1.json +tests/data/placebo/test_sns_set_encryption/sns.SetTopicAttributes_1.json +tests/data/placebo/test_sns_set_encryption_custom_key/sns.GetTopicAttributes_1.json +tests/data/placebo/test_sns_set_encryption_custom_key/sns.GetTopicAttributes_2.json +tests/data/placebo/test_sns_set_encryption_custom_key/sns.ListTopics_1.json +tests/data/placebo/test_sns_set_encryption_custom_key/sns.SetTopicAttributes_1.json +tests/data/placebo/test_sns_unset_encryption/sns.GetTopicAttributes_1.json +tests/data/placebo/test_sns_unset_encryption/sns.GetTopicAttributes_2.json +tests/data/placebo/test_sns_unset_encryption/sns.ListTopics_1.json +tests/data/placebo/test_sns_unset_encryption/sns.SetTopicAttributes_1.json +tests/test_sns.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-000682/tests/test_command.sh b/tasks/format-code-task-000682/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000682/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000685/environment/Dockerfile b/tasks/format-code-task-000685/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..33957f5928cfaa6980113edcd1e6e422431fca8f --- /dev/null +++ b/tasks/format-code-task-000685/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:068190ba8a09e9af2393f069dfedc74a1684da291ad9a25eb545a1906919b8f7 diff --git a/tasks/format-code-task-000685/environment/setup/files/blocklist b/tasks/format-code-task-000685/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000685/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000685/environment/setup/setup.sh b/tasks/format-code-task-000685/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000685/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000685/tests/test.patch b/tasks/format-code-task-000685/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1f3a675fa6f05fdcd0ca06b66b6877e75842d09c --- /dev/null +++ b/tasks/format-code-task-000685/tests/test.patch @@ -0,0 +1,139 @@ +diff --git a/api/handlers/service_plan_test.go b/api/handlers/service_plan_test.go +index 51e317662..745bc08d1 100644 +--- a/api/handlers/service_plan_test.go ++++ b/api/handlers/service_plan_test.go +@@ -22,6 +22,7 @@ var _ = Describe("ServicePlan", func() { + var ( + servicePlanRepo *fake.CFServicePlanRepository + serviceOfferingRepo *fake.CFServiceOfferingRepository ++ serviceBrokerRepo *fake.CFServiceBrokerRepository + requestValidator *fake.RequestValidator + ) + +@@ -29,12 +30,14 @@ var _ = Describe("ServicePlan", func() { + requestValidator = new(fake.RequestValidator) + servicePlanRepo = new(fake.CFServicePlanRepository) + serviceOfferingRepo = new(fake.CFServiceOfferingRepository) ++ serviceBrokerRepo = new(fake.CFServiceBrokerRepository) + + apiHandler := NewServicePlan( + *serverURL, + requestValidator, + servicePlanRepo, + serviceOfferingRepo, ++ serviceBrokerRepo, + ) + routerBuilder.LoadRoutes(apiHandler) + }) +@@ -121,7 +124,7 @@ var _ = Describe("ServicePlan", func() { + }) + }) + +- It("includes broker fields in the response", func() { ++ It("includes service offering in the response", func() { + Expect(rr).Should(HaveHTTPStatus(http.StatusOK)) + Expect(rr).To(HaveHTTPBody(SatisfyAll( + MatchJSONPath("$.included.service_offerings[0].guid", "service-offering-guid"), +@@ -130,6 +133,59 @@ var _ = Describe("ServicePlan", func() { + }) + }) + ++ Describe("fields service_offering.service_broker", func() { ++ BeforeEach(func() { ++ serviceBrokerRepo.ListServiceBrokersReturns([]repositories.ServiceBrokerRecord{{ ++ ServiceBroker: services.ServiceBroker{ ++ Name: "service-broker-name", ++ }, ++ CFResource: model.CFResource{ ++ GUID: "service-broker-guid", ++ }, ++ }}, nil) ++ ++ serviceOfferingRepo.ListOfferingsReturns([]repositories.ServiceOfferingRecord{{ ++ ServiceOffering: services.ServiceOffering{ ++ Name: "service-offering-name", ++ }, ++ CFResource: model.CFResource{ ++ GUID: "service-offering-guid", ++ }, ++ ServiceBrokerGUID: "service-broker-guid", ++ }}, nil) ++ ++ requestValidator.DecodeAndValidateURLValuesStub = decodeAndValidateURLValuesStub(&payloads.ServicePlanList{ ++ IncludeBrokerFields: []string{"guid", "name"}, ++ }) ++ }) ++ ++ It("lists the brokers", func() { ++ Expect(serviceBrokerRepo.ListServiceBrokersCallCount()).To(Equal(1)) ++ _, _, actualListMessage := serviceBrokerRepo.ListServiceBrokersArgsForCall(0) ++ Expect(actualListMessage).To(Equal(repositories.ListServiceBrokerMessage{ ++ GUIDs: []string{"service-broker-guid"}, ++ })) ++ }) ++ ++ When("listing brokers fails", func() { ++ BeforeEach(func() { ++ serviceBrokerRepo.ListServiceBrokersReturns([]repositories.ServiceBrokerRecord{}, errors.New("list-broker-err")) ++ }) ++ ++ It("returns an error", func() { ++ expectUnknownError() ++ }) ++ }) ++ ++ It("includes broker fields in the response", func() { ++ Expect(rr).Should(HaveHTTPStatus(http.StatusOK)) ++ Expect(rr).To(HaveHTTPBody(SatisfyAll( ++ MatchJSONPath("$.included.service_brokers[0].guid", "service-broker-guid"), ++ MatchJSONPath("$.included.service_brokers[0].name", "service-broker-name"), ++ ))) ++ }) ++ }) ++ + When("the request is invalid", func() { + BeforeEach(func() { + requestValidator.DecodeAndValidateURLValuesReturns(errors.New("invalid-request")) +diff --git a/api/payloads/service_plan_test.go b/api/payloads/service_plan_test.go +index 9a973b6de..98cc15743 100644 +--- a/api/payloads/service_plan_test.go ++++ b/api/payloads/service_plan_test.go +@@ -25,6 +25,7 @@ var _ = Describe("ServicePlan", func() { + Entry("available", "available=true", payloads.ServicePlanList{Available: tools.PtrTo(true)}), + Entry("not available", "available=false", payloads.ServicePlanList{Available: tools.PtrTo(false)}), + Entry("include", "include=service_offering", payloads.ServicePlanList{IncludeResources: []string{"service_offering"}}), ++ Entry("service broker fields", "fields[service_offering.service_broker]=guid,name", payloads.ServicePlanList{IncludeBrokerFields: []string{"guid", "name"}}), + ) + + DescribeTable("invalid query", +@@ -34,6 +35,7 @@ var _ = Describe("ServicePlan", func() { + }, + Entry("invalid available", "available=invalid", MatchError(ContainSubstring("failed to parse"))), + Entry("invalid include", "include=foo", MatchError(ContainSubstring("value must be one of: service_offering"))), ++ Entry("invalid service broker fields", "fields[service_offering.service_broker]=foo", MatchError(ContainSubstring("value must be one of"))), + ) + + Describe("ToMessage", func() { +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+3SPU/DMBAG4Mz5FUeLxFQ7SdNWQmJgY0SIPcqHmxhSO7LjCP49TigfQoIurRDi ++fZZznHN8yh0rnGyrTKiBB6cSeZvVaore1zit41USJ8kmXSdJEMXxOkoDWp2sok+c7XNDFBit+5/y ++Dr3/o9hH/3th+6zUu12uKmab491xqP/pMn3vf7r0ebEfg2VA0fFK+N4/7//8jBdS8SK3TVhWNA1B ++IaowFE+dNj3dXt/fXM24s4a3usxbXuvxwCUf/8fbw/mYNQvDOd05RX0jyAozyFJkXZsravxAtcKQ ++D9Tlz63OKxrvIeukj+SsVPV0rDP6QZT9haVaqsda0yCMlVqFfmn8p2vZN65gfki5Vlby1yw+JPsV ++LQZaLLa6dHaxla2g2edCsvFSVusZMZ53ku/rspwxtt/alzdthb/dGwAAAAAAAAAAAAAAAAAAAACA ++Q14ABmn5HwAoAAA= +diff --git 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-000685/tests/test.sh b/tasks/format-code-task-000685/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..694ac9991f16f326740c0f1a02aeaaf02956eaad --- /dev/null +++ b/tasks/format-code-task-000685/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' +api/handlers/service_plan_test.go +api/payloads/service_plan_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-000685/tests/test_command.sh b/tasks/format-code-task-000685/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000685/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000812/environment/Dockerfile b/tasks/format-code-task-000812/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ad7b17dc756a29891a2909cd33c8a6837ff7a318 --- /dev/null +++ b/tasks/format-code-task-000812/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d7cb330f159cb4895b43c693691287550c79fc5be1620969f20e2711ea12836e diff --git a/tasks/format-code-task-000812/environment/setup/files/blocklist b/tasks/format-code-task-000812/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000812/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000812/environment/setup/setup.sh b/tasks/format-code-task-000812/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000812/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000812/tests/test.patch b/tasks/format-code-task-000812/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b4d244f60256259bc273c9f590b3f74c6209a05c --- /dev/null +++ b/tasks/format-code-task-000812/tests/test.patch @@ -0,0 +1,135 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..6547e25 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["DJANGO_SETTINGS_MODULE=tests.settings python -m pytest tests/test_oidc_views.py -v -k \"get_additional_claims_default_signature_accepts_request or test_userinfo_endpoint_subclass_dict_with_request_uses_request_user or test_userinfo_endpoint_subclass_dict_multiple_claims or test_userinfo_endpoint_default_validator_returns_only_sub\""] ++} +diff --git a/tests/test_oidc_views.py b/tests/test_oidc_views.py +index 719d10e..b2efefc 100644 +--- a/tests/test_oidc_views.py ++++ b/tests/test_oidc_views.py +@@ -179,3 +179,108 @@ def test_userinfo_endpoint_custom_claims(oidc_tokens, client, oauth2_settings): + + assert "email" in data + assert data["email"] == EXAMPLE_EMAIL ++ ++ ++ ++ ++ ++ ++ ++def test_get_additional_claims_default_signature_accepts_request(): ++ """The default OAuth2Validator.get_additional_claims must accept a ++ `request` argument (backwards-compatible API contract that downstream ++ subclasses rely on). ++ """ ++ validator = OAuth2Validator() ++ ++ ++ dummy_request = object() ++ ++ result = validator.get_additional_claims(dummy_request) ++ ++ ++ assert result == {} or result == [] or result == () or list(result) == [] ++ ++ ++@pytest.mark.django_db ++def test_userinfo_endpoint_subclass_dict_with_request_uses_request_user( ++ oidc_tokens, client, oauth2_settings ++): ++ """A subclass overriding get_additional_claims(self, request) and ++ returning a dict must have its claims propagated to the userinfo ++ JSON response, and the `request` argument it receives must expose ++ the authenticated user (request.user). ++ """ ++ captured = {} ++ ++ class CustomValidator(OAuth2Validator): ++ def get_additional_claims(self, request): ++ ++ captured["user_pk"] = request.user.pk ++ return { ++ "user_pk_claim": str(request.user.pk), ++ } ++ ++ oidc_tokens.oauth2_settings.OAUTH2_VALIDATOR_CLASS = CustomValidator ++ auth_header = "Bearer %s" % oidc_tokens.access_token ++ rsp = client.get( ++ reverse("oauth2_provider:user-info"), ++ HTTP_AUTHORIZATION=auth_header, ++ ) ++ assert rsp.status_code == 200 ++ data = rsp.json() ++ ++ assert captured.get("user_pk") == oidc_tokens.user.pk ++ ++ assert data.get("user_pk_claim") == str(oidc_tokens.user.pk) ++ ++ assert data.get("sub") == str(oidc_tokens.user.pk) ++ ++ ++@pytest.mark.django_db ++def test_userinfo_endpoint_subclass_dict_multiple_claims( ++ oidc_tokens, client, oauth2_settings ++): ++ """A subclass override returning a dict with multiple static claims ++ must surface every (key, value) pair in the userinfo JSON response. ++ """ ++ ++ class CustomValidator(OAuth2Validator): ++ def get_additional_claims(self, request): ++ return { ++ "given_name": "Alice", ++ "family_name": "Liddell", ++ "custom_flag": "wonderland", ++ } ++ ++ oidc_tokens.oauth2_settings.OAUTH2_VALIDATOR_CLASS = CustomValidator ++ auth_header = "Bearer %s" % oidc_tokens.access_token ++ rsp = client.get( ++ reverse("oauth2_provider:user-info"), ++ HTTP_AUTHORIZATION=auth_header, ++ ) ++ assert rsp.status_code == 200 ++ data = rsp.json() ++ assert data.get("given_name") == "Alice" ++ assert data.get("family_name") == "Liddell" ++ assert data.get("custom_flag") == "wonderland" ++ assert data.get("sub") == str(oidc_tokens.user.pk) ++ ++ ++@pytest.mark.django_db ++def test_userinfo_endpoint_default_validator_returns_only_sub( ++ oidc_tokens, client, oauth2_settings ++): ++ """With the unmodified default OAuth2Validator (no subclassing), ++ the userinfo endpoint must still return the required `sub` claim ++ and the call path through get_additional_claims(request) must not ++ error out. ++ """ ++ auth_header = "Bearer %s" % oidc_tokens.access_token ++ rsp = client.get( ++ reverse("oauth2_provider:user-info"), ++ HTTP_AUTHORIZATION=auth_header, ++ ) ++ assert rsp.status_code == 200 ++ data = rsp.json() ++ assert data.get("sub") == str(oidc_tokens.user.pk) +diff --git 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 ++DJANGO_SETTINGS_MODULE=tests.settings python -m pytest tests/test_oidc_views.py -v -k "get_additional_claims_default_signature_accepts_request or test_userinfo_endpoint_subclass_dict_with_request_uses_request_user or test_userinfo_endpoint_subclass_dict_multiple_claims or test_userinfo_endpoint_default_validator_returns_only_sub" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000812/tests/test.sh b/tasks/format-code-task-000812/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..03ca42abf23962710a663f5a1ccb2f8fc3ba007a --- /dev/null +++ b/tasks/format-code-task-000812/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_oidc_views.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-000812/tests/test_command.sh b/tasks/format-code-task-000812/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000812/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000815/environment/Dockerfile b/tasks/format-code-task-000815/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b79941c67697dd075c383f5d17ba896b998a3cba --- /dev/null +++ b/tasks/format-code-task-000815/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1680db2f95503807e37198273e358783ca2b8f39b15eadad5f641aef368c762b diff --git a/tasks/format-code-task-000815/environment/setup/files/blocklist b/tasks/format-code-task-000815/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000815/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000815/environment/setup/setup.sh b/tasks/format-code-task-000815/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000815/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000815/tests/test.patch b/tasks/format-code-task-000815/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0a5a65efa06d12ca73d7982ea3cb7fd7a85b385b --- /dev/null +++ b/tasks/format-code-task-000815/tests/test.patch @@ -0,0 +1,373 @@ +diff --git a/usercase-test-coderl/snapshot_serialization.test.js b/usercase-test-coderl/snapshot_serialization.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/snapshot_serialization.test.js +@@ -0,0 +1,336 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import chai from 'chai'; ++import { System } from '../js/objects/System.js'; ++import handInterface from '../js/objects/utils/handInterface.js'; ++ ++const assert = chai.assert; ++const expect = chai.expect; ++ ++function ensureBrowserPolyfills(){ ++ if(!window.URL.createObjectURL){ ++ window.URL.createObjectURL = function createObjectURLMock(){ ++ return 'blob:localb-polyfill'; ++ }; ++ } ++ if(!window.URL.revokeObjectURL){ ++ window.URL.revokeObjectURL = function revokeObjectURLMock(){}; ++ } ++} ++ ++function sendSaveHTML(fileName){ ++ const args = fileName === undefined ? [] : [fileName]; ++ return System.world.sendMessage({ ++ type: 'command', ++ commandName: 'saveHTML', ++ args: args ++ }, System); ++} ++ ++function installDownloadRecorder(){ ++ ensureBrowserPolyfills(); ++ const clicks = []; ++ const revoked = []; ++ const objectUrls = []; ++ const originalClick = window.HTMLAnchorElement.prototype.click; ++ const originalCreateObjectURL = window.URL.createObjectURL; ++ const originalRevokeObjectURL = window.URL.revokeObjectURL; ++ ++ window.HTMLAnchorElement.prototype.click = function clickRecorder(){ ++ clicks.push({ ++ download: this.download, ++ href: this.href, ++ hrefPrefix: this.href.slice(0, 30), ++ hrefLength: this.href.length, ++ display: this.style.display, ++ hidden: this.hidden, ++ visibility: this.style.visibility, ++ inBodyAtClick: document.body.contains(this) ++ }); ++ }; ++ window.URL.createObjectURL = function createObjectURLRecorder(blob){ ++ const url = `blob:localb-${objectUrls.length}`; ++ objectUrls.push({url, blob}); ++ return url; ++ }; ++ window.URL.revokeObjectURL = function revokeRecorder(url){ ++ revoked.push({ ++ url, ++ prefix: url.slice(0, 30), ++ length: url.length ++ }); ++ }; ++ ++ return { ++ clicks, ++ revoked, ++ objectUrls, ++ restore(){ ++ window.HTMLAnchorElement.prototype.click = originalClick; ++ window.URL.createObjectURL = originalCreateObjectURL; ++ window.URL.revokeObjectURL = originalRevokeObjectURL; ++ } ++ }; ++} ++ ++function assertFullSnapshotHTML(html){ ++ ++ assert.strictEqual(typeof html, 'string'); ++ assert.isAbove(html.length, 0); ++ const parsed = new window.DOMParser().parseFromString(html, 'text/html'); ++ assert.strictEqual(parsed.documentElement.tagName.toLowerCase(), 'html'); ++ assert.strictEqual(parsed.querySelectorAll('st-world').length, 0); ++ assert.strictEqual(parsed.querySelectorAll('st-navigator').length, 0); ++ assert.strictEqual(Boolean(parsed.getElementById('serialization')), true); ++} ++ ++function assertHiddenAnchorClick(click){ ++ ++ assert.strictEqual(click.inBodyAtClick, true); ++ assert.isTrue(click.display === 'none' || click.hidden || click.visibility === 'hidden'); ++} ++ ++async function extractDownloadedHTML(click, downloadRecorder){ ++ if(click.href.startsWith('data:')){ ++ const commaIndex = click.href.indexOf(','); ++ assert.isAtLeast(commaIndex, 0); ++ return decodeURIComponent(click.href.slice(commaIndex + 1)); ++ } ++ ++ const objectUrl = downloadRecorder.objectUrls.find(entry => entry.url === click.href); ++ assert.isOk(objectUrl, `download href should be a recorded data or blob URL, got ${click.href}`); ++ assert.isFunction(objectUrl.blob.text, 'recorded Blob should expose text()'); ++ return objectUrl.blob.text(); ++} ++ ++describe('Usercase snapshot serialization acceptance', () => { ++ let recorder; ++ ++ beforeEach(() => { ++ recorder = installDownloadRecorder(); ++ handInterface.handDetectionRunning = false; ++ Array.from(document.querySelectorAll('a[download]')).forEach(anchor => anchor.remove()); ++ }); ++ ++ afterEach(() => { ++ recorder.restore(); ++ handInterface.handDetectionRunning = false; ++ Array.from(document.querySelectorAll('a[download]')).forEach(anchor => anchor.remove()); ++ }); ++ ++ it('returns a full cloned HTML snapshot without live world or navigator', () => { ++ ++ ++ ++ ++ const html = System.getFullHTMLString(); ++ ++ assertFullSnapshotHTML(html); ++ assert.strictEqual(html.includes('