Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- tasks/format-code-task-000011/environment/DockerfileAdded+3
- tasks/format-code-task-000011/environment/setup/files/blocklistAdded+33
- tasks/format-code-task-000011/environment/setup/setup.shAdded+34
- tasks/format-code-task-000011/tests/test.patchAdded+72
- tasks/format-code-task-000011/tests/test.shAdded+40
- tasks/format-code-task-000011/tests/test_command.shAdded+1
- tasks/format-code-task-000016/environment/DockerfileAdded+3
- tasks/format-code-task-000016/environment/setup/files/blocklistAdded+33
- tasks/format-code-task-000016/environment/setup/setup.shAdded+34
- tasks/format-code-task-000016/tests/test.patchAdded+981
- tasks/format-code-task-000016/tests/test.shAdded+39
- tasks/format-code-task-000016/tests/test_command.shAdded+1
- tasks/format-code-task-000018/environment/DockerfileAdded+3
- tasks/format-code-task-000018/environment/setup/files/blocklistAdded+33
- tasks/format-code-task-000018/environment/setup/setup.shAdded+34
- tasks/format-code-task-000018/tests/test.patchAdded+225
- tasks/format-code-task-000018/tests/test.shAdded+38
- tasks/format-code-task-000018/tests/test_command.shAdded+1
- tasks/format-code-task-000020/environment/DockerfileAdded+3
- tasks/format-code-task-000020/environment/setup/files/blocklistAdded+33
- tasks/format-code-task-000020/environment/setup/setup.shAdded+34
- tasks/format-code-task-000020/tests/test.patchAdded+133
- tasks/format-code-task-000020/tests/test.shAdded+38
- tasks/format-code-task-000020/tests/test_command.shAdded+1
- tasks/format-code-task-000027/environment/DockerfileAdded+3
- tasks/format-code-task-000027/environment/setup/files/blocklistAdded+33
- tasks/format-code-task-000027/environment/setup/setup.shAdded+34
- tasks/format-code-task-000027/tests/test.patchAdded+78
- tasks/format-code-task-000027/tests/test.shAdded+39
- tasks/format-code-task-000027/tests/test_command.shAdded+1
- tasks/format-code-task-000029/environment/DockerfileAdded+3
- tasks/format-code-task-000029/environment/setup/files/blocklistAdded+33
- tasks/format-code-task-000029/environment/setup/setup.shAdded+34
- tasks/format-code-task-000029/tests/test.patchAdded+79
- tasks/format-code-task-000029/tests/test.shAdded+39
- tasks/format-code-task-000029/tests/test_command.shAdded+1
- tasks/format-code-task-000042/environment/DockerfileAdded+3
- tasks/format-code-task-000042/environment/setup/files/blocklistAdded+33
- tasks/format-code-task-000042/environment/setup/setup.shAdded+34
- tasks/format-code-task-000042/tests/test.patchAdded+55
- tasks/format-code-task-000042/tests/test.shAdded+39
- tasks/format-code-task-000042/tests/test_command.shAdded+1
- tasks/format-code-task-000045/environment/DockerfileAdded+3
- tasks/format-code-task-000045/environment/setup/files/blocklistAdded+33
- tasks/format-code-task-000045/environment/setup/setup.shAdded+34
- tasks/format-code-task-000045/tests/test.patchAdded+120
- tasks/format-code-task-000045/tests/test.shAdded+39
- tasks/format-code-task-000045/tests/test_command.shAdded+1
- tasks/format-code-task-000089/environment/DockerfileAdded+3
- tasks/format-code-task-000089/environment/setup/files/blocklistAdded+33
123# The task's image, pinned by digest (the same as [environment].docker_image).# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c8522aaf8f02f486d9dfadc34812d082efbca8b337cf987d2940045cd93f00a3123456789101112131415161718192021222324252627282930313233# mimo answer-leak blocklist (mimoagent)0.0.0.0 github.com0.0.0.0 www.github.com0.0.0.0 api.github.com0.0.0.0 raw.githubusercontent.com0.0.0.0 codeload.github.com0.0.0.0 objects.githubusercontent.com0.0.0.0 gist.github.com0.0.0.0 gist.githubusercontent.com0.0.0.0 gitlab.com0.0.0.0 bitbucket.org0.0.0.0 sourceforge.net0.0.0.0 git.kernel.org0.0.0.0 chromium.googlesource.com0.0.0.0 android.googlesource.com0.0.0.0 sourcegraph.com0.0.0.0 bugs.chromium.org0.0.0.0 issues.oss-fuzz.com0.0.0.0 oss-fuzz.com0.0.0.0 osv.dev0.0.0.0 api.osv.dev0.0.0.0 bugzilla.mozilla.org0.0.0.0 proxy.golang.org0.0.0.0 sum.golang.org0.0.0.0 pkg.go.dev0.0.0.0 google.com0.0.0.0 www.google.com0.0.0.0 bing.com0.0.0.0 www.bing.com0.0.0.0 duckduckgo.com0.0.0.0 html.duckduckgo.com0.0.0.0 search.brave.com0.0.0.0 stackoverflow.com12345678910111213141516171819202122232425262728293031323334#!/bin/bash# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.M=/var/lib/mimo[ -f "$M/ready" ] && exit 0chmod 700 "$M"fail() { echo "setup: $*" >&2; exit 1; }# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installswrite_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).CWD=/testbedgit config --global --add safe.directory "$CWD"cd "$CWD" || fail "no working directory $CWD"if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-emptyfiBASE=$(git rev-parse HEAD 2>/dev/null)[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"echo "$BASE" > "$M/base"# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,# so .git is hidden while the agent works and put back for grading.LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; truegit clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; trueif [ "$LATER" -gt 0 ]; then mv "$CWD/.git" "$M/git-hidden" echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"fiwrite_blocklist
touch "$M/ready"echo "setup done"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172diff --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.goindex 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.goindex 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.b64new 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.shnew 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'12345678910111213141516171819202122232425262728293031323334353637383940#!/bin/bash# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.M=/var/lib/mimoCWD=/testbedV=/logs/verifiermkdir -p "$V"BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }cd "$CWD" || exit 1if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi# the agent's change against the base, so its own commits count toogit add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"git reset -qif ! (while IFS= read -r tf; do [ -z "$tf" ] && continue if git cat-file -e $BASE:"$tf" 2>/dev/null; then git checkout $BASE -- "$tf" 2>/dev/null || true else git rm -f --cached "$tf" >/dev/null 2>&1 || true rm -f "$tf" fidone <<'EOF_RESET_TEST_FILES'leetcode/1201-1300/1277.Count-Square-Submatrices-with-All-Ones/Solution_test.goleetcode/301-400/0338.Counting-Bits/Solution_test.gomimo_build_env.tar.gz.b64mimo_test_command.shEOF_RESET_TEST_FILES
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fiif ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then cat "$V/apply.log" >&2 echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 exit 1fitimeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1RC=$?tail -c 12000 "$V/test_output.log"if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fiecho "test command exited $RC"1bash /testbed/mimo_test_command.sh123# The task's image, pinned by digest (the same as [environment].docker_image).# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5f46605969f46946830b492ccca83d68404d50cce97b3796b8bd2257715d0ba1123456789101112131415161718192021222324252627282930313233# mimo answer-leak blocklist (mimoagent)0.0.0.0 github.com0.0.0.0 www.github.com0.0.0.0 api.github.com0.0.0.0 raw.githubusercontent.com0.0.0.0 codeload.github.com0.0.0.0 objects.githubusercontent.com0.0.0.0 gist.github.com0.0.0.0 gist.githubusercontent.com0.0.0.0 gitlab.com0.0.0.0 bitbucket.org0.0.0.0 sourceforge.net0.0.0.0 git.kernel.org0.0.0.0 chromium.googlesource.com0.0.0.0 android.googlesource.com0.0.0.0 sourcegraph.com0.0.0.0 bugs.chromium.org0.0.0.0 issues.oss-fuzz.com0.0.0.0 oss-fuzz.com0.0.0.0 osv.dev0.0.0.0 api.osv.dev0.0.0.0 bugzilla.mozilla.org0.0.0.0 proxy.golang.org0.0.0.0 sum.golang.org0.0.0.0 pkg.go.dev0.0.0.0 google.com0.0.0.0 www.google.com0.0.0.0 bing.com0.0.0.0 www.bing.com0.0.0.0 duckduckgo.com0.0.0.0 html.duckduckgo.com0.0.0.0 search.brave.com0.0.0.0 stackoverflow.com12345678910111213141516171819202122232425262728293031323334#!/bin/bash# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.M=/var/lib/mimo[ -f "$M/ready" ] && exit 0chmod 700 "$M"fail() { echo "setup: $*" >&2; exit 1; }# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installswrite_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).CWD=/testbedgit config --global --add safe.directory "$CWD"cd "$CWD" || fail "no working directory $CWD"if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-emptyfiBASE=$(git rev-parse HEAD 2>/dev/null)[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"echo "$BASE" > "$M/base"# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,# so .git is hidden while the agent works and put back for grading.LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; truegit clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; trueif [ "$LATER" -gt 0 ]; then mv "$CWD/.git" "$M/git-hidden" echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"fiwrite_blocklist
touch "$M/ready"echo "setup done"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981diff --git a/tests/tests_api.py b/tests/tests_api.pyindex 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.b64new 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/sQAAAAAAAAAAAAAAAAAAAAAALN5BXSVXu8AKAAAdiff --git a/mimo_test_command.sh b/mimo_test_command.shnew 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'123456789101112131415161718192021222324252627282930313233343536373839#!/bin/bash# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.M=/var/lib/mimoCWD=/testbedV=/logs/verifiermkdir -p "$V"BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }cd "$CWD" || exit 1if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi# the agent's change against the base, so its own commits count toogit add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"git reset -qif ! (while IFS= read -r tf; do [ -z "$tf" ] && continue if git cat-file -e $BASE:"$tf" 2>/dev/null; then git checkout $BASE -- "$tf" 2>/dev/null || true else git rm -f --cached "$tf" >/dev/null 2>&1 || true rm -f "$tf" fidone <<'EOF_RESET_TEST_FILES'tests/tests_api.pymimo_build_env.tar.gz.b64mimo_test_command.shEOF_RESET_TEST_FILES
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fiif ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then cat "$V/apply.log" >&2 echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 exit 1fitimeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1RC=$?tail -c 12000 "$V/test_output.log"if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fiecho "test command exited $RC"1bash /testbed/mimo_test_command.sh123# The task's image, pinned by digest (the same as [environment].docker_image).# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:627524c653f2b1669cafec6ac48ceeadbc3cd695383a5954f060fb4ee4d1f4a5123456789101112131415161718192021222324252627282930313233# mimo answer-leak blocklist (mimoagent)0.0.0.0 github.com0.0.0.0 www.github.com0.0.0.0 api.github.com0.0.0.0 raw.githubusercontent.com0.0.0.0 codeload.github.com0.0.0.0 objects.githubusercontent.com0.0.0.0 gist.github.com0.0.0.0 gist.githubusercontent.com0.0.0.0 gitlab.com0.0.0.0 bitbucket.org0.0.0.0 sourceforge.net0.0.0.0 git.kernel.org0.0.0.0 chromium.googlesource.com0.0.0.0 android.googlesource.com0.0.0.0 sourcegraph.com0.0.0.0 bugs.chromium.org0.0.0.0 issues.oss-fuzz.com0.0.0.0 oss-fuzz.com0.0.0.0 osv.dev0.0.0.0 api.osv.dev0.0.0.0 bugzilla.mozilla.org0.0.0.0 proxy.golang.org0.0.0.0 sum.golang.org0.0.0.0 pkg.go.dev0.0.0.0 google.com0.0.0.0 www.google.com0.0.0.0 bing.com0.0.0.0 www.bing.com0.0.0.0 duckduckgo.com0.0.0.0 html.duckduckgo.com0.0.0.0 search.brave.com0.0.0.0 stackoverflow.com12345678910111213141516171819202122232425262728293031323334#!/bin/bash# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.M=/var/lib/mimo[ -f "$M/ready" ] && exit 0chmod 700 "$M"fail() { echo "setup: $*" >&2; exit 1; }# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installswrite_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).CWD=/testbedgit config --global --add safe.directory "$CWD"cd "$CWD" || fail "no working directory $CWD"if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-emptyfiBASE=$(git rev-parse HEAD 2>/dev/null)[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"echo "$BASE" > "$M/base"# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,# so .git is hidden while the agent works and put back for grading.LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; truegit clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; trueif [ "$LATER" -gt 0 ]; then mv "$CWD/.git" "$M/git-hidden" echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"fiwrite_blocklist
touch "$M/ready"echo "setup done"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225diff --git a/tests/covalent_tests/results_manager_tests/root_dispatch_id_test.py b/tests/covalent_tests/results_manager_tests/root_dispatch_id_test.pynew file mode 100644index 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_iddiff --git a/mimo_test_command.sh b/mimo_test_command.shnew 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.py1234567891011121314151617181920212223242526272829303132333435363738#!/bin/bash# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.M=/var/lib/mimoCWD=/testbedV=/logs/verifiermkdir -p "$V"BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }cd "$CWD" || exit 1if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi# the agent's change against the base, so its own commits count toogit add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"git reset -qif ! (while IFS= read -r tf; do [ -z "$tf" ] && continue if git cat-file -e $BASE:"$tf" 2>/dev/null; then git checkout $BASE -- "$tf" 2>/dev/null || true else git rm -f --cached "$tf" >/dev/null 2>&1 || true rm -f "$tf" fidone <<'EOF_RESET_TEST_FILES'tests/covalent_tests/results_manager_tests/root_dispatch_id_test.pymimo_test_command.shEOF_RESET_TEST_FILES
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fiif ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then cat "$V/apply.log" >&2 echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 exit 1fitimeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1RC=$?tail -c 12000 "$V/test_output.log"if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fiecho "test command exited $RC"1bash /testbed/mimo_test_command.sh123# The task's image, pinned by digest (the same as [environment].docker_image).# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e8f805c67ada7162c7dfea3a3d48857b90ac0c5376b4822500c9053bf1987127123456789101112131415161718192021222324252627282930313233# mimo answer-leak blocklist (mimoagent)0.0.0.0 github.com0.0.0.0 www.github.com0.0.0.0 api.github.com0.0.0.0 raw.githubusercontent.com0.0.0.0 codeload.github.com0.0.0.0 objects.githubusercontent.com0.0.0.0 gist.github.com0.0.0.0 gist.githubusercontent.com0.0.0.0 gitlab.com0.0.0.0 bitbucket.org0.0.0.0 sourceforge.net0.0.0.0 git.kernel.org0.0.0.0 chromium.googlesource.com0.0.0.0 android.googlesource.com0.0.0.0 sourcegraph.com0.0.0.0 bugs.chromium.org0.0.0.0 issues.oss-fuzz.com0.0.0.0 oss-fuzz.com0.0.0.0 osv.dev0.0.0.0 api.osv.dev0.0.0.0 bugzilla.mozilla.org0.0.0.0 proxy.golang.org0.0.0.0 sum.golang.org0.0.0.0 pkg.go.dev0.0.0.0 google.com0.0.0.0 www.google.com0.0.0.0 bing.com0.0.0.0 www.bing.com0.0.0.0 duckduckgo.com0.0.0.0 html.duckduckgo.com0.0.0.0 search.brave.com0.0.0.0 stackoverflow.com12345678910111213141516171819202122232425262728293031323334#!/bin/bash# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.M=/var/lib/mimo[ -f "$M/ready" ] && exit 0chmod 700 "$M"fail() { echo "setup: $*" >&2; exit 1; }# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installswrite_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).CWD=/testbedgit config --global --add safe.directory "$CWD"cd "$CWD" || fail "no working directory $CWD"if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-emptyfiBASE=$(git rev-parse HEAD 2>/dev/null)[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"echo "$BASE" > "$M/base"# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,# so .git is hidden while the agent works and put back for grading.LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; truegit clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; trueif [ "$LATER" -gt 0 ]; then mv "$CWD/.git" "$M/git-hidden" echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"fiwrite_blocklist
touch "$M/ready"echo "setup done"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133diff --git a/test/categorical_algebra/CatElements.jl b/test/categorical_algebra/CatElements.jlindex 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 = 2diff --git a/mimo_test_command.sh b/mimo_test_command.shnew 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+ ;;+esac1234567891011121314151617181920212223242526272829303132333435363738#!/bin/bash# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.M=/var/lib/mimoCWD=/testbedV=/logs/verifiermkdir -p "$V"BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }cd "$CWD" || exit 1if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi# the agent's change against the base, so its own commits count toogit add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"git reset -qif ! (while IFS= read -r tf; do [ -z "$tf" ] && continue if git cat-file -e $BASE:"$tf" 2>/dev/null; then git checkout $BASE -- "$tf" 2>/dev/null || true else git rm -f --cached "$tf" >/dev/null 2>&1 || true rm -f "$tf" fidone <<'EOF_RESET_TEST_FILES'test/categorical_algebra/CatElements.jlmimo_test_command.shEOF_RESET_TEST_FILES
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fiif ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then cat "$V/apply.log" >&2 echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 exit 1fitimeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1RC=$?tail -c 12000 "$V/test_output.log"if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fiecho "test command exited $RC"1bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new123# The task's image, pinned by digest (the same as [environment].docker_image).# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b342c819994822f62255717bd8ed7917e91965ca9bc7fab36f339edd596bdb2f123456789101112131415161718192021222324252627282930313233# mimo answer-leak blocklist (mimoagent)0.0.0.0 github.com0.0.0.0 www.github.com0.0.0.0 api.github.com0.0.0.0 raw.githubusercontent.com0.0.0.0 codeload.github.com0.0.0.0 objects.githubusercontent.com0.0.0.0 gist.github.com0.0.0.0 gist.githubusercontent.com0.0.0.0 gitlab.com0.0.0.0 bitbucket.org0.0.0.0 sourceforge.net0.0.0.0 git.kernel.org0.0.0.0 chromium.googlesource.com0.0.0.0 android.googlesource.com0.0.0.0 sourcegraph.com0.0.0.0 bugs.chromium.org0.0.0.0 issues.oss-fuzz.com0.0.0.0 oss-fuzz.com0.0.0.0 osv.dev0.0.0.0 api.osv.dev0.0.0.0 bugzilla.mozilla.org0.0.0.0 proxy.golang.org0.0.0.0 sum.golang.org0.0.0.0 pkg.go.dev0.0.0.0 google.com0.0.0.0 www.google.com0.0.0.0 bing.com0.0.0.0 www.bing.com0.0.0.0 duckduckgo.com0.0.0.0 html.duckduckgo.com0.0.0.0 search.brave.com0.0.0.0 stackoverflow.com12345678910111213141516171819202122232425262728293031323334#!/bin/bash# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.M=/var/lib/mimo[ -f "$M/ready" ] && exit 0chmod 700 "$M"fail() { echo "setup: $*" >&2; exit 1; }# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installswrite_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).CWD=/testbedgit config --global --add safe.directory "$CWD"cd "$CWD" || fail "no working directory $CWD"if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-emptyfiBASE=$(git rev-parse HEAD 2>/dev/null)[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"echo "$BASE" > "$M/base"# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,# so .git is hidden while the agent works and put back for grading.LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; truegit clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; trueif [ "$LATER" -gt 0 ]; then mv "$CWD/.git" "$M/git-hidden" echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"fiwrite_blocklist
touch "$M/ready"echo "setup done"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778diff --git a/test/types/schema.test.ts b/test/types/schema.test.tsindex fc0204e2a..fc7ae0fa0 100644--- a/test/types/schema.test.ts+++ b/test/types/schema.test.ts@@ -1230,3 +1230,51 @@ async function gh13797() { expectType<IUser>(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<Map<string, number>>(doc.myMap);+ expectType<number | undefined>(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<Map<string, string>>(doc.myMap);+ expectType<string | undefined>(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<Map<string, any>>(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<Map<string, number>>(doc.myMap);+}diff --git a/test_commands.json b/test_commands.jsonnew file mode 100644index 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.shnew 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 $rc123456789101112131415161718192021222324252627282930313233343536373839#!/bin/bash# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.M=/var/lib/mimoCWD=/testbedV=/logs/verifiermkdir -p "$V"BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }cd "$CWD" || exit 1if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi# the agent's change against the base, so its own commits count toogit add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"git reset -qif ! (while IFS= read -r tf; do [ -z "$tf" ] && continue if git cat-file -e $BASE:"$tf" 2>/dev/null; then git checkout $BASE -- "$tf" 2>/dev/null || true else git rm -f --cached "$tf" >/dev/null 2>&1 || true rm -f "$tf" fidone <<'EOF_RESET_TEST_FILES'test/types/schema.test.tstest_commands.jsonmimo_test_command.shEOF_RESET_TEST_FILES
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fiif ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then cat "$V/apply.log" >&2 echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 exit 1fitimeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1RC=$?tail -c 12000 "$V/test_output.log"if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fiecho "test command exited $RC"1bash /testbed/mimo_test_command.sh123# The task's image, pinned by digest (the same as [environment].docker_image).# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:83c68bed4b1c6ec51847df71e135dd5635b377dfabfcc7f856f03e6203e1621e123456789101112131415161718192021222324252627282930313233# mimo answer-leak blocklist (mimoagent)0.0.0.0 github.com0.0.0.0 www.github.com0.0.0.0 api.github.com0.0.0.0 raw.githubusercontent.com0.0.0.0 codeload.github.com0.0.0.0 objects.githubusercontent.com0.0.0.0 gist.github.com0.0.0.0 gist.githubusercontent.com0.0.0.0 gitlab.com0.0.0.0 bitbucket.org0.0.0.0 sourceforge.net0.0.0.0 git.kernel.org0.0.0.0 chromium.googlesource.com0.0.0.0 android.googlesource.com0.0.0.0 sourcegraph.com0.0.0.0 bugs.chromium.org0.0.0.0 issues.oss-fuzz.com0.0.0.0 oss-fuzz.com0.0.0.0 osv.dev0.0.0.0 api.osv.dev0.0.0.0 bugzilla.mozilla.org0.0.0.0 proxy.golang.org0.0.0.0 sum.golang.org0.0.0.0 pkg.go.dev0.0.0.0 google.com0.0.0.0 www.google.com0.0.0.0 bing.com0.0.0.0 www.bing.com0.0.0.0 duckduckgo.com0.0.0.0 html.duckduckgo.com0.0.0.0 search.brave.com0.0.0.0 stackoverflow.com12345678910111213141516171819202122232425262728293031323334#!/bin/bash# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.M=/var/lib/mimo[ -f "$M/ready" ] && exit 0chmod 700 "$M"fail() { echo "setup: $*" >&2; exit 1; }# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installswrite_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).CWD=/testbedgit config --global --add safe.directory "$CWD"cd "$CWD" || fail "no working directory $CWD"if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-emptyfiBASE=$(git rev-parse HEAD 2>/dev/null)[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"echo "$BASE" > "$M/base"# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,# so .git is hidden while the agent works and put back for grading.LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; truegit clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; trueif [ "$LATER" -gt 0 ]; then mv "$CWD/.git" "$M/git-hidden" echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"fiwrite_blocklist
touch "$M/ready"echo "setup done"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879diff --git a/test/model.test.js b/test/model.test.jsindex 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.b64new 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.shnew 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'123456789101112131415161718192021222324252627282930313233343536373839#!/bin/bash# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.M=/var/lib/mimoCWD=/testbedV=/logs/verifiermkdir -p "$V"BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }cd "$CWD" || exit 1if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi# the agent's change against the base, so its own commits count toogit add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"git reset -qif ! (while IFS= read -r tf; do [ -z "$tf" ] && continue if git cat-file -e $BASE:"$tf" 2>/dev/null; then git checkout $BASE -- "$tf" 2>/dev/null || true else git rm -f --cached "$tf" >/dev/null 2>&1 || true rm -f "$tf" fidone <<'EOF_RESET_TEST_FILES'test/model.test.jsmimo_build_env.tar.gz.b64mimo_test_command.shEOF_RESET_TEST_FILES
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fiif ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then cat "$V/apply.log" >&2 echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 exit 1fitimeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1RC=$?tail -c 12000 "$V/test_output.log"if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fiecho "test command exited $RC"1bash /testbed/mimo_test_command.sh123# The task's image, pinned by digest (the same as [environment].docker_image).# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:df6d414cfb63da9b2b2766392a7de94f58a57b4f6d1656766599ceace007f75c123456789101112131415161718192021222324252627282930313233# mimo answer-leak blocklist (mimoagent)0.0.0.0 github.com0.0.0.0 www.github.com0.0.0.0 api.github.com0.0.0.0 raw.githubusercontent.com0.0.0.0 codeload.github.com0.0.0.0 objects.githubusercontent.com0.0.0.0 gist.github.com0.0.0.0 gist.githubusercontent.com0.0.0.0 gitlab.com0.0.0.0 bitbucket.org0.0.0.0 sourceforge.net0.0.0.0 git.kernel.org0.0.0.0 chromium.googlesource.com0.0.0.0 android.googlesource.com0.0.0.0 sourcegraph.com0.0.0.0 bugs.chromium.org0.0.0.0 issues.oss-fuzz.com0.0.0.0 oss-fuzz.com0.0.0.0 osv.dev0.0.0.0 api.osv.dev0.0.0.0 bugzilla.mozilla.org0.0.0.0 proxy.golang.org0.0.0.0 sum.golang.org0.0.0.0 pkg.go.dev0.0.0.0 google.com0.0.0.0 www.google.com0.0.0.0 bing.com0.0.0.0 www.bing.com0.0.0.0 duckduckgo.com0.0.0.0 html.duckduckgo.com0.0.0.0 search.brave.com0.0.0.0 stackoverflow.com12345678910111213141516171819202122232425262728293031323334#!/bin/bash# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.M=/var/lib/mimo[ -f "$M/ready" ] && exit 0chmod 700 "$M"fail() { echo "setup: $*" >&2; exit 1; }# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installswrite_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).CWD=/testbedgit config --global --add safe.directory "$CWD"cd "$CWD" || fail "no working directory $CWD"if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-emptyfiBASE=$(git rev-parse HEAD 2>/dev/null)[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"echo "$BASE" > "$M/base"# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,# so .git is hidden while the agent works and put back for grading.LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; truegit clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; trueif [ "$LATER" -gt 0 ]; then mv "$CWD/.git" "$M/git-hidden" echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"fiwrite_blocklist
touch "$M/ready"echo "setup done"12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455diff --git a/test/data/dataset/test_dataset.py b/test/data/dataset/test_dataset.pyindex 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.b64new 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.shnew 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'123456789101112131415161718192021222324252627282930313233343536373839#!/bin/bash# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.M=/var/lib/mimoCWD=/testbedV=/logs/verifiermkdir -p "$V"BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }cd "$CWD" || exit 1if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi# the agent's change against the base, so its own commits count toogit add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"git reset -qif ! (while IFS= read -r tf; do [ -z "$tf" ] && continue if git cat-file -e $BASE:"$tf" 2>/dev/null; then git checkout $BASE -- "$tf" 2>/dev/null || true else git rm -f --cached "$tf" >/dev/null 2>&1 || true rm -f "$tf" fidone <<'EOF_RESET_TEST_FILES'test/data/dataset/test_dataset.pymimo_build_env.tar.gz.b64mimo_test_command.shEOF_RESET_TEST_FILES
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fiif ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then cat "$V/apply.log" >&2 echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 exit 1fitimeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1RC=$?tail -c 12000 "$V/test_output.log"if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fiecho "test command exited $RC"1bash /testbed/mimo_test_command.sh123# The task's image, pinned by digest (the same as [environment].docker_image).# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fcb5d0910fc4725ca505d3cfb8e05b990140a83fe1c17f0152db8c742982feab123456789101112131415161718192021222324252627282930313233# mimo answer-leak blocklist (mimoagent)0.0.0.0 github.com0.0.0.0 www.github.com0.0.0.0 api.github.com0.0.0.0 raw.githubusercontent.com0.0.0.0 codeload.github.com0.0.0.0 objects.githubusercontent.com0.0.0.0 gist.github.com0.0.0.0 gist.githubusercontent.com0.0.0.0 gitlab.com0.0.0.0 bitbucket.org0.0.0.0 sourceforge.net0.0.0.0 git.kernel.org0.0.0.0 chromium.googlesource.com0.0.0.0 android.googlesource.com0.0.0.0 sourcegraph.com0.0.0.0 bugs.chromium.org0.0.0.0 issues.oss-fuzz.com0.0.0.0 oss-fuzz.com0.0.0.0 osv.dev0.0.0.0 api.osv.dev0.0.0.0 bugzilla.mozilla.org0.0.0.0 proxy.golang.org0.0.0.0 sum.golang.org0.0.0.0 pkg.go.dev0.0.0.0 google.com0.0.0.0 www.google.com0.0.0.0 bing.com0.0.0.0 www.bing.com0.0.0.0 duckduckgo.com0.0.0.0 html.duckduckgo.com0.0.0.0 search.brave.com0.0.0.0 stackoverflow.com12345678910111213141516171819202122232425262728293031323334#!/bin/bash# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness.M=/var/lib/mimo[ -f "$M/ready" ] && exit 0chmod 700 "$M"fail() { echo "setup: $*" >&2; exit 1; }# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installswrite_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; }
# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code).CWD=/testbedgit config --global --add safe.directory "$CWD"cd "$CWD" || fail "no working directory $CWD"if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-emptyfiBASE=$(git rev-parse HEAD 2>/dev/null)[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD"echo "$BASE" > "$M/base"# Images are built with history truncated at the base. If one is not, the fix could be read out of git log,# so .git is hidden while the agent works and put back for grading.LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true)rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; truegit clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; trueif [ "$LATER" -gt 0 ]; then mv "$CWD/.git" "$M/git-hidden" echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works"fiwrite_blocklist
touch "$M/ready"echo "setup done"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120diff --git a/test/BootBot.spec.js b/test/BootBot.spec.jsindex 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.jsonnew file mode 100644index 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.shnew 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 $rc123456789101112131415161718192021222324252627282930313233343536373839#!/bin/bash# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored.M=/var/lib/mimoCWD=/testbedV=/logs/verifiermkdir -p "$V"BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; }cd "$CWD" || exit 1if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi# the agent's change against the base, so its own commits count toogit add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff"git reset -qif ! (while IFS= read -r tf; do [ -z "$tf" ] && continue if git cat-file -e $BASE:"$tf" 2>/dev/null; then git checkout $BASE -- "$tf" 2>/dev/null || true else git rm -f --cached "$tf" >/dev/null 2>&1 || true rm -f "$tf" fidone <<'EOF_RESET_TEST_FILES'test/BootBot.spec.jstest_commands.jsonmimo_test_command.shEOF_RESET_TEST_FILES
); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fiif ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then cat "$V/apply.log" >&2 echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 exit 1fitimeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1RC=$?tail -c 12000 "$V/test_output.log"if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fiecho "test command exited $RC"1bash /testbed/mimo_test_command.sh123# The task's image, pinned by digest (the same as [environment].docker_image).# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy.FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:02c1b61699c8ba5562395a4c5ba9f565c5d5a31733ae3fe5603ddb069efea7c9123456789101112131415161718192021222324252627282930313233# mimo answer-leak blocklist (mimoagent)0.0.0.0 github.com0.0.0.0 www.github.com0.0.0.0 api.github.com0.0.0.0 raw.githubusercontent.com0.0.0.0 codeload.github.com0.0.0.0 objects.githubusercontent.com0.0.0.0 gist.github.com0.0.0.0 gist.githubusercontent.com0.0.0.0 gitlab.com0.0.0.0 bitbucket.org0.0.0.0 sourceforge.net0.0.0.0 git.kernel.org0.0.0.0 chromium.googlesource.com0.0.0.0 android.googlesource.com0.0.0.0 sourcegraph.com0.0.0.0 bugs.chromium.org0.0.0.0 issues.oss-fuzz.com0.0.0.0 oss-fuzz.com0.0.0.0 osv.dev0.0.0.0 api.osv.dev0.0.0.0 bugzilla.mozilla.org0.0.0.0 proxy.golang.org0.0.0.0 sum.golang.org0.0.0.0 pkg.go.dev0.0.0.0 google.com0.0.0.0 www.google.com0.0.0.0 bing.com0.0.0.0 www.bing.com0.0.0.0 duckduckgo.com0.0.0.0 html.duckduckgo.com0.0.0.0 search.brave.com0.0.0.0 stackoverflow.comtasks/format-code-task-000011/environment/DockerfileAdded+3
tasks/format-code-task-000011/environment/setup/files/blocklistAdded+33
tasks/format-code-task-000011/environment/setup/setup.shAdded+34
tasks/format-code-task-000011/tests/test.patchAdded+72
tasks/format-code-task-000011/tests/test.shAdded+40
tasks/format-code-task-000011/tests/test_command.shAdded+1
tasks/format-code-task-000016/environment/DockerfileAdded+3
tasks/format-code-task-000016/environment/setup/files/blocklistAdded+33
tasks/format-code-task-000016/environment/setup/setup.shAdded+34
tasks/format-code-task-000016/tests/test.patchAdded+981
tasks/format-code-task-000016/tests/test.shAdded+39
tasks/format-code-task-000016/tests/test_command.shAdded+1
tasks/format-code-task-000018/environment/DockerfileAdded+3
tasks/format-code-task-000018/environment/setup/files/blocklistAdded+33
tasks/format-code-task-000018/environment/setup/setup.shAdded+34
tasks/format-code-task-000018/tests/test.patchAdded+225
tasks/format-code-task-000018/tests/test.shAdded+38
tasks/format-code-task-000018/tests/test_command.shAdded+1
tasks/format-code-task-000020/environment/DockerfileAdded+3
tasks/format-code-task-000020/environment/setup/files/blocklistAdded+33
tasks/format-code-task-000020/environment/setup/setup.shAdded+34
tasks/format-code-task-000020/tests/test.patchAdded+133
tasks/format-code-task-000020/tests/test.shAdded+38
tasks/format-code-task-000020/tests/test_command.shAdded+1
tasks/format-code-task-000027/environment/DockerfileAdded+3
tasks/format-code-task-000027/environment/setup/files/blocklistAdded+33
tasks/format-code-task-000027/environment/setup/setup.shAdded+34
tasks/format-code-task-000027/tests/test.patchAdded+78
tasks/format-code-task-000027/tests/test.shAdded+39
tasks/format-code-task-000027/tests/test_command.shAdded+1
tasks/format-code-task-000029/environment/DockerfileAdded+3
tasks/format-code-task-000029/environment/setup/files/blocklistAdded+33
tasks/format-code-task-000029/environment/setup/setup.shAdded+34
tasks/format-code-task-000029/tests/test.patchAdded+79
tasks/format-code-task-000029/tests/test.shAdded+39
tasks/format-code-task-000029/tests/test_command.shAdded+1
tasks/format-code-task-000042/environment/DockerfileAdded+3
tasks/format-code-task-000042/environment/setup/files/blocklistAdded+33
tasks/format-code-task-000042/environment/setup/setup.shAdded+34
tasks/format-code-task-000042/tests/test.patchAdded+55
tasks/format-code-task-000042/tests/test.shAdded+39
tasks/format-code-task-000042/tests/test_command.shAdded+1
tasks/format-code-task-000045/environment/DockerfileAdded+3
tasks/format-code-task-000045/environment/setup/files/blocklistAdded+33
tasks/format-code-task-000045/environment/setup/setup.shAdded+34
tasks/format-code-task-000045/tests/test.patchAdded+120
tasks/format-code-task-000045/tests/test.shAdded+39
tasks/format-code-task-000045/tests/test_command.shAdded+1
tasks/format-code-task-000089/environment/DockerfileAdded+3
tasks/format-code-task-000089/environment/setup/files/blocklistAdded+33