diff --git a/tasks/format-code-task-000110/environment/Dockerfile b/tasks/format-code-task-000110/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..93602ef3da6e9ebdb6d6552608894ba34a99222f --- /dev/null +++ b/tasks/format-code-task-000110/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:73c51c6bcc159c75a12110d77e2a379dcbb68af16798259578598546132f5ca2 diff --git a/tasks/format-code-task-000110/environment/setup/files/blocklist b/tasks/format-code-task-000110/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000110/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000110/environment/setup/setup.sh b/tasks/format-code-task-000110/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000110/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000110/tests/test.patch b/tasks/format-code-task-000110/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8e0c066c323fd7ec63f432be81a43626f3d49810 --- /dev/null +++ b/tasks/format-code-task-000110/tests/test.patch @@ -0,0 +1,188 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..0b5744f +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/apps/test_paint_annotations.py -v"] ++} +diff --git a/tests/apps/test_paint_annotations.py b/tests/apps/test_paint_annotations.py +index b349c03..bb54615 100644 +--- a/tests/apps/test_paint_annotations.py ++++ b/tests/apps/test_paint_annotations.py +@@ -2,12 +2,161 @@ import json + from pathlib import Path + + import numpy as np ++import pytest + from matplotlib import cm + from PIL import Image + + from pyodi.apps.paint_annotations import paint_annotations + + ++def _make_crowd_dataset(tmp_path): ++ """Helper: 1 image, 2 annotations - one normal (cat 0) and one crowd (cat 1).""" ++ images_folder = tmp_path / "images" ++ Path(images_folder).mkdir(exist_ok=True, parents=True) ++ ++ output_folder = tmp_path / "test_result" ++ Path(output_folder).mkdir(exist_ok=True, parents=True) ++ ++ images = [ ++ {"id": 0, "width": 10, "height": 10, "file_name": "test_0.png"}, ++ ] ++ ++ annotations = [ ++ {"image_id": 0, "category_id": 0, "bbox": [0, 0, 2, 2], "score": 1, "iscrowd": 0}, ++ {"image_id": 0, "category_id": 1, "bbox": [5, 5, 2, 2], "score": 1, "iscrowd": 1}, ++ ] ++ ++ categories = [ ++ {"id": 0, "name": "", "supercategory": "object"}, ++ {"id": 1, "name": "", "supercategory": "object"}, ++ ] ++ ++ coco_data = dict(images=images, annotations=annotations, categories=categories) ++ ++ image = np.zeros((10, 10, 3), dtype=np.uint8) ++ Image.fromarray(image).save(images_folder / "test_0.png") ++ ++ annotation_path = tmp_path / "test_annotation.json" ++ with open(annotation_path, "w") as json_file: ++ json.dump(coco_data, json_file) ++ ++ return annotation_path, images_folder, output_folder ++ ++ ++def _pixel_is_background(rgba_pixel): ++ """A non-painted pixel of a black source image should have R=G=B=0.""" ++ return rgba_pixel[0] == 0 and rgba_pixel[1] == 0 and rgba_pixel[2] == 0 ++ ++ ++def _pixel_is_painted(rgba_pixel): ++ return not _pixel_is_background(rgba_pixel) ++ ++ ++def test_default_filters_crowd_annotation(tmp_path): ++ """User calls paint_annotations with default args; crowd bbox area is NOT painted.""" ++ annotation_path, images_folder, output_folder = _make_crowd_dataset(tmp_path) ++ ++ paint_annotations( ++ annotation_path, ++ images_folder, ++ output_folder, ++ show_label=False, ++ ) ++ ++ result = np.asarray(Image.open(output_folder / "test_0_result.png")) ++ ++ assert _pixel_is_background(result[6, 6]), ( ++ f"Default should filter crowd box; pixel (6,6) is {result[6, 6]}" ++ ) ++ ++ ++def test_filter_crowd_true_filters_crowd_annotation(tmp_path): ++ """Explicit filter_crowd=True: crowd bbox NOT painted.""" ++ annotation_path, images_folder, output_folder = _make_crowd_dataset(tmp_path) ++ ++ paint_annotations( ++ annotation_path, ++ images_folder, ++ output_folder, ++ show_label=False, ++ filter_crowd=True, ++ ) ++ ++ result = np.asarray(Image.open(output_folder / "test_0_result.png")) ++ assert _pixel_is_background(result[6, 6]), ( ++ f"filter_crowd=True should not paint crowd; pixel (6,6) is {result[6, 6]}" ++ ) ++ ++ ++def test_filter_crowd_false_paints_crowd_annotation(tmp_path): ++ """filter_crowd=False: crowd bbox IS painted.""" ++ annotation_path, images_folder, output_folder = _make_crowd_dataset(tmp_path) ++ ++ paint_annotations( ++ annotation_path, ++ images_folder, ++ output_folder, ++ show_label=False, ++ filter_crowd=False, ++ ) ++ ++ result = np.asarray(Image.open(output_folder / "test_0_result.png")) ++ ++ assert _pixel_is_painted(result[6, 6]), ( ++ f"filter_crowd=False should paint crowd box; pixel (6,6) is {result[6, 6]}" ++ ) ++ ++ ++def test_non_crowd_annotation_painted_with_default(tmp_path): ++ """Default filter_crowd=True does NOT affect non-crowd annotations.""" ++ annotation_path, images_folder, output_folder = _make_crowd_dataset(tmp_path) ++ ++ paint_annotations( ++ annotation_path, ++ images_folder, ++ output_folder, ++ show_label=False, ++ ) ++ ++ result = np.asarray(Image.open(output_folder / "test_0_result.png")) ++ ++ assert _pixel_is_painted(result[1, 1]), ( ++ f"Non-crowd annotation must still be painted; pixel (1,1) is {result[1, 1]}" ++ ) ++ ++ ++def test_annotation_without_iscrowd_key_is_painted(tmp_path): ++ """An annotation missing the iscrowd key is treated as non-crowd and painted.""" ++ images_folder = tmp_path / "images" ++ Path(images_folder).mkdir(exist_ok=True, parents=True) ++ output_folder = tmp_path / "test_result" ++ Path(output_folder).mkdir(exist_ok=True, parents=True) ++ ++ images = [{"id": 0, "width": 10, "height": 10, "file_name": "test_0.png"}] ++ annotations = [ ++ {"image_id": 0, "category_id": 0, "bbox": [0, 0, 2, 2], "score": 1}, ++ ] ++ categories = [{"id": 0, "name": "", "supercategory": "object"}] ++ coco_data = dict(images=images, annotations=annotations, categories=categories) ++ ++ Image.fromarray(np.zeros((10, 10, 3), dtype=np.uint8)).save(images_folder / "test_0.png") ++ annotation_path = tmp_path / "test_annotation.json" ++ with open(annotation_path, "w") as f: ++ json.dump(coco_data, f) ++ ++ paint_annotations( ++ annotation_path, ++ images_folder, ++ output_folder, ++ show_label=False, ++ ) ++ ++ result = np.asarray(Image.open(output_folder / "test_0_result.png")) ++ assert _pixel_is_painted(result[1, 1]), ( ++ f"Annotation without iscrowd should still be painted; pixel (1,1) is {result[1, 1]}" ++ ) ++ ++ + def test_image_annotations(tmp_path): + + images_folder = tmp_path / "images" +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -v -rA tests/apps/test_paint_annotations.py::test_default_filters_crowd_annotation tests/apps/test_paint_annotations.py::test_filter_crowd_true_filters_crowd_annotation tests/apps/test_paint_annotations.py::test_filter_crowd_false_paints_crowd_annotation tests/apps/test_paint_annotations.py::test_non_crowd_annotation_painted_with_default tests/apps/test_paint_annotations.py::test_annotation_without_iscrowd_key_is_painted ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000110/tests/test.sh b/tasks/format-code-task-000110/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4cd1232baa5cf57507770d07068d0977b66a07e4 --- /dev/null +++ b/tasks/format-code-task-000110/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/apps/test_paint_annotations.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000110/tests/test_command.sh b/tasks/format-code-task-000110/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000110/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000117/environment/Dockerfile b/tasks/format-code-task-000117/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..811d1d13f606aad65d9829c84c8266675ca56991 --- /dev/null +++ b/tasks/format-code-task-000117/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d399cf81531fbbaff66230c2417fa781c8392f7bb9d1478ef170d52b92f771f1 diff --git a/tasks/format-code-task-000117/environment/setup/files/blocklist b/tasks/format-code-task-000117/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000117/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000117/environment/setup/setup.sh b/tasks/format-code-task-000117/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000117/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000117/tests/test.patch b/tasks/format-code-task-000117/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3e77c423c886a28d306083b4ba8577506c93d057 --- /dev/null +++ b/tasks/format-code-task-000117/tests/test.patch @@ -0,0 +1,197 @@ +diff --git a/ibm/resource_ibm_dns_domain_registration_nameservers_contract_test.go b/ibm/resource_ibm_dns_domain_registration_nameservers_contract_test.go +new file mode 100644 +index 000000000..34c8321f0 +--- /dev/null ++++ b/ibm/resource_ibm_dns_domain_registration_nameservers_contract_test.go +@@ -0,0 +1,165 @@ ++package ibm ++ ++import ( ++ "strings" ++ "testing" ++ ++ tfconfig "github.com/hashicorp/terraform/config" ++ "github.com/hashicorp/terraform/helper/schema" ++ "github.com/hashicorp/terraform/terraform" ++) ++ ++ ++ ++func collectionElemType(t *testing.T, s *schema.Schema, field string) schema.ValueType { ++ t.Helper() ++ if s.Type != schema.TypeList && s.Type != schema.TypeSet { ++ t.Fatalf("expected %q to be a list or set, got %v", field, s.Type) ++ } ++ elem, ok := s.Elem.(*schema.Schema) ++ if !ok { ++ t.Fatalf("expected %q to have a scalar element schema", field) ++ } ++ return elem.Type ++} ++ ++func validateResourceConfig(t *testing.T, resourceType string, raw map[string]interface{}) []error { ++ t.Helper() ++ p := Provider().(*schema.Provider) ++ if _, ok := p.ResourcesMap[resourceType]; !ok { ++ t.Fatalf("resource %s is not registered", resourceType) ++ } ++ c, err := tfconfig.NewRawConfig(raw) ++ if err != nil { ++ t.Fatalf("err building raw config: %s", err) ++ } ++ _, errs := p.ValidateResource(resourceType, terraform.NewResourceConfig(c)) ++ return errs ++} ++ ++func TestDNSDomainRegistrationDataSourceRegistered(t *testing.T) { ++ p := Provider().(*schema.Provider) ++ ds, ok := p.DataSourcesMap["ibm_dns_domain_registration"] ++ if !ok { ++ t.Fatal("expected data source ibm_dns_domain_registration to be registered") ++ } ++ ++ name, ok := ds.Schema["name"] ++ if !ok { ++ t.Fatal("data source missing 'name' argument") ++ } ++ if !name.Required { ++ t.Error("data source 'name' must be required") ++ } ++ if name.Type != schema.TypeString { ++ t.Errorf("data source 'name' must be a string, got %v", name.Type) ++ } ++ ++ ns, ok := ds.Schema["name_servers"] ++ if !ok { ++ t.Fatal("data source missing 'name_servers' attribute") ++ } ++ if !ns.Computed { ++ t.Error("data source 'name_servers' must be computed") ++ } ++ if et := collectionElemType(t, ns, "name_servers"); et != schema.TypeString { ++ t.Errorf("data source 'name_servers' elements must be strings, got %v", et) ++ } ++} ++ ++func TestDNSDomainRegistrationNameserversResourceRegistered(t *testing.T) { ++ p := Provider().(*schema.Provider) ++ r, ok := p.ResourcesMap["ibm_dns_domain_registration_nameservers"] ++ if !ok { ++ t.Fatal("expected resource ibm_dns_domain_registration_nameservers to be registered") ++ } ++ ++ id, ok := r.Schema["dns_registration_id"] ++ if !ok { ++ t.Fatal("resource missing 'dns_registration_id' argument") ++ } ++ if !id.Required { ++ t.Error("resource 'dns_registration_id' must be required") ++ } ++ if id.Type != schema.TypeString { ++ t.Errorf("resource 'dns_registration_id' must be a string, got %v", id.Type) ++ } ++ ++ ns, ok := r.Schema["name_servers"] ++ if !ok { ++ t.Fatal("resource missing 'name_servers' argument") ++ } ++ if !ns.Required { ++ t.Error("resource 'name_servers' must be required") ++ } ++ if et := collectionElemType(t, ns, "name_servers"); et != schema.TypeString { ++ t.Errorf("resource 'name_servers' elements must be strings, got %v", et) ++ } ++ ++ orig, ok := r.Schema["original_name_servers"] ++ if !ok { ++ t.Fatal("resource missing 'original_name_servers' attribute") ++ } ++ if !orig.Computed { ++ t.Error("resource 'original_name_servers' must be computed") ++ } ++ if et := collectionElemType(t, orig, "original_name_servers"); et != schema.TypeString { ++ t.Errorf("resource 'original_name_servers' elements must be strings, got %v", et) ++ } ++} ++ ++func TestProviderInternalValidateWithDNSRegistration(t *testing.T) { ++ if err := Provider().(*schema.Provider).InternalValidate(); err != nil { ++ t.Fatalf("provider internal validation failed: %s", err) ++ } ++} ++ ++func TestDNSDomainRegistrationNameserversValidation(t *testing.T) { ++ valid := []string{ ++ "ns1.example.com", ++ "a.bb.ccc", ++ "ns-01.example.co.uk", ++ "NS1.Example.COM", ++ } ++ for _, v := range valid { ++ raw := map[string]interface{}{ ++ "dns_registration_id": "123456", ++ "name_servers": []interface{}{v}, ++ } ++ errs := validateResourceConfig(t, "ibm_dns_domain_registration_nameservers", raw) ++ if len(errs) != 0 { ++ t.Errorf("expected %q to be a valid nameserver, got errors: %v", v, errs) ++ } ++ } ++ ++ invalid := []string{ ++ "", ++ "localhost", ++ "-bad.example.com", ++ "bad-.example.com", ++ "ns1 .example.com", ++ "ns_1.example.com", ++ strings.Repeat("a", 64) + ".com", ++ } ++ for _, v := range invalid { ++ raw := map[string]interface{}{ ++ "dns_registration_id": "123456", ++ "name_servers": []interface{}{v}, ++ } ++ errs := validateResourceConfig(t, "ibm_dns_domain_registration_nameservers", raw) ++ if len(errs) == 0 { ++ t.Errorf("expected %q to be rejected as an invalid nameserver", v) ++ } ++ } ++} ++ ++func TestDNSDomainRegistrationNameserversValidationMixed(t *testing.T) { ++ raw := map[string]interface{}{ ++ "dns_registration_id": "123456", ++ "name_servers": []interface{}{"ns1.example.com", "bad_host"}, ++ } ++ errs := validateResourceConfig(t, "ibm_dns_domain_registration_nameservers", raw) ++ if len(errs) == 0 { ++ t.Error("expected validation errors when one of several nameservers is invalid") ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++export GO111MODULE=off ++REPO_DIR="$(go env GOPATH)/src/github.com/IBM-Cloud/terraform-provider-ibm" ++cd "$REPO_DIR" ++ ++ ++go test ./ibm/ -vet=off -run 'TestProvider$|TestProvider_impl' -count=1 ++ ++ ++go test ./ibm/ -vet=off -run 'TestDNSDomainRegistration|TestProviderInternalValidateWithDNSRegistration' -count=1 diff --git a/tasks/format-code-task-000117/tests/test.sh b/tasks/format-code-task-000117/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7d48db9238a2bc140f9afdcf7a12d9dad84d4ac6 --- /dev/null +++ b/tasks/format-code-task-000117/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +ibm/resource_ibm_dns_domain_registration_nameservers_contract_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000117/tests/test_command.sh b/tasks/format-code-task-000117/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000117/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000119/environment/Dockerfile b/tasks/format-code-task-000119/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4b947c03eed9f86b6f1458cb2bd2c4eccae3bd28 --- /dev/null +++ b/tasks/format-code-task-000119/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f3640b92ffdfa97570fac3bb9dc014e9b682256527ce3507d9eaed0410ef62ba diff --git a/tasks/format-code-task-000119/environment/setup/files/blocklist b/tasks/format-code-task-000119/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000119/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000119/environment/setup/setup.sh b/tasks/format-code-task-000119/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000119/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000119/tests/test.patch b/tasks/format-code-task-000119/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d85b1fd68fdf8fcc5a5cc8735555506d63b19243 --- /dev/null +++ b/tasks/format-code-task-000119/tests/test.patch @@ -0,0 +1,79 @@ +diff --git a/test/test_autoai_libs.py b/test/test_autoai_libs.py +index 5dd6bd5dd..ddf857ede 100644 +--- a/test/test_autoai_libs.py ++++ b/test/test_autoai_libs.py +@@ -123,6 +123,15 @@ def test_NumpyPermuteArray(self): + self.doTest(trainable, **self._iris) + self.do1DTest(trainable, **self._iris) + ++ def test_TNoOp(self): ++ from autoai_libs.utils.fc_methods import is_not_categorical ++ trainable = lale.lib.autoai_libs.TNoOp( ++ fun=np.rint, ++ name='do nothing', ++ datatypes=['numeric'], feat_constraints=[is_not_categorical], ++ ) ++ self.doTest(trainable, **self._iris) ++ + def test_TA1(self): + from autoai_libs.utils.fc_methods import is_not_categorical + float32 = np.dtype('float32') +diff --git a/test/test_json_pretty_viz.py b/test/test_json_pretty_viz.py +index f8456bc1e..edeb20dfc 100644 +--- a/test/test_json_pretty_viz.py ++++ b/test/test_json_pretty_viz.py +@@ -361,7 +361,6 @@ def test_autoai_libs_tam_2(self): + tam = TAM(tans_class=pca, name='pca', col_names=['a', 'b', 'c'], col_dtypes=[np.dtype('float32'), np.dtype('float32'), np.dtype('float32')]) + lgbm_classifier = LGBMClassifier(class_weight='balanced', learning_rate=0.18) + pipeline = make_pipeline(tam, lgbm_classifier) +- import lale.helpers + expected = \ + """from lale.lib.autoai_libs import TAM + import sklearn.decomposition.pca +@@ -393,6 +392,23 @@ def test_autoai_libs_ta1(self): + pipeline = ta1 >> LR()""" + self._roundtrip(expected, lale.pretty_print.to_string(pipeline)) + ++ def test_autoai_libs_t_no_op(self): ++ from lale.lib.autoai_libs import TNoOp ++ from lightgbm import LGBMClassifier ++ from lale.operators import make_pipeline ++ t_no_op = TNoOp(name='no_action', datatypes='x', feat_constraints=[]) ++ lgbm_classifier = LGBMClassifier(class_weight='balanced', learning_rate=0.18) ++ pipeline = make_pipeline(t_no_op, lgbm_classifier) ++ expected = \ ++"""from lale.lib.autoai_libs import TNoOp ++from lightgbm import LGBMClassifier ++from lale.operators import make_pipeline ++ ++t_no_op = TNoOp(name='no_action', datatypes='x', feat_constraints=[]) ++lgbm_classifier = LGBMClassifier(class_weight='balanced', learning_rate=0.18) ++pipeline = make_pipeline(t_no_op, lgbm_classifier)""" ++ self._roundtrip(expected, lale.pretty_print.to_string(pipeline, combinators=False)) ++ + + class TestToAndFromJSON(unittest.TestCase): + def test_trainable_individual_op(self): +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,7 @@ ++H4sIAAAAAAAAA+3ST0vDMBgG8J77KeLcQQ9tl2xdQVDwMNhFJzIET6Vdg41kTWjT4vz0ph26TdRd ++NkR8fof+yfM2TXjjp7WQWcyLJnCOZWBFYdjdrc/37pmGjDLGBnTInAGl4ThySHi0FW2pK5OUhDil ++Uuanun35H+Vv+m94ZeKFWi6TIvOr/HD/2Nf/kW32uv80Cpkdp6Mxow4ZHG4J3/vn/T89CVJRBGlS ++5e4iI90hSHnmuvxFq9KQu8fJ7UN8P5vNL3v96exmEvh6ZU9L76Pgej610aaune+i3w7bmiaRpNc/ ++6z4hohCGeJ5OTH7+dWaH169PUqU2HvqRTyPX1ULbCtspKYnHiW9nKZSXcV0RdhVkvAmKWsqdMr1q ++t7IT27lNrgriLd/T9rI+90ltVCJiKdLKbnAreK5UEeuSG7OKG/Hahl7j/nbbAAAAAAAAAAAAAAAA ++AAAAAAA6b8BQnlUAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000119/tests/test.sh b/tasks/format-code-task-000119/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c20b8aa52f6c093b677187d0881d0a15a95c8b63 --- /dev/null +++ b/tasks/format-code-task-000119/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/test_autoai_libs.py +test/test_json_pretty_viz.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000119/tests/test_command.sh b/tasks/format-code-task-000119/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000119/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000121/environment/Dockerfile b/tasks/format-code-task-000121/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f0a2642f234d5f1ebc926032cbbf154782998454 --- /dev/null +++ b/tasks/format-code-task-000121/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:85e99dbe4a8e4136fd93050e6c3a18b1decd7806bf1c55bec1d73152919e5ea8 diff --git a/tasks/format-code-task-000121/environment/setup/files/blocklist b/tasks/format-code-task-000121/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000121/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000121/environment/setup/setup.sh b/tasks/format-code-task-000121/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000121/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000121/tests/test.patch b/tasks/format-code-task-000121/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..21b1eb9429b74efde416ed25f1dea1bf7640d69e --- /dev/null +++ b/tasks/format-code-task-000121/tests/test.patch @@ -0,0 +1,229 @@ +diff --git ab/balance_strategy_roundrobin_global_test.go b/balance_strategy_roundrobin_global_test.go +new file mode 100644 +index 0000000..98dd53a +--- /dev/null ++++ b/balance_strategy_roundrobin_global_test.go +@@ -0,0 +1,123 @@ ++package sarama ++ ++import ( ++ "reflect" ++ "sort" ++ "testing" ++) ++ ++func roundRobinTestMetadata(memberTopics map[string][]string) map[string]ConsumerGroupMemberMetadata { ++ members := make(map[string]ConsumerGroupMemberMetadata, len(memberTopics)) ++ for memberID, topics := range memberTopics { ++ members[memberID] = ConsumerGroupMemberMetadata{Topics: topics} ++ } ++ return members ++} ++ ++func assertRoundRobinPlan(t *testing.T, plan BalanceStrategyPlan, err error, expected BalanceStrategyPlan) { ++ t.Helper() ++ if err != nil { ++ t.Fatalf("BalanceStrategyRoundRobin.Plan returned error: %v", err) ++ } ++ normalizedPlan := normalizeRoundRobinPlan(plan) ++ normalizedExpected := normalizeRoundRobinPlan(expected) ++ if !reflect.DeepEqual(normalizedPlan, normalizedExpected) { ++ t.Fatalf("unexpected round-robin plan\nexpected: %#v\nactual: %#v", normalizedExpected, normalizedPlan) ++ } ++} ++ ++func normalizeRoundRobinPlan(plan BalanceStrategyPlan) BalanceStrategyPlan { ++ normalized := make(BalanceStrategyPlan, len(plan)) ++ for memberID, topics := range plan { ++ topicCopy := make(map[string][]int32, len(topics)) ++ for topic, partitions := range topics { ++ if len(partitions) == 0 { ++ continue ++ } ++ partitionsCopy := append([]int32(nil), partitions...) ++ sort.Slice(partitionsCopy, func(i, j int) bool { ++ return partitionsCopy[i] < partitionsCopy[j] ++ }) ++ topicCopy[topic] = partitionsCopy ++ } ++ if len(topicCopy) > 0 { ++ normalized[memberID] = topicCopy ++ } ++ } ++ return normalized ++} ++ ++func TestBalanceStrategyRoundRobinGlobalAcrossSinglePartitionTopics(t *testing.T) { ++ members := roundRobinTestMetadata(map[string][]string{ ++ "M1": {"T1", "T2", "T3"}, ++ "M2": {"T1", "T2", "T3"}, ++ "M3": {"T1", "T2", "T3"}, ++ }) ++ topics := map[string][]int32{ ++ "T1": {0}, ++ "T2": {0}, ++ "T3": {0}, ++ } ++ ++ plan, err := BalanceStrategyRoundRobin.Plan(members, topics) ++ assertRoundRobinPlan(t, plan, err, BalanceStrategyPlan{ ++ "M1": map[string][]int32{"T1": {0}}, ++ "M2": map[string][]int32{"T2": {0}}, ++ "M3": map[string][]int32{"T3": {0}}, ++ }) ++} ++ ++func TestBalanceStrategyRoundRobinGlobalAcrossMixedPartitionCounts(t *testing.T) { ++ members := roundRobinTestMetadata(map[string][]string{ ++ "M1": {"T1", "T2", "T3"}, ++ "M2": {"T1", "T2", "T3"}, ++ }) ++ topics := map[string][]int32{ ++ "T1": {0}, ++ "T2": {0, 1}, ++ "T3": {0, 1, 2, 3}, ++ } ++ ++ plan, err := BalanceStrategyRoundRobin.Plan(members, topics) ++ assertRoundRobinPlan(t, plan, err, BalanceStrategyPlan{ ++ "M1": map[string][]int32{"T1": {0}, "T2": {1}, "T3": {1, 3}}, ++ "M2": map[string][]int32{"T2": {0}, "T3": {0, 2}}, ++ }) ++} ++ ++func TestBalanceStrategyRoundRobinSkipsUnsubscribedMembersWithoutResettingProgress(t *testing.T) { ++ members := roundRobinTestMetadata(map[string][]string{ ++ "M1": {"T1", "T2", "T3"}, ++ "M2": {"T1", "T3"}, ++ }) ++ topics := map[string][]int32{ ++ "T1": {0}, ++ "T2": {0}, ++ "T3": {0}, ++ } ++ ++ plan, err := BalanceStrategyRoundRobin.Plan(members, topics) ++ assertRoundRobinPlan(t, plan, err, BalanceStrategyPlan{ ++ "M1": map[string][]int32{"T1": {0}, "T2": {0}}, ++ "M2": map[string][]int32{"T3": {0}}, ++ }) ++} ++ ++func TestBalanceStrategyRoundRobinSkipsMultipleIneligibleMembers(t *testing.T) { ++ members := roundRobinTestMetadata(map[string][]string{ ++ "A": {"T1", "T2", "T3"}, ++ "B": {"T1"}, ++ "C": {"T1", "T3"}, ++ }) ++ topics := map[string][]int32{ ++ "T1": {0}, ++ "T2": {0}, ++ "T3": {0, 1}, ++ } ++ ++ plan, err := BalanceStrategyRoundRobin.Plan(members, topics) ++ assertRoundRobinPlan(t, plan, err, BalanceStrategyPlan{ ++ "A": map[string][]int32{"T1": {0}, "T2": {0}, "T3": {1}}, ++ "C": map[string][]int32{"T3": {0}}, ++ }) ++} +diff --git a/balance_strategy_test.go b/balance_strategy_test.go +index 25a51adaa..66af3d1c9 100644 +--- a/balance_strategy_test.go ++++ b/balance_strategy_test.go +@@ -90,26 +90,64 @@ func TestBalanceStrategyRoundRobin(t *testing.T) { + expected BalanceStrategyPlan + }{ + { +- members: map[string][]string{"M1": {"T1", "T2"}, "M2": {"T1", "T2"}}, +- topics: map[string][]int32{"T1": {0, 1, 2, 3}, "T2": {0, 1, 2, 3}}, ++ members: map[string][]string{"M1": {"T1", "T2", "T3"}, "M2": {"T1", "T2", "T3"}}, ++ topics: map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0}}, + expected: BalanceStrategyPlan{ +- "M1": map[string][]int32{"T1": {0, 2}, "T2": {1, 3}}, +- "M2": map[string][]int32{"T1": {1, 3}, "T2": {0, 2}}, ++ "M1": map[string][]int32{"T1": {0}, "T3": {0}}, ++ "M2": map[string][]int32{"T2": {0}}, + }, + }, + { +- members: map[string][]string{"M1": {"T1", "T2"}, "M2": {"T1", "T2"}}, +- topics: map[string][]int32{"T1": {0, 1, 2}, "T2": {0, 1, 2}}, ++ members: map[string][]string{"M1": {"T1", "T2", "T3"}, "M2": {"T1", "T2", "T3"}}, ++ topics: map[string][]int32{"T1": {0}, "T2": {0, 1}, "T3": {0, 1, 2, 3}}, ++ expected: BalanceStrategyPlan{ ++ "M1": map[string][]int32{"T1": {0}, "T2": {1}, "T3": {1, 3}}, ++ "M2": map[string][]int32{"T2": {0}, "T3": {0, 2}}, ++ }, ++ }, ++ { ++ members: map[string][]string{"M1": {"T1"}, "M2": {"T1"}}, ++ topics: map[string][]int32{"T1": {0}}, ++ expected: BalanceStrategyPlan{ ++ "M1": map[string][]int32{"T1": {0}}, ++ }, ++ }, ++ { ++ members: map[string][]string{"M1": {"T1", "T2", "T3"}}, ++ topics: map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0, 1, 2}}, + expected: BalanceStrategyPlan{ +- "M1": map[string][]int32{"T1": {0, 2}, "T2": {1}}, +- "M2": map[string][]int32{"T1": {1}, "T2": {0, 2}}, ++ "M1": map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0, 1, 2}}, ++ }, ++ }, ++ { ++ members: map[string][]string{"M1": {"T1", "T2", "T3"}, "M2": {"T1"}}, ++ topics: map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0}}, ++ expected: BalanceStrategyPlan{ ++ "M1": map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0}}, ++ }, ++ }, ++ { ++ members: map[string][]string{"M1": {"T1", "T2", "T3"}, "M2": {"T1", "T3"}}, ++ topics: map[string][]int32{"T1": {0}, "T2": {0}, "T3": {0}}, ++ expected: BalanceStrategyPlan{ ++ "M1": map[string][]int32{"T1": {0}, "T2": {0}}, ++ "M2": map[string][]int32{"T3": {0}}, ++ }, ++ }, ++ { ++ members: map[string][]string{"M": {"T1", "T2", "TT2"}, "M2": {"T1", "T2", "TT2"}, "M3": {"T1", "T2", "TT2"}}, ++ topics: map[string][]int32{"T1": {0}, "T2": {0}, "TT2": {0}}, ++ expected: BalanceStrategyPlan{ ++ "M": map[string][]int32{"T1": {0}}, ++ "M2": map[string][]int32{"T2": {0}}, ++ "M3": map[string][]int32{"TT2": {0}}, + }, + }, + } + + strategy := BalanceStrategyRoundRobin + if strategy.Name() != "roundrobin" { +- t.Errorf("Unexpected stategy name\nexpected: range\nactual: %v", strategy.Name()) ++ t.Errorf("Unexpected strategy name\nexpected: roundrobin\nactual: %v", strategy.Name()) + } + + for _, test := range tests { +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,17 @@ ++#!/usr/bin/env bash ++set -uo pipefail ++ ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ go test -v -run '^TestBalanceStrategyRoundRobin$' -count=1 . ++ ;; ++ new) ++ go test -v -run '^(TestBalanceStrategyRoundRobin|TestBalanceStrategyRoundRobinGlobalAcrossSinglePartitionTopics|TestBalanceStrategyRoundRobinGlobalAcrossMixedPartitionCounts|TestBalanceStrategyRoundRobinSkipsUnsubscribedMembersWithoutResettingProgress|TestBalanceStrategyRoundRobinSkipsMultipleIneligibleMembers)$' -count=1 . ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000121/tests/test.sh b/tasks/format-code-task-000121/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f1d0b19152997e2d9382a90820f4125b45cb9289 --- /dev/null +++ b/tasks/format-code-task-000121/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +balance_strategy_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000121/tests/test_command.sh b/tasks/format-code-task-000121/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000121/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000126/environment/Dockerfile b/tasks/format-code-task-000126/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2ed52b1418f0c19a56a0799cf95129565c8b9500 --- /dev/null +++ b/tasks/format-code-task-000126/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2e8c08eee42d867ac90d079d37f476b1a67579508fc181b53321a93a674ff4a7 diff --git a/tasks/format-code-task-000126/environment/setup/files/blocklist b/tasks/format-code-task-000126/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000126/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000126/environment/setup/setup.sh b/tasks/format-code-task-000126/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000126/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000126/tests/test.patch b/tasks/format-code-task-000126/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b9bf07a588bf8f1b93c7ea1aee2e3fb55f65c863 --- /dev/null +++ b/tasks/format-code-task-000126/tests/test.patch @@ -0,0 +1,379 @@ +diff --git a/tests/test_conf_branch_pipeline.py b/tests/test_conf_branch_pipeline.py +new file mode 100644 +index 0000000..a3c0538 +--- /dev/null ++++ b/tests/test_conf_branch_pipeline.py +@@ -0,0 +1,227 @@ ++import math ++import sys ++import types ++from pathlib import Path ++ ++import pytest ++import torch ++import torch.nn as nn ++import yaml ++ ++ ++def _install_optional_dependency_stubs(): ++ class Registry: ++ def register_module(self, *args, **kwargs): ++ def decorate(cls): ++ return cls ++ ++ return decorate ++ ++ mmcls = types.ModuleType("mmcls") ++ mmcls_models = types.ModuleType("mmcls.models") ++ mmcls_apis = types.ModuleType("mmcls.apis") ++ mmcls_models.CLASSIFIERS = Registry() ++ mmcls_models.ImageClassifier = nn.Module ++ mmcls_apis.init_model = lambda *args, **kwargs: None ++ mmcls.models = mmcls_models ++ mmcls.apis = mmcls_apis ++ sys.modules.setdefault("mmcls", mmcls) ++ sys.modules.setdefault("mmcls.models", mmcls_models) ++ sys.modules.setdefault("mmcls.apis", mmcls_apis) ++ ++ mmcv = types.ModuleType("mmcv") ++ ++ class Config: ++ @classmethod ++ def fromfile(cls, *args, **kwargs): ++ return cls() ++ ++ mmcv.Config = Config ++ sys.modules.setdefault("mmcv", mmcv) ++ ++ turtle = types.ModuleType("turtle") ++ turtle.forward = lambda *args, **kwargs: None ++ sys.modules.setdefault("turtle", turtle) ++ ++ diffdist = types.ModuleType("diffdist") ++ diffdist_functional = types.ModuleType("diffdist.functional") ++ diffdist.functional = diffdist_functional ++ sys.modules.setdefault("diffdist", diffdist) ++ sys.modules.setdefault("diffdist.functional", diffdist_functional) ++ ++ sys.modules.setdefault("libmr", types.ModuleType("libmr")) ++ sys.modules.setdefault("faiss", types.ModuleType("faiss")) ++ ++ ++_install_optional_dependency_stubs() ++ ++from openood.networks.conf_branch_net import ConfBranchNet ++from openood.recorders.utils import get_recorder ++ ++ ++class AttrDict(dict): ++ ++ ++ def __getattr__(self, name): ++ try: ++ value = self[name] ++ except KeyError as exc: ++ raise AttributeError(name) from exc ++ if isinstance(value, dict): ++ value = AttrDict(value) ++ self[name] = value ++ return value ++ ++ def __setattr__(self, name, value): ++ self[name] = value ++ ++ ++def _to_attrdict(value): ++ if isinstance(value, dict): ++ return AttrDict({key: _to_attrdict(val) for key, val in value.items()}) ++ if isinstance(value, list): ++ return [_to_attrdict(item) for item in value] ++ return value ++ ++ ++class DeterministicBackbone(nn.Module): ++ def __init__(self, num_classes, feature_size): ++ super().__init__() ++ self.num_classes = num_classes ++ self.feature_size = feature_size ++ ++ def forward(self, x, *args, **kwargs): ++ batch = x.shape[0] ++ signal = x.reshape(batch, -1).mean(dim=1, keepdim=True) ++ logits = signal.repeat(1, self.num_classes) ++ feature_scale = torch.arange( ++ 1, self.feature_size + 1, dtype=x.dtype, device=x.device ++ ).unsqueeze(0) ++ features = signal.repeat(1, self.feature_size) * feature_scale ++ return logits, features ++ ++ ++@pytest.mark.parametrize( ++ "batch_size,num_classes,feature_size", ++ [(2, 7, 19), (3, 5, 13)], ++) ++def test_conf_branch_forward_accepts_multiple_nontrivial_backbones( ++ batch_size, num_classes, feature_size ++): ++ net = ConfBranchNet( ++ DeterministicBackbone(num_classes=num_classes, feature_size=feature_size), ++ num_classes=num_classes, ++ ) ++ x = torch.randn(batch_size, 3, 4, 4) ++ ++ pred = net(x) ++ ++ assert pred.shape == (batch_size, num_classes) ++ ++ ++def test_conf_branch_forward_uses_backbone_dependent_signal_for_outputs(): ++ net = ConfBranchNet(DeterministicBackbone(num_classes=6, feature_size=17), 6) ++ x_low = torch.zeros(2, 3, 4, 4) ++ x_high = torch.ones(2, 3, 4, 4) ++ ++ pred_low, conf_low = net(x_low, return_confidence=True) ++ pred_high, conf_high = net(x_high, return_confidence=True) ++ ++ assert pred_low.shape == (2, 6) ++ assert conf_low.shape == (2, 1) ++ assert pred_high.shape == (2, 6) ++ assert conf_high.shape == (2, 1) ++ assert (not torch.allclose(pred_low, pred_high)) or ( ++ not torch.allclose(conf_low, conf_high) ++ ) ++ ++ ++def test_train_conf_branch_config_uses_constructible_recorder(tmp_path): ++ config_path = ( ++ Path(__file__).resolve().parents[1] ++ / "configs" ++ / "pipelines" ++ / "train" ++ / "train_conf_branch.yml" ++ ) ++ config = _to_attrdict(yaml.safe_load(config_path.read_text())) ++ config.output_dir = str(tmp_path) ++ ++ recorder = get_recorder(config) ++ ++ assert all(hasattr(recorder, name) for name in ("report", "save_model", "summary")) ++ ++ ++class TinyLoader: ++ def __init__(self, batches): ++ self.batches = batches ++ self._idx = 0 ++ ++ def __iter__(self): ++ self._idx = 0 ++ return self ++ ++ def __len__(self): ++ return len(self.batches) ++ ++ def __next__(self): ++ if self._idx >= len(self.batches): ++ raise StopIteration ++ batch = self.batches[self._idx] ++ self._idx += 1 ++ return batch ++ ++ ++def test_conf_branch_train_epoch_metrics_include_loss(monkeypatch): ++ from openood.trainers.conf_branch_trainer import ConfBranchTrainer ++ ++ monkeypatch.setattr(torch.Tensor, "cuda", lambda self, *args, **kwargs: self) ++ monkeypatch.setattr(nn.Module, "cuda", lambda self, *args, **kwargs: self) ++ ++ class TinyConfNet(nn.Module): ++ def __init__(self): ++ super().__init__() ++ self.linear = nn.Linear(4, 3) ++ self.confidence = nn.Linear(4, 1) ++ ++ def forward(self, x, return_confidence=False): ++ flat = x.view(x.shape[0], -1) ++ pred = self.linear(flat) ++ confidence = self.confidence(flat) ++ if return_confidence: ++ return pred, confidence ++ return pred ++ ++ config = AttrDict( ++ { ++ "baseline": False, ++ "num_classes": 3, ++ "trainer": {"budget": 0.3, "lmbda": 0.1, "eps": 1.0e-12}, ++ "optimizer": { ++ "lr": 0.01, ++ "momentum": 0.0, ++ "nesterov": False, ++ "weight_decay": 0.0, ++ }, ++ "scheduler": {"milestones": [1], "gamma": 1.0}, ++ } ++ ) ++ loader = TinyLoader( ++ [ ++ { ++ "data": torch.tensor( ++ [[[[0.0, 1.0], [2.0, 3.0]]], [[[1.0, 0.0], [1.0, 0.0]]]] ++ ), ++ "label": torch.tensor([0, 2]), ++ } ++ ] ++ ) ++ trainer = ConfBranchTrainer(TinyConfNet(), loader, config) ++ ++ _, metrics = trainer.train_epoch(epoch_idx=11) ++ ++ assert isinstance(metrics, dict) ++ assert metrics["epoch_idx"] == 11 ++ assert "train_acc" in metrics ++ assert "loss" in metrics ++ assert math.isfinite(float(torch.as_tensor(metrics["loss"]).item())) +diff --git a/tests/test_opengan_registry.py b/tests/test_opengan_registry.py +new file mode 100644 +index 0000000..10afecf +--- /dev/null ++++ b/tests/test_opengan_registry.py +@@ -0,0 +1,89 @@ ++import sys ++import types ++ ++import torch ++import torch.nn as nn ++ ++ ++def _install_optional_dependency_stubs(): ++ diffdist = types.ModuleType("diffdist") ++ diffdist_functional = types.ModuleType("diffdist.functional") ++ diffdist.functional = diffdist_functional ++ sys.modules.setdefault("diffdist", diffdist) ++ sys.modules.setdefault("diffdist.functional", diffdist_functional) ++ sys.modules.setdefault("libmr", types.ModuleType("libmr")) ++ sys.modules.setdefault("faiss", types.ModuleType("faiss")) ++ ++ ++_install_optional_dependency_stubs() ++ ++from openood.postprocessors.opengan_postprocessor import OpenGanPostprocessor ++from openood.postprocessors.utils import get_postprocessor ++from openood.trainers.opengan_trainer import OpenGanTrainer ++from openood.trainers.utils import get_trainer ++ ++ ++class AttrDict(dict): ++ def __getattr__(self, name): ++ try: ++ value = self[name] ++ except KeyError as exc: ++ raise AttributeError(name) from exc ++ if isinstance(value, dict): ++ value = AttrDict(value) ++ self[name] = value ++ return value ++ ++ def __setattr__(self, name, value): ++ self[name] = value ++ ++ ++def test_opengan_postprocessor_registry_accepts_lowercase_name(): ++ config = AttrDict( ++ { ++ "postprocessor": {"name": "opengan"}, ++ "network": {"name": "opengan"}, ++ "dataset": {"name": "cifar10", "num_classes": 10}, ++ "num_classes": 10, ++ } ++ ) ++ ++ postprocessor = get_postprocessor(config) ++ ++ assert isinstance(postprocessor, OpenGanPostprocessor) ++ ++ ++class TinyGenerator(nn.Module): ++ def __init__(self): ++ super().__init__() ++ self.weight = nn.Parameter(torch.ones(1)) ++ ++ def forward(self, z): ++ return z[:, :1] * self.weight.view(1, 1, 1, 1) ++ ++ ++class TinyDiscriminator(nn.Module): ++ def __init__(self): ++ super().__init__() ++ self.weight = nn.Parameter(torch.ones(1)) ++ ++ def forward(self, x): ++ dims = tuple(range(1, x.ndim)) ++ return torch.sigmoid(x.mean(dim=dims, keepdim=True) * self.weight) ++ ++ ++def test_opengan_trainer_registry_accepts_lowercase_name(): ++ config = AttrDict( ++ { ++ "trainer": {"name": "opengan"}, ++ "optimizer": {"num_epochs": 1, "lr": 0.001, "beta1": 0.5}, ++ "dataset": {"num_classes": 10}, ++ "network": {"name": "opengan", "nz": 2}, ++ "num_classes": 10, ++ } ++ ) ++ net = {"netG": TinyGenerator(), "netD": TinyDiscriminator()} ++ ++ trainer = get_trainer(net, [], config) ++ ++ assert isinstance(trainer, OpenGanTrainer) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,46 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++set +u ++source /testbed/.build_env/.venv/bin/activate ++set -u ++ ++ ++NEW_TESTS=( ++ tests/test_conf_branch_pipeline.py ++ tests/test_opengan_registry.py ++) ++ ++case "${1:-}" in ++ base) ++ base_tests=() ++ if [ -d tests ]; then ++ while IFS= read -r test_file; do ++ skip=false ++ for new_test in "${NEW_TESTS[@]}"; do ++ if [ "$test_file" = "$new_test" ]; then ++ skip=true ++ break ++ fi ++ done ++ if [ "$skip" = false ]; then ++ base_tests+=("$test_file") ++ fi ++ done < <(find tests -type f -name 'test*.py' | sort) ++ fi ++ if [ "${#base_tests[@]}" -eq 0 ]; then ++ echo "No pre-existing tests to run for base regression." ++ exit 0 ++ fi ++ python -m pytest -q "${base_tests[@]}" ++ ;; ++ new) ++ python -m pytest -q "${NEW_TESTS[@]}" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000126/tests/test.sh b/tasks/format-code-task-000126/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..500df3abe9ef8441a2dac709fe58e1b417d1892a --- /dev/null +++ b/tasks/format-code-task-000126/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_conf_branch_pipeline.py +tests/test_opengan_registry.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000126/tests/test_command.sh b/tasks/format-code-task-000126/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000126/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000128/environment/Dockerfile b/tasks/format-code-task-000128/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e06e7fc48509d64df08e89203dedd8e6ae1ae660 --- /dev/null +++ b/tasks/format-code-task-000128/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a25b8fadbd7967d3a6e5ac252a5f462ace826f0ba0ef615259bcdbafc444e7e2 diff --git a/tasks/format-code-task-000128/environment/setup/files/blocklist b/tasks/format-code-task-000128/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000128/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000128/environment/setup/setup.sh b/tasks/format-code-task-000128/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000128/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000128/tests/test.patch b/tasks/format-code-task-000128/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..86d2356ca88a0a334f95fac209448c7b087d6939 --- /dev/null +++ b/tasks/format-code-task-000128/tests/test.patch @@ -0,0 +1,79 @@ +diff --git a/src/blocks/blockAllContributors.prettierIgnore.test.ts b/src/blocks/blockAllContributors.prettierIgnore.test.ts +new file mode 100644 +index 0000000..ad10ef6 +--- /dev/null ++++ b/src/blocks/blockAllContributors.prettierIgnore.test.ts +@@ -0,0 +1,51 @@ ++import { testBlock } from "bingo-stratum-testers"; ++import { describe, expect, it } from "vitest"; ++ ++import { blockAllContributors } from "./blockAllContributors.js"; ++import { blockPrettier } from "./blockPrettier.js"; ++import { optionsBase } from "./options.fakes.js"; ++ ++describe("blockAllContributors prettier ignore", () => { ++ it("registers a Prettier addon ignoring .all-contributorsrc by default", () => { ++ const creation = testBlock(blockAllContributors, { options: optionsBase }); ++ ++ const prettierAddons = (creation.addons ?? []).filter( ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ (addon: any) => addon.block === blockPrettier, ++ ); ++ ++ expect(prettierAddons).toHaveLength(1); ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ expect((prettierAddons[0] as any).addons).toEqual({ ++ ignores: ["/.all-contributorsrc"], ++ }); ++ }); ++ ++ it("registers a Prettier addon ignoring .all-contributorsrc when contributors are provided", () => { ++ const creation = testBlock(blockAllContributors, { ++ options: { ++ ...optionsBase, ++ contributors: [ ++ { ++ avatar_url: "https://avatars.githubusercontent.com/u/3335181?v=4", ++ contributions: ["code"], ++ login: "JoshuaKGoldberg", ++ name: "Josh Goldberg", ++ profile: "http://www.joshuakgoldberg.com", ++ }, ++ ], ++ }, ++ }); ++ ++ const prettierAddons = (creation.addons ?? []).filter( ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ (addon: any) => addon.block === blockPrettier, ++ ); ++ ++ expect(prettierAddons).toHaveLength(1); ++ // eslint-disable-next-line @typescript-eslint/no-explicit-any ++ expect((prettierAddons[0] as any).addons).toEqual({ ++ ignores: ["/.all-contributorsrc"], ++ }); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..850c589 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/vitest run src/blocks/blockAllContributors.prettierIgnore.test.ts"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++./node_modules/.bin/vitest run src/blocks/blockAllContributors.prettierIgnore.test.ts ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000128/tests/test.sh b/tasks/format-code-task-000128/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..664b0bb69e41926bc31f91137efd2117e708c9a0 --- /dev/null +++ b/tasks/format-code-task-000128/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/blocks/blockAllContributors.prettierIgnore.test.ts +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000128/tests/test_command.sh b/tasks/format-code-task-000128/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000128/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000142/environment/Dockerfile b/tasks/format-code-task-000142/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bc6a31987e7e01f5eac402b6e5dcc1d00fb34287 --- /dev/null +++ b/tasks/format-code-task-000142/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:49f7045c50e95318ff47ec2e37825352f8f359a7f4a14b8e909be303494378ce diff --git a/tasks/format-code-task-000142/environment/setup/files/blocklist b/tasks/format-code-task-000142/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000142/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000142/environment/setup/setup.sh b/tasks/format-code-task-000142/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000142/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000142/tests/test.patch b/tasks/format-code-task-000142/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d22b113471f83056867376432f753a61fe01c072 --- /dev/null +++ b/tasks/format-code-task-000142/tests/test.patch @@ -0,0 +1,122 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..4a3500017 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/utilities/test_parsing.py -p no:cacheprovider -v"] ++} +diff --git a/tests/utilities/test_parsing.py b/tests/utilities/test_parsing.py +index c07a016ed..8994ee939 100644 +--- a/tests/utilities/test_parsing.py ++++ b/tests/utilities/test_parsing.py +@@ -12,6 +12,8 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + ++import pytest ++ + from pytorch_lightning.utilities.parsing import lightning_getattr, lightning_hasattr, lightning_setattr + + +@@ -126,3 +128,86 @@ def test_lightning_setattr(tmpdir): + 'batch_size not correctly set' + assert lightning_getattr(model7, 'batch_size') == 128, \ + 'batch_size not correctly set' ++ ++ ++def test_lightning_getattr_raises_attribute_error_on_missing_model_only(): ++ """lightning_getattr must raise AttributeError (not ValueError) when attribute is missing.""" ++ ++ class TestModel: ++ batch_size = 1 ++ ++ model = TestModel() ++ with pytest.raises(AttributeError): ++ lightning_getattr(model, 'learning_rate') ++ ++ ++def test_lightning_getattr_raises_attribute_error_on_missing_with_hparams_and_datamodule(): ++ """lightning_getattr must raise AttributeError when attribute is missing across model/hparams/datamodule.""" ++ models = _get_test_cases() ++ ++ model4 = models[3] ++ with pytest.raises(AttributeError): ++ lightning_getattr(model4, 'learning_rate') ++ ++ ++ model5 = models[4] ++ with pytest.raises(AttributeError): ++ lightning_getattr(model5, 'learning_rate') ++ ++ ++def test_lightning_getattr_not_value_error(): ++ """Regression: lightning_getattr must NOT raise ValueError when attribute is missing.""" ++ ++ class TestModel: ++ pass ++ ++ model = TestModel() ++ with pytest.raises(AttributeError): ++ lightning_getattr(model, 'nonexistent_attr') ++ ++ try: ++ lightning_getattr(model, 'nonexistent_attr') ++ except ValueError: ++ pytest.fail("lightning_getattr raised ValueError; expected AttributeError") ++ except AttributeError: ++ pass ++ ++ ++def test_lightning_setattr_raises_attribute_error_on_missing(): ++ """lightning_setattr must raise AttributeError (not ValueError) when attribute is missing.""" ++ ++ class TestModel: ++ batch_size = 1 ++ ++ model = TestModel() ++ with pytest.raises(AttributeError): ++ lightning_setattr(model, 'learning_rate', 10) ++ ++ ++def test_lightning_setattr_not_value_error(): ++ """Regression: lightning_setattr must NOT raise ValueError when attribute is missing.""" ++ ++ class TestModel: ++ pass ++ ++ model = TestModel() ++ with pytest.raises(AttributeError): ++ lightning_setattr(model, 'nonexistent_attr', 1) ++ try: ++ lightning_setattr(model, 'nonexistent_attr', 1) ++ except ValueError: ++ pytest.fail("lightning_setattr raised ValueError; expected AttributeError") ++ except AttributeError: ++ pass ++ ++ ++def test_lightning_getattr_preserves_successful_access(): ++ """Preservation: lightning_getattr still returns correct values for present attributes.""" ++ models = _get_test_cases() ++ for i, m in enumerate(models[:3]): ++ assert lightning_getattr(m, 'learning_rate') == i ++ ++ model5, model6, model7 = models[4:] ++ assert lightning_getattr(model5, 'batch_size') == 8 ++ assert lightning_getattr(model6, 'batch_size') == 8 ++ assert lightning_getattr(model7, 'batch_size') == 8 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/utilities/test_parsing.py -p no:cacheprovider -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000142/tests/test.sh b/tasks/format-code-task-000142/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..35960e41574bcf440a25f1800ef1c4a3a1e153c9 --- /dev/null +++ b/tasks/format-code-task-000142/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/utilities/test_parsing.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000142/tests/test_command.sh b/tasks/format-code-task-000142/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000142/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000143/environment/Dockerfile b/tasks/format-code-task-000143/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f18f01854b46030f58ec8aa73b3dde501bc1a059 --- /dev/null +++ b/tasks/format-code-task-000143/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1d1b433a00baa9203ea86bf4697e820e0e2367fa0de8d9186f80fb6d3c2fbc11 diff --git a/tasks/format-code-task-000143/environment/setup/files/blocklist b/tasks/format-code-task-000143/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000143/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000143/environment/setup/setup.sh b/tasks/format-code-task-000143/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000143/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000143/tests/test.patch b/tasks/format-code-task-000143/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ea4f3af9483fb6e028b720f2cc9bebf5a4801e7d --- /dev/null +++ b/tasks/format-code-task-000143/tests/test.patch @@ -0,0 +1,97 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..5c4667e36 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/core/test_datamodules.py -k \"iterable or map_dataset_still\" -v"] ++} +diff --git a/tests/core/test_datamodules.py b/tests/core/test_datamodules.py +index c8808ec37..801f69751 100644 +--- a/tests/core/test_datamodules.py ++++ b/tests/core/test_datamodules.py +@@ -497,3 +497,70 @@ def test_dm_init_from_datasets(tmpdir): + assert torch.all(next(iter(dm.val_dataloader()[1])) == torch.ones(4)) + assert torch.all(next(iter(dm.test_dataloader()[0])) == torch.ones(4)) + assert torch.all(next(iter(dm.test_dataloader()[1])) == torch.ones(4)) ++ ++ ++class DummyIDS(torch.utils.data.IterableDataset): ++ ++ def __iter__(self): ++ yield 1 ++ yield 1 ++ yield 1 ++ yield 1 ++ ++ ++def test_dm_init_from_datasets_iterable_train_single(tmpdir): ++ """Passing a single IterableDataset as train_dataset should not raise.""" ++ train_ds = DummyIDS() ++ dm = LightningDataModule.from_datasets(train_ds, batch_size=4, num_workers=0) ++ ++ ++ batch = next(iter(dm.train_dataloader())) ++ assert torch.all(batch == torch.ones(4)) ++ ++ ++def test_dm_init_from_datasets_iterable_train_sequence(tmpdir): ++ """Passing a Sequence of IterableDatasets as train_dataset should not raise.""" ++ train_dss = [DummyIDS(), DummyIDS()] ++ dm = LightningDataModule.from_datasets(train_dss, batch_size=4, num_workers=0) ++ dls = dm.train_dataloader() ++ assert isinstance(dls, list) and len(dls) == 2 ++ for dl in dls: ++ assert torch.all(next(iter(dl)) == torch.ones(4)) ++ ++ ++def test_dm_init_from_datasets_iterable_train_mapping(tmpdir): ++ """Passing a Mapping of IterableDatasets as train_dataset should not raise.""" ++ train_dss = {"a": DummyIDS(), "b": DummyIDS()} ++ dm = LightningDataModule.from_datasets(train_dss, batch_size=4, num_workers=0) ++ dls = dm.train_dataloader() ++ assert isinstance(dls, dict) and set(dls.keys()) == {"a", "b"} ++ for dl in dls.values(): ++ assert torch.all(next(iter(dl)) == torch.ones(4)) ++ ++ ++def test_dm_init_from_datasets_iterable_val_test(tmpdir): ++ """Passing IterableDatasets as val_dataset and test_dataset should not raise.""" ++ train_ds = DummyIDS() ++ val_ds = DummyIDS() ++ test_ds = DummyIDS() ++ dm = LightningDataModule.from_datasets(train_ds, val_ds, test_ds, batch_size=4, num_workers=0) ++ assert torch.all(next(iter(dm.val_dataloader())) == torch.ones(4)) ++ assert torch.all(next(iter(dm.test_dataloader())) == torch.ones(4)) ++ ++ ++def test_dm_init_from_datasets_map_dataset_still_shuffled(tmpdir): ++ """Preservation: regular Datasets passed as train_dataset still get a shuffling sampler.""" ++ from torch.utils.data.sampler import RandomSampler ++ train_ds = DummyDS() ++ dm = LightningDataModule.from_datasets(train_ds, batch_size=4, num_workers=0) ++ dl = dm.train_dataloader() ++ assert isinstance(dl.sampler, RandomSampler) ++ ++ ++def test_dm_init_from_datasets_iterable_train_no_random_sampler(tmpdir): ++ """Iterable train datasets must not be wrapped with a shuffling sampler.""" ++ from torch.utils.data.sampler import RandomSampler ++ train_ds = DummyIDS() ++ dm = LightningDataModule.from_datasets(train_ds, batch_size=4, num_workers=0) ++ dl = dm.train_dataloader() ++ assert not isinstance(dl.sampler, RandomSampler) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/core/test_datamodules.py -k "iterable or map_dataset_still" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000143/tests/test.sh b/tasks/format-code-task-000143/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ec5f55e3b55dea02410713913601e817e1070e39 --- /dev/null +++ b/tasks/format-code-task-000143/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/core/test_datamodules.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000143/tests/test_command.sh b/tasks/format-code-task-000143/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000143/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000145/environment/Dockerfile b/tasks/format-code-task-000145/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..22f53235eac9566d6f58256d7ba9f9c7422c5b53 --- /dev/null +++ b/tasks/format-code-task-000145/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:29577823022722e55b070071b9ed4d0f80d6f61af23eac17daeb2db05a34210a diff --git a/tasks/format-code-task-000145/environment/setup/files/blocklist b/tasks/format-code-task-000145/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000145/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000145/environment/setup/setup.sh b/tasks/format-code-task-000145/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000145/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000145/tests/test.patch b/tasks/format-code-task-000145/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ab98bd87c7340864a552c05d941d1cfb7df0deb8 --- /dev/null +++ b/tasks/format-code-task-000145/tests/test.patch @@ -0,0 +1,134 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..0eda835f6 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/deprecated_api/test_remove_1-7.py -v"] ++} +diff --git a/tests/deprecated_api/test_remove_1-7.py b/tests/deprecated_api/test_remove_1-7.py +index 38b1e5015..a056c770a 100644 +--- a/tests/deprecated_api/test_remove_1-7.py ++++ b/tests/deprecated_api/test_remove_1-7.py +@@ -15,7 +15,8 @@ + + import pytest + +-from tests.deprecated_api import _soft_unimport_module ++from pytorch_lightning import LightningDataModule ++from tests.deprecated_api import _soft_unimport_module, no_deprecated_call + from tests.helpers import BoringModel + + +@@ -46,3 +47,97 @@ def test_v1_7_0_deprecated_model_size(): + match="LightningModule.model_size` property was deprecated in v1.5 and will be removed in v1.7" + ): + _ = model.model_size ++ ++ ++def test_v1_7_0_datamodule_train_transforms_init_deprecation(): ++ with pytest.deprecated_call(match=r"DataModule.*`train_transforms`.*v1\.5.*v1\.7"): ++ LightningDataModule(train_transforms=object()) ++ ++ ++def test_v1_7_0_datamodule_val_transforms_init_deprecation(): ++ with pytest.deprecated_call(match=r"DataModule.*`val_transforms`.*v1\.5.*v1\.7"): ++ LightningDataModule(val_transforms=object()) ++ ++ ++def test_v1_7_0_datamodule_test_transforms_init_deprecation(): ++ with pytest.deprecated_call(match=r"DataModule.*`test_transforms`.*v1\.5.*v1\.7"): ++ LightningDataModule(test_transforms=object()) ++ ++ ++def test_v1_7_0_datamodule_dims_init_deprecation(): ++ with pytest.deprecated_call(match=r"DataModule.*`dims`.*v1\.5.*v1\.7"): ++ LightningDataModule(dims=(1, 1, 1)) ++ ++ ++def test_v1_7_0_datamodule_no_deprecation_when_init_defaults(): ++ import warnings ++ ++ with warnings.catch_warnings(record=True) as caught: ++ warnings.simplefilter("always") ++ LightningDataModule() ++ relevant = [str(x.message) for x in caught if issubclass(x.category, DeprecationWarning) and "DataModule" in str(x.message)] ++ assert relevant == [], f"Unexpected DataModule deprecation(s): {relevant}" ++ ++ ++def test_v1_7_0_datamodule_no_deprecation_when_init_with_none(): ++ import warnings ++ ++ with warnings.catch_warnings(record=True) as caught: ++ warnings.simplefilter("always") ++ LightningDataModule(train_transforms=None, val_transforms=None, test_transforms=None, dims=None) ++ relevant = [str(x.message) for x in caught if issubclass(x.category, DeprecationWarning) and "DataModule" in str(x.message)] ++ assert relevant == [], f"Unexpected DataModule deprecation(s): {relevant}" ++ ++ ++def test_v1_7_0_datamodule_train_transforms_getter_deprecation(): ++ dm = LightningDataModule() ++ with pytest.deprecated_call(match=r"DataModule.*`train_transforms`.*v1\.5.*v1\.7"): ++ _ = dm.train_transforms ++ ++ ++def test_v1_7_0_datamodule_train_transforms_setter_deprecation(): ++ dm = LightningDataModule() ++ with pytest.deprecated_call(match=r"DataModule.*`train_transforms`.*v1\.5.*v1\.7"): ++ dm.train_transforms = object() ++ ++ ++def test_v1_7_0_datamodule_val_transforms_getter_deprecation(): ++ dm = LightningDataModule() ++ with pytest.deprecated_call(match=r"DataModule.*`val_transforms`.*v1\.5.*v1\.7"): ++ _ = dm.val_transforms ++ ++ ++def test_v1_7_0_datamodule_val_transforms_setter_deprecation(): ++ dm = LightningDataModule() ++ with pytest.deprecated_call(match=r"DataModule.*`val_transforms`.*v1\.5.*v1\.7"): ++ dm.val_transforms = object() ++ ++ ++def test_v1_7_0_datamodule_test_transforms_getter_deprecation(): ++ dm = LightningDataModule() ++ with pytest.deprecated_call(match=r"DataModule.*`test_transforms`.*v1\.5.*v1\.7"): ++ _ = dm.test_transforms ++ ++ ++def test_v1_7_0_datamodule_test_transforms_setter_deprecation(): ++ dm = LightningDataModule() ++ with pytest.deprecated_call(match=r"DataModule.*`test_transforms`.*v1\.5.*v1\.7"): ++ dm.test_transforms = object() ++ ++ ++def test_v1_7_0_datamodule_dims_getter_deprecation(): ++ dm = LightningDataModule() ++ with pytest.deprecated_call(match=r"DataModule.*`dims`.*v1\.5.*v1\.7"): ++ _ = dm.dims ++ ++ ++def test_v1_7_0_datamodule_dims_setter_deprecation(): ++ dm = LightningDataModule() ++ with pytest.deprecated_call(match=r"DataModule.*`dims`.*v1\.5.*v1\.7"): ++ dm.dims = (2, 2) ++ ++ ++def test_v1_7_0_datamodule_size_deprecation(): ++ dm = LightningDataModule() ++ with pytest.deprecated_call(match=r"DataModule.*`size`.*v1\.5.*v1\.7"): ++ _ = dm.size() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/deprecated_api/test_remove_1-7.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000145/tests/test.sh b/tasks/format-code-task-000145/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ea995b7d9d4cd2fef20a8a16f359dc487f323c6 --- /dev/null +++ b/tasks/format-code-task-000145/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/deprecated_api/test_remove_1-7.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000145/tests/test_command.sh b/tasks/format-code-task-000145/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000145/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000175/environment/Dockerfile b/tasks/format-code-task-000175/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..23092fe85a3c4f3f2ae168cc64e0fece93dbbd3d --- /dev/null +++ b/tasks/format-code-task-000175/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:12a648bf14ccada54db347d5eff54db7ddaa06f6f646d99e2edab6852ebdd96a diff --git a/tasks/format-code-task-000175/environment/setup/files/blocklist b/tasks/format-code-task-000175/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000175/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000175/environment/setup/setup.sh b/tasks/format-code-task-000175/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000175/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000175/tests/test.patch b/tasks/format-code-task-000175/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8709ad0d0d80b1ef778f1bb5ee6967467693c5e8 --- /dev/null +++ b/tasks/format-code-task-000175/tests/test.patch @@ -0,0 +1,45 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..5c112182 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest tests/integration/utils/test_io_utils.py -v"] ++} +diff --git a/tests/integration/utils/test_io_utils.py b/tests/integration/utils/test_io_utils.py +index e712bb55..cd53a131 100644 +--- a/tests/integration/utils/test_io_utils.py ++++ b/tests/integration/utils/test_io_utils.py +@@ -46,3 +46,18 @@ class TestGetNWBVersion(TestCase): + builder1 = GroupBuilder(name="root") + builder1.set_attribute(name="nwb_version", value="2.0.0-alpha.sha-test.5114f85") + assert get_nwb_version(builder1, include_prerelease=True) == (2, 0, 0, "alpha.sha-test.5114f85") ++ ++ def test_get_nwb_version_20b_prerelease_false(self): ++ """The non-semver '2.0b' version (used by some NWB 2.0.1 test data) must ++ not raise and should be treated as the 2.0.0 release.""" ++ builder1 = GroupBuilder(name="root") ++ builder1.set_attribute(name="nwb_version", value="2.0b") ++ assert get_nwb_version(builder1) == (2, 0, 0) ++ ++ def test_get_nwb_version_20b_prerelease_true(self): ++ """The non-semver '2.0b' version must not raise when include_prerelease=True. ++ The prerelease component must be the 'b' suffix, not arbitrary other text.""" ++ builder1 = GroupBuilder(name="root") ++ builder1.set_attribute(name="nwb_version", value="2.0b") ++ result = get_nwb_version(builder1, include_prerelease=True) ++ assert result == (2, 0, 0, "b") +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest -v -rA tests/integration/utils/test_io_utils.py::TestGetNWBVersion::test_get_nwb_version_20b_prerelease_false tests/integration/utils/test_io_utils.py::TestGetNWBVersion::test_get_nwb_version_20b_prerelease_true ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000175/tests/test.sh b/tasks/format-code-task-000175/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..043a543a34ecab1d5e98b8da65ff28d5ffadb7e5 --- /dev/null +++ b/tasks/format-code-task-000175/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/integration/utils/test_io_utils.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000175/tests/test_command.sh b/tasks/format-code-task-000175/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000175/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000181/environment/Dockerfile b/tasks/format-code-task-000181/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8648631912210bb02da06db0ed2d58757dddaf16 --- /dev/null +++ b/tasks/format-code-task-000181/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:65a436926eb08625f223147b93981deafeb6e7e4aa09ca9dccfa4ea9f81e8d23 diff --git a/tasks/format-code-task-000181/environment/setup/files/blocklist b/tasks/format-code-task-000181/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000181/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000181/environment/setup/setup.sh b/tasks/format-code-task-000181/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000181/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000181/tests/test.patch b/tasks/format-code-task-000181/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b24f56f90fe40aa4d5ca094ca673ba374d070568 --- /dev/null +++ b/tasks/format-code-task-000181/tests/test.patch @@ -0,0 +1,245 @@ +diff --git a/tests/import_osm/create_hierarchy/test_linestring_parent_via_center.py b/tests/import_osm/create_hierarchy/test_linestring_parent_via_center.py +new file mode 100644 +index 0000000..dc70935 +--- /dev/null ++++ b/tests/import_osm/create_hierarchy/test_linestring_parent_via_center.py +@@ -0,0 +1,191 @@ ++import os ++ ++import pytest ++from geoalchemy2.elements import WKTElement ++ ++from osmnames.database.connection import engine ++from osmnames.database.functions import exec_sql_from_file ++from osmnames.database.tables import Tables ++from osmnames.import_osm.create_hierarchy import ( ++ set_parent_id_for_elements_covered_by_single_polygon, ++) ++ ++ ++@pytest.fixture(scope="function") ++def schema(engine): ++ current_directory = os.path.dirname(os.path.realpath(__file__)) ++ exec_sql_from_file('../fixtures/test_prepare_imported_data.sql.dump', cwd=current_directory) ++ ++ ++@pytest.fixture(scope="function") ++def tables(engine, schema): ++ return Tables(engine) ++ ++ ++def _polygon(tables, **kwargs): ++ kwargs.setdefault('type', 'city') ++ return tables.osm_polygon(**kwargs) ++ ++ ++def test_linestring_parented_when_center_inside_polygon_not_fully_covered(session, schema, tables): ++ ++ session.add( ++ tables.osm_linestring( ++ id=1, ++ name="street crossing the boundary", ++ type='street', ++ geometry=WKTElement("LINESTRING(0 1, 8 1)", srid=3857), ++ ) ++ ) ++ session.add( ++ _polygon( ++ tables, ++ id=2, ++ name="covering polygon", ++ place_rank=22, ++ geometry=WKTElement("POLYGON((0 0, 5 0, 5 5, 0 5, 0 0))", srid=3857), ++ ) ++ ) ++ session.commit() ++ ++ set_parent_id_for_elements_covered_by_single_polygon() ++ ++ assert session.query(tables.osm_linestring).get(1).parent_id == 2 ++ ++ ++def test_linestring_parented_regardless_of_polygon_place_rank(session, schema, tables): ++ session.add( ++ tables.osm_linestring( ++ id=1, ++ name="street inside a coarse polygon", ++ type='street', ++ geometry=WKTElement("LINESTRING(1 1, 3 1)", srid=3857), ++ ) ++ ) ++ session.add( ++ _polygon( ++ tables, ++ id=2, ++ name="low place_rank polygon", ++ place_rank=12, ++ geometry=WKTElement("POLYGON((0 0, 6 0, 6 6, 0 6, 0 0))", srid=3857), ++ ) ++ ) ++ session.commit() ++ ++ set_parent_id_for_elements_covered_by_single_polygon() ++ ++ assert session.query(tables.osm_linestring).get(1).parent_id == 2 ++ ++ ++def test_linestring_not_parented_when_center_outside_polygon(session, schema, tables): ++ ++ session.add( ++ tables.osm_linestring( ++ id=1, ++ name="street leaving the polygon", ++ type='street', ++ geometry=WKTElement("LINESTRING(1 1, 9 1)", srid=3857), ++ ) ++ ) ++ session.add( ++ _polygon( ++ tables, ++ id=2, ++ name="polygon only touching one end", ++ place_rank=22, ++ geometry=WKTElement("POLYGON((0 0, 4 0, 4 4, 0 4, 0 0))", srid=3857), ++ ) ++ ) ++ session.commit() ++ ++ set_parent_id_for_elements_covered_by_single_polygon() ++ ++ assert session.query(tables.osm_linestring).get(1).parent_id is None ++ ++ ++def test_linestring_parented_to_most_specific_polygon_containing_center(session, schema, tables): ++ session.add( ++ tables.osm_linestring( ++ id=1, ++ name="street inside two nested polygons", ++ type='street', ++ geometry=WKTElement("LINESTRING(2 2, 4 2)", srid=3857), ++ ) ++ ) ++ session.add( ++ _polygon( ++ tables, ++ id=2, ++ name="coarse polygon", ++ place_rank=18, ++ geometry=WKTElement("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))", srid=3857), ++ ) ++ ) ++ session.add( ++ _polygon( ++ tables, ++ id=3, ++ name="fine polygon", ++ place_rank=22, ++ geometry=WKTElement("POLYGON((1 1, 6 1, 6 6, 1 6, 1 1))", srid=3857), ++ ) ++ ) ++ session.commit() ++ ++ set_parent_id_for_elements_covered_by_single_polygon() ++ ++ assert session.query(tables.osm_linestring).get(1).parent_id == 3 ++ ++ ++def test_polygon_still_parented_by_full_containment(session, schema, tables): ++ session.add( ++ _polygon( ++ tables, ++ id=1, ++ name="enclosing polygon", ++ type='country', ++ place_rank=8, ++ geometry=WKTElement("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))", srid=3857), ++ ) ++ ) ++ session.add( ++ _polygon( ++ tables, ++ id=2, ++ name="inner polygon", ++ place_rank=20, ++ geometry=WKTElement("POLYGON((1 1, 3 1, 3 3, 1 3, 1 1))", srid=3857), ++ ) ++ ) ++ session.commit() ++ ++ set_parent_id_for_elements_covered_by_single_polygon() ++ ++ assert session.query(tables.osm_polygon).get(2).parent_id == 1 ++ ++ ++def test_point_still_parented_by_full_containment(session, schema, tables): ++ session.add( ++ _polygon( ++ tables, ++ id=1, ++ name="polygon covering the point", ++ place_rank=20, ++ geometry=WKTElement("POLYGON((0 0, 4 0, 4 4, 0 4, 0 0))", srid=3857), ++ ) ++ ) ++ session.add( ++ tables.osm_point( ++ id=2, ++ name="point inside polygon", ++ type='place', ++ linked=False, ++ geometry=WKTElement("POINT(2 2)", srid=3857), ++ ) ++ ) ++ session.commit() ++ ++ set_parent_id_for_elements_covered_by_single_polygon() ++ ++ assert session.query(tables.osm_point).get(2).parent_id == 1 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,43 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++export SIMPLE_SETTINGS="osmnames.settings_default,osmnames.settings_testing" ++ ++pg_ctlcluster 16 main start >/dev/null 2>&1 || true ++ ++for _ in $(seq 1 30); do ++ if sudo -u postgres psql -c 'SELECT 1' >/dev/null 2>&1; then break; fi ++ sleep 1 ++done ++ ++ ++ ++if ! sudo -u postgres psql -tAc "SELECT 1 FROM pg_database WHERE datname='template_postgis'" | grep -q 1; then ++ sudo -u postgres psql -v ON_ERROR_STOP=1 -c "CREATE DATABASE template_postgis;" ++ sudo -u postgres psql -v ON_ERROR_STOP=1 -c "UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_postgis';" ++fi ++sudo -u postgres psql -d template_postgis -v ON_ERROR_STOP=1 \ ++ -c "CREATE EXTENSION IF NOT EXISTS postgis; CREATE EXTENSION IF NOT EXISTS hstore;" ++ ++ ++grep -qE '(^|[[:space:]])postgres([[:space:]]|$)' /etc/hosts || echo "127.0.0.1 postgres" >> /etc/hosts ++ ++ ++ ++python -m pytest -p no:cacheprovider \ ++ "tests/export_osmnames/test_get_importance.py::test_calculates_importance_if_no_wikipedia_article_exists" \ ++ "tests/export_osmnames/test_get_importance.py::test_calculates_importance_if_no_wikipedia_article_defined" ++ ++ ++python -m pytest -p no:cacheprovider \ ++ tests/import_osm/create_hierarchy/test_linestring_parent_via_center.py diff --git a/tasks/format-code-task-000181/tests/test.sh b/tasks/format-code-task-000181/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6b4894e1b2148760406a0df9e406dd6763f9842e --- /dev/null +++ b/tasks/format-code-task-000181/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/import_osm/create_hierarchy/test_linestring_parent_via_center.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000181/tests/test_command.sh b/tasks/format-code-task-000181/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000181/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000187/environment/Dockerfile b/tasks/format-code-task-000187/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e04e008b7a00991d6842d31bc1c5ad2e667d7926 --- /dev/null +++ b/tasks/format-code-task-000187/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:65a89ccf1d5b0c29d5e97619498ee909caf869ea8787945625129fb14e405588 diff --git a/tasks/format-code-task-000187/environment/setup/files/blocklist b/tasks/format-code-task-000187/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000187/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000187/environment/setup/setup.sh b/tasks/format-code-task-000187/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000187/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000187/tests/test.patch b/tasks/format-code-task-000187/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2895ac231ee53bd18a177e12e4453ce23ec49ef1 --- /dev/null +++ b/tasks/format-code-task-000187/tests/test.patch @@ -0,0 +1,203 @@ +diff --git a/beacon-chain/core/validators/committees_nextepoch_test.go b/beacon-chain/core/validators/committees_nextepoch_test.go +new file mode 100644 +index 0000000000..f26b16a843 +--- /dev/null ++++ b/beacon-chain/core/validators/committees_nextepoch_test.go +@@ -0,0 +1,150 @@ ++package validators ++ ++import ( ++ "reflect" ++ "testing" ++ ++ "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" ++ pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" ++ "github.com/prysmaticlabs/prysm/shared/params" ++) ++ ++ ++ ++ ++func buildNextEpochState(t *testing.T) *pb.BeaconState { ++ config := params.BeaconConfig() ++ ++ validators := make([]*pb.ValidatorRecord, config.DepositsForChainStart) ++ for i := 0; i < len(validators); i++ { ++ validators[i] = &pb.ValidatorRecord{ ++ ExitEpoch: config.FarFutureEpoch, ++ } ++ } ++ ++ randaoMixes := make([][]byte, config.LatestRandaoMixesLength) ++ for i := range randaoMixes { ++ randaoMixes[i] = make([]byte, 32) ++ } ++ indexRoots := make([][]byte, config.LatestIndexRootsLength) ++ for i := range indexRoots { ++ indexRoots[i] = make([]byte, 32) ++ } ++ ++ ++ ++ stateSlot := 64 * config.EpochLength ++ return &pb.BeaconState{ ++ ValidatorRegistry: validators, ++ Slot: stateSlot, ++ ValidatorRegistryUpdateSlot: stateSlot, ++ CurrentEpochStartShard: 5, ++ CurrentEpochCalculationSlot: 0, ++ CurrentEpochSeedHash32: make([]byte, 32), ++ LatestRandaoMixesHash32S: randaoMixes, ++ LatestIndexRootHash32S: indexRoots, ++ } ++} ++ ++func TestCrosslinkCommitteesAtSlot_NextEpochAccepted(t *testing.T) { ++ state := buildNextEpochState(t) ++ nextEpochSlot := helpers.StartSlot(helpers.NextEpoch(state)) ++ ++ committees, err := CrosslinkCommitteesAtSlot(state, nextEpochSlot) ++ if err != nil { ++ t.Fatalf("expected next-epoch slot to be accepted, got error: %v", err) ++ } ++ if len(committees) == 0 { ++ t.Error("expected non-empty committees for next-epoch slot") ++ } ++} ++ ++func TestCrosslinkCommitteesAtSlot_RegistryChangeShiftsStartShard(t *testing.T) { ++ state := buildNextEpochState(t) ++ nextEpochSlot := helpers.StartSlot(helpers.NextEpoch(state)) ++ ++ withoutChange, err := CrosslinkCommitteesAtSlot(state, nextEpochSlot, false) ++ if err != nil { ++ t.Fatalf("could not get committees without registry change: %v", err) ++ } ++ withChange, err := CrosslinkCommitteesAtSlot(state, nextEpochSlot, true) ++ if err != nil { ++ t.Fatalf("could not get committees with registry change: %v", err) ++ } ++ ++ if len(withoutChange) == 0 || len(withChange) == 0 { ++ t.Fatal("expected non-empty committees for next-epoch slot") ++ } ++ ++ ++ if withoutChange[0].Shard != state.CurrentEpochStartShard { ++ t.Errorf( ++ "default next-epoch start shard wrong, wanted %d, got %d", ++ state.CurrentEpochStartShard, withoutChange[0].Shard, ++ ) ++ } ++ ++ ++ ++ currentCount := helpers.CurrentEpochCommitteeCount(state) ++ wantShard := (state.CurrentEpochStartShard + currentCount) % ++ params.BeaconConfig().ShardCount ++ if withChange[0].Shard != wantShard { ++ t.Errorf( ++ "registry-change start shard wrong, wanted %d, got %d", ++ wantShard, withChange[0].Shard, ++ ) ++ } ++ ++ if withChange[0].Shard == withoutChange[0].Shard { ++ t.Error("registry change should shift the start shard but did not") ++ } ++} ++ ++func TestCrosslinkCommitteesAtSlot_DefaultMatchesNoRegistryChange(t *testing.T) { ++ state := buildNextEpochState(t) ++ nextEpochSlot := helpers.StartSlot(helpers.NextEpoch(state)) ++ ++ omitted, err := CrosslinkCommitteesAtSlot(state, nextEpochSlot) ++ if err != nil { ++ t.Fatalf("could not get committees: %v", err) ++ } ++ explicitFalse, err := CrosslinkCommitteesAtSlot(state, nextEpochSlot, false) ++ if err != nil { ++ t.Fatalf("could not get committees: %v", err) ++ } ++ if !reflect.DeepEqual(omitted, explicitFalse) { ++ t.Error("omitting the registry-change flag should behave the same as passing false") ++ } ++} ++ ++func TestCrosslinkCommitteesAtSlot_RegistryChangeIgnoredForCurrentEpoch(t *testing.T) { ++ state := buildNextEpochState(t) ++ currentSlot := state.Slot + 5 ++ ++ withoutChange, err := CrosslinkCommitteesAtSlot(state, currentSlot, false) ++ if err != nil { ++ t.Fatalf("could not get current-epoch committees: %v", err) ++ } ++ withChange, err := CrosslinkCommitteesAtSlot(state, currentSlot, true) ++ if err != nil { ++ t.Fatalf("could not get current-epoch committees: %v", err) ++ } ++ if !reflect.DeepEqual(withoutChange, withChange) { ++ t.Error("registry-change flag must not affect current-epoch committees") ++ } ++} ++ ++func TestCrosslinkCommitteesAtSlot_OutOfBounds(t *testing.T) { ++ state := buildNextEpochState(t) ++ ++ beyondNext := helpers.StartSlot(helpers.NextEpoch(state) + 1) ++ if _, err := CrosslinkCommitteesAtSlot(state, beyondNext); err == nil { ++ t.Error("expected error for slot beyond the next epoch") ++ } ++ ++ beforePrev := helpers.StartSlot(helpers.PrevEpoch(state) - 1) ++ if _, err := CrosslinkCommitteesAtSlot(state, beforePrev); err == nil { ++ t.Error("expected error for slot before the previous epoch") ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,42 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++if [ ! -f go.mod ]; then ++ cat > go.mod <<'EOF' ++module github.com/prysmaticlabs/prysm ++ ++go 1.16 ++ ++require ( ++ github.com/ethereum/go-ethereum v1.8.27 ++ github.com/gogo/protobuf v1.2.1 ++ github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3 ++ github.com/urfave/cli v1.20.0 ++ golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a ++) ++EOF ++fi ++ ++export GOTOOLCHAIN=local ++export GOFLAGS=-mod=mod ++export GOPROXY=file:///root/go/pkg/mod/cache/download ++export GOSUMDB=off ++ ++ ++go test ./beacon-chain/core/helpers/ ++go test ./beacon-chain/core/validators/ -run \ ++'TestCrosslinkCommitteesAtSlot_Ok|TestCrosslinkCommitteesAtPrevSlot_ShuffleFailed|TestCrosslinkCommitteesAtCurrSlot_ShuffleFailed|TestAttestationParticipants_ok|TestAttestationParticipants_IncorrectBitfield|TestShuffling_Ok|TestShuffling_OutOfBound' ++ ++ ++go test ./beacon-chain/core/validators/ -run \ ++'TestCrosslinkCommitteesAtSlot_NextEpochAccepted|TestCrosslinkCommitteesAtSlot_RegistryChangeShiftsStartShard|TestCrosslinkCommitteesAtSlot_DefaultMatchesNoRegistryChange|TestCrosslinkCommitteesAtSlot_RegistryChangeIgnoredForCurrentEpoch|TestCrosslinkCommitteesAtSlot_OutOfBounds' diff --git a/tasks/format-code-task-000187/tests/test.sh b/tasks/format-code-task-000187/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..eda1f8d402281f550abb445aeeaf4cddc747ee77 --- /dev/null +++ b/tasks/format-code-task-000187/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +beacon-chain/core/validators/committees_nextepoch_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000187/tests/test_command.sh b/tasks/format-code-task-000187/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000187/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000188/environment/Dockerfile b/tasks/format-code-task-000188/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..201400490b276610384af01b0be66a42630eb582 --- /dev/null +++ b/tasks/format-code-task-000188/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5172a36009dd933d1e4e65f367df46edcba7b2f6f765329100c2597db10be577 diff --git a/tasks/format-code-task-000188/environment/setup/files/blocklist b/tasks/format-code-task-000188/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000188/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000188/environment/setup/setup.sh b/tasks/format-code-task-000188/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000188/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000188/tests/test.patch b/tasks/format-code-task-000188/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9cdeebed8c7773d3eb7a15b92dd04b76d8517fe --- /dev/null +++ b/tasks/format-code-task-000188/tests/test.patch @@ -0,0 +1,463 @@ +diff --git a/test/subgenerators.js b/test/subgenerators.js +index 98e22e7..8ee4e3f 100644 +--- a/test/subgenerators.js ++++ b/test/subgenerators.js +@@ -1,11 +1,33 @@ + 'use strict'; + var util = require('./test-utility'); ++var fs = require('fs'); ++var nodeAssert = require('assert'); + + /* + * Test for all subgenerators NOT requiring a name argument + */ + describe('Subgenerators without arguments tests', function() { + ++ function normalizedDockerfileLines(filePath) { ++ return fs.readFileSync(filePath, 'utf8') ++ .replace(/\r\n/g, '\n') ++ .split('\n') ++ .map(function(line) { return line.trim(); }) ++ .filter(function(line) { return line.length > 0; }); ++ } ++ ++ function assertDockerfileContents(filePath) { ++ nodeAssert.deepEqual(normalizedDockerfileLines(filePath), [ ++ 'FROM microsoft/aspnet:1.0.0-beta7', ++ 'COPY project.json /app/', ++ 'WORKDIR /app', ++ 'RUN ["dnu", "restore"]', ++ 'COPY . /app', ++ 'EXPOSE 5000', ++ 'ENTRYPOINT ["dnx", "-p", "project.json", "kestrel"]' ++ ]); ++ } ++ + describe('aspnet:PackageJson', function() { + util.goCreate('PackageJson'); + util.fileCheck('should create package json file', 'package.json'); +@@ -48,6 +70,14 @@ describe('Subgenerators without arguments tests', function() { + util.fileCheck('should create tsconfig.json file', 'tsconfig.json'); + }); + ++ describe('aspnet:Dockerfile', function() { ++ util.goCreate('Dockerfile'); ++ util.fileCheck('should create Dockerfile', 'Dockerfile'); ++ it('should create Dockerfile content for ASP.NET 5 kestrel apps', function() { ++ assertDockerfileContents('Dockerfile'); ++ }); ++ }); ++ + }); + + /* +diff --git a/test/test-core.js b/test/test-core.js +index 19c1d14..066d33d 100644 +--- a/test/test-core.js ++++ b/test/test-core.js +@@ -1,8 +1,31 @@ + 'use strict'; + var yeoman = require('yeoman-generator'); + var assert = yeoman.assert; ++var fs = require('fs'); ++var path = require('path'); ++var nodeAssert = require('assert'); + var util = require('./test-utility'); + ++function normalizedDockerfileLines(filePath) { ++ return fs.readFileSync(filePath, 'utf8') ++ .replace(/\r\n/g, '\n') ++ .split('\n') ++ .map(function(line) { return line.trim(); }) ++ .filter(function(line) { return line.length > 0; }); ++} ++ ++function assertDockerfileContents(filePath) { ++ nodeAssert.deepEqual(normalizedDockerfileLines(filePath), [ ++ 'FROM microsoft/aspnet:1.0.0-beta7', ++ 'COPY project.json /app/', ++ 'WORKDIR /app', ++ 'RUN ["dnu", "restore"]', ++ 'COPY . /app', ++ 'EXPOSE 5000', ++ 'ENTRYPOINT ["dnx", "-p", "project.json", "kestrel"]' ++ ]); ++} ++ + /* + * can be imported + */ +@@ -37,7 +60,8 @@ describe('aspnet - Empty Application', function() { + 'emptyTest/hosting.ini', + 'emptyTest/project.json', + 'emptyTest/Startup.cs', +- 'emptyTest/wwwroot/README.md' ++ 'emptyTest/wwwroot/README.md', ++ 'emptyTest/Dockerfile' + ]; + describe('Checking files', function() { + for (var i = 0; i < files.length; i++) { +@@ -45,6 +69,12 @@ describe('aspnet - Empty Application', function() { + } + }); + ++ describe('Checking Dockerfile content', function() { ++ it('should create a Dockerfile for ASP.NET 5 kestrel apps', function() { ++ assertDockerfileContents('emptyTest/Dockerfile'); ++ }); ++ }); ++ + }); + + /* +@@ -246,6 +276,7 @@ describe('aspnet - Web Application', function() { + + + var files = [ ++ 'webTest/Dockerfile', + 'webTest/.bowerrc', + 'webTest/.gitignore', + 'webTest/bower.json', +@@ -324,6 +355,12 @@ describe('aspnet - Web Application', function() { + } + }); + ++ describe('Checking Dockerfile content', function() { ++ it('should create a Dockerfile for ASP.NET 5 kestrel apps', function() { ++ assertDockerfileContents('webTest/Dockerfile'); ++ }); ++ }); ++ + }); + + /* +@@ -420,6 +457,7 @@ describe('aspnet - Web Application Basic', function() { + }); + + var files = [ ++ 'webTest/Dockerfile', + 'webTest/.bowerrc', + 'webTest/.gitignore', + 'webTest/bower.json', +@@ -452,6 +490,12 @@ describe('aspnet - Web Application Basic', function() { + } + }); + ++ describe('Checking Dockerfile content', function() { ++ it('should create a Dockerfile for ASP.NET 5 kestrel apps', function() { ++ assertDockerfileContents('webTest/Dockerfile'); ++ }); ++ }); ++ + }); + + /* +@@ -488,7 +532,8 @@ describe('aspnet - Web API Application', function() { + 'webAPITest/Properties/launchSettings.json', + 'webAPITest/Startup.cs', + 'webAPITest/.gitignore', +- 'webAPITest/wwwroot/README.md' ++ 'webAPITest/wwwroot/README.md', ++ 'webAPITest/Dockerfile' + ]; + describe('Checking files', function() { + for (var i = 0; i < files.length; i++) { +@@ -496,6 +541,49 @@ describe('aspnet - Web API Application', function() { + } + }); + ++ describe('Checking Dockerfile content', function() { ++ it('should create a Dockerfile for ASP.NET 5 kestrel apps', function() { ++ assertDockerfileContents('webAPITest/Dockerfile'); ++ }); ++ }); ++ ++}); ++ ++describe('aspnet - Web Application with non-fixture project name', function() { ++ var projectName = 'dockerWebApp' + Date.now(); ++ ++ before(function(done) { ++ yeoman.test.run(path.join(__dirname, '../app')) ++ .withPrompts({ ++ type: 'web', ++ applicationName: projectName ++ }) ++ .on('end', done); ++ }); ++ ++ it('should create Dockerfile in the generated project root', function() { ++ assert.file(projectName + '/Dockerfile'); ++ }); ++ ++ it('should create Dockerfile content for ASP.NET 5 kestrel apps', function() { ++ assertDockerfileContents(projectName + '/Dockerfile'); ++ }); ++ ++}); ++ ++describe('aspnet:Dockerfile usage text', function() { ++ ++ it('should describe the standalone Dockerfile generator to users', function() { ++ var usage = fs.readFileSync(path.join(__dirname, '../Dockerfile/USAGE'), 'utf8') ++ .replace(/\s+/g, ' ') ++ .toLowerCase(); ++ ++ nodeAssert(usage.indexOf('docker configuration file') !== -1); ++ nodeAssert(usage.indexOf('create') !== -1); ++ nodeAssert(usage.indexOf('yo aspnet:dockerfile') !== -1); ++ nodeAssert(usage.indexOf('dockerfile') !== -1); ++ }); ++ + }); + + +diff --git a/mimo_test.patch b/mimo_test.patch +new file mode 100644 +--- /dev/null ++++ b/mimo_test.patch +@@ -0,0 +1,214 @@ ++diff --git a/test/subgenerators.js b/test/subgenerators.js ++index 98e22e7..8ee4e3f 100644 ++--- a/test/subgenerators.js +++++ b/test/subgenerators.js ++@@ -1,11 +1,33 @@ ++ 'use strict'; ++ var util = require('./test-utility'); +++var fs = require('fs'); +++var nodeAssert = require('assert'); ++ ++ /* ++ * Test for all subgenerators NOT requiring a name argument ++ */ ++ describe('Subgenerators without arguments tests', function() { ++ +++ function normalizedDockerfileLines(filePath) { +++ return fs.readFileSync(filePath, 'utf8') +++ .replace(/\r\n/g, '\n') +++ .split('\n') +++ .map(function(line) { return line.trim(); }) +++ .filter(function(line) { return line.length > 0; }); +++ } +++ +++ function assertDockerfileContents(filePath) { +++ nodeAssert.deepEqual(normalizedDockerfileLines(filePath), [ +++ 'FROM microsoft/aspnet:1.0.0-beta7', +++ 'COPY project.json /app/', +++ 'WORKDIR /app', +++ 'RUN ["dnu", "restore"]', +++ 'COPY . /app', +++ 'EXPOSE 5000', +++ 'ENTRYPOINT ["dnx", "-p", "project.json", "kestrel"]' +++ ]); +++ } +++ ++ describe('aspnet:PackageJson', function() { ++ util.goCreate('PackageJson'); ++ util.fileCheck('should create package json file', 'package.json'); ++@@ -48,6 +70,14 @@ describe('Subgenerators without arguments tests', function() { ++ util.fileCheck('should create tsconfig.json file', 'tsconfig.json'); ++ }); ++ +++ describe('aspnet:Dockerfile', function() { +++ util.goCreate('Dockerfile'); +++ util.fileCheck('should create Dockerfile', 'Dockerfile'); +++ it('should create Dockerfile content for ASP.NET 5 kestrel apps', function() { +++ assertDockerfileContents('Dockerfile'); +++ }); +++ }); +++ ++ }); ++ ++ /* ++diff --git a/test/test-core.js b/test/test-core.js ++index 19c1d14..066d33d 100644 ++--- a/test/test-core.js +++++ b/test/test-core.js ++@@ -1,8 +1,31 @@ ++ 'use strict'; ++ var yeoman = require('yeoman-generator'); ++ var assert = yeoman.assert; +++var fs = require('fs'); +++var path = require('path'); +++var nodeAssert = require('assert'); ++ var util = require('./test-utility'); ++ +++function normalizedDockerfileLines(filePath) { +++ return fs.readFileSync(filePath, 'utf8') +++ .replace(/\r\n/g, '\n') +++ .split('\n') +++ .map(function(line) { return line.trim(); }) +++ .filter(function(line) { return line.length > 0; }); +++} +++ +++function assertDockerfileContents(filePath) { +++ nodeAssert.deepEqual(normalizedDockerfileLines(filePath), [ +++ 'FROM microsoft/aspnet:1.0.0-beta7', +++ 'COPY project.json /app/', +++ 'WORKDIR /app', +++ 'RUN ["dnu", "restore"]', +++ 'COPY . /app', +++ 'EXPOSE 5000', +++ 'ENTRYPOINT ["dnx", "-p", "project.json", "kestrel"]' +++ ]); +++} +++ ++ /* ++ * can be imported ++ */ ++@@ -37,7 +60,8 @@ describe('aspnet - Empty Application', function() { ++ 'emptyTest/hosting.ini', ++ 'emptyTest/project.json', ++ 'emptyTest/Startup.cs', ++- 'emptyTest/wwwroot/README.md' +++ 'emptyTest/wwwroot/README.md', +++ 'emptyTest/Dockerfile' ++ ]; ++ describe('Checking files', function() { ++ for (var i = 0; i < files.length; i++) { ++@@ -45,6 +69,12 @@ describe('aspnet - Empty Application', function() { ++ } ++ }); ++ +++ describe('Checking Dockerfile content', function() { +++ it('should create a Dockerfile for ASP.NET 5 kestrel apps', function() { +++ assertDockerfileContents('emptyTest/Dockerfile'); +++ }); +++ }); +++ ++ }); ++ ++ /* ++@@ -246,6 +276,7 @@ describe('aspnet - Web Application', function() { ++ ++ ++ var files = [ +++ 'webTest/Dockerfile', ++ 'webTest/.bowerrc', ++ 'webTest/.gitignore', ++ 'webTest/bower.json', ++@@ -324,6 +355,12 @@ describe('aspnet - Web Application', function() { ++ } ++ }); ++ +++ describe('Checking Dockerfile content', function() { +++ it('should create a Dockerfile for ASP.NET 5 kestrel apps', function() { +++ assertDockerfileContents('webTest/Dockerfile'); +++ }); +++ }); +++ ++ }); ++ ++ /* ++@@ -420,6 +457,7 @@ describe('aspnet - Web Application Basic', function() { ++ }); ++ ++ var files = [ +++ 'webTest/Dockerfile', ++ 'webTest/.bowerrc', ++ 'webTest/.gitignore', ++ 'webTest/bower.json', ++@@ -452,6 +490,12 @@ describe('aspnet - Web Application Basic', function() { ++ } ++ }); ++ +++ describe('Checking Dockerfile content', function() { +++ it('should create a Dockerfile for ASP.NET 5 kestrel apps', function() { +++ assertDockerfileContents('webTest/Dockerfile'); +++ }); +++ }); +++ ++ }); ++ ++ /* ++@@ -488,7 +532,8 @@ describe('aspnet - Web API Application', function() { ++ 'webAPITest/Properties/launchSettings.json', ++ 'webAPITest/Startup.cs', ++ 'webAPITest/.gitignore', ++- 'webAPITest/wwwroot/README.md' +++ 'webAPITest/wwwroot/README.md', +++ 'webAPITest/Dockerfile' ++ ]; ++ describe('Checking files', function() { ++ for (var i = 0; i < files.length; i++) { ++@@ -496,6 +541,49 @@ describe('aspnet - Web API Application', function() { ++ } ++ }); ++ +++ describe('Checking Dockerfile content', function() { +++ it('should create a Dockerfile for ASP.NET 5 kestrel apps', function() { +++ assertDockerfileContents('webAPITest/Dockerfile'); +++ }); +++ }); +++ +++}); +++ +++describe('aspnet - Web Application with non-fixture project name', function() { +++ var projectName = 'dockerWebApp' + Date.now(); +++ +++ before(function(done) { +++ yeoman.test.run(path.join(__dirname, '../app')) +++ .withPrompts({ +++ type: 'web', +++ applicationName: projectName +++ }) +++ .on('end', done); +++ }); +++ +++ it('should create Dockerfile in the generated project root', function() { +++ assert.file(projectName + '/Dockerfile'); +++ }); +++ +++ it('should create Dockerfile content for ASP.NET 5 kestrel apps', function() { +++ assertDockerfileContents(projectName + '/Dockerfile'); +++ }); +++ +++}); +++ +++describe('aspnet:Dockerfile usage text', function() { +++ +++ it('should describe the standalone Dockerfile generator to users', function() { +++ var usage = fs.readFileSync(path.join(__dirname, '../Dockerfile/USAGE'), 'utf8') +++ .replace(/\s+/g, ' ') +++ .toLowerCase(); +++ +++ nodeAssert(usage.indexOf('docker configuration file') !== -1); +++ nodeAssert(usage.indexOf('create') !== -1); +++ nodeAssert(usage.indexOf('yo aspnet:dockerfile') !== -1); +++ nodeAssert(usage.indexOf('dockerfile') !== -1); +++ }); +++ ++ }); ++ ++ +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,25 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++dev-switch node 22 ++npm install 2>&1 | tail -3 ++ ++ ++case "${1:-}" in ++ base) ++ git apply --reverse --whitespace=nowarn /testbed/mimo_test.patch ++ status=0 ++ npx mocha test/subgenerators.js test/test-core.js || status=$? ++ git apply --whitespace=nowarn /testbed/mimo_test.patch ++ exit "$status" ++ ;; ++ new) ++ npx mocha test/subgenerators.js test/test-core.js ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000188/tests/test.sh b/tasks/format-code-task-000188/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f39b7e4ff260a7729030bbc21d148d44d510d6a0 --- /dev/null +++ b/tasks/format-code-task-000188/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/subgenerators.js +test/test-core.js +mimo_test.patch +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000188/tests/test_command.sh b/tasks/format-code-task-000188/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000188/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000189/environment/Dockerfile b/tasks/format-code-task-000189/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3dc21273991be4fc2f4f867d8146f778db32a584 --- /dev/null +++ b/tasks/format-code-task-000189/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9f4cdf9a57f305759318bc157b662823187c4c436c84ac0be4640562546ea2c6 diff --git a/tasks/format-code-task-000189/environment/setup/files/blocklist b/tasks/format-code-task-000189/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000189/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000189/environment/setup/setup.sh b/tasks/format-code-task-000189/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000189/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000189/tests/test.patch b/tasks/format-code-task-000189/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..82721029383699b56eeabbc6fb8085774e9cdbcf --- /dev/null +++ b/tasks/format-code-task-000189/tests/test.patch @@ -0,0 +1,99 @@ +diff --git a/openmdao/recorders/tests/test_sqlite_recorder.py b/openmdao/recorders/tests/test_sqlite_recorder.py +index 3d454e8cc3..1f383d65d8 100644 +--- a/openmdao/recorders/tests/test_sqlite_recorder.py ++++ b/openmdao/recorders/tests/test_sqlite_recorder.py +@@ -1507,16 +1507,49 @@ def test_record_solver_nonlinear_newton(self): + expected_solver_output, expected_solver_residuals),) + assertSolverIterDataRecorded(self, expected_data, self.eps) + ++ def test_record_solver_nonlinear_broyden(self): ++ prob = SellarProblem( ++ linear_solver=om.DirectSolver, ++ nonlinear_solver=om.BroydenSolver() ++ ) ++ prob.setup() ++ ++ prob.model.nonlinear_solver.add_recorder(self.recorder) ++ ++ prob.set_solver_print(-1) ++ t0, t1 = run_driver(prob) ++ prob.cleanup() ++ ++ coordinate = [0, 'Driver', (0,), 'root._solve_nonlinear', (0,), 'BroydenSolver', (2,)] ++ ++ expected_abs_error = 0.0009547575844806033 ++ expected_rel_error = 0.00042348707505980126 ++ ++ expected_solver_output = { ++ '_auto_ivc.v1': [1.], ++ '_auto_ivc.v0': [5., 2.], ++ 'd1.y1': [25.58830237], ++ 'd2.y2': [12.05848815], ++ 'obj_cmp.obj': [28.58830817], ++ 'con_cmp1.con1': [-22.42830237], ++ 'con_cmp2.con2': [-11.94151185] ++ } ++ ++ expected_solver_residuals = None ++ ++ expected_data = ((coordinate, (t0, t1), expected_abs_error, expected_rel_error, ++ expected_solver_output, expected_solver_residuals),) ++ assertSolverIterDataRecorded(self, expected_data, self.eps) ++ + # Also check to make sure the first iteration has correct abs and rel errors + # as a regression test for + # https://github.com/OpenMDAO/OpenMDAO/issues/2435 + cr = om.CaseReader(self.filename) + + solver_cases = cr.get_cases("root.nonlinear_solver") +- self.assertAlmostEqual(solver_cases[0].abs_err, 36.331584, delta=1e-6) ++ self.assertAlmostEqual(solver_cases[0].abs_err, 2.254514106, delta=1e-6) + self.assertEqual(solver_cases[0].rel_err, 1.0) + +- + def test_record_solver_nonlinear_nonlinear_run_once(self): + prob = SellarProblem(nonlinear_solver=om.NonlinearRunOnce) + prob.setup() +diff --git a/openmdao/solvers/nonlinear/tests/test_broyden.py b/openmdao/solvers/nonlinear/tests/test_broyden.py +index 204e8d4ace..98634d8f48 100644 +--- a/openmdao/solvers/nonlinear/tests/test_broyden.py ++++ b/openmdao/solvers/nonlinear/tests/test_broyden.py +@@ -159,7 +159,7 @@ def test_reraise_error(self): + with self.assertRaises(om.AnalysisError) as context: + prob.run_model() + +- msg = "Solver 'BROYDEN' on system 'g1' failed to converge in 1 iterations." ++ msg = "Solver 'NL: BROYDEN' on system 'g1' failed to converge in 1 iterations." + self.assertEqual(str(context.exception), msg) + + def test_error_badname(self): +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,14 @@ ++H4sIAAAAAAAAA+2UzW/aMBTAOeeveMqkkUglEFJAqsakSe1hh6nTtGMlZJIHcUns1HagTP3j95xA ++CxVbL+2maf4d/JX3/exE85oX2QzFut95KwbEZDRqZuL53Kzj0TCOJ5PxeJx0BnE8jicdGL1ZRAfU ++2jAF0FFSmt/JvfT9HyV66r9BbWapLEsmskjnr+fjhf4Pk2T82P/RKKb+n4+TpAOD1wvh1/zn/U8z ++aBo/x8zz3sGV0LVC+Lo1uRSQRHEMXANLDV8jBNcVii+Xn65BIGYaRF1WW/gAcTQ8h4VUUOCSpVtg ++BWcadehluO7pDTdpDlVjMWlNDj/26VNf1EUBDw9gVI3W+WdBvaCjDMlPhiLlqIEvQEhDNhWybAuV ++Qo3CeHt7vRR8XlZSGeuCEvGfW3+ULKHiFfCdk15PyB4XVW3AbxKZTm0e0bkPvk55u48HUezvDFPS ++ZiPV6p72l9dXQ5oqpjQXS1B4V5OEBjpgJRpU/AdmoNHUlZGy0BTT+xgoU8bJ8+ig0m0N6dVVzIDO ++eQl4z62pgBI1kgYQVcS0TlnB1JndWOEC78lrKdfkhoudFYo/6dskwqPyeLv6aG7wDKT2dAXTZhct ++KUKNyq4rlq7YEnUQek0YU5KMKKg8upVcBLo6g66VTenByJLyi6ptN/R27dnLtsEH1kJ44QFBX0q2 ++wowr3RhpJGZyNf1OXQ8bEbohOUjqeaNHfjbdEJiGRWvBsog2ioIMut3uPp02Z2brs48iZ5oZowJB ++fm78fdFu/F0oB4Wk9ApWzjMGa1Zc2CEi82UQnja1K/mhpX0XprBbndZcFJKZQ73mgLSa+bQOF0ca ++tCV5Gk9Ly/ktpkcK7YntYLM4rTane3moZPekYqfTCtocVZK29hYZ5VFPQs+3d/pbLcDkSNdc0c0C +++2q0d/j+2odkW11mTPYVplJldP+aX1A7zvRdQa2Y7b/RNXtS0LJYW3EhRcEFMnWoOFdyS38Nq9Bb ++Ny/O+9t/V4fD4XA4HA6Hw+FwOBwOh8PhcDgcDofD4XA4/gw/AeErQ7gAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000189/tests/test.sh b/tasks/format-code-task-000189/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..33f4efafbd31aee4f5a848a514ffa4fc8224b00b --- /dev/null +++ b/tasks/format-code-task-000189/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +openmdao/recorders/tests/test_sqlite_recorder.py +openmdao/solvers/nonlinear/tests/test_broyden.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000189/tests/test_command.sh b/tasks/format-code-task-000189/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000189/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000313/environment/Dockerfile b/tasks/format-code-task-000313/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..afe2c03be94df3eee4119d11dca9172ecff72580 --- /dev/null +++ b/tasks/format-code-task-000313/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c42294e6d0eba6253f6b3e68b173f870d0d2f668df2511441c41df6d607d8d09 diff --git a/tasks/format-code-task-000313/environment/setup/files/blocklist b/tasks/format-code-task-000313/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000313/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000313/environment/setup/setup.sh b/tasks/format-code-task-000313/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000313/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000313/tests/test.patch b/tasks/format-code-task-000313/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..225e8fa68b461bc65d988b8e622882ac4e7f3d83 --- /dev/null +++ b/tasks/format-code-task-000313/tests/test.patch @@ -0,0 +1,460 @@ +diff --git a/usercase-test-coderl/test_configuration_lifecycle.py b/usercase-test-coderl/test_configuration_lifecycle.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_configuration_lifecycle.py +@@ -0,0 +1,432 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import builtins ++import hashlib ++import sys ++import types ++ ++import pytest ++ ++ ++def _install_python2_compatibility_shims(): ++ ++ builtins.long = int ++ ++ urlparse = types.ModuleType('urlparse') ++ sys.modules.setdefault('urlparse', urlparse) ++ ++ redis = types.ModuleType('redis') ++ redis.Redis = object ++ sys.modules.setdefault('redis', redis) ++ ++ pymongo = types.ModuleType('pymongo') ++ pymongo.MongoClient = object ++ sys.modules.setdefault('pymongo', pymongo) ++ ++ sqlalchemy = types.ModuleType('sqlalchemy') ++ sqlalchemy.create_engine = lambda *args, **kwargs: None ++ sys.modules.setdefault('sqlalchemy', sqlalchemy) ++ ++ sys.modules.setdefault('cql', types.ModuleType('cql')) ++ ++ kairos = types.ModuleType('kairos') ++ ++ class Timeseries(object): ++ def __init__(self, host, **config): ++ self.host = host ++ self.config = config ++ self.inserts = [] ++ ++ def insert(self, stat, val, timestamp=None, intervals=None): ++ self.inserts.append((stat, val, timestamp, intervals)) ++ ++ def list(self, *args, **kwargs): ++ return [] ++ ++ def properties(self, *args, **kwargs): ++ return {} ++ ++ def iterate(self, *args, **kwargs): ++ return iter(()) ++ ++ kairos.Timeseries = Timeseries ++ sys.modules.setdefault('kairos', kairos) ++ ++ imp = types.ModuleType('imp') ++ imp.PY_SOURCE = 1 ++ ++ def load_module(name, source, filename, details): ++ module = types.ModuleType(name) ++ module.__file__ = filename ++ sys.modules[name] = module ++ exec(compile(source.read(), filename, 'exec'), module.__dict__) ++ return module ++ ++ imp.load_module = load_module ++ sys.modules.setdefault('imp', imp) ++ ++ if not getattr(hashlib.sha1, '_torus_py2_compat', False): ++ original_sha1 = hashlib.sha1 ++ ++ def sha1_compat(data=b''): ++ if isinstance(data, str): ++ data = data.encode('utf-8') ++ return original_sha1(data) ++ ++ sha1_compat._torus_py2_compat = True ++ hashlib.sha1 = sha1_compat ++ ++ ++_install_python2_compatibility_shims() ++ ++from torus.configuration import Configuration ++ ++ ++def _write(path, source): ++ path.write_text(source) ++ return str(path) ++ ++ ++def test_fresh_configuration_and_empty_reload_are_empty(): ++ ++ ++ ++ ++ c = Configuration() ++ assert c.debug == 0 ++ assert [schema.name for schema in c.schemas()] == [] ++ assert c.aggregates() == [] ++ assert c.transform('missing') is None ++ assert c.macro('missing') is None ++ ++ c.reload() ++ c.reload() ++ ++ assert c.debug == 0 ++ assert [schema.name for schema in c.schemas()] == [] ++ assert c.aggregates() == [] ++ assert c.transform('missing') is None ++ assert c.macro('missing') is None ++ ++ ++def test_load_executable_file_exposes_public_configuration_globals(tmp_path): ++ ++ ++ ++ ++ hook_log = tmp_path / 'hooks.log' ++ config_path = _write(tmp_path / 'torus_conf.py', """ ++DEBUG = 2 ++SCHEMAS = { ++ 'raw': {'match': r'^app\\.hit$', 'intervals': {'10s': 6}}, ++ 'rollup': {'match': r'^app\\.total$', 'intervals': {'1m': 60}}, ++} ++AGGREGATES = [('app.total', 'app.*')] ++def plus_one(stat, value): ++ return (stat + '.converted', long_or_float(value) + 1) ++TRANSFORMS = {'plus_one': plus_one} ++MACROS = {'hourly': {'from': '-1h', 'until': 'now'}} ++def on_load(): ++ with open(%r, 'a') as handle: ++ handle.write('load\\n') ++""" % str(hook_log)) ++ ++ c = Configuration() ++ c.load(config_path) ++ ++ assert c.debug == 2 ++ assert c.schema('raw').name == 'raw' ++ ++ assert c.schema('raw') in c.schemas('app.hit') ++ ++ assert {schema.name for schema in c.schemas()} == {'raw', 'rollup'} ++ assert [schema.name for schema in c.schemas('app.hit')] == ['raw'] ++ assert [schema.name for schema in c.schemas('service.hit')] == [] ++ ++ assert len(c.aggregates()) == 1 ++ assert c.transform('plus_one')('metric', '4.5') == ('metric.converted', 5.5) ++ assert c.macro('hourly') == {'from': '-1h', 'until': 'now'} ++ assert hook_log.read_text() == 'load\n' ++ ++ ++def test_aggregates_participate_when_process_expands_matching_stats(tmp_path): ++ ++ ++ ++ ++ config_path = _write(tmp_path / 'aggregate_conf.py', """ ++SCHEMAS = { ++ 'raw': {'match': r'^app\\.hit$', 'intervals': {}}, ++ 'rollup': {'match': r'^app\\.total$', 'intervals': {}}, ++} ++AGGREGATES = [('app.total', 'app.*')] ++""") ++ ++ c = Configuration() ++ c.load(config_path) ++ ++ assert c.schema('raw').count == 0 ++ assert c.schema('rollup').count == 0 ++ ++ assert len(c.aggregates()) == 1 ++ ++ c.process('app.hit', '7', 123.5) ++ assert c.schema('raw').count == 1 ++ assert c.schema('rollup').count == 1 ++ ++ assert len(c.aggregates()) == 1 ++ ++ ++def test_reload_reexecutes_changed_file_and_removes_stale_entries(tmp_path): ++ ++ ++ ++ ++ hook_log = tmp_path / 'reload-hooks.log' ++ config_path = tmp_path / 'reload_conf.py' ++ _write(config_path, """ ++DEBUG = 2 ++SCHEMAS = { ++ 'raw': {'match': r'^app\\.hit$', 'intervals': {}}, ++ 'rollup': {'match': r'^app\\.total$', 'intervals': {}}, ++} ++AGGREGATES = [('app.total', 'app.*')] ++TRANSFORMS = {'plus_one': lambda stat, value: (stat + '.converted', long_or_float(value) + 1)} ++MACROS = {'hourly': {'from': '-1h', 'until': 'now'}} ++def on_load(): ++ with open(%r, 'a') as handle: ++ handle.write('load\\n') ++def on_reload(): ++ with open(%r, 'a') as handle: ++ handle.write('reload-v1\\n') ++""" % (str(hook_log), str(hook_log))) ++ ++ c = Configuration() ++ c.load(str(config_path)) ++ assert c.debug == 2 ++ ++ assert {schema.name for schema in c.schemas()} == {'raw', 'rollup'} ++ assert c.transform('plus_one')('metric', '4.5') == ('metric.converted', 5.5) ++ assert c.macro('hourly') == {'from': '-1h', 'until': 'now'} ++ assert hook_log.read_text() == 'load\n' ++ ++ _write(config_path, """ ++DEBUG = 0 ++SCHEMAS = { ++ 'fresh': {'match': r'^new\\.stat$', 'intervals': {'5s': 12}}, ++} ++AGGREGATES = [('new.total', 'new.*')] ++TRANSFORMS = {'double': lambda stat, value: (stat, long_or_float(value) * 2)} ++MACROS = {'daily': {'from': '-24h', 'until': 'now'}} ++def on_load(): ++ with open(%r, 'a') as handle: ++ handle.write('load-v2\\n') ++def on_reload(): ++ with open(%r, 'a') as handle: ++ handle.write('reload-v2\\n') ++""" % (str(hook_log), str(hook_log))) ++ ++ c.reload() ++ ++ assert c.debug == 0 ++ assert [schema.name for schema in c.schemas()] == ['fresh'] ++ assert [schema.name for schema in c.schemas('new.stat')] == ['fresh'] ++ assert c.schema('raw') is None ++ ++ assert len(c.aggregates()) == 1 ++ assert c.transform('plus_one') is None ++ assert c.transform('double')('new.stat', '3') == ('new.stat', 6) ++ assert c.macro('hourly') is None ++ assert c.macro('daily') == {'from': '-24h', 'until': 'now'} ++ assert hook_log.read_text() == 'load\nreload-v2\n' ++ ++ ++def test_reload_reexecutes_every_loaded_path_in_load_order(tmp_path): ++ ++ ++ ++ ++ hook_log = tmp_path / 'multi-hooks.log' ++ first = tmp_path / 'first.py' ++ second = tmp_path / 'second.py' ++ _write(first, """ ++DEBUG = 1 ++SCHEMAS = {'first': {'match': r'^one$', 'intervals': {}}} ++def on_load(): ++ with open(%r, 'a') as handle: ++ handle.write('load-first\\n') ++def on_reload(): ++ with open(%r, 'a') as handle: ++ handle.write('reload-first\\n') ++""" % (str(hook_log), str(hook_log))) ++ _write(second, """ ++DEBUG = 2 ++SCHEMAS = {'second': {'match': r'^two$', 'intervals': {}}} ++def on_load(): ++ with open(%r, 'a') as handle: ++ handle.write('load-second\\n') ++def on_reload(): ++ with open(%r, 'a') as handle: ++ handle.write('reload-second\\n') ++""" % (str(hook_log), str(hook_log))) ++ ++ c = Configuration() ++ c.load(str(first)) ++ c.load(str(second)) ++ assert c.debug == 2 ++ ++ assert {schema.name for schema in c.schemas()} == {'first', 'second'} ++ assert hook_log.read_text() == 'load-first\nload-second\n' ++ ++ _write(first, """ ++DEBUG = 3 ++SCHEMAS = {'first_new': {'match': r'^one\\.new$', 'intervals': {}}} ++def on_reload(): ++ with open(%r, 'a') as handle: ++ handle.write('reload-first-new\\n') ++""" % str(hook_log)) ++ _write(second, """ ++DEBUG = 4 ++SCHEMAS = {'second_new': {'match': r'^two\\.new$', 'intervals': {}}} ++def on_reload(): ++ with open(%r, 'a') as handle: ++ handle.write('reload-second-new\\n') ++""" % str(hook_log)) ++ ++ c.reload() ++ ++ ++ assert c.debug in {3, 4} ++ ++ assert {schema.name for schema in c.schemas()} == {'first_new', 'second_new'} ++ assert c.schema('first') is None ++ assert c.schema('second') is None ++ ++ assert hook_log.read_text().splitlines()[:2] == ['load-first', 'load-second'] ++ assert sorted(hook_log.read_text().splitlines()[2:]) == ['reload-first-new', 'reload-second-new'] ++ ++ ++def test_missing_load_path_raises_specific_file_not_found_error(tmp_path): ++ ++ ++ ++ ++ missing_path = str(tmp_path / 'does_not_exist.py') ++ ++ ++ with pytest.raises(OSError): ++ Configuration().load(missing_path) ++ ++ ++def test_two_configuration_instances_keep_loaded_state_independent(tmp_path): ++ ++ ++ ++ ++ first = tmp_path / 'first_instance.py' ++ second = tmp_path / 'second_instance.py' ++ _write(first, """ ++DEBUG = 1 ++SCHEMAS = {'alpha': {'match': r'^alpha$', 'intervals': {}}} ++MACROS = {'window': {'from': '-5m'}} ++""") ++ _write(second, """ ++DEBUG = 2 ++SCHEMAS = {'beta': {'match': r'^beta$', 'intervals': {}}} ++MACROS = {'window': {'from': '-10m'}} ++""") ++ ++ a = Configuration() ++ b = Configuration() ++ a.load(str(first)) ++ b.load(str(second)) ++ ++ assert a.debug == 1 ++ assert [schema.name for schema in a.schemas()] == ['alpha'] ++ assert a.macro('window') == {'from': '-5m'} ++ assert b.debug == 2 ++ assert [schema.name for schema in b.schemas()] == ['beta'] ++ assert b.macro('window') == {'from': '-10m'} ++ ++ _write(first, """ ++DEBUG = 3 ++SCHEMAS = {'alpha_new': {'match': r'^alpha\\.new$', 'intervals': {}}} ++MACROS = {'window': {'from': '-15m'}} ++""") ++ a.reload() ++ ++ assert a.debug == 3 ++ assert [schema.name for schema in a.schemas()] == ['alpha_new'] ++ assert a.macro('window') == {'from': '-15m'} ++ assert b.debug == 2 ++ assert [schema.name for schema in b.schemas()] == ['beta'] ++ assert b.macro('window') == {'from': '-10m'} ++ ++ ++def test_loaded_reload_cleanup_is_idempotent(tmp_path): ++ ++ ++ ++ ++ hook_log = tmp_path / 'idempotent-hooks.log' ++ config_path = _write(tmp_path / 'idempotent_conf.py', """ ++DEBUG = 5 ++SCHEMAS = {'steady': {'match': r'^steady$', 'intervals': {}}} ++AGGREGATES = [('steady.total', 'steady.*')] ++TRANSFORMS = {'identity': lambda stat, value: (stat, value)} ++MACROS = {'steady': {'from': '-30m'}} ++def on_load(): ++ with open(%r, 'a') as handle: ++ handle.write('load\\n') ++def on_reload(): ++ with open(%r, 'a') as handle: ++ handle.write('reload\\n') ++""" % (str(hook_log), str(hook_log))) ++ ++ c = Configuration() ++ c.load(config_path) ++ c.reload() ++ c.reload() ++ ++ assert c.debug == 5 ++ assert [schema.name for schema in c.schemas()] == ['steady'] ++ ++ assert len(c.aggregates()) == 1 ++ assert c.transform('identity')('steady', '9') == ('steady', '9') ++ assert c.macro('steady') == {'from': '-30m'} ++ assert hook_log.read_text() == 'load\nreload\nreload\n' ++ ++ ++def test_repeated_reload_cleanup_keeps_public_registry_sizes_bounded(tmp_path): ++ ++ ++ ++ ++ config_path = _write(tmp_path / 'bounded_conf.py', """ ++DEBUG = 7 ++SCHEMAS = {'bounded': {'match': r'^bounded$', 'intervals': {}}} ++AGGREGATES = [('bounded.total', 'bounded.*')] ++TRANSFORMS = {'identity': lambda stat, value: (stat, value)} ++MACROS = {'bounded': {'from': '-1m'}} ++""") ++ ++ c = Configuration() ++ c.load(config_path) ++ for _ in range(120): ++ c.reload() ++ ++ assert c.debug == 7 ++ assert [schema.name for schema in c.schemas()] == ['bounded'] ++ ++ assert len(c.aggregates()) == 1 ++ assert c.transform('identity')('bounded', '1') == ('bounded', '1') ++ assert c.macro('bounded') == {'from': '-1m'} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++ ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_configuration_lifecycle.py -v diff --git a/tasks/format-code-task-000313/tests/test.sh b/tasks/format-code-task-000313/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..54b4ce48780c6b8728d3e03151e65650e9aebb3c --- /dev/null +++ b/tasks/format-code-task-000313/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_configuration_lifecycle.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000313/tests/test_command.sh b/tasks/format-code-task-000313/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000313/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000322/environment/Dockerfile b/tasks/format-code-task-000322/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b30778599c930214153087f19650925c182fe392 --- /dev/null +++ b/tasks/format-code-task-000322/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1c7df96d51e375e20b089bb02a1ec226c9cb933ede7698d886a3ccfe1d61e3f8 diff --git a/tasks/format-code-task-000322/environment/setup/files/blocklist b/tasks/format-code-task-000322/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000322/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000322/environment/setup/setup.sh b/tasks/format-code-task-000322/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000322/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000322/tests/test.patch b/tasks/format-code-task-000322/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bb4317309ea687333700d924a87e07fdc68f329c --- /dev/null +++ b/tasks/format-code-task-000322/tests/test.patch @@ -0,0 +1,311 @@ +diff --git a/tests/test_web_sendfile_functional.py b/tests/test_web_sendfile_functional.py +index d7fa1a7346b..51c6a9de940 100644 +--- a/tests/test_web_sendfile_functional.py ++++ b/tests/test_web_sendfile_functional.py +@@ -354,6 +354,8 @@ async def test_static_file_huge(loop, aiohttp_client, tmpdir): + async def test_static_file_range(loop, aiohttp_client, sender): + filepath = (pathlib.Path(__file__).parent.parent / 'LICENSE.txt') + ++ filesize = filepath.stat().st_size ++ + async def handler(request): + return sender(filepath, chunk_size=16) + +@@ -374,10 +376,17 @@ async def handler(request): + assert len(responses) == 3 + assert responses[0].status == 206, \ + "failed 'bytes=0-999': %s" % responses[0].reason ++ assert responses[0].headers['Content-Range'] == 'bytes 0-999/{0}'.format( ++ filesize), 'failed: Content-Range Error' + assert responses[1].status == 206, \ + "failed 'bytes=1000-1999': %s" % responses[1].reason ++ assert responses[1].headers['Content-Range'] == \ ++ 'bytes 1000-1999/{0}'.format(filesize), 'failed: Content-Range Error' + assert responses[2].status == 206, \ + "failed 'bytes=2000-': %s" % responses[2].reason ++ assert responses[2].headers['Content-Range'] == \ ++ 'bytes 2000-{0}/{1}'.format(filesize - 1, filesize), \ ++ 'failed: Content-Range Error' + + body = await asyncio.gather( + *(resp.read() for resp in responses), +@@ -418,10 +427,12 @@ async def handler(request): + + assert response.status == 206, \ + "failed 'bytes=61000-62000': %s" % response.reason ++ assert response.headers['Content-Range'] == \ ++ 'bytes 61000-61107/61108', 'failed: Content-Range Error' + + body = await response.read() + assert len(body) == 108, \ +- "failed 'bytes=0-999', received %d bytes" % len(body[0]) ++ "failed 'bytes=61000-62000', received %d bytes" % len(body) + + assert content[61000:] == body + +@@ -440,9 +451,8 @@ async def handler(request): + response = await client.get( + '/', headers={'Range': 'bytes=1000000-1200000'}) + +- assert response.status == 206, \ ++ assert response.status == 416, \ + "failed 'bytes=1000000-1200000': %s" % response.reason +- assert response.headers['content-length'] == '0' + + + async def test_static_file_range_tail(loop, aiohttp_client, sender): +@@ -461,10 +471,18 @@ async def handler(request): + # Ensure the tail of the file is correct + resp = await client.get('/', headers={'Range': 'bytes=-500'}) + assert resp.status == 206, resp.reason ++ assert resp.headers['Content-Range'] == 'bytes 60608-61107/61108', \ ++ 'failed: Content-Range Error' + body4 = await resp.read() + resp.close() + assert content[-500:] == body4 + ++ ++ resp2 = await client.get('/', headers={'Range': 'bytes=-99999999999999'}) ++ assert resp2.status == 206, resp.reason ++ assert resp2.headers['Content-Range'] == 'bytes 0-61107/61108', \ ++ 'failed: Content-Range Error' ++ + + async def test_static_file_invalid_range(loop, aiohttp_client, sender): + filepath = (pathlib.Path(__file__).parent / 'aiohttp.png') +@@ -505,3 +523,209 @@ async def handler(request): + resp = await client.get('/', headers={'Range': 'bytes=-'}) + assert resp.status == 416, 'no range given' + resp.close() ++ ++ ++async def test_static_file_if_unmodified_since_past_with_range( ++ aiohttp_client, sender): ++ filename = 'data.unknown_mime_type' ++ filepath = pathlib.Path(__file__).parent / filename ++ ++ async def handler(request): ++ return sender(filepath) ++ ++ app = web.Application() ++ app.router.add_get('/', handler) ++ client = await aiohttp_client(app) ++ ++ lastmod = 'Mon, 1 Jan 1990 01:01:01 GMT' ++ ++ resp = await client.get('/', headers={ ++ 'If-Unmodified-Since': lastmod, ++ 'Range': 'bytes=2-'}) ++ assert 412 == resp.status ++ resp.close() ++ ++ ++async def test_static_file_if_unmodified_since_future_with_range( ++ aiohttp_client, sender): ++ filename = 'data.unknown_mime_type' ++ filepath = pathlib.Path(__file__).parent / filename ++ ++ async def handler(request): ++ return sender(filepath) ++ ++ app = web.Application() ++ app.router.add_get('/', handler) ++ client = await aiohttp_client(app) ++ ++ lastmod = 'Fri, 31 Dec 9999 23:59:59 GMT' ++ ++ resp = await client.get('/', headers={ ++ 'If-Unmodified-Since': lastmod, ++ 'Range': 'bytes=2-'}) ++ assert 206 == resp.status ++ assert resp.headers['Content-Range'] == 'bytes 2-12/13' ++ assert resp.headers['Content-Length'] == '11' ++ resp.close() ++ ++ ++async def test_static_file_if_range_past_with_range( ++ aiohttp_client, sender): ++ filename = 'data.unknown_mime_type' ++ filepath = pathlib.Path(__file__).parent / filename ++ ++ async def handler(request): ++ return sender(filepath) ++ ++ app = web.Application() ++ app.router.add_get('/', handler) ++ client = await aiohttp_client(app) ++ ++ lastmod = 'Mon, 1 Jan 1990 01:01:01 GMT' ++ ++ resp = await client.get('/', headers={ ++ 'If-Range': lastmod, ++ 'Range': 'bytes=2-'}) ++ assert 200 == resp.status ++ assert resp.headers['Content-Length'] == '13' ++ resp.close() ++ ++ ++async def test_static_file_if_range_future_with_range( ++ aiohttp_client, sender): ++ filename = 'data.unknown_mime_type' ++ filepath = pathlib.Path(__file__).parent / filename ++ ++ async def handler(request): ++ return sender(filepath) ++ ++ app = web.Application() ++ app.router.add_get('/', handler) ++ client = await aiohttp_client(app) ++ ++ lastmod = 'Fri, 31 Dec 9999 23:59:59 GMT' ++ ++ resp = await client.get('/', headers={ ++ 'If-Range': lastmod, ++ 'Range': 'bytes=2-'}) ++ assert 206 == resp.status ++ assert resp.headers['Content-Range'] == 'bytes 2-12/13' ++ assert resp.headers['Content-Length'] == '11' ++ resp.close() ++ ++ ++async def test_static_file_if_unmodified_since_past_without_range( ++ aiohttp_client, sender): ++ filename = 'data.unknown_mime_type' ++ filepath = pathlib.Path(__file__).parent / filename ++ ++ async def handler(request): ++ return sender(filepath) ++ ++ app = web.Application() ++ app.router.add_get('/', handler) ++ client = await aiohttp_client(app) ++ ++ lastmod = 'Mon, 1 Jan 1990 01:01:01 GMT' ++ ++ resp = await client.get('/', headers={'If-Unmodified-Since': lastmod}) ++ assert 412 == resp.status ++ resp.close() ++ ++ ++async def test_static_file_if_unmodified_since_future_without_range( ++ aiohttp_client, sender): ++ filename = 'data.unknown_mime_type' ++ filepath = pathlib.Path(__file__).parent / filename ++ ++ async def handler(request): ++ return sender(filepath) ++ ++ app = web.Application() ++ app.router.add_get('/', handler) ++ client = await aiohttp_client(app) ++ ++ lastmod = 'Fri, 31 Dec 9999 23:59:59 GMT' ++ ++ resp = await client.get('/', headers={'If-Unmodified-Since': lastmod}) ++ assert 200 == resp.status ++ assert resp.headers['Content-Length'] == '13' ++ resp.close() ++ ++ ++async def test_static_file_if_range_past_without_range( ++ aiohttp_client, sender): ++ filename = 'data.unknown_mime_type' ++ filepath = pathlib.Path(__file__).parent / filename ++ ++ async def handler(request): ++ return sender(filepath) ++ ++ app = web.Application() ++ app.router.add_get('/', handler) ++ client = await aiohttp_client(app) ++ ++ lastmod = 'Mon, 1 Jan 1990 01:01:01 GMT' ++ ++ resp = await client.get('/', headers={'If-Range': lastmod}) ++ assert 200 == resp.status ++ assert resp.headers['Content-Length'] == '13' ++ resp.close() ++ ++ ++async def test_static_file_if_range_future_without_range( ++ aiohttp_client, sender): ++ filename = 'data.unknown_mime_type' ++ filepath = pathlib.Path(__file__).parent / filename ++ ++ async def handler(request): ++ return sender(filepath) ++ ++ app = web.Application() ++ app.router.add_get('/', handler) ++ client = await aiohttp_client(app) ++ ++ lastmod = 'Fri, 31 Dec 9999 23:59:59 GMT' ++ ++ resp = await client.get('/', headers={'If-Range': lastmod}) ++ assert 200 == resp.status ++ assert resp.headers['Content-Length'] == '13' ++ resp.close() ++ ++ ++async def test_static_file_if_unmodified_since_invalid_date(aiohttp_client, ++ sender): ++ filename = 'data.unknown_mime_type' ++ filepath = pathlib.Path(__file__).parent / filename ++ ++ async def handler(request): ++ return sender(filepath) ++ ++ app = web.Application() ++ app.router.add_get('/', handler) ++ client = await aiohttp_client(app) ++ ++ lastmod = 'not a valid HTTP-date' ++ ++ resp = await client.get('/', headers={'If-Unmodified-Since': lastmod}) ++ assert 200 == resp.status ++ resp.close() ++ ++ ++async def test_static_file_if_range_invalid_date(aiohttp_client, ++ sender): ++ filename = 'data.unknown_mime_type' ++ filepath = pathlib.Path(__file__).parent / filename ++ ++ async def handler(request): ++ return sender(filepath) ++ ++ app = web.Application() ++ app.router.add_get('/', handler) ++ client = await aiohttp_client(app) ++ ++ lastmod = 'not a valid HTTP-date' ++ ++ resp = await client.get('/', headers={'If-Range': lastmod}) ++ assert 200 == resp.status ++ resp.close() +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,10 @@ ++H4sIAAAAAAAAA+3VTW/aMBgA4Jz9K6yIw3Yg5BsNCWmIpuqBFrSw9jBVKB9OsRTsyDbp+u/nBGjo ++2q0X2qna+xzw1+vY8MbGSre0zFeE1QPjrdjaMAjaUvu9bOtO4Nqe7QXh0Ddsxwnt0MDBm+3oyFaq ++RGBsCM7V3+JeG/+grC7/vCJMytLKWHHaNZoEh77/x/x7ttPl33F1/r2h7xnYPu02Xvaf53+f9FXG ++WYHH+NCkjCqEfhw3b9FRXFOVJGtiDlU9/iAV2axyUiTbUjVRTzoeJzzvvUWXlC0EVzzjpZ64nMW1 ++Y9loSqs1EbESlN3p7rPofPJ9thx9jaPpLLqOZmMb/esf8IM7Ov+KSKXzu9kkLLfk+nRrvHb/B+6w ++O/+e7nf80Anh/L+HLMdt4lOSI0R+VlwovJgsL8Zm72J+GQ2s6qF5N1LKRr2m30SkTkps9j61A7i5 ++GXD/s4l2zbuSp3rYs75Yrvv4wPkiuorj2Wo6vzofH5YbvPzXg5DkW5ER3MXV+x0MkkzROlEE6dXU ++mjMP9zdYV3Ugbj7k7h2+J6m+VVhe0JKsii3TszhLSv1VcL/G/Rts7u+e0Wg32Vq0xURKItQ3ci+o ++IjeJYPrWMZ/Gn5FKkCxpHtgFVJjxUZZkaz3Ia5oTAbcSAAAAAAAAAAAAAAAAAAAAAACA9/ULd35t ++OAAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000322/tests/test.sh b/tasks/format-code-task-000322/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..71778b8d6018769ee3ec9bfa2fdc18dfe23e4e91 --- /dev/null +++ b/tasks/format-code-task-000322/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_web_sendfile_functional.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000322/tests/test_command.sh b/tasks/format-code-task-000322/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000322/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000325/environment/Dockerfile b/tasks/format-code-task-000325/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8f3831351d9ed6562a35a21de4b4b39233410c7d --- /dev/null +++ b/tasks/format-code-task-000325/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d09d444b7e9d1095d4e7a5b974c4c465cca1f5d3c6b95a61c2184c754fe4de04 diff --git a/tasks/format-code-task-000325/environment/setup/files/blocklist b/tasks/format-code-task-000325/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000325/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000325/environment/setup/setup.sh b/tasks/format-code-task-000325/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000325/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000325/tests/test.patch b/tasks/format-code-task-000325/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..21604ce2194fe9f5168211b4382b2af5176e6229 --- /dev/null +++ b/tasks/format-code-task-000325/tests/test.patch @@ -0,0 +1,381 @@ +diff --git a/tests/test_api/test_client/test_session/test_middlewares/test_retry_codespec.py b/tests/test_api/test_client/test_session/test_middlewares/test_retry_codespec.py +new file mode 100644 +index 00000000..b13f2763 +--- /dev/null ++++ b/tests/test_api/test_client/test_session/test_middlewares/test_retry_codespec.py +@@ -0,0 +1,362 @@ ++import asyncio ++import contextvars ++import importlib ++ ++import pytest ++ ++from aiogram.client.session.middlewares.manager import RequestMiddlewareManager ++from aiogram.exceptions import ( ++ TelegramBadRequest, ++ TelegramEntityTooLarge, ++ TelegramNetworkError, ++ TelegramRetryAfter, ++ TelegramServerError, ++) ++from aiogram.methods import GetMe ++from aiogram.utils.backoff import BackoffConfig ++ ++ ++def retry_middleware_type(): ++ module_name = "aiogram.client.session.middlewares.retry" ++ try: ++ module = importlib.import_module(module_name) ++ except ModuleNotFoundError as exc: ++ if exc.name != module_name: ++ raise ++ pytest.fail(f"public retry middleware module {module_name!r} is missing") ++ middleware_type = getattr(module, "RetryRequestMiddleware", None) ++ assert middleware_type is not None, "RetryRequestMiddleware is missing from its public module" ++ return middleware_type ++ ++ ++def deterministic_backoff(): ++ return BackoffConfig(min_delay=0.25, max_delay=1.0, factor=2.0, jitter=0.0) ++ ++ ++class ScriptedEndpoint: ++ def __init__(self, *outcomes): ++ self.outcomes = list(outcomes) ++ self.calls = [] ++ ++ async def __call__(self, bot, method): ++ self.calls.append((bot, method)) ++ outcome = self.outcomes.pop(0) ++ if isinstance(outcome, BaseException): ++ raise outcome ++ return outcome ++ ++ ++async def test_codespec_success_is_returned_without_sleeping(): ++ middleware = retry_middleware_type()( ++ sleep=lambda delay: pytest.fail(f"unexpected sleep for {delay}"), ++ ) ++ bot = object() ++ method = GetMe() ++ result = object() ++ endpoint = ScriptedEndpoint(result) ++ ++ assert await middleware(endpoint, bot, method) is result ++ assert endpoint.calls == [(bot, method)] ++ ++ ++async def test_codespec_network_errors_retry_with_backoff_and_same_request(): ++ middleware_type = retry_middleware_type() ++ method = GetMe() ++ bot = object() ++ result = object() ++ delays = [] ++ ++ async def sleep(delay): ++ delays.append(delay) ++ ++ endpoint = ScriptedEndpoint( ++ TelegramNetworkError(method=method, message="network down"), ++ result, ++ ) ++ middleware = middleware_type( ++ max_attempts=3, ++ backoff_config=deterministic_backoff(), ++ sleep=sleep, ++ ) ++ ++ assert await middleware(endpoint, bot, method) is result ++ assert endpoint.calls == [(bot, method), (bot, method)] ++ assert delays == [0.25] ++ ++ ++async def test_codespec_server_errors_advance_exponential_backoff(): ++ middleware_type = retry_middleware_type() ++ method = GetMe() ++ delays = [] ++ ++ async def sleep(delay): ++ delays.append(delay) ++ ++ endpoint = ScriptedEndpoint( ++ TelegramServerError(method=method, message="server one"), ++ TelegramServerError(method=method, message="server two"), ++ "recovered", ++ ) ++ middleware = middleware_type( ++ max_attempts=3, ++ backoff_config=deterministic_backoff(), ++ sleep=sleep, ++ ) ++ ++ assert await middleware(endpoint, object(), method) == "recovered" ++ assert len(endpoint.calls) == 3 ++ assert delays == [0.25, 0.5] ++ ++ ++async def test_codespec_retry_after_never_sleeps_less_than_either_source(): ++ middleware_type = retry_middleware_type() ++ method = GetMe() ++ delays = [] ++ ++ async def sleep(delay): ++ delays.append(delay) ++ ++ endpoint = ScriptedEndpoint( ++ TelegramRetryAfter(method=method, message="short limit", retry_after=0.1), ++ TelegramRetryAfter(method=method, message="long limit", retry_after=2), ++ "ok", ++ ) ++ middleware = middleware_type( ++ max_attempts=3, ++ backoff_config=deterministic_backoff(), ++ sleep=sleep, ++ ) ++ ++ assert await middleware(endpoint, object(), method) == "ok" ++ assert delays == [0.25, 2] ++ ++ ++async def test_codespec_default_attempt_limit_reraises_last_error_without_final_sleep(): ++ middleware_type = retry_middleware_type() ++ method = GetMe() ++ delays = [] ++ failures = [ ++ TelegramNetworkError(method=method, message=f"failure {index}") for index in range(3) ++ ] ++ ++ async def sleep(delay): ++ delays.append(delay) ++ ++ endpoint = ScriptedEndpoint(*failures) ++ middleware = middleware_type(backoff_config=deterministic_backoff(), sleep=sleep) ++ ++ with pytest.raises(TelegramNetworkError) as caught: ++ await middleware(endpoint, object(), method) ++ ++ assert caught.value is failures[-1] ++ assert len(endpoint.calls) == 3 ++ assert delays == [0.25, 0.5] ++ ++ ++async def test_codespec_configured_attempt_limit_counts_the_initial_call(): ++ middleware_type = retry_middleware_type() ++ method = GetMe() ++ delays = [] ++ failures = [ ++ TelegramServerError(method=method, message="first"), ++ TelegramServerError(method=method, message="second"), ++ ] ++ ++ async def sleep(delay): ++ delays.append(delay) ++ ++ endpoint = ScriptedEndpoint(*failures, "must not be reached") ++ middleware = middleware_type( ++ max_attempts=2, ++ backoff_config=deterministic_backoff(), ++ sleep=sleep, ++ ) ++ ++ with pytest.raises(TelegramServerError) as caught: ++ await middleware(endpoint, object(), method) ++ ++ assert caught.value is failures[-1] ++ assert len(endpoint.calls) == 2 ++ assert delays == [0.25] ++ ++ ++@pytest.mark.parametrize( ++ "failure", ++ [ ++ TelegramBadRequest(method=GetMe(), message="bad request"), ++ TelegramEntityTooLarge(method=GetMe(), message="too large"), ++ RuntimeError("application failure"), ++ ], ++) ++async def test_codespec_unlisted_errors_are_not_retried(failure): ++ middleware_type = retry_middleware_type() ++ method = GetMe() ++ delays = [] ++ ++ async def sleep(delay): ++ delays.append(delay) ++ ++ endpoint = ScriptedEndpoint(failure, "must not be reached") ++ middleware = middleware_type( ++ max_attempts=3, ++ backoff_config=deterministic_backoff(), ++ sleep=sleep, ++ ) ++ ++ with pytest.raises(type(failure)) as caught: ++ await middleware(endpoint, object(), method) ++ ++ assert caught.value is failure ++ assert len(endpoint.calls) == 1 ++ assert delays == [] ++ ++ ++@pytest.mark.parametrize("max_attempts", [0, -1]) ++def test_codespec_attempt_limit_must_be_positive(max_attempts): ++ middleware_type = retry_middleware_type() ++ ++ with pytest.raises(ValueError): ++ middleware_type(max_attempts=max_attempts) ++ ++ ++async def test_codespec_handler_cancellation_is_propagated_immediately(): ++ middleware_type = retry_middleware_type() ++ delays = [] ++ ++ async def sleep(delay): ++ delays.append(delay) ++ ++ endpoint = ScriptedEndpoint(asyncio.CancelledError(), "must not be reached") ++ middleware = middleware_type( ++ max_attempts=3, ++ backoff_config=deterministic_backoff(), ++ sleep=sleep, ++ ) ++ ++ with pytest.raises(asyncio.CancelledError): ++ await middleware(endpoint, object(), GetMe()) ++ ++ assert len(endpoint.calls) == 1 ++ assert delays == [] ++ ++ ++async def test_codespec_sleep_cancellation_stops_before_another_attempt(): ++ middleware_type = retry_middleware_type() ++ method = GetMe() ++ failure = TelegramNetworkError(method=method, message="offline") ++ ++ async def cancelled_sleep(delay): ++ raise asyncio.CancelledError() ++ ++ endpoint = ScriptedEndpoint(failure, "must not be reached") ++ middleware = middleware_type( ++ max_attempts=3, ++ backoff_config=deterministic_backoff(), ++ sleep=cancelled_sleep, ++ ) ++ ++ with pytest.raises(asyncio.CancelledError): ++ await middleware(endpoint, object(), method) ++ ++ assert len(endpoint.calls) == 1 ++ ++ ++async def test_codespec_sequential_calls_restart_the_backoff_schedule(): ++ middleware_type = retry_middleware_type() ++ method = GetMe() ++ delays = [] ++ ++ async def sleep(delay): ++ delays.append(delay) ++ ++ middleware = middleware_type( ++ max_attempts=3, ++ backoff_config=deterministic_backoff(), ++ sleep=sleep, ++ ) ++ first = ScriptedEndpoint( ++ TelegramNetworkError(method=method, message="first"), ++ "first result", ++ ) ++ second = ScriptedEndpoint( ++ TelegramNetworkError(method=method, message="second"), ++ "second result", ++ ) ++ ++ assert await middleware(first, object(), method) == "first result" ++ assert await middleware(second, object(), method) == "second result" ++ assert delays == [0.25, 0.25] ++ ++ ++async def test_codespec_concurrent_calls_have_independent_backoff_state(): ++ middleware_type = retry_middleware_type() ++ methods = {"left": GetMe(), "right": GetMe()} ++ labels = {id(method): label for label, method in methods.items()} ++ counts = {"left": 0, "right": 0} ++ delays = {"left": [], "right": []} ++ active_label = contextvars.ContextVar("codespec_retry_request_label") ++ ++ async def endpoint(bot, method): ++ label = labels[id(method)] ++ active_label.set(label) ++ counts[label] += 1 ++ if counts[label] <= 2: ++ raise TelegramNetworkError(method=method, message=f"{label} transient") ++ return label ++ ++ async def sleep(delay): ++ delays[active_label.get()].append(delay) ++ await asyncio.sleep(0) ++ ++ middleware = middleware_type( ++ max_attempts=3, ++ backoff_config=deterministic_backoff(), ++ sleep=sleep, ++ ) ++ ++ results = await asyncio.gather( ++ middleware(endpoint, object(), methods["left"]), ++ middleware(endpoint, object(), methods["right"]), ++ ) ++ ++ assert results == ["left", "right"] ++ assert counts == {"left": 3, "right": 3} ++ assert delays == {"left": [0.25, 0.5], "right": [0.25, 0.5]} ++ ++ ++async def test_codespec_retries_reenter_only_downstream_middlewares(): ++ middleware_type = retry_middleware_type() ++ manager = RequestMiddlewareManager() ++ method = GetMe() ++ calls = {"outer": 0, "inner": 0, "target": 0} ++ ++ async def outer(make_request, bot, request_method): ++ calls["outer"] += 1 ++ return await make_request(bot, request_method) ++ ++ async def inner(make_request, bot, request_method): ++ calls["inner"] += 1 ++ return await make_request(bot, request_method) ++ ++ async def target(bot, request_method, timeout=None): ++ calls["target"] += 1 ++ if calls["target"] == 1: ++ raise TelegramNetworkError(method=request_method, message="once") ++ return timeout ++ ++ async def sleep(delay): ++ return None ++ ++ manager.register(outer) ++ manager.register( ++ middleware_type( ++ max_attempts=2, ++ backoff_config=deterministic_backoff(), ++ sleep=sleep, ++ ) ++ ) ++ manager.register(inner) ++ ++ wrapped = manager.wrap_middlewares(target, timeout=42) ++ assert await wrapped(object(), method) == 42 ++ assert calls == {"outer": 1, "inner": 2, "target": 2} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++pytest -q \ ++ tests/test_api/test_client/test_session/test_middlewares/test_retry_codespec.py \ ++ tests/test_api/test_client/test_session/test_middlewares/test_manager.py \ ++ tests/test_utils/test_backoff.py diff --git a/tasks/format-code-task-000325/tests/test.sh b/tasks/format-code-task-000325/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4ea463b532c2b600dfbcdfccb682029dc6fbd1a --- /dev/null +++ b/tasks/format-code-task-000325/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_api/test_client/test_session/test_middlewares/test_retry_codespec.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000325/tests/test_command.sh b/tasks/format-code-task-000325/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000325/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000347/environment/Dockerfile b/tasks/format-code-task-000347/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..80e421b1af44c0f86ff391653f3bb64e179ee9f6 --- /dev/null +++ b/tasks/format-code-task-000347/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:485a7151662318917a22a1d772815db1e29feaef17bf0ef9453b81b4696b482f diff --git a/tasks/format-code-task-000347/environment/setup/files/blocklist b/tasks/format-code-task-000347/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000347/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000347/environment/setup/setup.sh b/tasks/format-code-task-000347/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000347/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000347/tests/test.patch b/tasks/format-code-task-000347/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8d1ad7be070335200c4c6406bc7f983661a8e25f --- /dev/null +++ b/tasks/format-code-task-000347/tests/test.patch @@ -0,0 +1,354 @@ +diff --git a/alicloud/data_source_alicloud_cr_chart_repositories_hidden_test.go b/alicloud/data_source_alicloud_cr_chart_repositories_hidden_test.go +new file mode 100644 +index 000000000..2654de3fc +--- /dev/null ++++ b/alicloud/data_source_alicloud_cr_chart_repositories_hidden_test.go +@@ -0,0 +1,321 @@ ++package alicloud ++ ++import ( ++ "fmt" ++ "os" ++ "reflect" ++ "sort" ++ "strings" ++ "testing" ++ ++ "github.com/agiledragon/gomonkey/v2" ++ "github.com/alibabacloud-go/tea-rpc/client" ++ util "github.com/alibabacloud-go/tea-utils/service" ++ "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ++ ++ "github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity" ++) ++ ++func hiddenChartRepoObjects() []interface{} { ++ return hiddenChartRepoObjectsFor("cri-hidden") ++} ++ ++func hiddenChartRepoObjectsFor(instanceID string) []interface{} { ++ return []interface{}{ ++ map[string]interface{}{ ++ "RepoId": "repo-id-alpha", ++ "CreateTime": "2024-01-02T03:04:05Z", ++ "InstanceId": instanceID, ++ "RepoName": "app-alpha", ++ "RepoNamespaceName": "team-a", ++ "RepoType": "PUBLIC", ++ "Summary": "alpha summary", ++ }, ++ map[string]interface{}{ ++ "RepoId": "repo-id-beta", ++ "CreateTime": "2024-02-03T04:05:06Z", ++ "InstanceId": instanceID, ++ "RepoName": "app-beta", ++ "RepoNamespaceName": "team-b", ++ "RepoType": "PRIVATE", ++ "Summary": "beta summary", ++ }, ++ map[string]interface{}{ ++ "RepoId": "repo-id-db", ++ "CreateTime": "2024-03-04T05:06:07Z", ++ "InstanceId": instanceID, ++ "RepoName": "db-alpha", ++ "RepoNamespaceName": "team-a", ++ "RepoType": "PUBLIC", ++ "Summary": "db summary", ++ }, ++ map[string]interface{}{ ++ "RepoId": "repo-id-alpha-other-ns", ++ "CreateTime": "2024-04-05T06:07:08Z", ++ "InstanceId": instanceID, ++ "RepoName": "app-alpha", ++ "RepoNamespaceName": "team-c", ++ "RepoType": "PRIVATE", ++ "Summary": "same repo name, different namespace", ++ }, ++ } ++} ++ ++func TestUnitAlicloudCrChartRepositoriesSchema(t *testing.T) { ++ p := Provider().(*schema.Provider) ++ ds, ok := p.DataSourcesMap["alicloud_cr_chart_repositories"] ++ if !ok { ++ t.Fatalf("expected provider to expose data source alicloud_cr_chart_repositories") ++ } ++ if ds.Schema["instance_id"] == nil || !ds.Schema["instance_id"].Required { ++ t.Fatalf("instance_id should be a required input") ++ } ++ if ds.Schema["name_regex"] == nil || ds.Schema["name_regex"].ValidateFunc == nil { ++ t.Fatalf("name_regex should have validation for invalid regular expressions") ++ } ++ _, errs := ds.Schema["name_regex"].ValidateFunc("[", "name_regex") ++ if len(errs) == 0 { ++ t.Fatalf("invalid name_regex should be rejected during validation") ++ } ++ for _, field := range []string{"ids", "names", "output_file", "repositories"} { ++ if ds.Schema[field] == nil { ++ t.Fatalf("expected public schema field %q to exist", field) ++ } ++ } ++ repoSchema, ok := ds.Schema["repositories"].Elem.(*schema.Resource) ++ if !ok { ++ t.Fatalf("repositories should expose nested repository objects") ++ } ++ for _, field := range []string{ ++ "chart_repository_id", "create_time", "instance_id", "id", ++ "repo_name", "repo_namespace_name", "repo_type", "summary", ++ } { ++ if repoSchema.Schema[field] == nil { ++ t.Fatalf("repositories item missing public field %q", field) ++ } ++ } ++} ++ ++func TestUnitAlicloudCrChartRepositoriesReadFiltersAndOutputs(t *testing.T) { ++ d := readHiddenChartRepos(t, map[string]interface{}{ ++ "instance_id": "cri-hidden", ++ }, hiddenChartRepoObjects()) ++ repos := repositoryStateByID(t, d) ++ ++ if got := len(repos); got != 4 { ++ t.Fatalf("expected four repositories, got %d", got) ++ } ++ assertRepositoryFields(t, repos["cri-hidden:team-a:app-alpha"], map[string]string{ ++ "chart_repository_id": "repo-id-alpha", ++ "create_time": "2024-01-02T03:04:05Z", ++ "instance_id": "cri-hidden", ++ "repo_namespace_name": "team-a", ++ "repo_name": "app-alpha", ++ "repo_type": "PUBLIC", ++ "summary": "alpha summary", ++ "id": "cri-hidden:team-a:app-alpha", ++ }) ++ ++ assertStringSet(t, stateStringList(d, "ids"), []string{ ++ "cri-hidden:team-a:app-alpha", ++ "cri-hidden:team-b:app-beta", ++ "cri-hidden:team-a:db-alpha", ++ "cri-hidden:team-c:app-alpha", ++ }) ++ assertStringSet(t, stateStringList(d, "names"), []string{"app-alpha", "app-beta", "db-alpha", "app-alpha"}) ++} ++ ++func TestUnitAlicloudCrChartRepositoriesReadUsesConfiguredInstance(t *testing.T) { ++ instanceID := "cri-other" ++ d := readHiddenChartRepos(t, map[string]interface{}{ ++ "instance_id": instanceID, ++ }, hiddenChartRepoObjectsFor(instanceID)) ++ repos := repositoryStateByID(t, d) ++ ++ if got := len(repos); got != 4 { ++ t.Fatalf("expected four repositories for configured instance, got %d", got) ++ } ++ assertRepositoryFields(t, repos["cri-other:team-a:app-alpha"], map[string]string{ ++ "chart_repository_id": "repo-id-alpha", ++ "create_time": "2024-01-02T03:04:05Z", ++ "instance_id": instanceID, ++ "repo_namespace_name": "team-a", ++ "repo_name": "app-alpha", ++ "repo_type": "PUBLIC", ++ "summary": "alpha summary", ++ "id": "cri-other:team-a:app-alpha", ++ }) ++ assertStringSet(t, stateStringList(d, "ids"), []string{ ++ "cri-other:team-a:app-alpha", ++ "cri-other:team-b:app-beta", ++ "cri-other:team-a:db-alpha", ++ "cri-other:team-c:app-alpha", ++ }) ++} ++ ++func TestUnitAlicloudCrChartRepositoriesReadNameRegex(t *testing.T) { ++ appRepos := readHiddenChartRepos(t, map[string]interface{}{ ++ "instance_id": "cri-hidden", ++ "name_regex": "^app-", ++ }, hiddenChartRepoObjects()) ++ if got := len(repositoryStateByID(t, appRepos)); got != 3 { ++ t.Fatalf("expected three app repositories, got %d", got) ++ } ++ assertStringSet(t, stateStringList(appRepos, "names"), []string{"app-alpha", "app-beta", "app-alpha"}) ++ assertStringSet(t, stateStringList(appRepos, "ids"), []string{ ++ "cri-hidden:team-a:app-alpha", ++ "cri-hidden:team-b:app-beta", ++ "cri-hidden:team-c:app-alpha", ++ }) ++ ++ betaOnly := readHiddenChartRepos(t, map[string]interface{}{ ++ "instance_id": "cri-hidden", ++ "name_regex": "beta$", ++ }, hiddenChartRepoObjects()) ++ if got := len(repositoryStateByID(t, betaOnly)); got != 1 { ++ t.Fatalf("expected one beta repository, got %d", got) ++ } ++ assertStringSet(t, stateStringList(betaOnly, "names"), []string{"app-beta"}) ++} ++ ++func TestUnitAlicloudCrChartRepositoriesReadIDsFilter(t *testing.T) { ++ d := readHiddenChartRepos(t, map[string]interface{}{ ++ "instance_id": "cri-hidden", ++ "ids": []interface{}{ ++ "cri-hidden:team-b:app-beta", ++ "cri-hidden:team-c:app-alpha", ++ }, ++ }, hiddenChartRepoObjects()) ++ ++ if got := len(repositoryStateByID(t, d)); got != 2 { ++ t.Fatalf("expected two repositories after ids filtering, got %d", got) ++ } ++ assertStringSet(t, stateStringList(d, "ids"), []string{ ++ "cri-hidden:team-b:app-beta", ++ "cri-hidden:team-c:app-alpha", ++ }) ++ assertStringSet(t, stateStringList(d, "names"), []string{"app-beta", "app-alpha"}) ++} ++ ++func TestUnitAlicloudCrChartRepositoriesReadOutputFile(t *testing.T) { ++ output, err := os.CreateTemp("", "alicloud-cr-chart-repos-*.json") ++ if err != nil { ++ t.Fatal(err) ++ } ++ path := output.Name() ++ output.Close() ++ os.Remove(path) ++ defer os.Remove(path) ++ ++ d := readHiddenChartRepos(t, map[string]interface{}{ ++ "instance_id": "cri-hidden", ++ "name_regex": "^app-", ++ "output_file": path, ++ }, hiddenChartRepoObjects()) ++ if got := len(repositoryStateByID(t, d)); got != 3 { ++ t.Fatalf("expected three returned repositories, got %d", got) ++ } ++ body, err := os.ReadFile(path) ++ if err != nil { ++ t.Fatalf("expected output_file to be created: %v", err) ++ } ++ content := string(body) ++ for _, want := range []string{"app-alpha", "app-beta", "cri-hidden", "team-a", "team-b", "team-c"} { ++ if !strings.Contains(content, want) { ++ t.Fatalf("output_file content missing returned repository data %q: %s", want, content) ++ } ++ } ++ if strings.Contains(content, "db-alpha") || strings.Contains(content, "repo-id-db") { ++ t.Fatalf("output_file should not contain filtered-out repositories: %s", content) ++ } ++} ++ ++func readHiddenChartRepos(t *testing.T, attrs map[string]interface{}, repos []interface{}) *schema.ResourceData { ++ t.Helper() ++ ds := Provider().(*schema.Provider).DataSourcesMap["alicloud_cr_chart_repositories"] ++ if ds == nil { ++ t.Fatalf("data source alicloud_cr_chart_repositories is not registered") ++ } ++ d := ds.Data(nil) ++ for k, v := range attrs { ++ if err := d.Set(k, v); err != nil { ++ t.Fatalf("setting %s: %v", k, err) ++ } ++ } ++ ++ ++ patchClient := gomonkey.ApplyMethod(reflect.TypeOf(&connectivity.AliyunClient{}), "NewAcrClient", func(_ *connectivity.AliyunClient) (*client.Client, error) { ++ return &client.Client{}, nil ++ }) ++ defer patchClient.Reset() ++ ++ patchRequest := gomonkey.ApplyMethod(reflect.TypeOf(&client.Client{}), "DoRequest", func(_ *client.Client, action *string, _ *string, _ *string, _ *string, _ *string, _ map[string]interface{}, request map[string]interface{}, _ *util.RuntimeOptions) (map[string]interface{}, error) { ++ if action == nil || *action != "ListChartRepository" { ++ t.Fatalf("expected chart repository list request, got %v", action) ++ } ++ if want := fmt.Sprint(attrs["instance_id"]); want != "" && fmt.Sprint(request["InstanceId"]) != want { ++ t.Fatalf("request InstanceId = %q, want %q", fmt.Sprint(request["InstanceId"]), want) ++ } ++ return map[string]interface{}{"Repositories": repos}, nil ++ }) ++ defer patchRequest.Reset() ++ ++ if err := ds.Read(d, &connectivity.AliyunClient{RegionId: "cn-hidden"}); err != nil { ++ t.Fatalf("reading chart repositories data source: %v", err) ++ } ++ return d ++} ++ ++func repositoryStateByID(t *testing.T, d *schema.ResourceData) map[string]map[string]string { ++ t.Helper() ++ raw, ok := d.Get("repositories").([]interface{}) ++ if !ok { ++ t.Fatalf("repositories has unexpected type %T", d.Get("repositories")) ++ } ++ out := make(map[string]map[string]string, len(raw)) ++ for _, item := range raw { ++ m, ok := item.(map[string]interface{}) ++ if !ok { ++ t.Fatalf("repository item has unexpected type %T", item) ++ } ++ id := fmt.Sprint(m["id"]) ++ values := make(map[string]string, len(m)) ++ for k, v := range m { ++ values[k] = fmt.Sprint(v) ++ } ++ out[id] = values ++ } ++ return out ++} ++ ++func assertRepositoryFields(t *testing.T, got map[string]string, want map[string]string) { ++ t.Helper() ++ if got == nil { ++ t.Fatalf("expected repository id %q to exist", want["id"]) ++ } ++ for key, wantValue := range want { ++ if got[key] != wantValue { ++ t.Fatalf("repository field %s = %q, want %q", key, got[key], wantValue) ++ } ++ } ++} ++ ++func stateStringList(d *schema.ResourceData, key string) []string { ++ raw := d.Get(key).([]interface{}) ++ out := make([]string, 0, len(raw)) ++ for _, v := range raw { ++ out = append(out, v.(string)) ++ } ++ return out ++} ++ ++func assertStringSet(t *testing.T, got, want []string) { ++ t.Helper() ++ gotCopy := append([]string(nil), got...) ++ wantCopy := append([]string(nil), want...) ++ sort.Strings(gotCopy) ++ sort.Strings(wantCopy) ++ if !reflect.DeepEqual(gotCopy, wantCopy) { ++ t.Fatalf("string set mismatch\ngot: %#v\nwant: %#v", gotCopy, wantCopy) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,22 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++export ALICLOUD_ACCESS_KEY=mock ++export ALICLOUD_SECRET_KEY=mock ++export ALICLOUD_REGION=cn-beijing ++ ++ ++case "${1:-}" in ++ base) ++ go test -v -gcflags=all=-l -run "TestAccAlicloudCRRepoDataSource|TestAccAlicloudAmqpBinding|TestAccAlicloudCRChartRepository" ./alicloud/ -timeout 30m ++ ;; ++ new) ++ go test -v -gcflags=all=-l -run "TestUnitAlicloudCrChartRepositories(Schema|ReadFiltersAndOutputs|ReadUsesConfiguredInstance|ReadNameRegex|ReadIDsFilter|ReadOutputFile)$" ./alicloud/ -timeout 30m ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000347/tests/test.sh b/tasks/format-code-task-000347/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1681516b8a838fbd15d2bacdb9bb1cf7cb8e315b --- /dev/null +++ b/tasks/format-code-task-000347/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +alicloud/data_source_alicloud_cr_chart_repositories_hidden_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000347/tests/test_command.sh b/tasks/format-code-task-000347/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000347/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000348/environment/Dockerfile b/tasks/format-code-task-000348/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9bca832f5a334dec471dcc53e3ea64c3553473b7 --- /dev/null +++ b/tasks/format-code-task-000348/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:dead70eede3a5be808c77b7184aaea34db67385fb237f4ae4ae5c7202d5d5db6 diff --git a/tasks/format-code-task-000348/environment/setup/files/blocklist b/tasks/format-code-task-000348/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000348/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000348/environment/setup/setup.sh b/tasks/format-code-task-000348/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000348/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000348/tests/test.patch b/tasks/format-code-task-000348/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..20a4048c7575a20b6e3b1a116097f855f94cc4d5 --- /dev/null +++ b/tasks/format-code-task-000348/tests/test.patch @@ -0,0 +1,123 @@ +diff --git a/alicloud/resource_alicloud_emrv2_cluster_unit_test.go b/alicloud/resource_alicloud_emrv2_cluster_unit_test.go +new file mode 100644 +index 000000000..de8a9df17 +--- /dev/null ++++ b/alicloud/resource_alicloud_emrv2_cluster_unit_test.go +@@ -0,0 +1,91 @@ ++package alicloud ++ ++import ( ++ "testing" ++ ++ "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ++ "github.com/stretchr/testify/assert" ++) ++ ++ ++ ++func emrV2NestedBlockSchema(t *testing.T, block string) map[string]*schema.Schema { ++ r := resourceAlicloudEmrV2Cluster() ++ s, ok := r.Schema[block] ++ assert.Truef(t, ok, "%q block should exist on the resource schema", block) ++ res, ok := s.Elem.(*schema.Resource) ++ assert.Truef(t, ok, "%q block should be a nested resource block", block) ++ return res.Schema ++} ++ ++ ++ ++func valueAccepted(vf schema.SchemaValidateFunc, val interface{}, key string) bool { ++ if vf == nil { ++ return true ++ } ++ ws, es := vf(val, key) ++ return len(ws) == 0 && len(es) == 0 ++} ++ ++func TestUnitEmrV2SystemDiskEncryptedSchema(t *testing.T) { ++ na := emrV2NestedBlockSchema(t, "node_attributes") ++ ++ f, ok := na["system_disk_encrypted"] ++ assert.True(t, ok, "node_attributes should expose system_disk_encrypted") ++ if ok { ++ assert.Equal(t, schema.TypeBool, f.Type, "system_disk_encrypted should be a boolean") ++ assert.True(t, f.Optional, "system_disk_encrypted should be optional") ++ assert.True(t, f.ForceNew, "system_disk_encrypted should force recreation") ++ } ++} ++ ++func TestUnitEmrV2SystemDiskKmsKeyIdSchema(t *testing.T) { ++ na := emrV2NestedBlockSchema(t, "node_attributes") ++ ++ f, ok := na["system_disk_kms_key_id"] ++ assert.True(t, ok, "node_attributes should expose system_disk_kms_key_id") ++ if !ok { ++ return ++ } ++ assert.Equal(t, schema.TypeString, f.Type, "system_disk_kms_key_id should be a string") ++ assert.True(t, f.Optional, "system_disk_kms_key_id should be optional") ++ assert.True(t, f.ForceNew, "system_disk_kms_key_id should force recreation") ++ ++ assert.False(t, valueAccepted(f.ValidateFunc, "", "system_disk_kms_key_id"), ++ "an empty system_disk_kms_key_id should be rejected") ++ assert.True(t, valueAccepted(f.ValidateFunc, "alias/my-key", "system_disk_kms_key_id"), ++ "a non-empty system_disk_kms_key_id should be accepted") ++} ++ ++func TestUnitEmrV2NodeGroupTypeAcceptsMasterExtend(t *testing.T) { ++ ng := emrV2NestedBlockSchema(t, "node_groups") ++ f, ok := ng["node_group_type"] ++ assert.True(t, ok, "node_groups should expose node_group_type") ++ if !ok { ++ return ++ } ++ ++ for _, v := range []string{"MASTER", "CORE", "TASK", "GATEWAY", "MASTER-EXTEND"} { ++ assert.Truef(t, valueAccepted(f.ValidateFunc, v, "node_group_type"), ++ "node_group_type should accept %q", v) ++ } ++ assert.False(t, valueAccepted(f.ValidateFunc, "NOT_A_TYPE", "node_group_type"), ++ "node_group_type should reject values outside the accepted set") ++} ++ ++func TestUnitEmrV2ExecutionMomentAcceptsBeforeStart(t *testing.T) { ++ bs := emrV2NestedBlockSchema(t, "bootstrap_scripts") ++ f, ok := bs["execution_moment"] ++ assert.True(t, ok, "bootstrap_scripts should expose execution_moment") ++ if !ok { ++ return ++ } ++ ++ for _, v := range []string{"BEFORE_INSTALL", "AFTER_STARTED", "BEFORE_START"} { ++ assert.Truef(t, valueAccepted(f.ValidateFunc, v, "execution_moment"), ++ "execution_moment should accept %q", v) ++ } ++ assert.False(t, valueAccepted(f.ValidateFunc, "NOT_A_MOMENT", "execution_moment"), ++ "execution_moment should reject values outside the accepted set") ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++export GOFLAGS=-mod=vendor ++GOGC=10 go test -c -o /tmp/alicloud_grade.test ./alicloud/ ++ ++ ++/tmp/alicloud_grade.test -test.run '^(TestProvider|TestProvider_impl)$' -test.v ++ ++ ++/tmp/alicloud_grade.test -test.run '^TestUnitEmrV2' -test.v diff --git a/tasks/format-code-task-000348/tests/test.sh b/tasks/format-code-task-000348/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ca9663905149c0e5d54b646b6c174f19b78a9682 --- /dev/null +++ b/tasks/format-code-task-000348/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +alicloud/resource_alicloud_emrv2_cluster_unit_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000348/tests/test_command.sh b/tasks/format-code-task-000348/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000348/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000370/environment/Dockerfile b/tasks/format-code-task-000370/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..80b00b9b6e1c971c8fc6fca99ab736128f726245 --- /dev/null +++ b/tasks/format-code-task-000370/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:41d30d3b051ab77408e4961edea508e1b22c7f2adf3fa36a7eb3c0278ee87e10 diff --git a/tasks/format-code-task-000370/environment/setup/files/blocklist b/tasks/format-code-task-000370/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000370/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000370/environment/setup/setup.sh b/tasks/format-code-task-000370/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000370/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000370/tests/test.patch b/tasks/format-code-task-000370/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3e78ba8a79d50c1fa4d37b127e1165f68d6b4692 --- /dev/null +++ b/tasks/format-code-task-000370/tests/test.patch @@ -0,0 +1,218 @@ +diff --git a/featuretools/tests/entityset_tests/test_pandas_es.py b/featuretools/tests/entityset_tests/test_pandas_es.py +index 50b73fd7..2a02ea76 100644 +--- a/featuretools/tests/entityset_tests/test_pandas_es.py ++++ b/featuretools/tests/entityset_tests/test_pandas_es.py +@@ -632,3 +632,171 @@ class TestNormalizeEntity(object): + assert entityset['values'].time_index == 'value_time' + assert 'value_time' in entityset['values'].df.columns + assert len(entityset['values'].df.columns) == 3 ++ ++ ++def test_head_of_entity(entityset): ++ ++ entity = entityset['log'] ++ assert(isinstance(entityset.head('log', 3), pd.DataFrame)) ++ assert(isinstance(entity.head(3), pd.DataFrame)) ++ assert(isinstance(entity['product_id'].head(3), pd.DataFrame)) ++ ++ assert(entity.head(n=5).shape == (5, 9)) ++ ++ timestamp1 = pd.to_datetime("2011-04-09 10:30:10") ++ timestamp2 = pd.to_datetime("2011-04-09 10:30:18") ++ datetime1 = datetime(2011, 4, 9, 10, 30, 18) ++ ++ assert(entity.head(5, cutoff_time=timestamp1).shape == (2, 9)) ++ assert(entity.head(5, cutoff_time=timestamp2).shape == (3, 9)) ++ assert(entity.head(5, cutoff_time=datetime1).shape == (3, 9)) ++ ++ time_list = [timestamp2]*3+[timestamp1]*2 ++ cutoff_times = pd.DataFrame(zip(range(5), time_list)) ++ ++ assert(entityset.head('log', 5, cutoff_time=cutoff_times).shape == (3, 9)) ++ assert(entity.head(5, cutoff_time=cutoff_times).shape == (3, 9)) ++ assert(entity['product_id'].head(5, cutoff_time=cutoff_times).shape == (3, 1)) ++ ++ ++def _time_index(entity): ++ return entity.time_index ++ ++ ++def _entity_index(entity): ++ return entity.index ++ ++ ++def _expected_for_timestamp(entity, n, cutoff_time): ++ time_index = _time_index(entity) ++ return entity.df[entity.df[time_index] < cutoff_time].head(n) ++ ++ ++def _cutoff_frame_for_rows(entity): ++ index = _entity_index(entity) ++ time_index = _time_index(entity) ++ rows = entity.df.iloc[[1, 3, 5]] ++ cutoff_times = rows[time_index].copy() ++ cutoff_times.iloc[0] = cutoff_times.iloc[0] + pd.Timedelta(seconds=1) ++ cutoff_times.iloc[1] = cutoff_times.iloc[1] ++ cutoff_times.iloc[2] = cutoff_times.iloc[2] + pd.Timedelta(seconds=1) ++ return pd.DataFrame({ ++ 'instance_id': rows[index].values, ++ 'cutoff_time': cutoff_times.values, ++ }, index=rows.index, columns=['instance_id', 'cutoff_time']) ++ ++ ++def _assert_timestamp_cutoff(entity, result, n, cutoff_time): ++ time_index = _time_index(entity) ++ assert isinstance(result, pd.DataFrame) ++ assert len(result) <= n ++ assert not result.empty ++ assert (result[time_index] < cutoff_time).all() ++ assert (entity.df.head(n)[time_index] >= cutoff_time).any() ++ ++ ++def _assert_dataframe_cutoff(entity, result, n, cutoff_time): ++ index = _entity_index(entity) ++ time_index = _time_index(entity) ++ assert isinstance(result, pd.DataFrame) ++ assert len(result) <= n ++ assert set(result[index]).issubset(set(cutoff_time['instance_id'])) ++ cutoffs = cutoff_time['cutoff_time'] ++ for row_index, row in result.iterrows(): ++ assert row[time_index] < cutoffs.loc[row_index] ++ ++ ++def test_entity_head_filters_timestamp_cutoff(entityset): ++ entity = entityset['log'] ++ n = 5 ++ cutoff_time = entity.df[_time_index(entity)].iloc[3] ++ ++ result = entity.head(n=n, cutoff_time=cutoff_time) ++ _assert_timestamp_cutoff(entity, result, n, cutoff_time) ++ ++ datetime_cutoff = cutoff_time.to_pydatetime() ++ datetime_result = entity.head(n=n, cutoff_time=datetime_cutoff) ++ _assert_timestamp_cutoff(entity, datetime_result, n, datetime_cutoff) ++ ++ expected = _expected_for_timestamp(entity, n, cutoff_time) ++ pd.testing.assert_frame_equal(result, expected) ++ ++ ++def test_entityset_head_filters_timestamp_cutoff(entityset): ++ entity = entityset['log'] ++ n = 5 ++ cutoff_time = entity.df[_time_index(entity)].iloc[3] ++ ++ result = entityset.head('log', n=n, cutoff_time=cutoff_time) ++ ++ _assert_timestamp_cutoff(entity, result, n, cutoff_time) ++ expected = _expected_for_timestamp(entity, n, cutoff_time) ++ pd.testing.assert_frame_equal(result, expected) ++ ++ ++def test_entity_head_filters_dataframe_cutoff_by_instance_and_time(entityset): ++ entity = entityset['log'] ++ n = 10 ++ cutoff_time = _cutoff_frame_for_rows(entity) ++ ++ result = entity.head(n=n, cutoff_time=cutoff_time) ++ ++ _assert_dataframe_cutoff(entity, result, n, cutoff_time) ++ assert len(result) < len(cutoff_time) ++ ++ ++def test_entityset_head_filters_dataframe_cutoff_by_instance_and_time(entityset): ++ entity = entityset['log'] ++ n = 10 ++ cutoff_time = _cutoff_frame_for_rows(entity) ++ ++ result = entityset.head('log', n=n, cutoff_time=cutoff_time) ++ ++ _assert_dataframe_cutoff(entity, result, n, cutoff_time) ++ assert len(result) < len(cutoff_time) ++ ++ ++def test_variable_head_returns_single_column_dataframe_with_timestamp_cutoff(entityset): ++ entity = entityset['log'] ++ variable = entity['product_id'] ++ n = 5 ++ cutoff_time = entity.df[_time_index(entity)].iloc[3] ++ ++ result = variable.head(n=n, cutoff_time=cutoff_time) ++ ++ expected = _expected_for_timestamp(entity, n, cutoff_time)[[variable.id]] ++ assert isinstance(result, pd.DataFrame) ++ assert list(result.columns) == [variable.id] ++ pd.testing.assert_frame_equal(result, expected) ++ ++ ++def test_variable_head_returns_single_column_dataframe_with_dataframe_cutoff(entityset): ++ entity = entityset['log'] ++ variable = entity['product_id'] ++ n = 10 ++ cutoff_time = _cutoff_frame_for_rows(entity) ++ ++ result = variable.head(n=n, cutoff_time=cutoff_time) ++ ++ expected = entity.head(n=n, cutoff_time=cutoff_time)[[variable.id]] ++ assert isinstance(result, pd.DataFrame) ++ assert list(result.columns) == [variable.id] ++ pd.testing.assert_frame_equal(result, expected) ++ ++ ++def test_head_rejects_unsupported_cutoff_type(entityset): ++ entity = entityset['log'] ++ ++ with pytest.raises(ValueError) as exc: ++ entity.head(cutoff_time=object()) ++ ++ assert str(exc.value) == ( ++ 'cutoff_time must be None, a Datetime, a pd.Timestamp, or a pd.DataFrame') ++ ++ ++def test_entityset_head_rejects_unsupported_cutoff_type(entityset): ++ with pytest.raises(ValueError) as exc: ++ entityset.head('log', cutoff_time=object()) ++ ++ assert str(exc.value) == ( ++ 'cutoff_time must be None, a Datetime, a pd.Timestamp, or a pd.DataFrame') +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,37 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++set +u ++export PYENV_ROOT="$HOME/.pyenv" ++export PATH="$PYENV_ROOT/bin:$PATH" ++eval "$(pyenv init -)" ++pyenv global 2.7.18 ++ ++pip install -e . --no-deps 2>/dev/null ++set -u ++ ++ ++case "${1:-}" in ++ base) ++ python -m pytest featuretools/tests/entityset_tests/test_pandas_es.py -xvs -k \ ++ 'not test_head_of_entity and not test_entity_head_filters_timestamp_cutoff and not test_entityset_head_filters_timestamp_cutoff and not test_entity_head_filters_dataframe_cutoff_by_instance_and_time and not test_entityset_head_filters_dataframe_cutoff_by_instance_and_time and not test_variable_head_returns_single_column_dataframe_with_timestamp_cutoff and not test_variable_head_returns_single_column_dataframe_with_dataframe_cutoff and not test_head_rejects_unsupported_cutoff_type and not test_entityset_head_rejects_unsupported_cutoff_type' ++ ;; ++ new) ++ python -m pytest -xvs \ ++ featuretools/tests/entityset_tests/test_pandas_es.py::test_head_of_entity \ ++ featuretools/tests/entityset_tests/test_pandas_es.py::test_entity_head_filters_timestamp_cutoff \ ++ featuretools/tests/entityset_tests/test_pandas_es.py::test_entityset_head_filters_timestamp_cutoff \ ++ featuretools/tests/entityset_tests/test_pandas_es.py::test_entity_head_filters_dataframe_cutoff_by_instance_and_time \ ++ featuretools/tests/entityset_tests/test_pandas_es.py::test_entityset_head_filters_dataframe_cutoff_by_instance_and_time \ ++ featuretools/tests/entityset_tests/test_pandas_es.py::test_variable_head_returns_single_column_dataframe_with_timestamp_cutoff \ ++ featuretools/tests/entityset_tests/test_pandas_es.py::test_variable_head_returns_single_column_dataframe_with_dataframe_cutoff \ ++ featuretools/tests/entityset_tests/test_pandas_es.py::test_head_rejects_unsupported_cutoff_type \ ++ featuretools/tests/entityset_tests/test_pandas_es.py::test_entityset_head_rejects_unsupported_cutoff_type ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000370/tests/test.sh b/tasks/format-code-task-000370/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c25c112d9d3aae581c6dca01de4673b3b217d748 --- /dev/null +++ b/tasks/format-code-task-000370/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +featuretools/tests/entityset_tests/test_pandas_es.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000370/tests/test_command.sh b/tasks/format-code-task-000370/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000370/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000371/environment/Dockerfile b/tasks/format-code-task-000371/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1ea99b8a596c64c136787347f1b79622ef8e0b42 --- /dev/null +++ b/tasks/format-code-task-000371/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:651201025c0403d4b1c5516985fc72c953ae2cab7aec1d4ce0146f551101d997 diff --git a/tasks/format-code-task-000371/environment/setup/files/blocklist b/tasks/format-code-task-000371/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000371/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000371/environment/setup/setup.sh b/tasks/format-code-task-000371/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000371/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000371/tests/test.patch b/tasks/format-code-task-000371/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..78f834c652d55c9b80f4bd02e6c575db124d5914 --- /dev/null +++ b/tasks/format-code-task-000371/tests/test.patch @@ -0,0 +1,76 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..016e8d4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,5 @@ ++{ ++ "test_commands": [ ++ "python -m pytest woodwork/tests/logical_types/test_logical_types.py::test_ordinal_with_valid_order_preserved woodwork/tests/schema/test_column_schema.py::test_column_schema_with_uninstantiated_ordinal_class woodwork/tests/schema/test_column_schema.py::test_column_schema_with_uninstantiated_ordinal_repr woodwork/tests/schema/test_column_schema.py::test_column_schema_with_uninstantiated_ordinal_is_instance woodwork/tests/schema/test_column_schema.py::test_column_schema_with_instantiated_ordinal_preserved -v" ++ ] ++} +diff --git a/woodwork/tests/logical_types/test_logical_types.py b/woodwork/tests/logical_types/test_logical_types.py +index 2f08f9c..8cb497d 100644 +--- a/woodwork/tests/logical_types/test_logical_types.py ++++ b/woodwork/tests/logical_types/test_logical_types.py +@@ -122,3 +122,10 @@ def test_ordinal_transform(sample_series): + + with pytest.raises(ValueError, match=error_msg): + ordinal_incomplete_order.transform(sample_series) ++ ++ ++def test_ordinal_with_valid_order_preserved(): ++ ++ order = ['bronze', 'silver', 'gold'] ++ ordinal = Ordinal(order=order) ++ assert ordinal.order == order +diff --git a/woodwork/tests/schema/test_column_schema.py b/woodwork/tests/schema/test_column_schema.py +index 8e2c55e..e220680 100644 +--- a/woodwork/tests/schema/test_column_schema.py ++++ b/woodwork/tests/schema/test_column_schema.py +@@ -410,3 +410,32 @@ def test_schema_repr(): + "") + assert (repr(ColumnSchema()) == + "") ++ ++ ++def test_column_schema_with_uninstantiated_ordinal_class(): ++ ++ ++ schema = ColumnSchema(logical_type=Ordinal) ++ assert schema is not None ++ assert schema.logical_type is not None ++ ++ ++def test_column_schema_with_uninstantiated_ordinal_repr(): ++ ++ schema = ColumnSchema(logical_type=Ordinal) ++ assert repr(schema) == "" ++ ++ ++def test_column_schema_with_uninstantiated_ordinal_is_instance(): ++ ++ ++ schema = ColumnSchema(logical_type=Ordinal) ++ assert isinstance(schema.logical_type, Ordinal) ++ assert schema.logical_type.order is None ++ ++ ++def test_column_schema_with_instantiated_ordinal_preserved(): ++ ++ schema = ColumnSchema(logical_type=Ordinal(order=['a', 'b', 'c'])) ++ assert isinstance(schema.logical_type, Ordinal) ++ assert schema.logical_type.order == ['a', 'b', 'c'] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -v -rA woodwork/tests/logical_types/test_logical_types.py::test_ordinal_with_valid_order_preserved woodwork/tests/schema/test_column_schema.py::test_column_schema_with_uninstantiated_ordinal_class woodwork/tests/schema/test_column_schema.py::test_column_schema_with_uninstantiated_ordinal_repr woodwork/tests/schema/test_column_schema.py::test_column_schema_with_uninstantiated_ordinal_is_instance woodwork/tests/schema/test_column_schema.py::test_column_schema_with_instantiated_ordinal_preserved ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000371/tests/test.sh b/tasks/format-code-task-000371/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..43ad4891b5598bbba5fc09e3492b802b06a28bfe --- /dev/null +++ b/tasks/format-code-task-000371/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +woodwork/tests/logical_types/test_logical_types.py +woodwork/tests/schema/test_column_schema.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000371/tests/test_command.sh b/tasks/format-code-task-000371/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000371/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000377/environment/Dockerfile b/tasks/format-code-task-000377/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..60cb41f1d25d5cf6925fa962caf88fa6d76c689d --- /dev/null +++ b/tasks/format-code-task-000377/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3488f7f3e9fb32e514bc82f7b9dcf26d73407d70aa8e35b4f3ee52c4d1aa1acc diff --git a/tasks/format-code-task-000377/environment/setup/files/blocklist b/tasks/format-code-task-000377/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000377/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000377/environment/setup/setup.sh b/tasks/format-code-task-000377/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000377/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000377/tests/test.patch b/tasks/format-code-task-000377/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..669c4996bb2a63df48e811847beb737f2a5a0533 --- /dev/null +++ b/tasks/format-code-task-000377/tests/test.patch @@ -0,0 +1,405 @@ +diff --git a/usercase-test-coderl/test_recolor_session.py b/usercase-test-coderl/test_recolor_session.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_recolor_session.py +@@ -0,0 +1,375 @@ ++ ++ ++ ++ ++import re ++import sys ++import types ++ ++import numpy as np ++import pytest ++from PIL import Image ++from PIL import ImageColor ++ ++ ++def _install_query_integral_image_fallback(): ++ ++ module_name = "wordcloud.query_integral_image" ++ if module_name in sys.modules: ++ return ++ ++ fallback = types.ModuleType(module_name) ++ ++ def query_integral_image(integral_image, size_x, size_y, random_state): ++ x, y = integral_image.shape ++ hits = 0 ++ for i in range(max(0, x - size_x)): ++ for j in range(max(0, y - size_y)): ++ area = int(integral_image[i, j]) ++ area += int(integral_image[i + size_x, j + size_y]) ++ area -= int(integral_image[i + size_x, j]) ++ area -= int(integral_image[i, j + size_y]) ++ if not area: ++ hits += 1 ++ if not hits: ++ return None ++ ++ goal = random_state.randint(0, hits) ++ if goal == 0: ++ return None ++ hits = 0 ++ for i in range(max(0, x - size_x)): ++ for j in range(max(0, y - size_y)): ++ area = int(integral_image[i, j]) ++ area += int(integral_image[i + size_x, j + size_y]) ++ area -= int(integral_image[i + size_x, j]) ++ area -= int(integral_image[i, j + size_y]) ++ if not area: ++ hits += 1 ++ if hits == goal: ++ return i, j ++ return None ++ ++ fallback.query_integral_image = query_integral_image ++ ++ sys.modules[module_name] = fallback ++ ++ ++_install_query_integral_image_fallback() ++ ++from wordcloud import WordCloud # noqa: E402 ++ ++ ++TEXT = "alpha beta beta gamma gamma gamma" ++BASE_OPTIONS = { ++ "random_state": 0, ++ "width": 220, ++ "height": 120, ++ "max_words": 3, ++ "collocations": False, ++ "background_color": "white", ++} ++ ++ ++def _layout_public(wc): ++ return [ ++ ( ++ (word, freq), ++ int(font_size), ++ (int(position[0]), int(position[1])), ++ orientation, ++ color, ++ ) ++ for (word, freq), font_size, position, orientation, color in wc.layout_ ++ ] ++ ++ ++def _layout_shape_by_word(wc): ++ return { ++ word: (freq, int(font_size), (int(position[0]), int(position[1])), orientation) ++ for (word, freq), font_size, position, orientation, _ in wc.layout_ ++ } ++ ++ ++def _layout_colors_by_word(wc): ++ return {word: color for (word, _), _, _, _, color in wc.layout_} ++ ++ ++def _rgb_tuple(color): ++ if isinstance(color, str): ++ return ImageColor.getrgb(color)[:3] ++ return tuple(int(channel) for channel in color[:3]) ++ ++ ++def _svg_word_fills(wc): ++ return re.findall( ++ r']+style="fill:([^"]+)"[^>]*>([^<]+)', ++ wc.to_svg(), ++ ) ++ ++ ++def _assert_layout_shape_preserved(before_shape, wc): ++ ++ assert _layout_shape_by_word(wc) == before_shape ++ ++ ++def _assert_all_layout_colors(wc, expected_color): ++ ++ assert set(_layout_colors_by_word(wc).values()) == {expected_color} ++ ++ ++def _assert_array_uses_red_words(array): ++ assert array.shape == (BASE_OPTIONS["height"], BASE_OPTIONS["width"], 3) ++ non_background = np.any(array != np.array([255, 255, 255]), axis=2) ++ ++ assert np.any(non_background) ++ assert np.all(array[:, :, 0][non_background] == 255) ++ assert np.all(array[:, :, 1][non_background] == array[:, :, 2][non_background]) ++ assert np.all(array[:, :, 1][non_background] < 255) ++ ++ ++def _assert_svg_fills(wc, expected_by_word): ++ fills = _svg_word_fills(wc) ++ ++ assert {word: fill for fill, word in fills} == expected_by_word ++ ++ ++def _assert_colors_from_colormap(colors, colormap_name): ++ import matplotlib.pyplot as plt ++ ++ cmap = plt.get_cmap(colormap_name) ++ samples = np.array([np.array(cmap(i / 1023.0)[:3]) * 255 for i in range(1024)]) ++ for color in colors: ++ rgb = np.array(_rgb_tuple(color), dtype=float) ++ ++ assert np.min(np.abs(samples - rgb).sum(axis=1)) <= 6 ++ ++ ++def test_recolor_with_custom_color_func_preserves_layout_and_updates_outputs(tmp_path): ++ ++ ++ ++ ++ wc = WordCloud(**BASE_OPTIONS) ++ generated = wc.generate(TEXT) ++ assert generated is wc ++ assert len(wc.layout_) == 3 ++ before_words = dict(wc.words_) ++ before_shape = _layout_shape_by_word(wc) ++ ++ calls = [] ++ ++ def red(**kwargs): ++ calls.append( ++ { ++ "word": kwargs["word"], ++ "font_size": int(kwargs["font_size"]), ++ "position": (int(kwargs["position"][0]), int(kwargs["position"][1])), ++ "orientation": kwargs["orientation"], ++ "font_path": kwargs["font_path"], ++ "has_random_state": "random_state" in kwargs, ++ } ++ ) ++ return "rgb(255, 0, 0)" ++ ++ same = wc.recolor(color_func=red) ++ assert same is wc ++ ++ assert len(calls) == len(before_shape) ++ assert {call["word"] for call in calls} == set(before_shape) ++ for call in calls: ++ freq, font_size, position, orientation = before_shape[call["word"]] ++ assert freq > 0 ++ assert call["font_size"] == font_size ++ assert call["position"] == position ++ assert call["orientation"] == orientation ++ assert call["font_path"] == wc.font_path ++ assert call["has_random_state"] ++ assert dict(wc.words_) == before_words ++ _assert_layout_shape_preserved(before_shape, wc) ++ _assert_all_layout_colors(wc, "rgb(255, 0, 0)") ++ ++ image = wc.to_image() ++ assert image.size == (BASE_OPTIONS["width"], BASE_OPTIONS["height"]) ++ _assert_array_uses_red_words(np.asarray(image.convert("RGB"))) ++ ++ array = wc.to_array() ++ _assert_array_uses_red_words(array) ++ _assert_svg_fills( ++ wc, ++ {word: "rgb(255, 0, 0)" for word in before_shape}, ++ ) ++ ++ out_path = tmp_path / "red-cloud.png" ++ file_result = wc.to_file(str(out_path)) ++ assert file_result is wc ++ file_array = np.asarray(Image.open(out_path).convert("RGB")) ++ _assert_array_uses_red_words(file_array) ++ ++ ++def test_recolor_without_color_func_uses_current_instance_color_func(): ++ ++ ++ ++ ++ recolor_calls = [] ++ expected_colors = { ++ "gamma": "rgb(11, 21, 31)", ++ "beta": "rgb(41, 51, 61)", ++ "alpha": "rgb(71, 81, 91)", ++ } ++ ++ def phase_color(*args, **kwargs): ++ if args: ++ return "rgb(0, 0, 255)" ++ recolor_calls.append(kwargs["word"]) ++ return expected_colors[kwargs["word"]] ++ ++ wc = WordCloud(**BASE_OPTIONS, color_func=phase_color).generate(TEXT) ++ before_shape = _layout_shape_by_word(wc) ++ assert set(_layout_colors_by_word(wc).values()) == {"rgb(0, 0, 255)"} ++ ++ same = wc.recolor() ++ assert same is wc ++ ++ assert set(recolor_calls) == set(before_shape) ++ assert len(recolor_calls) == len(before_shape) ++ _assert_layout_shape_preserved(before_shape, wc) ++ assert _layout_colors_by_word(wc) == { ++ word: expected_colors[word] for word in before_shape ++ } ++ _assert_svg_fills(wc, {word: expected_colors[word] for word in before_shape}) ++ ++ ++def test_recolor_with_colormap_draws_replacement_colors_from_that_colormap(): ++ ++ ++ ++ ++ wc = WordCloud(**BASE_OPTIONS).generate(TEXT) ++ before_shape = _layout_shape_by_word(wc) ++ before_colors = _layout_colors_by_word(wc) ++ ++ same = wc.recolor(random_state=10, colormap="plasma") ++ assert same is wc ++ _assert_layout_shape_preserved(before_shape, wc) ++ after_colors = _layout_colors_by_word(wc) ++ ++ assert after_colors != before_colors ++ _assert_colors_from_colormap(after_colors.values(), "plasma") ++ _assert_svg_fills(wc, after_colors) ++ ++ ++def test_integer_random_state_is_passed_to_color_func_as_seeded_random(): ++ ++ ++ ++ ++ calls = [] ++ ++ def seeded_color(**kwargs): ++ random_state = kwargs["random_state"] ++ draw = random_state.random() ++ calls.append( ++ { ++ "word": kwargs["word"], ++ "font_size": int(kwargs["font_size"]), ++ "position": (int(kwargs["position"][0]), int(kwargs["position"][1])), ++ "orientation": kwargs["orientation"], ++ "font_path": kwargs["font_path"], ++ "random_draw": draw, ++ } ++ ) ++ channel = int(draw * 200) + 1 ++ return "rgb({}, 2, 3)".format(channel) ++ ++ wc = WordCloud(**BASE_OPTIONS).generate(TEXT) ++ before_shape = _layout_shape_by_word(wc) ++ same = wc.recolor(random_state=10, color_func=seeded_color) ++ assert same is wc ++ ++ assert len(calls) == len(before_shape) ++ assert {call["word"] for call in calls} == set(before_shape) ++ assert all(0 <= call["random_draw"] < 1 for call in calls) ++ for call in calls: ++ _, font_size, position, orientation = before_shape[call["word"]] ++ assert call["font_size"] == font_size ++ assert call["position"] == position ++ assert call["orientation"] == orientation ++ assert call["font_path"] == wc.font_path ++ _assert_layout_shape_preserved(before_shape, wc) ++ ++ ++def test_same_integer_random_state_recolor_is_repeatable_on_same_layout(): ++ ++ ++ ++ ++ wc = WordCloud(**BASE_OPTIONS).generate(TEXT) ++ before_shape = _layout_shape_by_word(wc) ++ first_same = wc.recolor(random_state=10) ++ first_shape = _layout_shape_by_word(wc) ++ first_colors = _layout_colors_by_word(wc) ++ first_array = wc.to_array() ++ second_same = wc.recolor(random_state=10) ++ second_shape = _layout_shape_by_word(wc) ++ second_colors = _layout_colors_by_word(wc) ++ second_array = wc.to_array() ++ ++ assert first_same is wc ++ assert second_same is wc ++ ++ assert first_shape == before_shape ++ assert second_shape == before_shape ++ assert first_colors == second_colors ++ assert np.array_equal(first_array, second_array) ++ ++ ++def test_recolor_before_generate_raises_value_error(): ++ ++ ++ ++ ++ ++ with pytest.raises(ValueError): ++ WordCloud().recolor() ++ ++ ++def test_recolor_state_is_independent_between_instances(): ++ ++ ++ ++ ++ red = lambda *args, **kwargs: "rgb(255, 0, 0)" ++ blue = lambda *args, **kwargs: "rgb(0, 0, 255)" ++ ++ a = WordCloud(**BASE_OPTIONS, color_func=blue).generate(TEXT) ++ b = WordCloud(**BASE_OPTIONS, color_func=blue).generate(TEXT) ++ a_before_shape = _layout_shape_by_word(a) ++ b_before_layout = _layout_public(b) ++ a_result = a.recolor(color_func=red) ++ ++ assert a_result is a ++ _assert_layout_shape_preserved(a_before_shape, a) ++ _assert_all_layout_colors(a, "rgb(255, 0, 0)") ++ ++ assert _layout_public(b) == b_before_layout ++ assert set(_layout_colors_by_word(b).values()) == {"rgb(0, 0, 255)"} ++ ++ ++def test_repeated_recolor_sessions_preserve_layout_size_and_remain_renderable(): ++ ++ ++ ++ ++ red = lambda *args, **kwargs: "rgb(255, 0, 0)" ++ ++ ++ for _ in range(8): ++ wc = WordCloud(**BASE_OPTIONS).generate(TEXT) ++ before_shape = _layout_shape_by_word(wc) ++ same = wc.recolor(color_func=red) ++ assert same is wc ++ _assert_layout_shape_preserved(before_shape, wc) ++ _assert_all_layout_colors(wc, "rgb(255, 0, 0)") ++ _assert_array_uses_red_words(wc.to_array()) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTHONNOUSERSITE=1 ++export PYTHONDONTWRITEBYTECODE=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export MPLBACKEND=Agg ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++exec /usr/local/bin/python -m pytest /workspace/repo/usercase-test-coderl/test_recolor_session.py -v -o addopts= -p no:cacheprovider diff --git a/tasks/format-code-task-000377/tests/test.sh b/tasks/format-code-task-000377/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6b51a210f19d6bd4e0a2151f1889ea1ffec7cd32 --- /dev/null +++ b/tasks/format-code-task-000377/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_recolor_session.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000377/tests/test_command.sh b/tasks/format-code-task-000377/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000377/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000383/environment/Dockerfile b/tasks/format-code-task-000383/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..57c1ac07d41df4a8e7ab351ddf0c130911f804bb --- /dev/null +++ b/tasks/format-code-task-000383/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1750d6e290c921ad85a7a469871f44151cb6760a802df0c05ad16000271aa1ea diff --git a/tasks/format-code-task-000383/environment/setup/files/blocklist b/tasks/format-code-task-000383/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000383/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000383/environment/setup/setup.sh b/tasks/format-code-task-000383/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000383/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000383/tests/test.patch b/tasks/format-code-task-000383/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5b1c20c5665db3fcd00c6945dc5527d7c87ba37b --- /dev/null +++ b/tasks/format-code-task-000383/tests/test.patch @@ -0,0 +1,398 @@ +diff --git a/usercase-test-coderl/fixtures/quickfix_two_sessions.cfg b/usercase-test-coderl/fixtures/quickfix_two_sessions.cfg +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/quickfix_two_sessions.cfg +@@ -0,0 +1,47 @@ ++[DEFAULT] ++ConnectionType=initiator ++LogonTimeout=30 ++ReconnectInterval=30 ++ResetOnLogon=Y ++FileLogPath=/tmp ++UseLocalTime=N ++StartTime=00:00:00 ++EndTime=23:59:59 ++HeartBtInt=30 ++UseDataDictionary=Y ++DataDictionary=/workspace/repo/FIX44.xml ++FileStorePath=/tmp ++AllowUnknownMsgFields=Y ++ValidateUserDefinedFields=N ++PreserveMessageFieldsOrder=Y ++ ++[SESSION] ++BeginString=FIX.4.4 ++SenderCompID=******* ++Username=******* ++Password=******* ++TargetCompID=FIXUAT3-QUOTE.FORTEX.COM ++StartTime=00:00:00 ++EndTime=23:59:59 ++HeartBtInt=30 ++CheckLatency=N ++MaxLatency=240 ++SocketConnectPort=29993 ++SocketConnectHost=FIXUAT3-QUOTE.FORTEX.COM ++SessionQualifier=****** ++ ++[SESSION] ++BeginString=FIX.4.4 ++SenderCompID=***** ++Account=****** ++Username=****** ++Password=****** ++TargetCompID=FIXUAT3-TRADE.FORTEX.COM ++StartTime=00:00:00 ++EndTime=23:59:59 ++HeartBtInt=30 ++CheckLatency=N ++MaxLatency=240 ++SocketConnectPort=28174 ++SocketConnectHost=FIXUAT3-TRADE.FORTEX.COM ++SessionQualifier=****** +diff --git a/usercase-test-coderl/test_market_data_requests.py b/usercase-test-coderl/test_market_data_requests.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_market_data_requests.py +@@ -0,0 +1,319 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++from __future__ import annotations ++ ++import warnings ++ ++import pytest ++import quickfix as fix ++ ++warnings.filterwarnings("ignore", category=DeprecationWarning) ++ ++FIXTURES = "/workspace/repo/usercase-test-coderl/fixtures" ++QUOTE_SESSION = "FIX.4.4:*******->FIXUAT3-QUOTE.FORTEX.COM:******" ++QUOTE_TARGET = "FIXUAT3-QUOTE.FORTEX.COM" ++ ++ ++def _patch_quickfix_constants() -> None: ++ ++ ++ ++ if not hasattr(fix, "SubscriptionRequestType_SNAPSHOT_PLUS_UPDATES"): ++ fix.SubscriptionRequestType_SNAPSHOT_PLUS_UPDATES = "1" ++ if not hasattr( ++ fix, "SubscriptionRequestType_DISABLE_PREVIOUS_SNAPSHOT_PLUS_UPDATE_REQUEST" ++ ): ++ fix.SubscriptionRequestType_DISABLE_PREVIOUS_SNAPSHOT_PLUS_UPDATE_REQUEST = "2" ++ ++ ++_patch_quickfix_constants() ++ ++from fixapp import DataStream, FixDecoder, OrderStore, Tier1FXAuto # noqa: E402 ++ ++ ++def _settings() -> fix.SessionSettings: ++ return fix.SessionSettings(f"{FIXTURES}/quickfix_two_sessions.cfg") ++ ++ ++def _configured_client() -> Tier1FXAuto: ++ settings = _settings() ++ client = Tier1FXAuto(DataStream(), FixDecoder(), OrderStore(), settings) ++ for session_id in settings.getSessions(): ++ client.onCreate(session_id) ++ return client ++ ++ ++def _capture_send( ++ monkeypatch: pytest.MonkeyPatch, ++) -> list[tuple[fix.Message, object | None]]: ++ sent: list[tuple[fix.Message, object | None]] = [] ++ ++ def capture(message: fix.Message, session_id: object | None = None) -> bool: ++ sent.append((message, session_id)) ++ return True ++ ++ monkeypatch.setattr(fix.Session, "sendToTarget", capture) ++ return sent ++ ++ ++def _assert_sent_to_quote_session( ++ message: fix.Message, session_id: object | None ++) -> None: ++ if session_id is not None: ++ assert session_id.toString() == QUOTE_SESSION ++ return ++ ++ ++ assert message.getHeader().getField(56) == QUOTE_TARGET ++ ++ ++def _field_snapshot(message: fix.Message) -> dict[str, object]: ++ entry_group = fix.Group(267, 269) ++ entry_values: list[str] = [] ++ for index in (1, 2): ++ message.getGroup(index, entry_group) ++ entry_values.append(entry_group.getField(269)) ++ ++ symbol_group = fix.Group(146, 55) ++ message.getGroup(1, symbol_group) ++ ++ return { ++ "35": message.getHeader().getField(35), ++ "262": message.getField(262), ++ "263": message.getField(263), ++ "264": message.getField(264), ++ "265": message.getField(265), ++ "267": message.getField(267), ++ "269_groups": entry_values, ++ "146": message.getField(146), ++ "55_groups": [symbol_group.getField(55)], ++ } ++ ++ ++def _assert_market_data_request( ++ message: fix.Message, ++ *, ++ subscription_type: str, ++ market_depth: str = "1", ++ update_type: str = "0", ++ entry_count: str = "2", ++ symbol: str = "EUR/USD", ++) -> None: ++ snapshot = _field_snapshot(message) ++ ++ assert snapshot["35"] == "V" ++ ++ assert isinstance(snapshot["262"], str) and snapshot["262"].strip() != "" ++ assert snapshot["263"] == subscription_type ++ assert snapshot["264"] == market_depth ++ assert snapshot["265"] == update_type ++ assert snapshot["267"] == entry_count ++ ++ assert set(snapshot["269_groups"]) == {"0", "1"} ++ assert snapshot["146"] == "1" ++ assert snapshot["55_groups"] == [symbol] ++ ++ ++def test_subscribe_to_data_sends_default_market_data_request(monkeypatch): ++ ++ ++ ++ ++ client = _configured_client() ++ sent = _capture_send(monkeypatch) ++ ++ client.subscribe_to_data(**{"55": "EUR/USD"}) ++ ++ assert len(sent) == 1 ++ message, session_id = sent[0] ++ _assert_sent_to_quote_session(message, session_id) ++ ++ _assert_market_data_request(message, subscription_type="1", symbol="EUR/USD") ++ ++ ++def test_unsubscribe_to_data_sends_disable_request(monkeypatch): ++ ++ ++ ++ ++ client = _configured_client() ++ sent = _capture_send(monkeypatch) ++ ++ client.unsubscribe_to_data(**{"55": "EUR/USD"}) ++ ++ assert len(sent) == 1 ++ message, session_id = sent[0] ++ _assert_sent_to_quote_session(message, session_id) ++ ++ _assert_market_data_request(message, subscription_type="2", symbol="EUR/USD") ++ ++ ++def test_subscribe_omitted_symbol_defaults_to_eur_usd(monkeypatch): ++ ++ ++ ++ ++ client = _configured_client() ++ sent = _capture_send(monkeypatch) ++ ++ client.subscribe_to_data() ++ ++ assert len(sent) == 1 ++ message, session_id = sent[0] ++ _assert_sent_to_quote_session(message, session_id) ++ ++ _assert_market_data_request(message, subscription_type="1", symbol="EUR/USD") ++ ++ ++def test_subscribe_reflects_market_data_option_overrides(monkeypatch): ++ ++ ++ ++ ++ client = _configured_client() ++ sent = _capture_send(monkeypatch) ++ ++ client.subscribe_to_data(**{"55": "GBP/USD", "264": "0", "267": "2", "265": 1}) ++ ++ assert len(sent) == 1 ++ message, session_id = sent[0] ++ _assert_sent_to_quote_session(message, session_id) ++ ++ _assert_market_data_request( ++ message, ++ subscription_type="1", ++ market_depth="0", ++ update_type="1", ++ entry_count="2", ++ symbol="GBP/USD", ++ ) ++ ++ ++def test_same_client_advances_generated_market_data_request_ids(monkeypatch): ++ ++ ++ ++ ++ client = _configured_client() ++ sent = _capture_send(monkeypatch) ++ ++ client.subscribe_to_data(**{"55": "EUR/USD"}) ++ client.unsubscribe_to_data(**{"55": "EUR/USD"}) ++ client.subscribe_to_data(**{"55": "GBP/USD"}) ++ ++ assert len(sent) == 3 ++ ++ generated_ids = [message.getField(262) for message, _ in sent] ++ assert all(value.strip() for value in generated_ids) ++ assert len(set(generated_ids)) == len(generated_ids) ++ assert [message.getField(263) for message, _ in sent] == ["1", "2", "1"] ++ symbols = [] ++ for message, _ in sent: ++ symbol_group = fix.Group(146, 55) ++ message.getGroup(1, symbol_group) ++ symbols.append(symbol_group.getField(55)) ++ assert symbols == [ ++ "EUR/USD", ++ "EUR/USD", ++ "GBP/USD", ++ ] ++ ++ ++@pytest.mark.parametrize("method_name", ["subscribe_to_data", "unsubscribe_to_data"]) ++@pytest.mark.parametrize("bad_kwargs", [{"264": "not-an-int"}, {"267": "not-an-int"}]) ++def test_non_integer_market_data_counts_raise_value_error_without_send( ++ monkeypatch, method_name, bad_kwargs ++): ++ ++ ++ ++ ++ client = _configured_client() ++ sent = _capture_send(monkeypatch) ++ ++ with pytest.raises(ValueError): ++ getattr(client, method_name)(**bad_kwargs) ++ ++ assert sent == [] ++ ++ ++def test_configured_client_exposes_public_market_data_methods(): ++ ++ ++ ++ ++ client = _configured_client() ++ ++ ++ assert callable(getattr(client, "subscribe_to_data", None)) ++ assert callable(getattr(client, "unsubscribe_to_data", None)) ++ ++ ++def test_two_configured_clients_emit_generated_market_data_request_ids(monkeypatch): ++ ++ ++ ++ ++ client_a = _configured_client() ++ client_b = _configured_client() ++ sent = _capture_send(monkeypatch) ++ ++ client_a.subscribe_to_data(**{"55": "EUR/USD"}) ++ client_a.subscribe_to_data(**{"55": "EUR/USD"}) ++ client_b.subscribe_to_data(**{"55": "EUR/USD"}) ++ ++ assert len(sent) == 3 ++ ++ generated_ids = [message.getField(262) for message, _ in sent] ++ assert all(value.strip() for value in generated_ids) ++ ++ ++def test_unsubscribe_reflects_market_data_option_overrides(monkeypatch): ++ ++ ++ ++ ++ client = _configured_client() ++ sent = _capture_send(monkeypatch) ++ ++ client.unsubscribe_to_data(**{"55": "GBP/USD", "264": "0", "267": "2", "265": 1}) ++ ++ assert len(sent) == 1 ++ message, session_id = sent[0] ++ _assert_sent_to_quote_session(message, session_id) ++ ++ _assert_market_data_request( ++ message, ++ subscription_type="2", ++ market_depth="0", ++ update_type="1", ++ entry_count="2", ++ symbol="GBP/USD", ++ ) ++ ++ ++def test_repeated_construct_use_cycles_send_one_market_data_request_each(monkeypatch): ++ ++ ++ ++ ++ sent = _capture_send(monkeypatch) ++ ++ for _ in range(10): ++ client = _configured_client() ++ before = len(sent) ++ client.subscribe_to_data(**{"55": "EUR/USD"}) ++ assert len(sent) == before + 1 ++ message, session_id = sent[-1] ++ _assert_sent_to_quote_session(message, session_id) ++ ++ _assert_market_data_request(message, subscription_type="1", symbol="EUR/USD") ++ ++ assert len(sent) == 10 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,17 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_market_data_requests.py -v diff --git a/tasks/format-code-task-000383/tests/test.sh b/tasks/format-code-task-000383/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ab766f43812efdfa81bb0eed933a93b232b50099 --- /dev/null +++ b/tasks/format-code-task-000383/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/quickfix_two_sessions.cfg +usercase-test-coderl/test_market_data_requests.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000383/tests/test_command.sh b/tasks/format-code-task-000383/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000383/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000384/environment/Dockerfile b/tasks/format-code-task-000384/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5aa73cc005db209870d53308cd8b71aad2f9fef7 --- /dev/null +++ b/tasks/format-code-task-000384/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:49371a9b01742ddf2126d5e33e4cabc355db4bb9f4436e05b3f3f4dbf70b383d diff --git a/tasks/format-code-task-000384/environment/setup/files/blocklist b/tasks/format-code-task-000384/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000384/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000384/environment/setup/setup.sh b/tasks/format-code-task-000384/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000384/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000384/tests/test.patch b/tasks/format-code-task-000384/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..20fc8dbf0fc28d0ac18bef6214de4a859ecabbb1 --- /dev/null +++ b/tasks/format-code-task-000384/tests/test.patch @@ -0,0 +1,78 @@ +diff --git a/server/server/upstream/server_integration_test.go b/server/server/upstream/server_integration_test.go +index 2b76a25b..966dbf82 100644 +--- a/server/server/upstream/server_integration_test.go ++++ b/server/server/upstream/server_integration_test.go +@@ -9,7 +9,7 @@ import ( + "testing" + "time" + +- "github.com/andydunstall/piko/pkg/conn" ++ "github.com/andydunstall/piko/pkg/conn/websocket" + "github.com/andydunstall/piko/pkg/log" + "github.com/andydunstall/piko/pkg/rpc" + "github.com/andydunstall/piko/server/auth" +@@ -70,7 +70,7 @@ func TestServer_AddConn(t *testing.T) { + upstreamLn.Addr().String(), + ) + rpcServer := newRPCServer() +- conn, err := conn.DialWebsocket(context.TODO(), url, "") ++ conn, err := websocket.Dial(context.TODO(), url) + require.NoError(t, err) + + // Add client stream and ensure upstream added to proxy. +@@ -113,7 +113,7 @@ func TestServer_AddConn(t *testing.T) { + upstreamLn.Addr().String(), + ) + rpcServer := newRPCServer() +- conn, err := conn.DialWebsocket(context.TODO(), url, "123") ++ conn, err := websocket.Dial(context.TODO(), url, websocket.WithToken("123")) + require.NoError(t, err) + + // Add client stream and ensure upstream added to proxy. +@@ -157,7 +157,7 @@ func TestServer_AddConn(t *testing.T) { + upstreamLn.Addr().String(), + ) + rpcServer := newRPCServer() +- conn, err := conn.DialWebsocket(context.TODO(), url, "123") ++ conn, err := websocket.Dial(context.TODO(), url, websocket.WithToken("123")) + require.NoError(t, err) + + // Add client stream and ensure upstream added to proxy. +@@ -199,7 +199,7 @@ func TestServer_AddConn(t *testing.T) { + "ws://%s/piko/v1/listener/my-endpoint", + upstreamLn.Addr().String(), + ) +- _, err = conn.DialWebsocket(context.TODO(), url, "123") ++ _, err = websocket.Dial(context.TODO(), url, websocket.WithToken("123")) + require.Error(t, err) + }) + +@@ -229,7 +229,7 @@ func TestServer_AddConn(t *testing.T) { + "ws://%s/piko/v1/listener/my-endpoint", + upstreamLn.Addr().String(), + ) +- _, err = conn.DialWebsocket(context.TODO(), url, "123") ++ _, err = websocket.Dial(context.TODO(), url, websocket.WithToken("123")) + require.Error(t, err) + }) + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RQQrCMBAF0Kw9xVygaRJMu/IsEttQCzaRZNrzWwuiCOpGEfG/zR9IIBO+3I39 ++od36MJXiU9SstnbJ2X0us7ZGmdpUpl4LpXWllSD7sY1ujJldIhIpRn5279X5j5LX/tln3jZxGFxo ++Zd6/741X/WtdX/q3lTJz/+tKW0HqfSs89uf9Ny0txe98u+oinUcq2HWZ+sC+S477GKiYqGjiGHij ++SZbZp8mnS4zHzMm7oZRSrr79HQAAAAAAAAAAAAAAAAAAAACAv3ICCSbpeAAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000384/tests/test.sh b/tasks/format-code-task-000384/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ffd8b18f8bb8cdbeee7f6f0495beb877f8a84e4b --- /dev/null +++ b/tasks/format-code-task-000384/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +server/server/upstream/server_integration_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000384/tests/test_command.sh b/tasks/format-code-task-000384/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000384/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000385/environment/Dockerfile b/tasks/format-code-task-000385/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..dd4300dc37589b1279d6308063262a567df3e285 --- /dev/null +++ b/tasks/format-code-task-000385/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2684dd35d2427cc1a8553cfe2ccd1a5b55c0eef74213c7eb5b3aa5556f4249f0 diff --git a/tasks/format-code-task-000385/environment/setup/files/blocklist b/tasks/format-code-task-000385/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000385/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000385/environment/setup/setup.sh b/tasks/format-code-task-000385/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000385/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000385/tests/test.patch b/tasks/format-code-task-000385/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8b9563f28c66dd2b3b115b43b191b45bcda1a1e7 --- /dev/null +++ b/tasks/format-code-task-000385/tests/test.patch @@ -0,0 +1,85 @@ +diff --git a/pkg/md/jirawiki/parser_test.go b/pkg/md/jirawiki/parser_test.go +index 88c70be1..e9a23229 100644 +--- a/pkg/md/jirawiki/parser_test.go ++++ b/pkg/md/jirawiki/parser_test.go +@@ -111,6 +111,11 @@ func TestParseTextEffectTags(t *testing.T) { + input: "Line with *bold and _italic text.", + expected: "Line with **bold and _italic text.**\n", + }, ++ { ++ name: "normal sentence with braces and semicolon should be parsed as is", ++ input: "Line with semicolon inside curly braces {{MySQL::Conn()}}.", ++ expected: "Line with semicolon inside curly braces {{MySQL::Conn()}}.", ++ }, + } + + for _, tc := range cases { +@@ -503,6 +508,48 @@ fn main() { + } + ` + "```\n", + }, ++ { ++ name: "Back to back fenced code block in the list should render properly", ++ input: `1. Ordered list item A ++{code:go} ++package main ++ ++func main() { ++ println("Hello, World!") ++}{code} ++ ++2. Ordered list item B ++{code:go} ++// no code ++{code}`, ++ expected: "1. Ordered list item A\n\n```go" + ` ++package main ++ ++func main() { ++ println("Hello, World!") ++}` + "\n```\n\n2. Ordered list item B\n\n```go\n// no code" + "\n```\n", ++ }, ++ { ++ name: "Back to back preformatted block in the list should render properly", ++ input: `1. Ordered list item A ++{noformat} ++package main ++ ++func main() { ++ println("Hello, World!") ++}{noformat} ++ ++2. Ordered list item B ++{noformat} ++// no code ++{noformat}`, ++ expected: "1. Ordered list item A\n\n```" + ` ++package main ++ ++func main() { ++ println("Hello, World!") ++}` + "\n```\n\n2. Ordered list item B\n\n```\n// no code" + "\n```\n", ++ }, + } + + for _, tc := range cases { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RwQqCQBDGcc89xbxArmupp54lzJWy0g1d6/XbJCqC6lJE9P8ddgZmYAe+cNFX ++WzMvm70KPiXysiQZqndfh14nsY5jnWnt9/yTpYEkH7voRt+5vBUJWmvds71X8x8VXvN3Zefmha3r ++vDFht3rfHy/zTyeX/KM48/lPUz0JJHrfCY/9ef6FkSH4RWlGSyunVkK12yxVbdS6avNDtamUjPcy ++LmzfuJkefftkAAAAAAAAAAAAAAAAAGdHlgZkdwAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000385/tests/test.sh b/tasks/format-code-task-000385/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..51aa3784d5b57ff2d66c20bd4eff9fcbf3b51b9f --- /dev/null +++ b/tasks/format-code-task-000385/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/md/jirawiki/parser_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000385/tests/test_command.sh b/tasks/format-code-task-000385/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000385/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000511/environment/Dockerfile b/tasks/format-code-task-000511/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..81db7338e2391512a06ecc8452aef174072f7d05 --- /dev/null +++ b/tasks/format-code-task-000511/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d4e57a04bd7d544df911b90f54d01364a426dd045d1d59a98ea24b078feb59f7 diff --git a/tasks/format-code-task-000511/environment/setup/files/blocklist b/tasks/format-code-task-000511/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000511/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000511/environment/setup/setup.sh b/tasks/format-code-task-000511/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000511/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000511/tests/test.patch b/tasks/format-code-task-000511/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5e5b199798d03d86565929a9e9e459f0eef3e666 --- /dev/null +++ b/tasks/format-code-task-000511/tests/test.patch @@ -0,0 +1,135 @@ +diff --git a/tests/config/test_config.py b/tests/config/test_config.py +index 532bdc4..d4c559d 100644 +--- a/tests/config/test_config.py ++++ b/tests/config/test_config.py +@@ -23,6 +23,7 @@ def test_can_get_config_from_environment(monkeypatch): + agent_endpoint = fake.word() + ec2_metadata_endpoint = fake.word() + namespace = fake.word() ++ disable_metric_extraction = True + + monkeypatch.setenv("AWS_EMF_ENABLE_DEBUG_LOGGING", str(debug_enabled)) + monkeypatch.setenv("AWS_EMF_SERVICE_NAME", service_name) +@@ -32,6 +33,7 @@ def test_can_get_config_from_environment(monkeypatch): + monkeypatch.setenv("AWS_EMF_AGENT_ENDPOINT", agent_endpoint) + monkeypatch.setenv("AWS_EMF_EC2_METADATA_ENDPOINT", ec2_metadata_endpoint) + monkeypatch.setenv("AWS_EMF_NAMESPACE", namespace) ++ monkeypatch.setenv("AWS_EMF_DISABLE_METRIC_EXTRACTION", str(disable_metric_extraction)) + + # act + result = get_config() +@@ -45,6 +47,7 @@ def test_can_get_config_from_environment(monkeypatch): + assert result.agent_endpoint == agent_endpoint + assert result.ec2_metadata_endpoint == ec2_metadata_endpoint + assert result.namespace == namespace ++ assert result.disable_metric_extraction == disable_metric_extraction + + + def test_can_override_config(monkeypatch): +@@ -57,6 +60,7 @@ def test_can_override_config(monkeypatch): + monkeypatch.setenv("AWS_EMF_AGENT_ENDPOINT", fake.word()) + monkeypatch.setenv("AWS_EMF_EC2_METADATA_ENDPOINT", fake.word()) + monkeypatch.setenv("AWS_EMF_NAMESPACE", fake.word()) ++ monkeypatch.setenv("AWS_EMF_DISABLE_METRIC_EXTRACTION", str(True)) + + config = get_config() + +@@ -68,6 +72,7 @@ def test_can_override_config(monkeypatch): + agent_endpoint = fake.word() + ec2_metadata_endpoint = fake.word() + namespace = fake.word() ++ disable_metric_extraction = False + + # act + config.debug_logging_enabled = debug_enabled +@@ -78,6 +83,7 @@ def test_can_override_config(monkeypatch): + config.agent_endpoint = agent_endpoint + config.ec2_metadata_endpoint = ec2_metadata_endpoint + config.namespace = namespace ++ config.disable_metric_extraction = disable_metric_extraction + + # assert + assert config.debug_logging_enabled == debug_enabled +@@ -88,3 +94,4 @@ def test_can_override_config(monkeypatch): + assert config.agent_endpoint == agent_endpoint + assert config.ec2_metadata_endpoint == ec2_metadata_endpoint + assert config.namespace == namespace ++ assert config.disable_metric_extraction == disable_metric_extraction +diff --git a/tests/serializer/test_log_serializer.py b/tests/serializer/test_log_serializer.py +index 2d7c05f..32795f7 100644 +--- a/tests/serializer/test_log_serializer.py ++++ b/tests/serializer/test_log_serializer.py +@@ -1,3 +1,4 @@ ++from aws_embedded_metrics.config import get_config + from aws_embedded_metrics.logger.metrics_context import MetricsContext + from aws_embedded_metrics.serializers.log_serializer import LogSerializer + from faker import Faker +@@ -177,6 +178,27 @@ def test_serialize_metrics_with_multiple_datapoints(): + assert results == [json.dumps(expected)] + + ++def test_serialize_metrics_with_aggregation_disabled(): ++ """Test log records don't contain metadata when aggregation is disabled.""" ++ ++ config = get_config() ++ config.disable_metric_extraction = True ++ ++ expected_key = fake.word() ++ expected_value = fake.random.randrange(0, 100) ++ ++ expected = {expected_key: expected_value} ++ ++ context = get_context() ++ context.put_metric(expected_key, expected_value) ++ ++ ++ result_json = serializer.serialize(context)[0] ++ ++ ++ assert_json_equality(result_json, expected) ++ ++ + # Test utility method + + +diff --git a/tests/sinks/test_lambda_sink.py b/tests/sinks/test_lambda_sink.py +index 2856c49..79aeb84 100644 +--- a/tests/sinks/test_lambda_sink.py ++++ b/tests/sinks/test_lambda_sink.py +@@ -1,3 +1,6 @@ ++from importlib import reload ++ ++from aws_embedded_metrics import config + from aws_embedded_metrics.sinks.lambda_sink import LambdaSink + from aws_embedded_metrics.logger.metrics_context import MetricsContext + from faker import Faker +@@ -9,6 +12,8 @@ + + def test_accept_writes_to_stdout(capfd): + # arrange ++ reload(config) ++ + sink = LambdaSink() + context = MetricsContext.empty() + context.meta["Timestamp"] = 1 +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3S0W6DIBQGYK/7FOcFtMAGPo5BoS2ZQiO0Sff0Q9uty5LOmzbbsv+7gBPwBMJv ++1R5cbxrrj+viUVhWSznP2dd5rrkUXDClhKwLxrlidUHyYTf65BCTHomKMYT03XdL+39Udc0/2Zia ++LgyD9qaKu/udsZS/UOojf654zv9ZCV4Qu98Vbvvn+XeG5uBba1bRJirtan9Ku+CfqBwol3mPpiGu ++u+A3bvv+m0x1tT9RebzZEO3odO9e7Xhu6sO2ua4tNTv/Ei99emiNbqaVS9NPvxoAAAAAAAAAAAAA ++AAAAAAAAwO/wBnyaq+EAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000511/tests/test.sh b/tasks/format-code-task-000511/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d98fed6251aef2f94f48b50d07a63310e23a22fd --- /dev/null +++ b/tasks/format-code-task-000511/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/config/test_config.py +tests/serializer/test_log_serializer.py +tests/sinks/test_lambda_sink.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000511/tests/test_command.sh b/tasks/format-code-task-000511/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000511/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000519/environment/Dockerfile b/tasks/format-code-task-000519/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..37efcda2755c2ec696d9d8ddd45bab76501ad91d --- /dev/null +++ b/tasks/format-code-task-000519/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8075c3c8e471b069495bf5bba1ef9a4160cfc3a1a4012ee13297ac9149c43a7b diff --git a/tasks/format-code-task-000519/environment/setup/files/blocklist b/tasks/format-code-task-000519/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000519/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000519/environment/setup/setup.sh b/tasks/format-code-task-000519/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000519/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000519/tests/test.patch b/tasks/format-code-task-000519/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a9f7a8fb61fe8e7150815e8d3ee89c5b3c97484c --- /dev/null +++ b/tasks/format-code-task-000519/tests/test.patch @@ -0,0 +1,395 @@ +diff --git a/usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/__init__.py b/usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/__init__.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/__init__.py +@@ -0,0 +1,6 @@ ++def register_plugin(registry): ++ registry.set_plugin_version('rastervision.acceptance_local_runner', 0) ++ ++ ++import rastervision.pipeline # noqa ++import rastervision.acceptance_local_runner.pipeline # noqa +diff --git a/usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/config.py b/usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/config.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/config.py +@@ -0,0 +1,7 @@ ++from rastervision.acceptance_local_runner.pipeline import ( ++ AcceptancePipelineConfig) ++ ++ ++def get_config(runner, root_uri, fail_command=''): ++ return AcceptancePipelineConfig( ++ root_uri=root_uri, fail_command=fail_command) +diff --git a/usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/pipeline.py b/usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/pipeline.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/pipeline.py +@@ -0,0 +1,48 @@ ++from os.path import join ++import os ++ ++from rastervision.pipeline.config import register_config ++from rastervision.pipeline.pipeline import Pipeline ++from rastervision.pipeline.pipeline_config import PipelineConfig ++ ++ ++@register_config( ++ 'acceptance_local_runner.pipeline', ++ plugin='rastervision.acceptance_local_runner') ++class AcceptancePipelineConfig(PipelineConfig): ++ event_log_uri: str | None = None ++ fail_command: str = '' ++ ++ def update(self): ++ if self.event_log_uri is None: ++ self.event_log_uri = join(self.root_uri, 'events.log') ++ ++ def build(self, tmp_dir): ++ return AcceptancePipeline(self, tmp_dir) ++ ++ ++class AcceptancePipeline(Pipeline): ++ commands = ['chip', 'train', 'predict', 'package'] ++ split_commands = ['chip', 'predict'] ++ gpu_commands = [] ++ ++ def _record(self, command, split_ind=0, num_splits=1): ++ if self.config.fail_command == command: ++ raise RuntimeError(f'intentional failure in {command}') ++ ++ os.makedirs(os.path.dirname(self.config.event_log_uri), exist_ok=True) ++ with open(self.config.event_log_uri, 'a') as f: ++ f.write(f'{command}|{split_ind}|{num_splits}\n') ++ print(f'event {command} {split_ind}/{num_splits}') ++ ++ def chip(self, split_ind=0, num_splits=1): ++ self._record('chip', split_ind, num_splits) ++ ++ def train(self): ++ self._record('train') ++ ++ def predict(self, split_ind=0, num_splits=1): ++ self._record('predict', split_ind, num_splits) ++ ++ def package(self): ++ self._record('package') +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,294 @@ ++#!/usr/bin/env bash ++ ++set -u ++set -o pipefail ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++export PYTHONDONTWRITEBYTECODE=1 ++export PYTHONPATH="/workspace/repo/usercase-test-coderl/fixtures:/workspace/repo/rastervision_pipeline${PYTHONPATH:+:$PYTHONPATH}" ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++( cd /workspace/repo && python - <<'PY' ++import rastervision.pipeline.cli ++PY ++) || fail "build" ++ ++REAL_MAKE=$(command -v make) || fail "make not found" ++RUN_ROOT=/tmp/rv-local-runner-acceptance-coderl ++rm -rf "$RUN_ROOT" ++mkdir -p "$RUN_ROOT/bin" ++trap 'rm -rf "$RUN_ROOT"' EXIT ++ ++cat > "$RUN_ROOT/bin/make" <<'EOF' ++#!/usr/bin/env bash ++{ ++ printf 'argc=%s\n' "$#" ++ i=0 ++ for arg in "$@"; do ++ printf 'arg%d=%s\n' "$i" "$arg" ++ i=$((i + 1)) ++ done ++} >> "$ACCEPTANCE_MAKE_LOG" ++ ++if [ "${ACCEPTANCE_FORCE_MAKE_FAIL:-}" != "" ]; then ++ echo "forced make failure $ACCEPTANCE_FORCE_MAKE_FAIL" >&2 ++ exit "$ACCEPTANCE_FORCE_MAKE_FAIL" ++fi ++ ++exec "$ACCEPTANCE_REAL_MAKE" "$@" ++EOF ++chmod +x "$RUN_ROOT/bin/make" ++ ++export PATH="$RUN_ROOT/bin:$PATH" ++export ACCEPTANCE_REAL_MAKE="$REAL_MAKE" ++ ++run_rv() { ++ python -m rastervision.pipeline.cli --tmpdir "$RUN_ROOT/tmp" "$@" ++} ++ ++assert_file_eq() { ++ local actual=$1 ++ local expected=$2 ++ cmp -s "$actual" "$expected" || { ++ echo "FAIL: $actual differs from expected" >&2 ++ echo "--- actual ---" >&2 ++ sed -n '1,240p' "$actual" >&2 ++ echo "--- expected ---" >&2 ++ sed -n '1,240p' "$expected" >&2 ++ exit 1 ++ } ++} ++ ++assert_makefile_shape() { ++ local makefile=$1 ++ local scenario=$2 ++ local cfg_json_uri=$3 ++ python - "$makefile" "$scenario" "$cfg_json_uri" <<'PY' ++import sys ++ ++makefile, scenario, cfg_json_uri = sys.argv[1:4] ++ ++with open(makefile) as f: ++ lines = [line.rstrip('\n') for line in f] ++ ++phony = None ++all_targets = None ++targets = {} ++i = 0 ++while i < len(lines): ++ line = lines[i] ++ if line.startswith('.PHONY:'): ++ phony = line.split(':', 1)[1].split() ++ i += 1 ++ continue ++ if line.startswith('all:'): ++ all_targets = line.split(':', 1)[1].split() ++ i += 1 ++ continue ++ if ':' in line and not line.startswith('\t') and line.strip(): ++ target, deps = line.split(':', 1) ++ recipe = None ++ j = i + 1 ++ while j < len(lines): ++ if lines[j].startswith('\t'): ++ recipe = lines[j][1:] ++ break ++ if lines[j].strip() and ':' in lines[j] and not lines[j].startswith('\t'): ++ break ++ j += 1 ++ targets[target.strip()] = { ++ 'deps': deps.split(), ++ 'recipe': recipe, ++ } ++ i = j + 1 ++ continue ++ i += 1 ++ ++expected_by_scenario = { ++ 'f1': [ ++ ('chip', [], {'--num-splits': '2', '--split-ind': '0'}), ++ ('chip', [], {'--num-splits': '2', '--split-ind': '1'}), ++ ('train', ['chip:0', 'chip:1'], {}), ++ ('predict', ['train'], {'--num-splits': '2', '--split-ind': '0'}), ++ ('predict', ['train'], {'--num-splits': '2', '--split-ind': '1'}), ++ ], ++ 'f2': [ ++ ('chip', [], {}), ++ ('train', ['chip'], {}), ++ ('predict', ['train'], {}), ++ ('package', ['predict'], {}), ++ ], ++ 'f3': [ ++ ('package', [], {}), ++ ], ++} ++ ++expected = expected_by_scenario[scenario] ++target_names = set(targets) ++if phony is None: ++ raise SystemExit('missing .PHONY target list') ++if all_targets is None: ++ raise SystemExit('missing all target') ++if set(phony) != target_names: ++ raise SystemExit(f'.PHONY does not list exactly the numeric job targets: {phony} vs {sorted(target_names)}') ++if set(all_targets) != target_names: ++ raise SystemExit(f'all target does not depend on every job target: {all_targets} vs {sorted(target_names)}') ++if len(targets) != len(expected): ++ raise SystemExit(f'expected {len(expected)} job targets, found {len(targets)}') ++if any(not target.isdigit() for target in targets): ++ raise SystemExit(f'all job targets must be numeric, found {sorted(targets)}') ++ ++def parse_recipe(recipe): ++ if recipe is None: ++ raise SystemExit('target missing recipe') ++ prefix = f'python -m rastervision.pipeline.cli run_command {cfg_json_uri} ' ++ if not recipe.startswith(prefix): ++ raise SystemExit(f'recipe has wrong run_command shape: {recipe}') ++ parts = recipe[len(prefix):].split() ++ if not parts: ++ raise SystemExit(f'recipe missing command: {recipe}') ++ command = parts[0] ++ opts = {} ++ rest = parts[1:] ++ if len(rest) % 2 != 0: ++ raise SystemExit(f'recipe has malformed options: {recipe}') ++ for opt, value in zip(rest[::2], rest[1::2]): ++ opts[opt] = value ++ return command, opts ++ ++recipe_to_target = {} ++command_targets = {} ++for target, data in targets.items(): ++ command, opts = parse_recipe(data['recipe']) ++ split_key = opts.get('--split-ind') ++ key = f'{command}:{split_key}' if split_key is not None else command ++ if key in recipe_to_target: ++ raise SystemExit(f'duplicate recipe for {key}') ++ recipe_to_target[key] = target ++ command_targets.setdefault(command, []).append(target) ++ ++expected_keys = { ++ f'{command}:{opts["--split-ind"]}' if '--split-ind' in opts else command ++ for command, _deps, opts in expected ++} ++if set(recipe_to_target) != expected_keys: ++ raise SystemExit(f'recipes do not match expected command jobs: {sorted(recipe_to_target)} vs {sorted(expected_keys)}') ++ ++for command, dep_specs, opts in expected: ++ key = f'{command}:{opts["--split-ind"]}' if '--split-ind' in opts else command ++ target = recipe_to_target[key] ++ actual_command, actual_opts = parse_recipe(targets[target]['recipe']) ++ if actual_command != command or actual_opts != opts: ++ raise SystemExit(f'{key} recipe options mismatch: {actual_command} {actual_opts} vs {opts}') ++ ++ expected_deps = set() ++ for dep_spec in dep_specs: ++ if ':' in dep_spec: ++ expected_deps.add(recipe_to_target[dep_spec]) ++ else: ++ expected_deps.update(command_targets[dep_spec]) ++ actual_deps = set(targets[target]['deps']) ++ if actual_deps != expected_deps: ++ raise SystemExit(f'{key} dependency mismatch: {actual_deps} vs {expected_deps}') ++PY ++} ++ ++cd "$RUN_ROOT" ++ ++ ++ ++ ++mkdir -p f1 ++export ACCEPTANCE_MAKE_LOG="$RUN_ROOT/f1/make.log" ++unset ACCEPTANCE_FORCE_MAKE_FAIL ++run_rv run local rastervision.acceptance_local_runner.config chip train predict \ ++ --splits 2 -a root_uri "$RUN_ROOT/f1/out" >f1/out.txt 2>f1/err.txt ++ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++[ -f "$RUN_ROOT/f1/out/pipeline-config.json" ] || fail "F1 missing serialized pipeline config" ++[ -f "$RUN_ROOT/f1/out/Makefile" ] || fail "F1 missing Makefile next to serialized config" ++ ++ ++assert_makefile_shape "$RUN_ROOT/f1/out/Makefile" f1 "$RUN_ROOT/f1/out/pipeline-config.json" ++ ++cat > f1/expected_make_log <<'EOF' ++argc=3 ++arg0=-j ++arg1=-f ++arg2=/tmp/rv-local-runner-acceptance-coderl/f1/out/Makefile ++EOF ++assert_file_eq "$ACCEPTANCE_MAKE_LOG" f1/expected_make_log ++ ++sort "$RUN_ROOT/f1/out/events.log" > f1/events.sorted ++cat > f1/expected_events <<'EOF' ++chip|0|2 ++chip|1|2 ++predict|0|2 ++predict|1|2 ++train|0|1 ++EOF ++assert_file_eq f1/events.sorted f1/expected_events ++ ++grep -Fq 'train|0|1' f1/events.sorted \ ++ || fail "F1 selected non-split stage did not run" ++ ++ ++ ++ ++mkdir -p f2 ++export ACCEPTANCE_MAKE_LOG="$RUN_ROOT/f2/make.log" ++unset ACCEPTANCE_FORCE_MAKE_FAIL ++run_rv run local rastervision.acceptance_local_runner.config chip train predict package \ ++ --splits 1 -a root_uri "$RUN_ROOT/f2/out" >f2/out.txt 2>f2/err.txt ++ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++ ++ ++assert_makefile_shape "$RUN_ROOT/f2/out/Makefile" f2 "$RUN_ROOT/f2/out/pipeline-config.json" ++ ++cat > f2/expected_make_log <<'EOF' ++argc=3 ++arg0=-j ++arg1=-f ++arg2=/tmp/rv-local-runner-acceptance-coderl/f2/out/Makefile ++EOF ++assert_file_eq "$ACCEPTANCE_MAKE_LOG" f2/expected_make_log ++ ++sort "$RUN_ROOT/f2/out/events.log" > f2/events.sorted ++cat > f2/expected_events <<'EOF' ++chip|0|1 ++package|0|1 ++predict|0|1 ++train|0|1 ++EOF ++assert_file_eq f2/events.sorted f2/expected_events ++ ++grep -Fq 'package|0|1' f2/events.sorted \ ++ || fail "F2 package command did not run" ++ ++ ++ ++ ++mkdir -p f3 ++export ACCEPTANCE_MAKE_LOG="$RUN_ROOT/f3/make.log" ++export ACCEPTANCE_FORCE_MAKE_FAIL=17 ++run_rv run local rastervision.acceptance_local_runner.config package \ ++ --splits 1 -a root_uri "$RUN_ROOT/f3/out" >f3/out.txt 2>f3/err.txt ++ec=$? ++[ "$ec" -eq 17 ] || fail "F3 exit $ec; want propagated make exit 17" ++ ++ ++ ++assert_makefile_shape "$RUN_ROOT/f3/out/Makefile" f3 "$RUN_ROOT/f3/out/pipeline-config.json" ++ ++cat > f3/expected_make_log <<'EOF' ++argc=3 ++arg0=-j ++arg1=-f ++arg2=/tmp/rv-local-runner-acceptance-coderl/f3/out/Makefile ++EOF ++assert_file_eq "$ACCEPTANCE_MAKE_LOG" f3/expected_make_log ++[ ! -e "$RUN_ROOT/f3/out/events.log" ] || fail "F3 should not run package after forced make failure" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,15 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export PATH="/opt/stage4a_rv_venv/bin:$PATH" ++export PYTHONNOUSERSITE=1 ++unset PYTHONPATH ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000519/tests/test.sh b/tasks/format-code-task-000519/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e46829b8b06438b95b59875bc9f5d354c36badfe --- /dev/null +++ b/tasks/format-code-task-000519/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/__init__.py +usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/config.py +usercase-test-coderl/fixtures/rastervision/acceptance_local_runner/pipeline.py +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000519/tests/test_command.sh b/tasks/format-code-task-000519/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000519/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000521/environment/Dockerfile b/tasks/format-code-task-000521/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d8348d283c8dfcc7278e7c6288982d1d754affce --- /dev/null +++ b/tasks/format-code-task-000521/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:255748b322c2a66f1828bddd436dee8a4ad459b3eb275bf09cc17a6063333c48 diff --git a/tasks/format-code-task-000521/environment/setup/files/blocklist b/tasks/format-code-task-000521/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000521/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000521/environment/setup/setup.sh b/tasks/format-code-task-000521/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000521/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000521/tests/test.patch b/tasks/format-code-task-000521/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..46930a37a75a9255c98c6b5b2c0bff908befc95f --- /dev/null +++ b/tasks/format-code-task-000521/tests/test.patch @@ -0,0 +1,325 @@ +diff --git a/usercase-test-coderl/fixtures/rc_fixture_defaults/__init__.py b/usercase-test-coderl/fixtures/rc_fixture_defaults/__init__.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/rc_fixture_defaults/__init__.py +@@ -0,0 +1,1 @@ ++ +diff --git a/usercase-test-coderl/fixtures/rc_fixture_defaults/rcparams.default b/usercase-test-coderl/fixtures/rc_fixture_defaults/rcparams.default +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/rc_fixture_defaults/rcparams.default +@@ -0,0 +1,7 @@ ++# Fixture rc defaults for write_RC_file formatting coverage. ++ ++###***START OF RC DEFINITION***### ++# Fixture Parameters ++'fixture.enabled' : [True | validate_boolean] # inline switch ++ ++'fixture.count' : [7 | validate_int] +diff --git a/usercase-test-coderl/fixtures/seed_11111.pyabmrc b/usercase-test-coderl/fixtures/seed_11111.pyabmrc +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/seed_11111.pyabmrc +@@ -0,0 +1,1 @@ ++random_seed : 11111 +diff --git a/usercase-test-coderl/fixtures/seed_12345.pyabmrc b/usercase-test-coderl/fixtures/seed_12345.pyabmrc +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/seed_12345.pyabmrc +@@ -0,0 +1,1 @@ ++random_seed : 12345 +diff --git a/usercase-test-coderl/fixtures/seed_22222.pyabmrc b/usercase-test-coderl/fixtures/seed_22222.pyabmrc +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/seed_22222.pyabmrc +@@ -0,0 +1,1 @@ ++random_seed : 22222 +diff --git a/usercase-test-coderl/test_rc_write_file.py b/usercase-test-coderl/test_rc_write_file.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_rc_write_file.py +@@ -0,0 +1,264 @@ ++from __future__ import division ++ ++import errno ++import os ++import shutil ++import sys ++import tempfile ++import unittest ++ ++ ++REPO = "/workspace/repo" ++FIXTURES = "/workspace/repo/usercase-test-coderl/fixtures" ++ ++if REPO not in sys.path: ++ sys.path.insert(0, REPO) ++if FIXTURES not in sys.path: ++ sys.path.insert(0, FIXTURES) ++ ++from pyabm import rc_params_management ++ ++ ++START_MARKER = "###***START OF RC DEFINITION***###" ++ ++ ++def text_from_lines(lines): ++ return "\n".join(lines) + "\n" ++ ++ ++def definition_path(module_name): ++ if module_name == "pyabm": ++ return os.path.join(REPO, "pyabm", "rcparams.default") ++ return os.path.join(FIXTURES, module_name, "rcparams.default") ++ ++ ++def read_definition_descriptors(module_names): ++ descriptors = [] ++ for module_name in module_names: ++ handle = open(definition_path(module_name), "r") ++ try: ++ started = False ++ for raw_line in handle: ++ line = raw_line.rstrip("\n") ++ if not started: ++ if line == START_MARKER: ++ started = True ++ continue ++ stripped = line.strip() ++ if stripped == "" or stripped.startswith("#"): ++ descriptors.append(("literal", line)) ++ continue ++ before_comment, marker, comment_rest = line.partition("#") ++ key = before_comment.partition(":")[0].strip("'\" ") ++ if key: ++ descriptors.append(("param", key, marker + comment_rest)) ++ else: ++ descriptors.append(("literal", line)) ++ finally: ++ handle.close() ++ return descriptors ++ ++ ++def make_initialized_manager(seed_fixture="seed_12345.pyabmrc"): ++ manager = rc_params_management() ++ manager.initialize("pyabm", custom_rc_file=os.path.join(FIXTURES, seed_fixture)) ++ return manager ++ ++ ++class RcWriteFileAcceptanceTest(unittest.TestCase): ++ ++ def setUp(self): ++ self.tmpdir = tempfile.mkdtemp(prefix="pyabm-rc-write-") ++ ++ def tearDown(self): ++ shutil.rmtree(self.tmpdir) ++ ++ def read_file(self, path): ++ handle = open(path, "r") ++ try: ++ return handle.read() ++ finally: ++ handle.close() ++ ++ def assert_output_matches_loaded_definitions(self, manager, output_path, ++ module_names=("pyabm",), ++ expected_header_lines=None): ++ contents = self.read_file(output_path) ++ descriptors = read_definition_descriptors(module_names) ++ first_body_line = descriptors[0][1] ++ lines = contents.splitlines() ++ body_start = None ++ for index, line in enumerate(lines): ++ if line == first_body_line and index > 0 and lines[index - 1] == "": ++ body_start = index ++ break ++ self.assertNotEqual(body_start, None) ++ header_lines = lines[:body_start - 1] ++ body_lines = lines[body_start:] ++ ++ if expected_header_lines is None: ++ ++ self.assertNotEqual(header_lines, []) ++ self.assertNotEqual(header_lines[-1], "") ++ else: ++ self.assertEqual(header_lines, expected_header_lines) ++ self.assertEqual(lines[body_start - 1], "") ++ ++ ++ ++ self.assertEqual(len(body_lines), len(descriptors)) ++ for body_line, descriptor in zip(body_lines, descriptors): ++ if descriptor[0] == "literal": ++ self.assertEqual(body_line, descriptor[1]) ++ continue ++ key, inline_comment = descriptor[1], descriptor[2] ++ self.assertTrue(body_line.startswith("%s : " % key)) ++ suffix = "" ++ if inline_comment: ++ suffix = " " + inline_comment ++ self.assertTrue(body_line.endswith(suffix)) ++ value_text = body_line[len("%s : " % key):] ++ if suffix: ++ value_text = value_text[:-len(suffix)] ++ self.assertEqual(value_text, str(manager.get_params()[key])) ++ ++ def test_default_header_ordered_body_active_values_and_no_mutation(self): ++ ++ ++ ++ manager = make_initialized_manager() ++ params = manager.get_params() ++ params.update({"user.extra.setting": "SHOULD_NOT_APPEAR"}) ++ output_path = os.path.join(self.tmpdir, "model.pyabmrc") ++ ++ self.assertEqual(manager.is_initialized(), True) ++ self.assertEqual(manager.is_validated(), True) ++ self.assertEqual(len(params), 15) ++ self.assertEqual(params["random_seed"], 12345) ++ self.assertEqual(params["batchrun.num_runs"], 20) ++ self.assertEqual(params["email_log"], False) ++ ++ result = manager.write_RC_file(output_path) ++ ++ self.assertEqual(result, None) ++ self.assertEqual(params["random_seed"], 12345) ++ self.assertEqual(params["batchrun.num_runs"], 20) ++ self.assertEqual(params["email_log"], False) ++ self.assertEqual(params["user.extra.setting"], "SHOULD_NOT_APPEAR") ++ ++ self.assert_output_matches_loaded_definitions(manager, output_path) ++ self.assertEqual("user.extra.setting" in self.read_file(output_path), False) ++ self.assertEqual("SHOULD_NOT_APPEAR" in self.read_file(output_path), False) ++ ++ def test_custom_docstring_replaces_header_with_one_blank_line(self): ++ ++ ++ ++ manager = make_initialized_manager() ++ output_path = os.path.join(self.tmpdir, "custom.pyabmrc") ++ ++ result = manager.write_RC_file(output_path, docstring="# My model configuration") ++ ++ self.assertEqual(result, None) ++ ++ ++ self.assert_output_matches_loaded_definitions( ++ manager, output_path, expected_header_lines=["# My model configuration"]) ++ ++ def test_loaded_definition_inline_comments_are_preserved(self): ++ ++ ++ ++ manager = make_initialized_manager() ++ manager.load_default_params("rc_fixture_defaults") ++ output_path = os.path.join(self.tmpdir, "inline.pyabmrc") ++ ++ result = manager.write_RC_file(output_path, docstring="# My model configuration") ++ ++ self.assertEqual(result, None) ++ expected_tail = text_from_lines([ ++ "random_seed : 12345", ++ "# Fixture Parameters", ++ "fixture.enabled : True # inline switch", ++ "", ++ "fixture.count : 7", ++ ]) ++ self.assertEqual(self.read_file(output_path).endswith(expected_tail), True) ++ ++ def test_repeated_write_overwrites_existing_file(self): ++ ++ ++ ++ manager = make_initialized_manager() ++ output_path = os.path.join(self.tmpdir, "overwrite.pyabmrc") ++ ++ first_result = manager.write_RC_file(output_path, docstring="# First") ++ second_result = manager.write_RC_file(output_path, docstring="# My model configuration") ++ ++ self.assertEqual(first_result, None) ++ self.assertEqual(second_result, None) ++ ++ self.assert_output_matches_loaded_definitions( ++ manager, output_path, expected_header_lines=["# My model configuration"]) ++ self.assertEqual("stale content" in self.read_file(output_path), False) ++ self.assertEqual("# First" in self.read_file(output_path), False) ++ ++ def test_open_failure_propagates_specific_ioerror(self): ++ ++ ++ ++ manager = make_initialized_manager() ++ missing_parent_path = os.path.join(self.tmpdir, "missing", "out.pyabmrc") ++ ++ with self.assertRaises(IOError) as caught: ++ manager.write_RC_file(missing_parent_path) ++ ++ ++ self.assertEqual(caught.exception.errno, errno.ENOENT) ++ self.assertEqual(os.path.basename(caught.exception.filename), "out.pyabmrc") ++ ++ def test_two_managers_write_their_own_current_seed_values(self): ++ ++ ++ ++ first = make_initialized_manager("seed_11111.pyabmrc") ++ second = make_initialized_manager("seed_22222.pyabmrc") ++ first.get_params().update({"user.extra.setting": "FIRST_ONLY"}) ++ first_path = os.path.join(self.tmpdir, "first.pyabmrc") ++ second_path = os.path.join(self.tmpdir, "second.pyabmrc") ++ ++ first_result = first.write_RC_file(first_path, docstring="# First") ++ second_result = second.write_RC_file(second_path, docstring="# Second") ++ ++ self.assertEqual(first_result, None) ++ self.assertEqual(second_result, None) ++ self.assertEqual(first.get_params()["random_seed"], 11111) ++ self.assertEqual(second.get_params()["random_seed"], 22222) ++ self.assertEqual("random_seed : 11111" in self.read_file(first_path), True) ++ self.assertEqual("random_seed : 22222" in self.read_file(first_path), False) ++ self.assertEqual("random_seed : 22222" in self.read_file(second_path), True) ++ self.assertEqual("random_seed : 11111" in self.read_file(second_path), False) ++ self.assertEqual("FIRST_ONLY" in self.read_file(second_path), False) ++ ++ def test_repeated_write_cycles_produce_complete_files(self): ++ ++ ++ ++ manager = make_initialized_manager() ++ paths = [] ++ ++ for index in range(30): ++ output_path = os.path.join(self.tmpdir, "cycle-%03d.pyabmrc" % index) ++ paths.append(output_path) ++ self.assertEqual(manager.write_RC_file(output_path, docstring="# Cycle"), None) ++ ++ ++ ++ self.assert_output_matches_loaded_definitions( ++ manager, paths[0], expected_header_lines=["# Cycle"]) ++ self.assert_output_matches_loaded_definitions( ++ manager, paths[-1], expected_header_lines=["# Cycle"]) ++ ++ ++if __name__ == "__main__": ++ unittest.main(verbosity=2) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,15 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++exec python2 /workspace/repo/usercase-test-coderl/test_rc_write_file.py diff --git a/tasks/format-code-task-000521/tests/test.sh b/tasks/format-code-task-000521/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0d4c5ff69c827d89a95e6fbada127f21b2a52aaa --- /dev/null +++ b/tasks/format-code-task-000521/tests/test.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/rc_fixture_defaults/__init__.py +usercase-test-coderl/fixtures/rc_fixture_defaults/rcparams.default +usercase-test-coderl/fixtures/seed_11111.pyabmrc +usercase-test-coderl/fixtures/seed_12345.pyabmrc +usercase-test-coderl/fixtures/seed_22222.pyabmrc +usercase-test-coderl/test_rc_write_file.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000521/tests/test_command.sh b/tasks/format-code-task-000521/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000521/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000526/environment/Dockerfile b/tasks/format-code-task-000526/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2abf67adf39a6b8dac53d2580a2c26f7fc7be566 --- /dev/null +++ b/tasks/format-code-task-000526/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b8e168fa93ff62a629b33979ffdb403622144acc058cd7963fa692b21103b776 diff --git a/tasks/format-code-task-000526/environment/setup/files/blocklist b/tasks/format-code-task-000526/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000526/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000526/environment/setup/setup.sh b/tasks/format-code-task-000526/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000526/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000526/tests/test.patch b/tasks/format-code-task-000526/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..68092b933b2707693349b4b65b075c38fa4dc02e --- /dev/null +++ b/tasks/format-code-task-000526/tests/test.patch @@ -0,0 +1,318 @@ +diff --git a/usercase-test-coderl/test_gameshark_stateful.py b/usercase-test-coderl/test_gameshark_stateful.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_gameshark_stateful.py +@@ -0,0 +1,290 @@ ++ ++ ++ ++ ++ ++ ++ ++import gc ++import sys ++from pathlib import Path ++ ++import pytest ++ ++sys.path.insert(0, "/workspace/repo") ++ ++from pyboy import PyBoy ++from pyboy.utils import PyBoyInvalidInputException ++ ++ ++ROM = "/tmp/pyboy_gameshark_minimal.gb" ++BOOTROM = "/tmp/pyboy_gameshark_bootrom.bin" ++CODE_CD38 = "010138CD" ++CODE_CE38 = "010138CE" ++ADDR_CD38 = 0xCD38 ++ADDR_CE38 = 0xCE38 ++ ++ ++def ensure_test_rom(): ++ ++ rom_path = Path(ROM) ++ bootrom_path = Path(BOOTROM) ++ ++ rom = bytearray([0] * 0x4000) ++ rom[0x100:0x103] = b"\xC3\x00\x01" ++ rom[0x134:0x140] = b"TSTGAMESHARK" ++ rom[0x147] = 0x00 ++ rom[0x148] = 0x00 ++ rom[0x149] = 0x00 ++ ++ checksum = 0 ++ for address in range(0x134, 0x14D): ++ checksum = (checksum - rom[address] - 1) & 0xFF ++ rom[0x14D] = checksum ++ rom_path.write_bytes(rom) ++ ++ bootrom = bytearray([0] * 0x100) ++ bootrom[0:3] = b"\xC3\x00\x00" ++ bootrom_path.write_bytes(bootrom) ++ ++ ++def make_pyboy(**kwargs): ++ ensure_test_rom() ++ return PyBoy(ROM, window="null", bootrom=BOOTROM, cgb=False, **kwargs) ++ ++ ++def stop_pyboy(pyboy): ++ pyboy.stop(save=False) ++ ++ ++def assert_gameshark_public_api(pyboy): ++ ++ assert pyboy.gameshark is not None ++ assert callable(pyboy.gameshark.add) ++ assert callable(pyboy.gameshark.remove) ++ assert callable(pyboy.gameshark.clear_all) ++ ++ ++def test_add_tick_remove_restore_and_remove_without_restore(): ++ ++ ++ ++ ++ pyboy = make_pyboy() ++ try: ++ pyboy.tick(60) ++ assert_gameshark_public_api(pyboy) ++ ++ original_cd38 = pyboy.memory[ADDR_CD38] ++ assert original_cd38 != 0x01 ++ ++ pyboy.gameshark.add(CODE_CD38) ++ ++ assert pyboy.memory[ADDR_CD38] == original_cd38 ++ ++ pyboy.tick() ++ assert pyboy.memory[ADDR_CD38] == 0x01 ++ ++ pyboy.gameshark.remove(CODE_CD38) ++ ++ assert pyboy.memory[ADDR_CD38] == original_cd38 ++ ++ pyboy.gameshark.add(CODE_CD38) ++ pyboy.tick() ++ assert pyboy.memory[ADDR_CD38] == 0x01 ++ ++ pyboy.gameshark.remove(CODE_CD38, False) ++ assert pyboy.memory[ADDR_CD38] == 0x01 ++ finally: ++ stop_pyboy(pyboy) ++ ++ ++def test_multiple_cheats_clear_all_restores_each_address(): ++ ++ ++ ++ ++ pyboy = make_pyboy() ++ try: ++ pyboy.tick(60) ++ assert_gameshark_public_api(pyboy) ++ ++ original_cd38 = pyboy.memory[ADDR_CD38] ++ original_ce38 = pyboy.memory[ADDR_CE38] ++ assert original_cd38 != 0x01 ++ assert original_ce38 != 0x01 ++ ++ pyboy.gameshark.add(CODE_CD38) ++ ++ assert pyboy.memory[ADDR_CD38] == original_cd38 ++ ++ pyboy.gameshark.add(CODE_CE38) ++ ++ assert pyboy.memory[ADDR_CE38] == original_ce38 ++ ++ pyboy.tick() ++ assert pyboy.memory[ADDR_CD38] == 0x01 ++ assert pyboy.memory[ADDR_CE38] == 0x01 ++ ++ pyboy.gameshark.clear_all() ++ ++ assert pyboy.memory[ADDR_CD38] == original_cd38 ++ assert pyboy.memory[ADDR_CE38] == original_ce38 ++ ++ pyboy.tick() ++ assert pyboy.memory[ADDR_CD38] == original_cd38 ++ assert pyboy.memory[ADDR_CE38] == original_ce38 ++ finally: ++ stop_pyboy(pyboy) ++ ++ ++def test_constructor_registers_comma_separated_startup_cheats_with_whitespace(): ++ ++ ++ ++ ++ pyboy = make_pyboy(gameshark="010138CD, 010138CE") ++ try: ++ assert_gameshark_public_api(pyboy) ++ pyboy.tick(60) ++ assert pyboy.memory[ADDR_CD38] == 0x01 ++ assert pyboy.memory[ADDR_CE38] == 0x01 ++ ++ pyboy.tick() ++ assert pyboy.memory[ADDR_CD38] == 0x01 ++ assert pyboy.memory[ADDR_CE38] == 0x01 ++ finally: ++ stop_pyboy(pyboy) ++ ++ ++def test_invalid_add_inputs_raise_specific_exceptions(): ++ ++ ++ ++ ++ pyboy = make_pyboy() ++ try: ++ ++ with pytest.raises(ValueError): ++ pyboy.gameshark.add("010138C") ++ ++ ++ with pytest.raises(ValueError): ++ pyboy.gameshark.add("0101387F") ++ ++ ++ with pytest.raises(ValueError): ++ pyboy.gameshark.add("020138CD") ++ ++ pyboy.gameshark.add(CODE_CD38) ++ pyboy.tick() ++ assert pyboy.memory[ADDR_CD38] == 0x01 ++ finally: ++ stop_pyboy(pyboy) ++ ++ ++def test_duplicate_add_and_missing_remove_raise_specific_exceptions(): ++ ++ ++ ++ ++ pyboy = make_pyboy() ++ try: ++ pyboy.tick(60) ++ ++ original_cd38 = pyboy.memory[ADDR_CD38] ++ assert original_cd38 != 0x01 ++ ++ pyboy.gameshark.add(CODE_CD38) ++ ++ ++ with pytest.raises(PyBoyInvalidInputException): ++ pyboy.gameshark.add(CODE_CD38) ++ pyboy.tick() ++ assert pyboy.memory[ADDR_CD38] == 0x01 ++ ++ pyboy.gameshark.remove(CODE_CD38) ++ assert pyboy.memory[ADDR_CD38] == original_cd38 ++ ++ ++ with pytest.raises(ValueError): ++ pyboy.gameshark.remove(CODE_CD38) ++ finally: ++ stop_pyboy(pyboy) ++ ++ ++def test_two_pyboy_instances_keep_gameshark_state_independent(): ++ ++ ++ ++ ++ first = make_pyboy() ++ second = make_pyboy() ++ try: ++ first.tick(60) ++ second.tick(60) ++ assert_gameshark_public_api(first) ++ assert_gameshark_public_api(second) ++ ++ first_original = first.memory[ADDR_CD38] ++ second_original = second.memory[ADDR_CD38] ++ assert first_original != 0x01 ++ assert second_original != 0x01 ++ ++ first.gameshark.add(CODE_CD38) ++ first.tick() ++ assert first.memory[ADDR_CD38] == 0x01 ++ assert second.memory[ADDR_CD38] == second_original ++ ++ second.tick() ++ assert first.memory[ADDR_CD38] == 0x01 ++ assert second.memory[ADDR_CD38] == second_original ++ finally: ++ stop_pyboy(first) ++ stop_pyboy(second) ++ ++ ++def test_pyboy_stop_is_idempotent_after_gameshark_session(): ++ ++ ++ ++ ++ pyboy = make_pyboy() ++ try: ++ pyboy.tick(60) ++ original_cd38 = pyboy.memory[ADDR_CD38] ++ assert original_cd38 != 0x01 ++ ++ pyboy.gameshark.add(CODE_CD38) ++ pyboy.tick() ++ assert pyboy.memory[ADDR_CD38] == 0x01 ++ ++ ++ pyboy.gameshark.clear_all() ++ assert pyboy.memory[ADDR_CD38] == original_cd38 ++ finally: ++ stop_pyboy(pyboy) ++ ++ ++def test_repeated_gameshark_sessions_do_not_retain_unbounded_resources(): ++ ++ ++ ++ ++ ++ gc.collect() ++ ++ for _ in range(5): ++ pyboy = make_pyboy() ++ try: ++ pyboy.tick(60) ++ original_cd38 = pyboy.memory[ADDR_CD38] ++ assert original_cd38 != 0x01 ++ ++ pyboy.gameshark.add(CODE_CD38) ++ pyboy.tick() ++ assert pyboy.memory[ADDR_CD38] == 0x01 ++ pyboy.gameshark.clear_all() ++ assert pyboy.memory[ADDR_CD38] == original_cd38 ++ finally: ++ pyboy.stop(save=False) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++ ++exec /usr/bin/python -m pytest -p pytest_benchmark.plugin /workspace/repo/usercase-test-coderl/test_gameshark_stateful.py -v diff --git a/tasks/format-code-task-000526/tests/test.sh b/tasks/format-code-task-000526/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fa974d0372f633a4d3e05245c463d981f95bb3cf --- /dev/null +++ b/tasks/format-code-task-000526/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_gameshark_stateful.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000526/tests/test_command.sh b/tasks/format-code-task-000526/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000526/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000527/environment/Dockerfile b/tasks/format-code-task-000527/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d01ea71bbdb77083542a7caebfb7dd9a4873eed9 --- /dev/null +++ b/tasks/format-code-task-000527/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6a07b1ae0e22d36e27d714258907571247d3e45f5a735776182be12d8b2a21b8 diff --git a/tasks/format-code-task-000527/environment/setup/files/blocklist b/tasks/format-code-task-000527/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000527/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000527/environment/setup/setup.sh b/tasks/format-code-task-000527/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000527/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000527/tests/test.patch b/tasks/format-code-task-000527/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7e4f21042fd34f06ce3d0e37475246c8d9a6a311 --- /dev/null +++ b/tasks/format-code-task-000527/tests/test.patch @@ -0,0 +1,145 @@ +diff --git a/tests/banditml_pkg/banditml/serving/test_sklearn_predictor_support.py b/tests/banditml_pkg/banditml/serving/test_sklearn_predictor_support.py +new file mode 100644 +index 0000000..995cb95 +--- /dev/null ++++ b/tests/banditml_pkg/banditml/serving/test_sklearn_predictor_support.py +@@ -0,0 +1,128 @@ ++import json ++import os ++import tempfile ++import unittest ++ ++import numpy as np ++import pandas as pd ++from sklearn.linear_model import LogisticRegression, Ridge ++ ++from banditml_pkg.banditml.preprocessing import preprocessor ++from banditml_pkg.banditml.serving.predictor import BanditPredictor ++from utils import model_constructors ++ ++ ++EXPERIMENT = { ++ "features": { ++ "age": {"type": "N"}, ++ "decision": {"type": "C", "possible_values": ["left", "right"]}, ++ }, ++ "product_sets": {}, ++} ++ ++ ++def prepared_training_data(binary=False): ++ rows = [] ++ for age, decision in enumerate(["left", "right", "left", "right", "left", "right"]): ++ reward = int(age >= 3) if binary else float(age * 2 + (decision == "right")) ++ rows.append( ++ { ++ "context": json.dumps({"age": age}), ++ "decision": decision, ++ "immediate_reward": json.dumps({"reward": reward}), ++ "delayed_reward": json.dumps( ++ {"left": {"reward": 0}, "right": {"reward": 0}} ++ ), ++ } ++ ) ++ raw = pd.DataFrame(rows) ++ return preprocessor.preprocess_data( ++ raw, {"reward": 1}, EXPERIMENT, shuffle_data=False ++ ) ++ ++ ++def make_predictor(model, data, reward_type): ++ return BanditPredictor( ++ experiment_params=EXPERIMENT, ++ float_feature_order=data["float_feature_order"], ++ id_feature_order=data["id_feature_order"], ++ id_feature_str_to_int_map=data["id_feature_str_to_int_map"], ++ transforms=data["transforms"], ++ imputers=data["imputers"], ++ model=model, ++ reward_type=reward_type, ++ ) ++ ++ ++class TestSklearnPredictorSupport(unittest.TestCase): ++ def assert_serves_estimator(self, model, reward_type, binary=False): ++ data = prepared_training_data(binary=binary) ++ model.fit(data["X_float"], data["y"]) ++ predictor = make_predictor(model, data, reward_type) ++ context = {"age": 2} ++ ++ prepared = predictor.preprocess_input(context) ++ if binary: ++ expected = model.predict_proba(prepared["X_float"])[:, 1] ++ else: ++ expected = model.predict(prepared["X_float"]) ++ try: ++ served = predictor.predict(context) ++ except Exception as exc: ++ self.fail("sklearn estimator could not be served: %r" % (exc,)) ++ ++ self.assertEqual(served["ids"], ["left", "right"]) ++ self.assertEqual(np.asarray(served["scores"]).shape, (2, 1)) ++ np.testing.assert_allclose(np.asarray(served["scores"]).ravel(), expected) ++ ++ def test_regression_estimators_are_scored(self): ++ self.assert_serves_estimator(Ridge(alpha=1.0), "regression") ++ self.assert_serves_estimator( ++ model_constructors.build_gbdt("regression", 0.1, 8, 2), "regression" ++ ) ++ self.assert_serves_estimator( ++ model_constructors.build_random_forest("regression", 8, 2), "regression" ++ ) ++ ++ def test_binary_estimators_return_positive_class_scores(self): ++ self.assert_serves_estimator( ++ LogisticRegression(penalty="l2"), "binary", binary=True ++ ) ++ self.assert_serves_estimator( ++ model_constructors.build_gbdt("binary", 0.1, 8, 2), "binary", binary=True ++ ) ++ self.assert_serves_estimator( ++ model_constructors.build_random_forest("binary", 8, 2), "binary", binary=True ++ ) ++ ++ def test_sklearn_regression_round_trip(self): ++ data = prepared_training_data() ++ model = Ridge(alpha=1.0).fit(data["X_float"], data["y"]) ++ predictor = make_predictor(model, data, "regression") ++ context = {"age": 4} ++ before = predictor.predict(context) ++ with tempfile.TemporaryDirectory() as directory: ++ config_path = os.path.join(directory, "model.json") ++ model_path = os.path.join(directory, "model.bin") ++ predictor.config_to_file(config_path) ++ predictor.model_to_file(model_path) ++ restored = BanditPredictor.predictor_from_file(config_path, model_path) ++ after = restored.predict(context) ++ np.testing.assert_allclose(after["scores"], before["scores"]) ++ self.assertEqual(after["ids"], before["ids"]) ++ ++ def test_sklearn_binary_round_trip(self): ++ data = prepared_training_data(binary=True) ++ model = LogisticRegression(penalty="l2").fit(data["X_float"], data["y"]) ++ predictor = make_predictor(model, data, "binary") ++ context = {"age": 1} ++ before = predictor.predict(context) ++ with tempfile.TemporaryDirectory() as directory: ++ config_path = os.path.join(directory, "model.json") ++ model_path = os.path.join(directory, "model.bin") ++ predictor.config_to_file(config_path) ++ predictor.model_to_file(model_path) ++ restored = BanditPredictor.predictor_from_file(config_path, model_path) ++ after = restored.predict(context) ++ np.testing.assert_allclose(after["scores"], before["scores"]) ++ self.assertEqual(after["ids"], before["ids"]) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/bin/bash ++set -euo pipefail ++ ++PYTHONPATH=. pytest -q \ ++ tests/banditml_pkg/banditml/serving/test_sklearn_predictor_support.py \ ++ tests/banditml_pkg/banditml/serving/test_predictor.py::TestPredictor::test_same_predictions_country_as_categorical diff --git a/tasks/format-code-task-000527/tests/test.sh b/tasks/format-code-task-000527/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea6dbd4c1d2c26a49e11a8764fde48d7e3d925e9 --- /dev/null +++ b/tasks/format-code-task-000527/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/banditml_pkg/banditml/serving/test_sklearn_predictor_support.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000527/tests/test_command.sh b/tasks/format-code-task-000527/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000527/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000542/environment/Dockerfile b/tasks/format-code-task-000542/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f7083eecc06e357a4e4c186ecfdc91de4eb8584d --- /dev/null +++ b/tasks/format-code-task-000542/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1990390aefe634ba1db5a7ce5520a9f7d0772a56575d28dcba6d28762be8ea9d diff --git a/tasks/format-code-task-000542/environment/setup/files/blocklist b/tasks/format-code-task-000542/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000542/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000542/environment/setup/setup.sh b/tasks/format-code-task-000542/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000542/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000542/tests/test.patch b/tasks/format-code-task-000542/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..473b450f4bb10b5bf22d914a62dcb251fa760f97 --- /dev/null +++ b/tasks/format-code-task-000542/tests/test.patch @@ -0,0 +1,218 @@ +diff --git a/tests/datatypes/test_tuple_operations.py b/tests/datatypes/test_tuple_operations.py +new file mode 100644 +index 00000000..5235d132 +--- /dev/null ++++ b/tests/datatypes/test_tuple_operations.py +@@ -0,0 +1,183 @@ ++from .. utils import TranspileTestCase ++ ++ ++class TupleOperatorTests(TranspileTestCase): ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ def test_equality(self): ++ self.assertCodeExecution(""" ++ a = (1, 2, 3) ++ b = (1, 2, 3) ++ c = (1, 2, 4) ++ d = (1, 2) ++ e = () ++ f = ('a', 'b') ++ print(a == b) ++ print(a == c) ++ print(d == a) ++ print(e == ()) ++ print(f == ('a', 'b')) ++ print(a != b) ++ print(a != c) ++ """) ++ ++ def test_equality_with_non_tuple(self): ++ self.assertCodeExecution(""" ++ a = (1, 2, 3) ++ e = () ++ print(a == 5) ++ print(a == "hello") ++ print(a == [1, 2, 3]) ++ print(a != 5) ++ print(a != [1, 2, 3]) ++ print(e == 0) ++ """) ++ ++ def test_ordering_lt(self): ++ self.assertCodeExecution(""" ++ a = (1, 2, 3) ++ print(a < (1, 2, 4)) ++ print((1, 2, 4) < a) ++ print((1, 2) < a) ++ print(a < (1, 2)) ++ print((2, 0) < (1, 5)) ++ print((1, 5) < (2, 0)) ++ print(a < (1, 2, 3)) ++ """) ++ ++ def test_ordering_le_gt_ge(self): ++ self.assertCodeExecution(""" ++ a = (1, 2, 3) ++ print(a <= (1, 2, 3)) ++ print(a <= (1, 2, 4)) ++ print((1, 2, 4) <= a) ++ print((1, 2) <= a) ++ print(a > (1, 2, 4)) ++ print((1, 2, 4) > a) ++ print(a > (1, 2)) ++ print(a >= (1, 2, 3)) ++ print((1, 2, 4) >= a) ++ print(a >= (1, 2, 4)) ++ """) ++ ++ def test_ordering_with_non_tuple_raises(self): ++ self.assertCodeExecution(""" ++ a = (1, 2, 3) ++ print(a < 5) ++ """) ++ self.assertCodeExecution(""" ++ a = (1, 2, 3) ++ print(a <= 5) ++ """) ++ self.assertCodeExecution(""" ++ a = (1, 2, 3) ++ print(a > 5) ++ """) ++ self.assertCodeExecution(""" ++ a = (1, 2, 3) ++ print(a >= 5) ++ """) ++ ++ def test_concatenation(self): ++ self.assertCodeExecution(""" ++ x = (1, 2) ++ y = (3, 4) ++ e = () ++ print(x + y) ++ print(e + x) ++ print(x + e) ++ print(('a',) + ('b', 'c')) ++ print(x + y) ++ print(x) ++ print(y) ++ """) ++ ++ def test_concatenation_with_non_tuple_raises(self): ++ self.assertCodeExecution(""" ++ x = (1, 2) ++ print(x + 3) ++ """) ++ self.assertCodeExecution(""" ++ x = (1, 2) ++ print(x + [3, 4]) ++ """) ++ self.assertCodeExecution(""" ++ x = (1, 2) ++ print(x + "ab") ++ """) ++ ++ def test_repetition(self): ++ self.assertCodeExecution(""" ++ x = (1, 2) ++ n3 = 3 ++ n1 = 1 ++ n0 = 0 ++ nm2 = -2 ++ print(x * n3) ++ print(x * n1) ++ print(x * n0) ++ print(x * nm2) ++ print(('a',) * 4) ++ print(x * True) ++ print(x * False) ++ """) ++ ++ def test_repetition_with_non_int_raises(self): ++ self.assertCodeExecution(""" ++ x = (1, 2) ++ print(x * "a") ++ """) ++ self.assertCodeExecution(""" ++ x = (1, 2) ++ print(x * 1.5) ++ """) ++ self.assertCodeExecution(""" ++ x = (1, 2) ++ print(x * (3, 4)) ++ """) ++ ++ def test_truthiness(self): ++ self.assertCodeExecution(""" ++ e = () ++ x = (1, 2) ++ z = (0,) ++ if e: ++ print("empty truthy") ++ else: ++ print("empty falsy") ++ ++ if x: ++ print("nonempty truthy") ++ else: ++ print("nonempty falsy") ++ ++ if z: ++ print("zero-element truthy") ++ else: ++ print("zero-element falsy") ++ ++ print(not e) ++ print(not x) ++ """) ++ ++ def test_unary_operators_raise(self): ++ self.assertCodeExecution(""" ++ x = (1, 2, 3) ++ print(+x) ++ """) ++ self.assertCodeExecution(""" ++ x = (1, 2, 3) ++ print(-x) ++ """) ++ self.assertCodeExecution(""" ++ x = (1, 2, 3) ++ print(~x) ++ """) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,24 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++export PYENV_VERSION=3.5.10 ++PYTHON="$HOME/.pyenv/bin/pyenv exec python" ++ant java >/dev/null ++ ++ ++$PYTHON -m pytest tests/datatypes/test_tuple.py::TupleTests -q ++ ++ ++$PYTHON -m pytest tests/datatypes/test_tuple_operations.py -q diff --git a/tasks/format-code-task-000542/tests/test.sh b/tasks/format-code-task-000542/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f9d468a560c704c394f96c7f71831926c4536872 --- /dev/null +++ b/tasks/format-code-task-000542/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/datatypes/test_tuple_operations.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000542/tests/test_command.sh b/tasks/format-code-task-000542/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000542/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000545/environment/Dockerfile b/tasks/format-code-task-000545/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b5c8dea55fabda5c5b601052bda75cfab8bf7efe --- /dev/null +++ b/tasks/format-code-task-000545/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a3de4a9f8f8825c93a836fbf547716f5ac0d4b0c25e48f6e1fffad7ad9d2db40 diff --git a/tasks/format-code-task-000545/environment/setup/files/blocklist b/tasks/format-code-task-000545/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000545/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000545/environment/setup/setup.sh b/tasks/format-code-task-000545/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000545/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000545/tests/test.patch b/tasks/format-code-task-000545/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9ad4ef042486a93ca0b6b7c4f3415c0f5762ead5 --- /dev/null +++ b/tasks/format-code-task-000545/tests/test.patch @@ -0,0 +1,191 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..52254da +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/unit/test_configuration.py::TestPyprojectTomlConfiguration -v"] ++} +diff --git a/tests/unit/test_configuration.py b/tests/unit/test_configuration.py +index 2268bcb..28060a4 100644 +--- a/tests/unit/test_configuration.py ++++ b/tests/unit/test_configuration.py +@@ -6,6 +6,21 @@ from behave import configuration + from behave.configuration import Configuration, UserData + from unittest import TestCase + ++ ++TEST_CONFIG_TOML = """\ ++[tool.behave] ++default_tags = ["@foo,~@bar", "@zap"] ++format = ["pretty", "tag-counter"] ++stdout_capture = false ++paths = ["/absolute/path3", "relative/path4"] ++outfiles = ["/absolute/path1", "relative/path2"] ++bogus = "spam" ++ ++[tool.behave.userdata] ++foo = "bar" ++answer = 42 ++""" ++ + + # one entry of each kind handled + TEST_CONFIG="""[behave] +@@ -182,3 +197,142 @@ class TestConfigurationUserData(TestCase): + expected_data = dict(person1="Alice", person2="Bob", person3="Charly") + assert config.userdata == expected_data + assert config.userdata_defines is None ++ ++ ++ ++ ++ ++def _write_pyproject_toml(tmpdir, content): ++ path = os.path.join(tmpdir, "pyproject.toml") ++ with open(path, "w") as f: ++ f.write(content) ++ return path ++ ++ ++class TestPyprojectTomlConfiguration(TestCase): ++ """Tests for [tool.behave] in pyproject.toml (PEP 518).""" ++ ++ def _make_toml(self, content, suffix=".toml"): ++ fd, tn = tempfile.mkstemp(suffix=suffix) ++ os.close(fd) ++ with open(tn, "w") as f: ++ f.write(content) ++ self.addCleanup(self._safe_unlink, tn) ++ return tn ++ ++ @staticmethod ++ def _safe_unlink(path): ++ try: ++ os.unlink(path) ++ except OSError: ++ pass ++ ++ def test_read_toml_file_basic_options(self): ++ """Reading a .toml file returns the same option dict shape as INI.""" ++ tn = self._make_toml(TEST_CONFIG_TOML) ++ tndir = os.path.dirname(tn) ++ ++ d = configuration.read_configuration(tn) ++ assert d["default_tags"] == ["@foo,~@bar", "@zap"] ++ assert d["format"] == ["pretty", "tag-counter"] ++ assert d["stdout_capture"] is False ++ ++ assert "bogus" not in d ++ ++ def test_read_toml_file_userdata_subsection(self): ++ """[tool.behave.userdata] becomes userdata dict with stringified values.""" ++ tn = self._make_toml(TEST_CONFIG_TOML) ++ d = configuration.read_configuration(tn) ++ ++ assert d["userdata"] == {"foo": "bar", "answer": "42"} ++ ++ def test_read_toml_file_paths_are_normalized(self): ++ """Relative paths are evaluated relative to the config file location.""" ++ tn = self._make_toml(TEST_CONFIG_TOML) ++ tndir = os.path.dirname(tn) ++ d = configuration.read_configuration(tn) ++ assert d["paths"] == [ ++ os.path.normpath(ROOTDIR_PREFIX + "/absolute/path3"), ++ os.path.normpath(os.path.join(tndir, "relative/path4")), ++ ] ++ ++ def test_read_toml_file_outfiles_normalized(self): ++ tn = self._make_toml(TEST_CONFIG_TOML) ++ tndir = os.path.dirname(tn) ++ d = configuration.read_configuration(tn) ++ assert d["outfiles"] == [ ++ os.path.normpath(ROOTDIR_PREFIX + "/absolute/path1"), ++ os.path.normpath(os.path.join(tndir, "relative/path2")), ++ ] ++ ++ def test_read_toml_file_boolean_store_true(self): ++ """A boolean TOML value maps to a Python bool (not string).""" ++ content = ( ++ "[tool.behave]\n" ++ "stdout_capture = false\n" ++ "stderr_capture = true\n" ++ ) ++ tn = self._make_toml(content) ++ d = configuration.read_configuration(tn) ++ assert d["stdout_capture"] is False ++ assert d["stderr_capture"] is True ++ ++ def test_read_toml_file_empty_tool_behave(self): ++ """A pyproject.toml without [tool.behave] yields no behave options.""" ++ content = '[tool.other]\nfoo = "bar"\n' ++ tn = self._make_toml(content) ++ d = configuration.read_configuration(tn) ++ ++ assert "default_tags" not in d ++ assert "format" not in d ++ assert "stdout_capture" not in d ++ ++ def test_read_toml_file_list_format(self): ++ """TOML native arrays are used directly for append-type options.""" ++ content = ( ++ '[tool.behave]\n' ++ 'format = ["pretty", "json"]\n' ++ ) ++ tn = self._make_toml(content) ++ d = configuration.read_configuration(tn) ++ assert d["format"] == ["pretty", "json"] ++ ++ def test_pyproject_toml_listed_in_config_filenames(self): ++ """config_filenames() picks up pyproject.toml in current directory.""" ++ tmpd = tempfile.mkdtemp() ++ old_cwd = os.getcwd() ++ try: ++ os.chdir(tmpd) ++ _write_pyproject_toml(tmpd, '[tool.behave]\nstdout_capture = false\n') ++ files = list(configuration.config_filenames()) ++ assert any(f.endswith("pyproject.toml") for f in files), \ ++ "pyproject.toml not found in: %r" % files ++ finally: ++ os.chdir(old_cwd) ++ ++ def test_load_configuration_with_pyproject_toml(self): ++ """load_configuration reads pyproject.toml [tool.behave] settings.""" ++ tmpd = tempfile.mkdtemp() ++ old_cwd = os.getcwd() ++ try: ++ os.chdir(tmpd) ++ _write_pyproject_toml(tmpd, ( ++ '[tool.behave]\n' ++ 'stdout_capture = false\n' ++ 'default_tags = ["@foo"]\n' ++ 'format = ["pretty"]\n' ++ '\n' ++ '[tool.behave.userdata]\n' ++ 'person = "Alice"\n' ++ 'answer = 42\n' ++ )) ++ defaults = {} ++ configuration.load_configuration(defaults, verbose=False) ++ assert defaults.get("stdout_capture") is False ++ assert defaults.get("default_tags") == ["@foo"] ++ assert defaults.get("format") == ["pretty"] ++ assert defaults.get("userdata", {}).get("person") == "Alice" ++ ++ assert defaults.get("userdata", {}).get("answer") == "42" ++ finally: ++ os.chdir(old_cwd) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/unit/test_configuration.py::TestPyprojectTomlConfiguration -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000545/tests/test.sh b/tasks/format-code-task-000545/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..364674f42f80c5368c00e22e418afa97f79be583 --- /dev/null +++ b/tasks/format-code-task-000545/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/unit/test_configuration.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000545/tests/test_command.sh b/tasks/format-code-task-000545/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000545/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000573/environment/Dockerfile b/tasks/format-code-task-000573/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7ebe314700038560d4de259ae2c3c63170cf1d80 --- /dev/null +++ b/tasks/format-code-task-000573/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:13ef01a4ec92ad82fb02bd3548dd0cea608095ec6a088118efa4caa7f45d368c diff --git a/tasks/format-code-task-000573/environment/setup/files/blocklist b/tasks/format-code-task-000573/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000573/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000573/environment/setup/setup.sh b/tasks/format-code-task-000573/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000573/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000573/tests/test.patch b/tasks/format-code-task-000573/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..59fa9e6d62d2b0ae32388e5a0d93a4d3b26c9fac --- /dev/null +++ b/tasks/format-code-task-000573/tests/test.patch @@ -0,0 +1,41 @@ +diff --git a/bluesky/tests/test_callbacks.py b/bluesky/tests/test_callbacks.py +index 7253eae1b6..599150d220 100644 +--- a/bluesky/tests/test_callbacks.py ++++ b/bluesky/tests/test_callbacks.py +@@ -112,6 +112,14 @@ def f(name, doc): + RE._subscribe_lossless('not a thing', f) + + ++def test_table_warns(): ++ table = LiveTable(['field']) ++ table('start', {}) ++ with pytest.warns(UserWarning): ++ table('descriptor', {'uid': 'asdf', 'name': 'primary', ++ 'data_keys': {'field': {'dtype': 'array'}}}) ++ ++ + def test_table(): + with _print_redirect() as fout: + det.precision = 2 +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SS0vDQBAH8Jz7KYaQgx7y2NQkEPDgodCLRqQInsLmAQnNi+wmmm/vGqQVsfbS ++KuL/d9llZpYddtZKhrLK4rwZbe1cHCXwvHlVPq/znnkucx3P9QMVZ8x3mEbe2Tr6YBCS90Ra37by ++u7pj+T/K2s9f5kLGaVvXvMksUZzujmPzX7Llbv5eoOrYlc98jZzTtXDYP59/mtE8+CTPFvlL1/aS ++7p9Wd4/xQxRtrnVjHd2ubKub1AfRdwU3m7VK7evspGxC4y2sakZekW5czEeobEpJptlxWVx+nVPh ++bpJF2yzJrEltVTOUVEMuttPcmXj/mLyqEp5uhWomDOeQ5EmVx8+8bwSZ4+K3nxIAAAAAAAAAAAAA ++AAAAAAAA4Me9ArvJu6IAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000573/tests/test.sh b/tasks/format-code-task-000573/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..329f348690ed053c0ea6aee32903c51ac9456e49 --- /dev/null +++ b/tasks/format-code-task-000573/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +bluesky/tests/test_callbacks.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000573/tests/test_command.sh b/tasks/format-code-task-000573/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000573/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000574/environment/Dockerfile b/tasks/format-code-task-000574/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8984568adec9d5d4202c99f3df062dfd254ec766 --- /dev/null +++ b/tasks/format-code-task-000574/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fbbddcb3bb0822a8804a69623c9767acdcdce4b9f6b893b8c9f8e0943a89949a diff --git a/tasks/format-code-task-000574/environment/setup/files/blocklist b/tasks/format-code-task-000574/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000574/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000574/environment/setup/setup.sh b/tasks/format-code-task-000574/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000574/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000574/tests/test.patch b/tasks/format-code-task-000574/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a571e21e80bef8dc59859be4b258f7e1e561ca0a --- /dev/null +++ b/tasks/format-code-task-000574/tests/test.patch @@ -0,0 +1,123 @@ +diff --git a/eth/fetcher/block_fetcher_test.go b/eth/fetcher/block_fetcher_test.go +index a7e1a2ffb1..79f4e4f40d 100644 +--- a/eth/fetcher/block_fetcher_test.go ++++ b/eth/fetcher/block_fetcher_test.go +@@ -96,7 +96,9 @@ func newTester(light bool) *fetcherTester { + blocks: map[common.Hash]*types.Block{genesis.Hash(): genesis}, + drops: make(map[string]bool), + } +- tester.fetcher = NewBlockFetcher(light, tester.getHeader, tester.getBlock, tester.verifyHeader, tester.broadcastBlock, tester.chainHeight, tester.insertHeaders, tester.insertChain, tester.dropPeer) ++ tester.fetcher = NewBlockFetcher(light, tester.getHeader, tester.getBlock, tester.verifyHeader, ++ tester.broadcastBlock, tester.chainHeight, tester.chainFinalizedHeight, tester.insertHeaders, ++ tester.insertChain, tester.dropPeer) + tester.fetcher.Start() + + return tester +@@ -138,6 +140,18 @@ func (f *fetcherTester) chainHeight() uint64 { + return f.blocks[f.hashes[len(f.hashes)-1]].NumberU64() + } + ++func (f *fetcherTester) chainFinalizedHeight() uint64 { ++ f.lock.RLock() ++ defer f.lock.RUnlock() ++ if len(f.hashes) < 3 { ++ return 0 ++ } ++ if f.fetcher.light { ++ return f.headers[f.hashes[len(f.hashes)-3]].Number.Uint64() ++ } ++ return f.blocks[f.hashes[len(f.hashes)-3]].NumberU64() ++} ++ + // insertChain injects a new headers into the simulated chain. + func (f *fetcherTester) insertHeaders(headers []*types.Header) (int, error) { + f.lock.Lock() +@@ -730,6 +744,67 @@ func testDistantAnnouncementDiscarding(t *testing.T, light bool) { + } + } + ++ ++ ++func TestFullFinalizedAnnouncementDiscarding(t *testing.T) { ++ testFinalizedAnnouncementDiscarding(t, false) ++} ++func TestLightFinalizedAnnouncementDiscarding(t *testing.T) { ++ testFinalizedAnnouncementDiscarding(t, true) ++} ++ ++func testFinalizedAnnouncementDiscarding(t *testing.T, light bool) { ++ ++ hashes, blocks := makeChain(3*maxQueueDist, 0, genesis) ++ ++ head := hashes[len(hashes)/2] ++ justified := hashes[len(hashes)/2+1] ++ finalized := hashes[len(hashes)/2+2] ++ beforeFinalized := hashes[len(hashes)/2+3] ++ ++ low, equal := len(hashes)/2+3, len(hashes)/2+2 ++ ++ ++ tester := newTester(light) ++ ++ tester.lock.Lock() ++ tester.hashes = []common.Hash{beforeFinalized, finalized, justified, head} ++ tester.headers = map[common.Hash]*types.Header{ ++ beforeFinalized: blocks[beforeFinalized].Header(), ++ finalized: blocks[finalized].Header(), ++ justified: blocks[justified].Header(), ++ head: blocks[head].Header(), ++ } ++ tester.blocks = map[common.Hash]*types.Block{ ++ beforeFinalized: blocks[beforeFinalized], ++ finalized: blocks[finalized], ++ justified: blocks[justified], ++ head: blocks[head], ++ } ++ tester.lock.Unlock() ++ ++ headerFetcher := tester.makeHeaderFetcher("lower", blocks, -gatherSlack) ++ bodyFetcher := tester.makeBodyFetcher("lower", blocks, 0) ++ ++ fetching := make(chan struct{}, 2) ++ tester.fetcher.fetchingHook = func(hashes []common.Hash) { fetching <- struct{}{} } ++ ++ ++ tester.fetcher.Notify("lower", hashes[low], blocks[hashes[low]].NumberU64(), time.Now().Add(-arriveTimeout), headerFetcher, bodyFetcher, nil) ++ select { ++ case <-time.After(50 * time.Millisecond): ++ case <-fetching: ++ t.Fatalf("fetcher requested stale header") ++ } ++ ++ tester.fetcher.Notify("equal", hashes[equal], blocks[hashes[equal]].NumberU64(), time.Now().Add(-arriveTimeout), headerFetcher, bodyFetcher, nil) ++ select { ++ case <-time.After(50 * time.Millisecond): ++ case <-fetching: ++ t.Fatalf("fetcher requested future header") ++ } ++} ++ + // Tests that peers announcing blocks with invalid numbers (i.e. not matching + // the headers provided afterwards) get dropped as malicious. + func TestFullInvalidNumberAnnouncement(t *testing.T) { testInvalidNumberAnnouncement(t, false) } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3RS27DIBgEYNY5xX8B87KxV81VogRobck2kgF3k8OXWqr6UNtsElVR59uAYASI ++4ac8jO7g51WwW5FFZ8w2Fl/Hba6MlrozbdMpJpVqlWZkbvaiD3JMx4WILSGk33KX9u8Uf+8/+ZgO ++NkzTcXY89te741L/upT91n/dlZxqWt0wktd7ws/+ef/W0Vb8ybud82sVn4dke3oKpLiuSe9FWRVz ++Hkc6nykt2X+KWUuq+TZVTng9l7jwqRePvsT9IqhaqbIhz+lBUZWGyYecqJYy7v76JwAAAAAAAAAA ++AAAAAAAAAAAA7s8LeXwQIAAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000574/tests/test.sh b/tasks/format-code-task-000574/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..49036ae81e64112c86be290a75b49ad9d9ae8042 --- /dev/null +++ b/tasks/format-code-task-000574/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +eth/fetcher/block_fetcher_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000574/tests/test_command.sh b/tasks/format-code-task-000574/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000574/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000580/environment/Dockerfile b/tasks/format-code-task-000580/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3053ace6547837ffe8382c278f82c9e0efbca75c --- /dev/null +++ b/tasks/format-code-task-000580/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a773e1f4319675498f034a48600e6f37abb9c8274a120e139979a4f6d75ba47e diff --git a/tasks/format-code-task-000580/environment/setup/files/blocklist b/tasks/format-code-task-000580/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000580/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000580/environment/setup/setup.sh b/tasks/format-code-task-000580/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000580/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000580/tests/test.patch b/tasks/format-code-task-000580/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1f2b008cf691ffab0c1c388463b36ba96724ef5a --- /dev/null +++ b/tasks/format-code-task-000580/tests/test.patch @@ -0,0 +1,523 @@ +diff --git a/usercase-test-coderl/test_dynamodb_high_level_resource.py b/usercase-test-coderl/test_dynamodb_high_level_resource.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_dynamodb_high_level_resource.py +@@ -0,0 +1,486 @@ ++import gc ++import json ++import os ++import tempfile ++from decimal import Decimal ++ ++import boto3 ++import pytest ++from boto3.docs.service import ServiceDocumenter ++from boto3.dynamodb.conditions import Attr, Key ++from boto3.exceptions import DynamoDBNeedsKeyConditionError ++from botocore.stub import Stubber ++ ++ ++os.environ.setdefault("AWS_ACCESS_KEY_ID", "fixture-test") ++os.environ.setdefault("AWS_SECRET_ACCESS_KEY", "fixture-test") ++os.environ.setdefault("AWS_EC2_METADATA_DISABLED", "true") ++ ++ ++class LateRequestRecorder: ++ def __init__(self, client): ++ self.bodies = [] ++ client.meta.events.register_first("before-call.*.*", self.record) ++ ++ def record(self, event_name, params, **kwargs): ++ body = params.get("body", b"") ++ if isinstance(body, bytes): ++ body = body.decode("utf-8") ++ self.bodies.append(json.loads(body) if body else {}) ++ ++ ++def make_table(name="Users"): ++ session = boto3.Session(region_name="us-east-1") ++ dynamodb = session.resource("dynamodb") ++ return dynamodb.Table(name) ++ ++ ++def placeholders_for(mapping, expected_value): ++ return {key for key, value in mapping.items() if value == expected_value} ++ ++ ++def assert_placeholder_expression( ++ body, ++ *, ++ table_name, ++ key_attr, ++ key_wire_value, ++ filter_attr=None, ++ filter_wire_value=None, ++ caller_names=None, ++ caller_values=None, ++): ++ ++ ++ ++ assert body["TableName"] == table_name ++ names = body["ExpressionAttributeNames"] ++ values = body["ExpressionAttributeValues"] ++ caller_names = caller_names or {} ++ caller_values = caller_values or {} ++ ++ for placeholder, name in caller_names.items(): ++ assert names[placeholder] == name ++ for placeholder, value in caller_values.items(): ++ assert values[placeholder] == value ++ ++ key_expression = body["KeyConditionExpression"] ++ assert isinstance(key_expression, str) ++ assert "=" in key_expression ++ key_name_placeholders = placeholders_for(names, key_attr) ++ key_value_placeholders = placeholders_for(values, key_wire_value) ++ assert key_name_placeholders ++ assert key_value_placeholders ++ assert any(placeholder in key_expression for placeholder in key_name_placeholders) ++ assert any(placeholder in key_expression for placeholder in key_value_placeholders) ++ ++ if filter_attr is not None: ++ filter_expression = body["FilterExpression"] ++ assert isinstance(filter_expression, str) ++ assert ">=" in filter_expression ++ filter_name_placeholders = placeholders_for(names, filter_attr) ++ filter_value_placeholders = placeholders_for(values, filter_wire_value) ++ assert filter_name_placeholders ++ assert filter_value_placeholders ++ assert any( ++ placeholder in filter_expression ++ for placeholder in filter_name_placeholders ++ ) ++ assert any( ++ placeholder in filter_expression ++ for placeholder in filter_value_placeholders ++ ) ++ ++ ++def assert_doc_section_mentions(content, section_name, required_text): ++ indexes = [ ++ index ++ for index in range(len(content)) ++ if content.startswith(section_name, index) ++ ] ++ assert indexes ++ assert any(required_text in content[index : index + 1200] for index in indexes) ++ ++ ++def test_put_item_serializes_python_values_and_preserves_input(): ++ ++ ++ ++ ++ table = make_table() ++ recorder = LateRequestRecorder(table.meta.client) ++ item = { ++ "pk": "u#1", ++ "age": 42, ++ "active": True, ++ "tags": {"admin"}, ++ "profile": {"name": "Ada"}, ++ "scores": [1, 2], ++ "empty": None, ++ } ++ ++ with Stubber(table.meta.client) as stubber: ++ stubber.add_response( ++ "put_item", ++ {}, ++ expected_params={"TableName": "Users", "Item": item}, ++ ) ++ response = table.put_item(Item=item) ++ ++ assert response == {} ++ assert recorder.bodies == [ ++ { ++ "TableName": "Users", ++ "Item": { ++ "pk": {"S": "u#1"}, ++ "age": {"N": "42"}, ++ "active": {"BOOL": True}, ++ "tags": {"SS": ["admin"]}, ++ "profile": {"M": {"name": {"S": "Ada"}}}, ++ "scores": {"L": [{"N": "1"}, {"N": "2"}]}, ++ "empty": {"NULL": True}, ++ }, ++ } ++ ] ++ assert item == { ++ "pk": "u#1", ++ "age": 42, ++ "active": True, ++ "tags": {"admin"}, ++ "profile": {"name": "Ada"}, ++ "scores": [1, 2], ++ "empty": None, ++ } ++ ++ ++def test_get_item_deserializes_attribute_value_response(): ++ ++ ++ ++ ++ table = make_table() ++ ++ with Stubber(table.meta.client) as stubber: ++ stubber.add_response( ++ "get_item", ++ { ++ "Item": { ++ "pk": {"S": "u#1"}, ++ "age": {"N": "42"}, ++ "active": {"BOOL": True}, ++ "empty": {"NULL": True}, ++ } ++ }, ++ expected_params={"TableName": "Users", "Key": {"pk": "u#1"}}, ++ ) ++ response = table.get_item(Key={"pk": "u#1"}) ++ ++ assert response == { ++ "Item": { ++ "pk": "u#1", ++ "age": Decimal("42"), ++ "active": True, ++ "empty": None, ++ } ++ } ++ ++ ++def test_query_accepts_condition_objects_and_merges_placeholders(): ++ ++ ++ ++ ++ table = make_table() ++ recorder = LateRequestRecorder(table.meta.client) ++ ++ with Stubber(table.meta.client) as stubber: ++ stubber.add_response( ++ "query", ++ { ++ "Items": [{"pk": {"S": "u#1"}, "age": {"N": "42"}}], ++ "Count": 1, ++ "ScannedCount": 1, ++ }, ++ expected_params={ ++ "TableName": "Users", ++ "KeyConditionExpression": Key("pk").eq("u#1"), ++ "FilterExpression": Attr("age").gte(21), ++ "ExpressionAttributeNames": {"#caller": "caller_supplied"}, ++ "ExpressionAttributeValues": {":caller": "kept"}, ++ }, ++ ) ++ response = table.query( ++ KeyConditionExpression=Key("pk").eq("u#1"), ++ FilterExpression=Attr("age").gte(21), ++ ExpressionAttributeNames={"#caller": "caller_supplied"}, ++ ExpressionAttributeValues={":caller": "kept"}, ++ ) ++ ++ assert response == { ++ "Items": [{"pk": "u#1", "age": Decimal("42")}], ++ "Count": 1, ++ "ScannedCount": 1, ++ } ++ assert len(recorder.bodies) == 1 ++ assert_placeholder_expression( ++ recorder.bodies[0], ++ table_name="Users", ++ key_attr="pk", ++ key_wire_value={"S": "u#1"}, ++ filter_attr="age", ++ filter_wire_value={"N": "21"}, ++ caller_names={"#caller": "caller_supplied"}, ++ caller_values={":caller": {"S": "kept"}}, ++ ) ++ ++ ++def test_attr_in_key_condition_raises_specific_validation_error(): ++ ++ ++ ++ ++ table = make_table() ++ ++ with Stubber(table.meta.client) as stubber: ++ stubber.add_response("query", {"Items": []}) ++ with pytest.raises(DynamoDBNeedsKeyConditionError) as excinfo: ++ table.query(KeyConditionExpression=Attr("pk").eq("u#1")) ++ ++ ++ ++ assert isinstance(excinfo.value, DynamoDBNeedsKeyConditionError) ++ ++ ++def test_repeated_item_object_is_copied_before_serialization(): ++ ++ ++ ++ ++ table = make_table() ++ recorder = LateRequestRecorder(table.meta.client) ++ used_twice = {"pk": "u#2", "profile": {"name": "Grace"}} ++ ++ with Stubber(table.meta.client) as stubber: ++ stubber.add_response( ++ "batch_write_item", ++ {"UnprocessedItems": {}}, ++ expected_params={ ++ "RequestItems": { ++ "Users": [ ++ {"PutRequest": {"Item": used_twice}}, ++ {"PutRequest": {"Item": used_twice}}, ++ ] ++ } ++ }, ++ ) ++ batch = table.batch_writer() ++ batch.put_item(Item=used_twice) ++ batch.put_item(Item=used_twice) ++ batch._flush() ++ ++ assert recorder.bodies == [ ++ { ++ "RequestItems": { ++ "Users": [ ++ { ++ "PutRequest": { ++ "Item": { ++ "pk": {"S": "u#2"}, ++ "profile": { ++ "M": {"name": {"S": "Grace"}} ++ }, ++ } ++ } ++ }, ++ { ++ "PutRequest": { ++ "Item": { ++ "pk": {"S": "u#2"}, ++ "profile": { ++ "M": {"name": {"S": "Grace"}} ++ }, ++ } ++ } ++ }, ++ ] ++ } ++ } ++ ] ++ assert used_twice == {"pk": "u#2", "profile": {"name": "Grace"}} ++ ++ ++def test_no_output_shape_operation_completes_without_response_conversion(): ++ ++ ++ ++ ++ table = make_table() ++ arn = "arn:aws:dynamodb:us-east-1:123456789012:table/Users" ++ ++ with Stubber(table.meta.client) as stubber: ++ stubber.add_response("tag_resource", {}) ++ response = table.meta.client.tag_resource( ++ ResourceArn=arn, Tags=[{"Key": "project", "Value": "val"}] ++ ) ++ ++ assert response == {} ++ ++ ++def test_generated_documentation_describes_python_values_and_conditions(): ++ ++ ++ ++ ++ with tempfile.TemporaryDirectory() as docs_root: ++ root_services_path = os.path.join(docs_root, "reference", "services") ++ ServiceDocumenter( ++ "dynamodb", ++ session=boto3.Session(region_name="us-east-1"), ++ root_docs_path=root_services_path, ++ ).document_service() ++ ++ with open( ++ os.path.join(root_services_path, "dynamodb", "table", "put_item.rst"), ++ encoding="utf-8", ++ ) as f: ++ put_item_content = f.read() ++ with open( ++ os.path.join(root_services_path, "dynamodb", "table", "query.rst"), ++ encoding="utf-8", ++ ) as f: ++ query_content = f.read() ++ ++ ++ ++ ++ put_item_lower = put_item_content.lower() ++ assert "valid dynamodb type" in put_item_lower ++ assert "true" in put_item_lower ++ assert "none" in put_item_lower ++ assert "set([" in put_item_content ++ assert_doc_section_mentions(query_content, "FilterExpression", "Attr(") ++ assert_doc_section_mentions(query_content, "KeyConditionExpression", "Key(") ++ ++ ++def test_two_resource_instances_keep_condition_builder_state_independent(): ++ ++ ++ ++ ++ table_a = make_table("UsersA") ++ table_b = make_table("UsersB") ++ recorder_a = LateRequestRecorder(table_a.meta.client) ++ recorder_b = LateRequestRecorder(table_b.meta.client) ++ ++ with Stubber(table_a.meta.client) as stubber_a: ++ stubber_a.add_response( ++ "query", ++ {"Items": [], "Count": 0, "ScannedCount": 0}, ++ expected_params={ ++ "TableName": "UsersA", ++ "KeyConditionExpression": Key("pk").eq("a#1"), ++ "FilterExpression": Attr("age").gte(30), ++ }, ++ ) ++ response_a = table_a.query( ++ KeyConditionExpression=Key("pk").eq("a#1"), ++ FilterExpression=Attr("age").gte(30), ++ ) ++ ++ with Stubber(table_b.meta.client) as stubber_b: ++ stubber_b.add_response( ++ "query", ++ {"Items": [], "Count": 0, "ScannedCount": 0}, ++ expected_params={ ++ "TableName": "UsersB", ++ "KeyConditionExpression": Key("pk").eq("b#1"), ++ "FilterExpression": Attr("age").gte(40), ++ }, ++ ) ++ response_b = table_b.query( ++ KeyConditionExpression=Key("pk").eq("b#1"), ++ FilterExpression=Attr("age").gte(40), ++ ) ++ ++ assert response_a == {"Items": [], "Count": 0, "ScannedCount": 0} ++ assert response_b == {"Items": [], "Count": 0, "ScannedCount": 0} ++ assert len(recorder_a.bodies) == 1 ++ assert len(recorder_b.bodies) == 1 ++ assert_placeholder_expression( ++ recorder_a.bodies[0], ++ table_name="UsersA", ++ key_attr="pk", ++ key_wire_value={"S": "a#1"}, ++ filter_attr="age", ++ filter_wire_value={"N": "30"}, ++ ) ++ assert_placeholder_expression( ++ recorder_b.bodies[0], ++ table_name="UsersB", ++ key_attr="pk", ++ key_wire_value={"S": "b#1"}, ++ filter_attr="age", ++ filter_wire_value={"N": "40"}, ++ ) ++ ++ ++def test_resource_session_has_high_level_interface_for_generated_table_method(): ++ ++ ++ ++ ++ table = make_table() ++ recorder = LateRequestRecorder(table.meta.client) ++ ++ with Stubber(table.meta.client) as stubber: ++ stubber.add_response( ++ "put_item", ++ {}, ++ expected_params={"TableName": "Users", "Item": {"pk": "u#close"}}, ++ ) ++ response = table.put_item(Item={"pk": "u#close"}) ++ ++ ++ ++ assert response == {} ++ assert recorder.bodies == [ ++ {"TableName": "Users", "Item": {"pk": {"S": "u#close"}}} ++ ] ++ ++ ++def test_repeated_resource_cycles_apply_high_level_interface_each_time(): ++ ++ ++ ++ ++ ++ def cycle(index): ++ table = make_table(f"LeakUsers{index}") ++ recorder = LateRequestRecorder(table.meta.client) ++ with Stubber(table.meta.client) as stubber: ++ stubber.add_response( ++ "put_item", ++ {}, ++ expected_params={ ++ "TableName": f"LeakUsers{index}", ++ "Item": {"pk": f"u#{index}"}, ++ }, ++ ) ++ response = table.put_item(Item={"pk": f"u#{index}"}) ++ assert response == {} ++ assert recorder.bodies == [ ++ { ++ "TableName": f"LeakUsers{index}", ++ "Item": {"pk": {"S": f"u#{index}"}}, ++ } ++ ] ++ ++ for warmup_index in range(5): ++ cycle(warmup_index) ++ ++ ++ ++ for index in range(10): ++ cycle(index) ++ if index % 10 == 0: ++ gc.collect() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,27 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++ ++ ++ ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++export AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:-fixture-test}" ++export AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:-fixture-test}" ++export AWS_EC2_METADATA_DISABLED="${AWS_EC2_METADATA_DISABLED:-true}" ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_dynamodb_high_level_resource.py -v diff --git a/tasks/format-code-task-000580/tests/test.sh b/tasks/format-code-task-000580/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..583b778ece9a92634fd92487688e4162b98bb78e --- /dev/null +++ b/tasks/format-code-task-000580/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_dynamodb_high_level_resource.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000580/tests/test_command.sh b/tasks/format-code-task-000580/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000580/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000587/environment/Dockerfile b/tasks/format-code-task-000587/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..52ebd5413d5360262a12484d900e41409409479c --- /dev/null +++ b/tasks/format-code-task-000587/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:693941370708e2e630765b01aaf56bc8d4a97cab19a31b816804c254eeaa6793 diff --git a/tasks/format-code-task-000587/environment/setup/files/blocklist b/tasks/format-code-task-000587/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000587/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000587/environment/setup/setup.sh b/tasks/format-code-task-000587/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000587/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000587/tests/test.patch b/tasks/format-code-task-000587/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ae271e4ad7d123a4c387a65dc5e516b6179ecb7e --- /dev/null +++ b/tasks/format-code-task-000587/tests/test.patch @@ -0,0 +1,70 @@ +diff --git a/tests/test_redlock.py b/tests/test_redlock.py +index 1fa75732..5f97ed11 100644 +--- a/tests/test_redlock.py ++++ b/tests/test_redlock.py +@@ -7,6 +7,7 @@ + 'Distributed Redis-powered lock tests.' + + ++import concurrent.futures + import contextlib + import time + +@@ -15,6 +16,7 @@ + from pottery import Redlock + from pottery import ReleaseUnlockedLock + from pottery import TooManyExtensions ++from pottery import redlock + from tests.base import TestCase # type: ignore + + +@@ -176,3 +178,25 @@ def test_context_manager_release_before_exit(self): + def test_repr(self): + assert repr(self.redlock) == \ + "" ++ ++ ++class RedlockDecoratorTests(TestCase): ++ def setUp(self): ++ super().setUp() ++ ++ def expensive_method(*args, **kwargs): ++ time.sleep(1) ++ return time.time() ++ ++ self.expensive_method = redlock( ++ key='expensive-method', ++ masters={self.redis}, ++ )(expensive_method) ++ ++ def test_redlock_decorator(self): ++ with concurrent.futures.ThreadPoolExecutor() as executor: ++ futures = [executor.submit(self.expensive_method) for _ in range(3)] ++ results = sorted(future.result() for future in futures) ++ for result1, result2 in zip(results, results[1:]): ++ delta = result2 - result1 ++ assert 1 < delta < 2 +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,8 @@ ++H4sIAAAAAAAAA+3TzY6bMBAAYM48xVR7Nj8hbA7V9tI3aI+rKiJ4srEKY2QPaFnl4WtA2qwadaOV ++ElVV5zsAgvF47DHJrjeN3iINaXQrWbApy/ke/H6fn/NylRVZti6muDwvN/cRlDer6I3ec+UAImct ++vxd36fs/Kjn1n9HztrZtW5FO/OF6c1zq/6Zcnfqfh/f5+j4rI8iuV8Kf/ef9rzXMjd+hjuM7+B42 ++g+EbauPB7IEsQ9U4rPQIricy9BS76aPy6AZ0oJSusLVkXhBG9LD6kmocUuqbBo5HYNfjlPZrSMEI ++Qzhmc1pEjRrCOQNDYf9DsMYOSSPVBn0cQh7hE6g9pLbjtLPM6EY1DU93htKqZjNMCX98Bj4gxRB0 ++Ix8sFaDaZZ6zoXOUt72r8ULeJZ/pXqvzyH3H1jYe5uU/PBRJmRTQtocCeOzCvmzxmZG8seSnUsKW ++nmVRiqya/zdlvG0qDsGg8NQAbDx+oMq9ieNl1dOil0lhuvjlXw6lNrb+mXQjqCH+2ydNCCGEEEII ++IYQQQgghhBBCCCGEEELcwi/fcHRRACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000587/tests/test.sh b/tasks/format-code-task-000587/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e93336f43f83e7033f01eb6ff16cea881dd941ec --- /dev/null +++ b/tasks/format-code-task-000587/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_redlock.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000587/tests/test_command.sh b/tasks/format-code-task-000587/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000587/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000589/environment/Dockerfile b/tasks/format-code-task-000589/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0dad2595d190ac457b11b02676c7404c1c9d7327 --- /dev/null +++ b/tasks/format-code-task-000589/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1d9872c1d78beae42d4cb19d0c4e9cbfa5e5a4eccbe926103f5a8024f17f0718 diff --git a/tasks/format-code-task-000589/environment/setup/files/blocklist b/tasks/format-code-task-000589/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000589/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000589/environment/setup/setup.sh b/tasks/format-code-task-000589/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000589/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000589/tests/test.patch b/tasks/format-code-task-000589/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..866e807049bb40795cc1dc7d41483e259c0085b6 --- /dev/null +++ b/tasks/format-code-task-000589/tests/test.patch @@ -0,0 +1,79 @@ +diff --git a/userena/tests/tests_views.py b/userena/tests/tests_views.py +index 4c18a7fc..0ab66673 100644 +--- a/userena/tests/tests_views.py ++++ b/userena/tests/tests_views.py +@@ -1,3 +1,5 @@ ++import re ++ + from datetime import datetime, timedelta + from django.core.urlresolvers import reverse + from django.core import mail +@@ -445,3 +447,39 @@ def test_profile_list_view(self): + userena_settings.USERENA_DISABLE_PROFILE_LIST = True + response = self.client.get(reverse('userena_profile_list')) + self.assertEqual(response.status_code, 404) ++ ++ def test_password_reset_view_success(self): ++ """ A ``POST`` to the password reset view with email that exists""" ++ response = self.client.post(reverse('userena_password_reset'), ++ data={'email': 'john@example.com',}) ++ ++ ++ self.assertEqual(response.status_code, 302) ++ self.assertIn(reverse('userena_password_reset_done'), str(response)) ++ self.assertTrue(mail.outbox) ++ ++ def test_password_reset_view_failure(self): ++ """ A ``POST`` to the password reset view with incorrect email""" ++ response = self.client.post(reverse('userena_password_reset'), ++ data={'email': 'no.such.user@example.com',}) ++ ++ self.assertIn(response.status_code, [200, 302]) ++ self.assertFalse(mail.outbox) ++ ++ def test_password_reset_confirm(self): ++ ++ self.client.post(reverse('userena_password_reset'), ++ data={'email': 'john@example.com',}) ++ confirm_mail = mail.outbox[0] ++ confirm_url = re.search(r'\bhttps?://\S+', confirm_mail.body).group() ++ ++ ++ response = self.client.get(confirm_url) ++ self.assertEqual(response.status_code, 200) ++ ++ ++ response = self.client.post(confirm_url, ++ data={'new_password1': 'pass', ++ 'new_password2': 'pass',}) ++ self.assertEqual(response.status_code, 302) ++ self.assertIn(reverse('userena_password_reset_complete'), str(response)) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,13 @@ ++H4sIAAAAAAAAA+2UbW/TMBDH+zqf4sgmtZXWtOnWDiGCNGljG2IP2sorQJHTXBqjxI5ip7Tfnovb ++0K4ChtAmhPDvRV07d/+7y13sRRXP4hDFvN96LgbE8WhkVmJ3Nf/90XBwODjyybA18P3R8bgFo2fL ++aItKaVYCtEop9a/sHnv+j+Jt+q9R6XAq85yJ2FPp08V4pP/DgT/e9P/Qp/4fjQd+CwZPl8LP+c/7 ++v/eiH3HRj5hKnWkMZggijB1nD+5RQ1VAsaThgESWcLvUqRQw9I49/6WDi0KWGm5PJheBu39xc3XW ++94xtLfhqvz53HZyzDNz9zkqEC66h13Wd1XaWyYger/Uo4qWgZmQZFKX8glMNMRYoYhRTjgp4AkJq ++YFmJLF6SlrGlVAteNDvo9YTscVFUGtz4CxMzGQS+N/Z8F1wlK526zXlvKudYshnSSfP39ZELnxwg ++XGRqGeq0yiPBeKZqldHGd1axMuZM1Me+EU91ng01LnQdiC9cGL7pxzjviyrLtkvTKX4vj2uFWUK5 ++A8ZcsyhDyGWMDwtC8Ha17rBXkNOpyQW0BFMhdHZyhpwtIWVzpC7OShZjTBG7v/u6dmNWwuROH8uM ++5qIeE0h4httD068UlihYv6xEfaSaGTl9d3J9fhPen00ml9fn9+HVzemH92eBQq25mCkaBzNYvSm4 ++Ds+Ni1qqA5DKodUrmE49ShlL3RkcQLuJ1+46SSlzMI316NqiFuYotLe+xGhmVmIkME1DGuHQ3HFx ++FFLoqlh5r+r26idepev3tvaiOkOqRGD5wHAqRdKYbCr4cYRO15nQ/s6oQLAl2Wlcu47xKBuTjX2H ++hjKSiutlMDyAhFqaMKWDtyxTSJXTvirpuwhgS8CjxaSgOh/b63aY0tTqN5xz/Kran7vmxeKC604j ++1HVc52/fRhaLxWKxWCwWi8VisVgsFovFYrFYLBaLxWKxWP6Eb+9DkBkAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000589/tests/test.sh b/tasks/format-code-task-000589/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..98984b4e94c07b4f9239a8c1c27e64a0f4619c02 --- /dev/null +++ b/tasks/format-code-task-000589/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +userena/tests/tests_views.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000589/tests/test_command.sh b/tasks/format-code-task-000589/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000589/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000714/environment/Dockerfile b/tasks/format-code-task-000714/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1b78154b025f8ee53c149240036399d00b30a744 --- /dev/null +++ b/tasks/format-code-task-000714/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d1ee762a50b3ecb158d0983a79d86cf04991fc13d92c09bd284df55398d5ae3e diff --git a/tasks/format-code-task-000714/environment/setup/files/blocklist b/tasks/format-code-task-000714/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000714/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000714/environment/setup/setup.sh b/tasks/format-code-task-000714/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000714/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000714/tests/test.patch b/tasks/format-code-task-000714/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fd99d705d316b30b612600557c86c1d484502980 --- /dev/null +++ b/tasks/format-code-task-000714/tests/test.patch @@ -0,0 +1,105 @@ +diff --git a/bodyprocessors/json_contract_test.go b/bodyprocessors/json_contract_test.go +new file mode 100644 +index 00000000..7d62e84b +--- /dev/null ++++ b/bodyprocessors/json_contract_test.go +@@ -0,0 +1,89 @@ ++package bodyprocessors_test ++ ++import ( ++ "strings" ++ "testing" ++ ++ "github.com/corazawaf/coraza/v2" ++ "github.com/corazawaf/coraza/v2/bodyprocessors" ++ "github.com/corazawaf/coraza/v2/seclang" ++ "github.com/corazawaf/coraza/v2/types/variables" ++) ++ ++func TestJSONProcessorFlattensTopLevelArraysAndScalars(t *testing.T) { ++ p, err := bodyprocessors.GetBodyProcessor("json") ++ if err != nil { ++ t.Fatal(err) ++ } ++ err = p.Read(strings.NewReader(`["alpha", 2, true, null, ["nested"]]`), bodyprocessors.Options{}) ++ if err != nil { ++ t.Fatalf("reading JSON array: %v", err) ++ } ++ args := p.Collections()[variables.Args] ++ want := map[string]string{ ++ "json.0": "alpha", ++ "json.1": "2", ++ "json.2": "true", ++ "json.3": "", ++ "json.4.0": "nested", ++ } ++ for key, value := range want { ++ got := args[key] ++ if len(got) != 1 || got[0] != value { ++ t.Errorf("%s = %v, want %q", key, got, value) ++ } ++ } ++} ++ ++func TestJSONProcessorFindsPathsForSecRule(t *testing.T) { ++ waf := coraza.NewWaf() ++ parser, err := seclang.NewParser(waf) ++ if err != nil { ++ t.Fatal(err) ++ } ++ if err := parser.FromString(` ++SecRuleEngine On ++SecRule JSON:user.name "alice" "id:9101,phase:2,pass" ++SecRule JSON:items.1 "2" "id:9102,phase:2,pass" ++SecRule JSON:user.missing ".+" "id:9103,phase:2,pass" ++`); err != nil { ++ t.Fatal(err) ++ } ++ tx := waf.NewTransaction() ++ tx.RequestBodyAccess = true ++ tx.GetCollection(variables.ReqbodyProcessor).Set("", []string{"JSON"}) ++ if _, err := tx.RequestBodyBuffer.Write([]byte(`{"user":{"name":"alice"},"items":["x",2]}`)); err != nil { ++ t.Fatal(err) ++ } ++ if _, err := tx.ProcessRequestBody(); err != nil { ++ t.Fatal(err) ++ } ++ if got := tx.GetCollection(variables.ArgsPost).GetFirstString("json.user.name"); got != "alice" { ++ t.Fatalf("ARGS_POST did not receive JSON field: %q", got) ++ } ++ if got := tx.GetCollection(variables.Args).GetFirstString("json.items.1"); got != "2" { ++ t.Fatalf("ARGS did not receive JSON array field: %q", got) ++ } ++ matched := map[int]bool{} ++ for _, rule := range tx.MatchedRules { ++ matched[rule.Rule.ID] = true ++ } ++ if !matched[9101] || !matched[9102] { ++ t.Fatalf("JSON paths did not match: %#v", matched) ++ } ++ if matched[9103] { ++ t.Fatal("missing JSON path unexpectedly matched") ++ } ++} ++ ++func TestJSONProcessorRejectsInvalidAndScalarRoots(t *testing.T) { ++ for _, body := range []string{`not-json`, `42`, `"text"`, `true`, `null`} { ++ p, err := bodyprocessors.GetBodyProcessor("json") ++ if err != nil { ++ t.Fatal(err) ++ } ++ if err := p.Read(strings.NewReader(body), bodyprocessors.Options{}); err == nil { ++ t.Errorf("Read(%q) succeeded, want an error", body) ++ } ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++go test ./bodyprocessors diff --git a/tasks/format-code-task-000714/tests/test.sh b/tasks/format-code-task-000714/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ce8b05c5ab54cee56f1e57840d2bc4324b89d6c1 --- /dev/null +++ b/tasks/format-code-task-000714/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +bodyprocessors/json_contract_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000714/tests/test_command.sh b/tasks/format-code-task-000714/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000714/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000715/environment/Dockerfile b/tasks/format-code-task-000715/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d87288560fd6b7125705c3acdf5c07d54453cac7 --- /dev/null +++ b/tasks/format-code-task-000715/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1636d3ac9ed0f4ee8b6cc2fae6dbe52df28e4fe8dd1f5cc8276b181203a4a0c7 diff --git a/tasks/format-code-task-000715/environment/setup/files/blocklist b/tasks/format-code-task-000715/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000715/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000715/environment/setup/setup.sh b/tasks/format-code-task-000715/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000715/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000715/tests/test.patch b/tasks/format-code-task-000715/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0ffee03fd8917463a47ae0cf48e11ce760be9597 --- /dev/null +++ b/tasks/format-code-task-000715/tests/test.patch @@ -0,0 +1,45 @@ +diff --git a/etcd/client_test.go b/etcd/client_test.go +index 66d79d7..4720d8d 100644 +--- a/etcd/client_test.go ++++ b/etcd/client_test.go +@@ -94,3 +94,15 @@ func TestPersistence(t *testing.T) { + t.Fatalf("The two configs should be equal!") + } + } ++ ++func TestClientRetry(t *testing.T) { ++ c := NewClient([]string{"http://strange", "http://127.0.0.1:4001"}) ++ ++ c.cluster.picked = 0 ++ if _, err := c.Set("foo", "bar", 5); err != nil { ++ t.Fatal(err) ++ } ++ if _, err := c.Delete("foo", true); err != nil { ++ t.Fatal(err) ++ } ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+3TUWvbMBAA4Dz7V1wp5E2W5SQ2dCQwtrI9bHSU7q1QHPuSCGTJSLLZ/v1ktSxZ ++1jYvLdvYfXmwrdz5Dp2crnupmjvUA5+8liwoF4t4DY6v8V4s8iwvyzKbFZNMiELkE1i8WkcHeucr ++CzCxxvjn4k79/49K9/P36Pxdbdq20k3qdi9X48T8RR5m/jD/oixEmP+8mM0nkL1cC0/7z+d/fsbX ++UvN15XZJ3UA8BGtsEvzWGevhw5UQ4vPV+6+fLpdms9kvf3l783HJx03hW5Mk53CpXW8R0Ie3SAe2 ++11rqLRgNMWMe5pzIDZxB3VsFzMHO++6Cc5GXaRZ+4mIM4QNaJ0PSijc4cN0rBflqKt6A36FOIIgV ++GNNVi6BNgyI8NJWvWCNt6L/t+BhxvyTgNuZAiFHSedSsVhK1Z6GJny1ksYEsNnCQUDWhGS8dPpaj ++TF2pnXH+OOuhTIdoHy1S/houtfSyUgfFfsvcl3oit1bhEKO9343lqSzU1VohG/Kltz0edm62TOGA ++CtBaY2G62u9mfHUaImAa451C7CBPNnKc/XWvx/lA+JK26GE8Q8nRyYGtievABmDhcMBNeHgX9/Ua ++vf0OzMsWTe9hljlIY1We/OmvgxBCCCGEEEIIIYQQQgghhBBCCCHk7/cDWujacgAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000715/tests/test.sh b/tasks/format-code-task-000715/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e888d783f06cbb6283048e25a5637d9a65519f4d --- /dev/null +++ b/tasks/format-code-task-000715/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +etcd/client_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000715/tests/test_command.sh b/tasks/format-code-task-000715/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000715/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000723/environment/Dockerfile b/tasks/format-code-task-000723/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d6f924f038be0a25197299f612e0dc6d3260eb64 --- /dev/null +++ b/tasks/format-code-task-000723/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:837362be0a1fa7f3999ac2c8e694d14b73ab7220fca342ff69ffd4bd84ae465d diff --git a/tasks/format-code-task-000723/environment/setup/files/blocklist b/tasks/format-code-task-000723/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000723/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000723/environment/setup/setup.sh b/tasks/format-code-task-000723/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000723/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000723/tests/test.patch b/tasks/format-code-task-000723/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c41c17897dd8a22ba4891c3e6649df39ac1a1ea4 --- /dev/null +++ b/tasks/format-code-task-000723/tests/test.patch @@ -0,0 +1,94 @@ +diff --git a/api/system/spec/role.json b/api/system/spec/role.json +index e09e1de6f6..29baaddf7d 100644 +--- a/api/system/spec/role.json ++++ b/api/system/spec/role.json +@@ -40,6 +40,12 @@ + "title": "Name of Role", + "type": "string" + }, ++ { ++ "name": "handle", ++ "required": true, ++ "title": "Handle for Role", ++ "type": "string" ++ }, + { + "name": "members", + "required": false, +@@ -70,6 +76,12 @@ + "title": "Name of Role", + "type": "string" + }, ++ { ++ "name": "handle", ++ "required": false, ++ "title": "Handle for Role", ++ "type": "string" ++ }, + { + "name": "members", + "required": false, +diff --git a/tests/system/role_test.go b/tests/system/role_test.go +index 7909e6ee35..8839dfb52c 100644 +--- a/tests/system/role_test.go ++++ b/tests/system/role_test.go +@@ -75,6 +75,7 @@ func TestRoleCreate(t *testing.T) { + h.apiInit(). + Post("/roles/"). + FormData("name", string(rand.Bytes(10))). ++ FormData("handle", string(rand.Bytes(10))). + Expect(t). + Status(http.StatusOK). + Assert(helpers.AssertNoErrors). +@@ -100,10 +101,12 @@ func TestRoleUpdate(t *testing.T) { + h.allow(types.RolePermissionResource.AppendWildcard(), "update") + + newName := "updated-" + string(rand.Bytes(10)) ++ newHandle := "updated-" + string(rand.Bytes(10)) + + h.apiInit(). + Put(fmt.Sprintf("/roles/%d", u.ID)). + FormData("name", newName). ++ FormData("handle", newHandle). + Expect(t). + Status(http.StatusOK). + Assert(helpers.AssertNoErrors). +@@ -113,6 +116,7 @@ func TestRoleUpdate(t *testing.T) { + h.a.NoError(err) + h.a.NotNil(u) + h.a.Equal(newName, u.Name) ++ h.a.Equal(newHandle, u.Handle) + } + + func TestRoleDeleteForbidden(t *testing.T) { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,15 @@ ++H4sIAAAAAAAAA+2Ua2/bNhSG81m/4jQF4naALF/iZEjqrrItO8ZUq7WUbsMwCLocyVwk0iOprO6v ++LyXbiXtbh67FMIzPB4ni5bxH58J2XJEiDZHeWkffio7ifDBo3or33824O+h1u2eD07OemlejTv8I ++Bt/MowMqISMOcMQZk3+173Pr/1Ha9/mXKGSYsLKMaNoWq6+n8Zn8904753f5H5z3VP5Pz/qdI+h8 ++PRc+zf88/w8fWDGhVhyJlZGk0BRBjKlhPASHioojPI84iSYjIAJ4RSmhuUEyeADlRvxRRGlJKJgV ++1OGBtVoE0xSkQCqh99RK8daiVVFcglwhNUBR3qSEg7kGS1mzGiMpnJxAsmJ/0q3Ri+Z5uGF7shmG ++IsoQTpoZUSCuoW9kpPZ3zDGSCGkkI/U7CKqMoRLIQbmr5DeQMtqSgK+JkMZWYu+4iXA8Xjp24MDE ++DuyR7Tswn8LCC8D5ee4HPiSMS3wTwfjKXtrjwFmC7wRQyez7Mj6Fsee69eHdd5gjRR4VYUIujw/j ++8GnZa1+ZfFeytdNsPWsVLImKFROyBfOJswjm07kzgdEv93suYba0FwHYrgsvlvNXc9eZOT54i73n ++7e8g8D5u8xKm7rV/dXDuPa9VcCdERHGBkDGOJKdwo+KZrDC5EZAXLI6KYgOPKGKKKaQVgmRQYB4l ++GyhJziNJGAX/pQvTH4FjhhxpghBX+eOPhKSO7Mz1Rra7lwuVXLiTG0LnQ/d+4kSlvq2usfpInW6o ++KxlEpeaNJJLw9K62rWbbkyfQcrxpy5iMwom/GO4Cc7F7P5PJ+tFdiC76/c7ZY2u39kPCiqL5peGH ++CTdcbxa6zivHHSLnjBtKpPbQRwnVGmbeCzu4ArEpC0Jv6tLcBs3A12tlfbc+tOpgWDm7n+52u8+9 ++ybXrDFmWGQddtN1oCZ5YOZGrKm6rO3zv6pqz3zGRdcf+qnrWdP/mgf2nqfrnVrXQbwcdXKiGF9ld ++OL/M4q5nlxVVeVd1RajEfZ3UhkVzG32R5Zxtc2/egpmwisphF9qNt8ISGyGxtMBUdwscB2puqdSP ++jX/7GtZoNBqNRqPRaDQajUaj0Wg0Go1Go9FoNBqN5h/xFhvazbIAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000723/tests/test.sh b/tasks/format-code-task-000723/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..966464e1bb2c6b2ccb08d125c50b2bfdac9b5d67 --- /dev/null +++ b/tasks/format-code-task-000723/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +api/system/spec/role.json +tests/system/role_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000723/tests/test_command.sh b/tasks/format-code-task-000723/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000723/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000725/environment/Dockerfile b/tasks/format-code-task-000725/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..79c059a9c24e97eeba8463ecf45f7cf1bfa5e1e3 --- /dev/null +++ b/tasks/format-code-task-000725/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:287c8900834a792784570c8f2373d3036fe83f3945c5ca4065a82e8a650315a9 diff --git a/tasks/format-code-task-000725/environment/setup/files/blocklist b/tasks/format-code-task-000725/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000725/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000725/environment/setup/setup.sh b/tasks/format-code-task-000725/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000725/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000725/tests/test.patch b/tasks/format-code-task-000725/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..da00e618f7fc0309144553ac68b06539f3b047c3 --- /dev/null +++ b/tasks/format-code-task-000725/tests/test.patch @@ -0,0 +1,209 @@ +diff --git a/all/approximation/approximation_test.py b/all/approximation/approximation_test.py +new file mode 100644 +index 0000000..81528dd +--- /dev/null ++++ b/all/approximation/approximation_test.py +@@ -0,0 +1,66 @@ ++import unittest ++ ++import torch ++ ++from all.approximation import Approximation ++ ++ ++class ApproximationClipGradTest(unittest.TestCase): ++ ++ def _make_approximation(self): ++ torch.manual_seed(0) ++ model = torch.nn.Linear(2, 1, bias=False) ++ optimizer = torch.optim.SGD(model.parameters(), lr=0.25) ++ approximation = Approximation( ++ model, ++ optimizer, ++ name='clip_grad_test', ++ clip_grad=1.0 ++ ) ++ return approximation, model ++ ++ def _parameter_clone(self, model): ++ return [parameter.detach().clone() for parameter in model.parameters()] ++ ++ def _set_gradient(self, model, value): ++ for parameter in model.parameters(): ++ parameter.grad = torch.full_like(parameter, value) ++ ++ def test_clip_grad_raises_on_infinite_norm(self): ++ approximation, model = self._make_approximation() ++ before = self._parameter_clone(model) ++ self._set_gradient(model, float('inf')) ++ ++ with self.assertRaises(RuntimeError): ++ approximation.step() ++ ++ for expected, actual in zip(before, model.parameters()): ++ self.assertTrue(torch.allclose(expected, actual.detach())) ++ ++ def test_clip_grad_raises_on_nan_norm(self): ++ approximation, model = self._make_approximation() ++ before = self._parameter_clone(model) ++ self._set_gradient(model, float('nan')) ++ ++ with self.assertRaises(RuntimeError): ++ approximation.step() ++ ++ for expected, actual in zip(before, model.parameters()): ++ self.assertTrue(torch.allclose(expected, actual.detach())) ++ ++ def test_clip_grad_allows_finite_gradients(self): ++ approximation, model = self._make_approximation() ++ before = self._parameter_clone(model) ++ self._set_gradient(model, 0.5) ++ ++ result = approximation.step() ++ ++ self.assertIs(result, approximation) ++ self.assertFalse(all(torch.allclose(expected, actual.detach()) ++ for expected, actual in zip(before, model.parameters()))) ++ self.assertTrue(all(parameter.grad is None or torch.all(parameter.grad == 0) ++ for parameter in model.parameters())) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/all/policies/soft_deterministic_test.py b/all/policies/soft_deterministic_test.py +index 135bd69..cd4a1ec 100644 +--- a/all/policies/soft_deterministic_test.py ++++ b/all/policies/soft_deterministic_test.py +@@ -56,16 +56,27 @@ class TestSoftDeterministic(unittest.TestCase): + self.assertLess(loss, 0.2) + + def test_scaling(self): +- self.space = Box(np.array([-10, -5, 100]), np.array([10, -2, 200])) +- self.policy = SoftDeterministicPolicy( ++ action1, log_prob1 = self._sample_with_space(np.array([1., 1., 1.])) ++ ++ scales = np.array([2., 1., 1.]) ++ action2, log_prob2 = self._sample_with_space(scales) ++ tt.assert_allclose(action1 * torch.tensor(scales, dtype=action1.dtype), action2) ++ tt.assert_allclose(log_prob1 - np.log(scales).sum(), log_prob2) ++ ++ scales = np.array([3., 0.5, 4.]) ++ action3, log_prob3 = self._sample_with_space(scales) ++ tt.assert_allclose(action1 * torch.tensor(scales, dtype=action1.dtype), action3) ++ tt.assert_allclose(log_prob1 - np.log(scales).sum(), log_prob3) ++ ++ def _sample_with_space(self, scales): ++ torch.manual_seed(0) ++ state = State(torch.randn(1, STATE_DIM)) ++ policy = SoftDeterministicPolicy( + self.model, + self.optimizer, +- self.space ++ Box(-scales, scales) + ) +- state = State(torch.randn(1, STATE_DIM)) +- action, log_prob = self.policy(state) +- tt.assert_allclose(action, torch.tensor([[-3.09055, -4.752777, 188.98222]])) +- tt.assert_allclose(log_prob, torch.tensor([-0.397002]), rtol=1e-4) ++ return policy(state) + + + if __name__ == '__main__': +diff --git a/setup_config_test.py b/setup_config_test.py +new file mode 100644 +index 0000000..c95f8df +--- /dev/null ++++ b/setup_config_test.py +@@ -0,0 +1,61 @@ ++import ast ++import pathlib ++import re ++import unittest ++ ++ ++class SetupConfigTest(unittest.TestCase): ++ ++ def _repo_root(self): ++ return pathlib.Path(__file__).resolve().parent ++ ++ def _setup_call_keywords(self): ++ setup_path = self._repo_root() / 'setup.py' ++ module = ast.parse(setup_path.read_text()) ++ for node in ast.walk(module): ++ if isinstance(node, ast.Call) and getattr(node.func, 'id', None) == 'setup': ++ return { ++ keyword.arg: keyword.value ++ for keyword in node.keywords ++ if keyword.arg is not None ++ } ++ self.fail('setup.py does not contain a setup() call') ++ ++ def _docs_release(self): ++ conf_path = self._repo_root() / 'docs' / 'source' / 'conf.py' ++ module = ast.parse(conf_path.read_text()) ++ for node in module.body: ++ if isinstance(node, ast.Assign): ++ for target in node.targets: ++ if isinstance(target, ast.Name) and target.id == 'release': ++ return ast.literal_eval(node.value) ++ self.fail('docs/source/conf.py does not assign release') ++ ++ def _install_requires(self): ++ keywords = self._setup_call_keywords() ++ self.assertIn('install_requires', keywords) ++ return ast.literal_eval(keywords['install_requires']) ++ ++ def test_package_and_docs_versions_are_072(self): ++ keywords = self._setup_call_keywords() ++ self.assertIn('version', keywords) ++ ++ ++ self.assertEqual(ast.literal_eval(keywords['version']), '0.7.2') ++ self.assertEqual(self._docs_release(), '0.7.2') ++ ++ def test_torch_dependency_targets_19(self): ++ install_requires = self._install_requires() ++ ++ self.assertIn('torch~=1.9.0', install_requires) ++ ++ workflow = (self._repo_root() / '.github' / 'workflows' / 'python-package.yml').read_text() ++ ++ self.assertRegex( ++ workflow, ++ r'pip\s+install\s+torch==1\.9\.0\+cpu(?:\s|$)' ++ ) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,26 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++cd /testbed ++ ++ ++case "$1" in ++ base) ++ python3 -m pytest -q \ ++ all/policies/soft_deterministic_test.py::TestSoftDeterministic::test_output_shape \ ++ all/policies/soft_deterministic_test.py::TestSoftDeterministic::test_step_one \ ++ all/policies/soft_deterministic_test.py::TestSoftDeterministic::test_converge ++ ;; ++ new) ++ python3 -m pytest -q \ ++ all/policies/soft_deterministic_test.py::TestSoftDeterministic::test_scaling \ ++ all/approximation/approximation_test.py::ApproximationClipGradTest \ ++ setup_config_test.py::SetupConfigTest ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000725/tests/test.sh b/tasks/format-code-task-000725/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a2a3211a4d8d4f2dedcc0cddfad2a3e232483356 --- /dev/null +++ b/tasks/format-code-task-000725/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +all/approximation/approximation_test.py +all/policies/soft_deterministic_test.py +setup_config_test.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000725/tests/test_command.sh b/tasks/format-code-task-000725/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000725/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000741/environment/Dockerfile b/tasks/format-code-task-000741/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4797ad7cb1f06de6bafb1752e900ee288ad7050e --- /dev/null +++ b/tasks/format-code-task-000741/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5a33ea1ce8a36076d293421f3a3c957e76ce71ae79f31340bf0cdc63aaa1654c diff --git a/tasks/format-code-task-000741/environment/setup/files/blocklist b/tasks/format-code-task-000741/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000741/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000741/environment/setup/setup.sh b/tasks/format-code-task-000741/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000741/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000741/tests/test.patch b/tasks/format-code-task-000741/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..368107776d277dc189f5504fe170a560a28a5999 --- /dev/null +++ b/tasks/format-code-task-000741/tests/test.patch @@ -0,0 +1,345 @@ +diff --git a/tests/run/cpp_stl_associated_containers_contains_cpp20.pyx b/tests/run/cpp_stl_associated_containers_contains_cpp20.pyx +new file mode 100644 +index 00000000000..ebe8d8fa883 +--- /dev/null ++++ b/tests/run/cpp_stl_associated_containers_contains_cpp20.pyx +@@ -0,0 +1,106 @@ ++# mode: run ++# tag: cpp, cpp20 ++ ++# cython: language_level=3 ++ ++from libcpp.map cimport map, multimap ++from libcpp.set cimport set, multiset ++from libcpp.unordered_map cimport unordered_map, unordered_multimap ++from libcpp.unordered_set cimport unordered_set, unordered_multiset ++ ++def test_map_contains(vals, int key_to_find): ++ """ ++ >>> test_map_contains([(1,100),(2,200),(3,300)], 3) ++ True ++ >>> test_map_contains([(1,100),(2,200),(3,300)], 4) ++ False ++ """ ++ cdef map[int,int] m = map[int, int]() ++ for v in vals: ++ m.insert(v) ++ return m.contains(key_to_find) ++ ++def test_unordered_map_contains(vals, int key_to_find): ++ """ ++ >>> test_unordered_map_contains([(1,100),(2,200),(3,300)], 3) ++ True ++ >>> test_unordered_map_contains([(1,100),(2,200),(3,300)], 4) ++ False ++ """ ++ cdef unordered_map[int,int] um = unordered_map[int, int]() ++ for v in vals: ++ um.insert(v) ++ return um.contains(key_to_find) ++ ++def test_multimap_contains(vals, int key_to_find): ++ """ ++ >>> test_multimap_contains([(1,100),(2,200),(3,300)], 3) ++ True ++ >>> test_multimap_contains([(1,100),(2,200),(3,300)], 4) ++ False ++ """ ++ cdef multimap[int,int] mm = multimap[int, int]() ++ for v in vals: ++ mm.insert(v) ++ return mm.contains(key_to_find) ++ ++def test_unordered_multimap_contains(vals, int key_to_find): ++ """ ++ >>> test_unordered_multimap_contains([(1,100),(2,200),(3,300)], 3) ++ True ++ >>> test_unordered_multimap_contains([(1,100),(2,200),(3,300)], 4) ++ False ++ """ ++ cdef unordered_multimap[int,int] umm = unordered_multimap[int, int]() ++ for v in vals: ++ umm.insert(v) ++ return umm.contains(key_to_find) ++ ++ ++def test_set_contains(vals, int val_to_find): ++ """ ++ >>> test_set_contains([1, 2, 3], 3) ++ True ++ >>> test_set_contains([1, 2, 3], 4) ++ False ++ """ ++ cdef set[int] s = set[int]() ++ for v in vals: ++ s.insert(v) ++ return s.contains(val_to_find) ++ ++def test_unordered_set_contains(vals, int val_to_find): ++ """ ++ >>> test_unordered_set_contains([1, 2, 3], 3) ++ True ++ >>> test_unordered_set_contains([1, 2, 3], 4) ++ False ++ """ ++ cdef unordered_set[int] us = unordered_set[int]() ++ for v in vals: ++ us.insert(v) ++ return us.contains(val_to_find) ++ ++def test_multiset_contains(vals, int val_to_find): ++ """ ++ >>> test_multiset_contains([1, 2, 3], 3) ++ True ++ >>> test_multiset_contains([1, 2, 3], 4) ++ False ++ """ ++ cdef multiset[int] ms = multiset[int]() ++ for v in vals: ++ ms.insert(v) ++ return ms.contains(val_to_find) ++ ++def test_unordered_multiset_contains(vals, int val_to_find): ++ """ ++ >>> test_unordered_multiset_contains([1, 2, 3], 3) ++ True ++ >>> test_unordered_multiset_contains([1, 2, 3], 4) ++ False ++ """ ++ cdef unordered_multiset[int] ums = unordered_multiset[int]() ++ for v in vals: ++ ums.insert(v) ++ return ums.contains(val_to_find) +diff --git a/tests/run/cpp_stl_numeric_ops_cpp17.pyx b/tests/run/cpp_stl_numeric_ops_cpp17.pyx +index eba4d2beb86..d0e3f8b7b2 100644 +--- a/tests/run/cpp_stl_numeric_ops_cpp17.pyx ++++ b/tests/run/cpp_stl_numeric_ops_cpp17.pyx +@@ -3,7 +3,7 @@ + + from libcpp.numeric cimport (reduce, transform_reduce, inclusive_scan, + exclusive_scan, transform_inclusive_scan, +- transform_exclusive_scan) ++ transform_exclusive_scan, gcd, lcm) + from libcpp.execution cimport seq + from libcpp.vector cimport vector + +@@ -275,3 +275,23 @@ def test_transform_exclusive_scan_with_execpolicy(vector[int] v, int init): + cdef vector[int] out = vector[int](v.size()) + transform_exclusive_scan(seq, v.begin(), v.end(), out.begin(), init, add_integers, multiply_with_2) + return out ++ ++ ++def test_gcd(int a, int b): ++ """ ++ >>> test_gcd(12, 18) ++ 6 ++ >>> test_gcd(21, 14) ++ 7 ++ """ ++ return gcd[int](a, b) ++ ++ ++def test_lcm(int a, int b): ++ """ ++ >>> test_lcm(45, 75) ++ 225 ++ >>> test_lcm(4, 6) ++ 12 ++ """ ++ return lcm[int](a, b) +diff --git a/tests/run/cpp_stl_numeric_ops_cpp20.pyx b/tests/run/cpp_stl_numeric_ops_cpp20.pyx +new file mode 100644 +index 00000000000..9a8f5ec4ac +--- /dev/null ++++ b/tests/run/cpp_stl_numeric_ops_cpp20.pyx +@@ -0,0 +1,26 @@ ++# mode: run ++# tag: cpp, werror, cpp20 ++ ++from libcpp.numeric cimport midpoint ++ ++ ++def test_midpoint_integer(int a, int b): ++ """ ++ >>> test_midpoint_integer(2, 6) ++ 4 ++ >>> test_midpoint_integer(10, 20) ++ 15 ++ """ ++ cdef int res = midpoint[int](a, b) ++ return res ++ ++ ++def test_midpoint_float(float a, float b): ++ """ ++ >>> test_midpoint_float(2, 6) ++ 4.0 ++ >>> test_midpoint_float(1, 2) ++ 1.5 ++ """ ++ cdef float res = midpoint[float](a, b) ++ return res +diff --git a/tests/run/cpp_stl_string_cpp20.pyx b/tests/run/cpp_stl_string_cpp20.pyx +new file mode 100644 +index 00000000000..f3a2b80d15f +--- /dev/null ++++ b/tests/run/cpp_stl_string_cpp20.pyx +@@ -0,0 +1,61 @@ ++# mode: run ++# tag: cpp, werror, cpp20 ++ ++from libcpp cimport bool ++from libcpp.string cimport string ++ ++b_A = b'A' ++b_F = b'F' ++b_abc = b"ABC" ++b_def = b"DEF" ++ ++def test_string_starts_with_char(bytes py_str): ++ """ ++ Test std::string.starts_with() with char type argument ++ >>> test_string_starts_with_char(b'A') ++ True ++ >>> test_string_starts_with_char(b'F') ++ False ++ """ ++ cdef char c = py_str[0] ++ cdef string s = b"ABCDEF" ++ return s.starts_with(c) ++ ++ ++def test_string_starts_with_cstr(bytes py_str): ++ """ ++ Test std::string.starts_with() with c str type argument (char*) ++ >>> test_string_starts_with_cstr(b"ABC") ++ True ++ >>> test_string_starts_with_cstr(b"DEF") ++ False ++ """ ++ cdef char* c = py_str ++ cdef string s = b"ABCDEF" ++ return s.starts_with(c) ++ ++ ++def test_string_ends_with_char(bytes py_str): ++ """ ++ Test std::string.ends_with() with char type argument ++ >>> test_string_ends_with_char(b'F') ++ True ++ >>> test_string_ends_with_char(b'A') ++ False ++ """ ++ cdef char c = py_str[0] ++ cdef string s = b"ABCDEF" ++ return s.ends_with(c) ++ ++ ++def test_string_ends_with_cstr(bytes py_str): ++ """ ++ Test std::string.ends_with() with c str type argument (char*) ++ >>> test_string_ends_with_cstr(b"DEF") ++ True ++ >>> test_string_ends_with_cstr(b"ABC") ++ False ++ """ ++ cdef char* c = py_str ++ cdef string s = b"ABCDEF" ++ return s.ends_with(c) +\ No newline at end of file +diff --git a/tests/run/cpp_stl_string_cpp23.pyx b/tests/run/cpp_stl_string_cpp23.pyx +new file mode 100644 +index 00000000000..74866c8a16 +--- /dev/null ++++ b/tests/run/cpp_stl_string_cpp23.pyx +@@ -0,0 +1,29 @@ ++# mode: run ++# tag: cpp, werror, cpp23 ++# distutils: extra_compile_args=-std=c++23 ++ ++from libcpp.string cimport string ++ ++ ++def test_string_contains_char(bytes py_str): ++ """ ++ >>> test_string_contains_char(b"C") ++ True ++ >>> test_string_contains_char(b"Z") ++ False ++ """ ++ cdef char c = py_str[0] ++ cdef string s = b"ABCDEF" ++ return s.contains(c) ++ ++ ++def test_string_contains_cstr(bytes py_str): ++ """ ++ >>> test_string_contains_cstr(b"BCD") ++ True ++ >>> test_string_contains_cstr(b"XYZ") ++ False ++ """ ++ cdef char* c = py_str ++ cdef string s = b"ABCDEF" ++ return s.contains(c) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,56 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++dev-switch python3 3.11 ++ ++ ++if ! command -v g++-15 >/dev/null 2>&1; then ++ apt-get update ++ apt-get install -y gcc-15 g++-15 ++fi ++export CC=gcc-15 ++export CXX=g++-15 ++ ++ ++if [ ! -d /testbed/.build_env/.venv ]; then ++ python3 -m venv /testbed/.build_env/.venv ++fi ++set +u ++source /testbed/.build_env/.venv/bin/activate ++set -u ++ ++ ++pip install --quiet setuptools ++ ++ ++python3 setup.py build_ext --inplace 2>&1 | tail -5 ++ ++ ++case "${1:-}" in ++ base) ++ rm -rf TEST_TMP/run/cpp/cpp_stl_vector* ++ python3 runtests.py --no-c \ ++ cpp_stl_vector ++ ;; ++ new) ++ rm -rf \ ++ TEST_TMP/run/cpp/cpp_stl_numeric_ops_cpp17* \ ++ TEST_TMP/run/cpp/cpp_stl_numeric_ops_cpp20* \ ++ TEST_TMP/run/cpp/cpp_stl_associated_containers_contains_cpp20* \ ++ TEST_TMP/run/cpp/cpp_stl_string_cpp20* \ ++ TEST_TMP/run/cpp/cpp_stl_string_cpp23* ++ python3 runtests.py --no-c \ ++ cpp_stl_numeric_ops_cpp17 \ ++ cpp_stl_numeric_ops_cpp20 \ ++ cpp_stl_associated_containers_contains_cpp20 \ ++ cpp_stl_string_cpp20 \ ++ cpp_stl_string_cpp23 ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000741/tests/test.sh b/tasks/format-code-task-000741/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1dfc16fe6fc6098b0c13ff0b090cac6174df61b7 --- /dev/null +++ b/tasks/format-code-task-000741/tests/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/run/cpp_stl_associated_containers_contains_cpp20.pyx +tests/run/cpp_stl_numeric_ops_cpp17.pyx +tests/run/cpp_stl_numeric_ops_cpp20.pyx +tests/run/cpp_stl_string_cpp20.pyx +tests/run/cpp_stl_string_cpp23.pyx +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000741/tests/test_command.sh b/tasks/format-code-task-000741/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000741/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000746/environment/Dockerfile b/tasks/format-code-task-000746/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1985b6914021ceaae5060a88f8dbc2ea86df654e --- /dev/null +++ b/tasks/format-code-task-000746/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:36af50c59f533e59af375817ee01a8cc98d04e5bd6b051c0482a94d735422003 diff --git a/tasks/format-code-task-000746/environment/setup/files/blocklist b/tasks/format-code-task-000746/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000746/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000746/environment/setup/setup.sh b/tasks/format-code-task-000746/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000746/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000746/tests/test.patch b/tasks/format-code-task-000746/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3fb4893c70f2c49adee5ce59fede265d990e00c1 --- /dev/null +++ b/tasks/format-code-task-000746/tests/test.patch @@ -0,0 +1,315 @@ +diff --git a/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_scheduler.py b/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_scheduler.py +index 1822dfcaf7..83f058fcff 100644 +--- a/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_scheduler.py ++++ b/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_scheduler.py +@@ -132,6 +132,7 @@ + scheduleOrError(scheduleSelector: $scheduleSelector) { + __typename + ... on Schedule { ++ id + defaultStatus + canReset + scheduleState { +@@ -196,6 +197,33 @@ + } + """ + ++STOP_SCHEDULE_WITH_OPTIONAL_IDS_QUERY = """ ++mutation StopScheduleWithOptionalIds( ++ $id: String ++ $scheduleOriginId: String ++ $scheduleSelectorId: String ++) { ++ stopRunningSchedule( ++ id: $id ++ scheduleOriginId: $scheduleOriginId ++ scheduleSelectorId: $scheduleSelectorId ++ ) { ++ __typename ++ ... on PythonError { ++ message ++ className ++ stack ++ } ++ ... on ScheduleStateResult { ++ scheduleState { ++ id ++ status ++ } ++ } ++ } ++} ++""" ++ + RESET_SCHEDULES_QUERY = """ + mutation( + $scheduleSelector: ScheduleSelector! +@@ -809,6 +837,101 @@ def test_repository_batching(graphql_context): + + + class TestScheduleMutations(ExecutingGraphQLContextTestMatrix): ++ def _start_schedule_and_get_id( ++ self, ++ graphql_context: WorkspaceRequestContext, ++ schedule_name: str = "no_config_job_hourly_schedule", ++ ) -> str: ++ schedule_selector = infer_schedule_selector(graphql_context, schedule_name) ++ start_result = execute_dagster_graphql( ++ graphql_context, ++ START_SCHEDULES_QUERY, ++ variables={"scheduleSelector": schedule_selector}, ++ ) ++ assert start_result.data ++ assert start_result.data["startSchedule"]["__typename"] == "ScheduleStateResult" ++ return start_result.data["startSchedule"]["scheduleState"]["id"] ++ ++ def _get_schedule_state( ++ self, ++ graphql_context: WorkspaceRequestContext, ++ schedule_name: str = "no_config_job_hourly_schedule", ++ ): ++ schedule_selector = infer_schedule_selector(graphql_context, schedule_name) ++ result = execute_dagster_graphql( ++ graphql_context, ++ GET_SCHEDULE_STATE_QUERY, ++ variables={"scheduleSelector": schedule_selector}, ++ ) ++ assert result.data ++ assert result.data["scheduleOrError"]["__typename"] == "Schedule" ++ return result.data["scheduleOrError"] ++ ++ def test_stop_schedule_accepts_queried_id(self, graphql_context: WorkspaceRequestContext): ++ schedule_id = self._start_schedule_and_get_id(graphql_context) ++ ++ result = execute_dagster_graphql( ++ graphql_context, ++ STOP_SCHEDULE_WITH_OPTIONAL_IDS_QUERY, ++ variables={"id": schedule_id}, ++ ) ++ ++ assert result.data ++ assert result.data["stopRunningSchedule"]["__typename"] == "ScheduleStateResult" ++ assert result.data["stopRunningSchedule"]["scheduleState"]["status"] == "STOPPED" ++ ++ def test_schedule_state_id_matches_schedule_id_and_can_be_reused( ++ self, graphql_context: WorkspaceRequestContext ++ ): ++ schedule = self._get_schedule_state(graphql_context, "running_in_code_schedule") ++ ++ assert schedule["id"] == schedule["scheduleState"]["id"] ++ ++ result = execute_dagster_graphql( ++ graphql_context, ++ STOP_SCHEDULE_WITH_OPTIONAL_IDS_QUERY, ++ variables={"id": schedule["scheduleState"]["id"]}, ++ ) ++ assert result.data ++ assert result.data["stopRunningSchedule"]["__typename"] == "ScheduleStateResult" ++ assert result.data["stopRunningSchedule"]["scheduleState"]["status"] == "STOPPED" ++ ++ def test_stop_schedule_accepts_queried_id_in_legacy_origin_arg( ++ self, graphql_context: WorkspaceRequestContext ++ ): ++ schedule_id = self._start_schedule_and_get_id(graphql_context) ++ ++ result = execute_dagster_graphql( ++ graphql_context, ++ STOP_SCHEDULE_WITH_OPTIONAL_IDS_QUERY, ++ variables={"scheduleOriginId": schedule_id}, ++ ) ++ ++ assert result.data ++ assert result.data["stopRunningSchedule"]["__typename"] == "ScheduleStateResult" ++ assert result.data["stopRunningSchedule"]["scheduleState"]["status"] == "STOPPED" ++ ++ def test_stop_schedule_requires_id_or_complete_legacy_pair( ++ self, graphql_context: WorkspaceRequestContext ++ ): ++ for variables in [ ++ {}, ++ {"scheduleOriginId": "not-a-complete-id"}, ++ {"scheduleSelectorId": "selector-only"}, ++ ]: ++ result = execute_dagster_graphql( ++ graphql_context, ++ STOP_SCHEDULE_WITH_OPTIONAL_IDS_QUERY, ++ variables=variables, ++ ) ++ assert result.data ++ assert result.data["stopRunningSchedule"]["__typename"] == "PythonError" ++ ++ assert ( ++ "Must specify id or scheduleOriginId and scheduleSelectorId" ++ in result.data["stopRunningSchedule"]["message"] ++ ) ++ + def test_start_and_stop_schedule(self, graphql_context: WorkspaceRequestContext): + schedule_selector = infer_schedule_selector( + graphql_context, "no_config_job_hourly_schedule" +diff --git a/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_sensors.py b/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_sensors.py +index 4e3f88ad03..be41bc4241 100644 +--- a/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_sensors.py ++++ b/python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_sensors.py +@@ -217,6 +217,7 @@ + sensorOrError(sensorSelector: $sensorSelector) { + __typename + ... on Sensor { ++ id + canReset + defaultStatus + sensorState { +@@ -294,6 +295,29 @@ + } + """ + ++STOP_SENSOR_WITH_OPTIONAL_IDS_QUERY = """ ++mutation StopSensorWithOptionalIds( ++ $id: String ++ $jobOriginId: String ++ $jobSelectorId: String ++) { ++ stopSensor(id: $id, jobOriginId: $jobOriginId, jobSelectorId: $jobSelectorId) { ++ __typename ++ ... on PythonError { ++ message ++ className ++ stack ++ } ++ ... on StopSensorMutationResult { ++ instigationState { ++ id ++ status ++ } ++ } ++ } ++} ++""" ++ + RESET_SENSORS_QUERY = """ + mutation($sensorSelector: SensorSelector!) { + resetSensor(sensorSelector: $sensorSelector) { +@@ -779,6 +803,93 @@ def test_set_cursor_failure(self, graphql_context: WorkspaceRequestContext): + + + class TestSensorMutations(ExecutingGraphQLContextTestMatrix): ++ def _start_sensor_and_get_id( ++ self, graphql_context: WorkspaceRequestContext, sensor_name: str = "always_no_config_sensor" ++ ) -> str: ++ sensor_selector = infer_sensor_selector(graphql_context, sensor_name) ++ start_result = execute_dagster_graphql( ++ graphql_context, ++ START_SENSORS_QUERY, ++ variables={"sensorSelector": sensor_selector}, ++ ) ++ assert start_result.data ++ assert start_result.data["startSensor"]["__typename"] == "Sensor" ++ return start_result.data["startSensor"]["id"] ++ ++ def _get_sensor_status( ++ self, graphql_context: WorkspaceRequestContext, sensor_name: str = "always_no_config_sensor" ++ ): ++ sensor_selector = infer_sensor_selector(graphql_context, sensor_name) ++ result = execute_dagster_graphql( ++ graphql_context, ++ GET_SENSOR_STATUS_QUERY, ++ variables={"sensorSelector": sensor_selector}, ++ ) ++ assert result.data ++ assert result.data["sensorOrError"]["__typename"] == "Sensor" ++ return result.data["sensorOrError"] ++ ++ def test_stop_sensor_accepts_queried_id(self, graphql_context: WorkspaceRequestContext): ++ sensor_id = self._start_sensor_and_get_id(graphql_context) ++ ++ result = execute_dagster_graphql( ++ graphql_context, ++ STOP_SENSOR_WITH_OPTIONAL_IDS_QUERY, ++ variables={"id": sensor_id}, ++ ) ++ ++ assert result.data ++ assert result.data["stopSensor"]["__typename"] == "StopSensorMutationResult" ++ assert result.data["stopSensor"]["instigationState"]["status"] == "STOPPED" ++ ++ def test_sensor_state_id_matches_sensor_id_and_can_be_reused( ++ self, graphql_context: WorkspaceRequestContext ++ ): ++ sensor = self._get_sensor_status(graphql_context, "running_in_code_sensor") ++ ++ assert sensor["id"] == sensor["sensorState"]["id"] ++ ++ result = execute_dagster_graphql( ++ graphql_context, ++ STOP_SENSOR_WITH_OPTIONAL_IDS_QUERY, ++ variables={"id": sensor["sensorState"]["id"]}, ++ ) ++ assert result.data ++ assert result.data["stopSensor"]["__typename"] == "StopSensorMutationResult" ++ assert result.data["stopSensor"]["instigationState"]["status"] == "STOPPED" ++ ++ def test_stop_sensor_accepts_queried_id_in_legacy_origin_arg( ++ self, graphql_context: WorkspaceRequestContext ++ ): ++ sensor_id = self._start_sensor_and_get_id(graphql_context) ++ ++ result = execute_dagster_graphql( ++ graphql_context, ++ STOP_SENSOR_WITH_OPTIONAL_IDS_QUERY, ++ variables={"jobOriginId": sensor_id}, ++ ) ++ ++ assert result.data ++ assert result.data["stopSensor"]["__typename"] == "StopSensorMutationResult" ++ assert result.data["stopSensor"]["instigationState"]["status"] == "STOPPED" ++ ++ def test_stop_sensor_requires_id_or_complete_legacy_pair( ++ self, graphql_context: WorkspaceRequestContext ++ ): ++ for variables in [{}, {"jobOriginId": "not-a-complete-id"}, {"jobSelectorId": "selector-only"}]: ++ result = execute_dagster_graphql( ++ graphql_context, ++ STOP_SENSOR_WITH_OPTIONAL_IDS_QUERY, ++ variables=variables, ++ ) ++ assert result.data ++ assert result.data["stopSensor"]["__typename"] == "PythonError" ++ ++ assert ( ++ "Must specify id or jobOriginId and jobSelectorId" ++ in result.data["stopSensor"]["message"] ++ ) ++ + def test_start_sensor(self, graphql_context: WorkspaceRequestContext): + sensor_selector = infer_sensor_selector(graphql_context, "always_no_config_sensor") + result = execute_dagster_graphql( +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,26 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++set +u ++source /testbed/.build_env/venv/bin/activate ++set -u ++cd /testbed/python_modules/dagster-graphql ++ ++ ++BASE_FILTER="not postgres and not (test_dry_run_with_dynamic_partition_requests and lazy_repository) and not code_server_cli_env and not test_stop_sensor_accepts_queried_id and not test_sensor_state_id_matches_sensor_id_and_can_be_reused and not test_stop_sensor_accepts_queried_id_in_legacy_origin_arg and not test_stop_sensor_requires_id_or_complete_legacy_pair and not test_stop_schedule_accepts_queried_id and not test_schedule_state_id_matches_schedule_id_and_can_be_reused and not test_stop_schedule_accepts_queried_id_in_legacy_origin_arg and not test_stop_schedule_requires_id_or_complete_legacy_pair" ++NEW_FILTER="not postgres and not code_server_cli_env and (test_stop_sensor_accepts_queried_id or test_sensor_state_id_matches_sensor_id_and_can_be_reused or test_stop_sensor_accepts_queried_id_in_legacy_origin_arg or test_stop_sensor_requires_id_or_complete_legacy_pair or test_stop_schedule_accepts_queried_id or test_schedule_state_id_matches_schedule_id_and_can_be_reused or test_stop_schedule_accepts_queried_id_in_legacy_origin_arg or test_stop_schedule_requires_id_or_complete_legacy_pair)" ++ ++case "${1:-}" in ++ base) ++ python -m pytest dagster_graphql_tests/graphql/test_scheduler.py dagster_graphql_tests/graphql/test_sensors.py -v -k "$BASE_FILTER" ++ ;; ++ new) ++ python -m pytest dagster_graphql_tests/graphql/test_scheduler.py dagster_graphql_tests/graphql/test_sensors.py -v -k "$NEW_FILTER" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000746/tests/test.sh b/tasks/format-code-task-000746/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..574b5728edd3a66f08736bde525f9fa49c2b07fa --- /dev/null +++ b/tasks/format-code-task-000746/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_scheduler.py +python_modules/dagster-graphql/dagster_graphql_tests/graphql/test_sensors.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000746/tests/test_command.sh b/tasks/format-code-task-000746/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000746/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000748/environment/Dockerfile b/tasks/format-code-task-000748/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4f56d2588026e2882fa05ea51b628bf64d26d8fd --- /dev/null +++ b/tasks/format-code-task-000748/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4c593ccd07662b6c0b5da1261ed0d89c5e612b90545f213296bcab507cc60610 diff --git a/tasks/format-code-task-000748/environment/setup/files/blocklist b/tasks/format-code-task-000748/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000748/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000748/environment/setup/setup.sh b/tasks/format-code-task-000748/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000748/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000748/tests/test.patch b/tasks/format-code-task-000748/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..98feac1400250a2ff9590bc9945c72c91c635d02 --- /dev/null +++ b/tasks/format-code-task-000748/tests/test.patch @@ -0,0 +1,149 @@ +diff --git a/huma_test.go b/huma_test.go +index 21af0418..86e0bd65 100644 +--- a/huma_test.go ++++ b/huma_test.go +@@ -94,9 +94,21 @@ func TestFeatures(t *testing.T) { + QueryUint uint32 `query:"uint"` + QueryBool bool `query:"bool"` + QueryStrings []string `query:"strings"` +- HeaderString string `header:"String"` +- HeaderInt int `header:"Int"` +- HeaderDate time.Time `header:"Date"` ++ QueryInts []int `query:"ints"` ++ QueryInts8 []int8 `query:"ints8"` ++ QueryInts16 []int16 `query:"ints16"` ++ QueryInts32 []int32 `query:"ints32"` ++ QueryInts64 []int64 `query:"ints64"` ++ QueryUints []uint `query:"uints"` ++ ++ QueryUints16 []uint16 `query:"uints16"` ++ QueryUints32 []uint32 `query:"uints32"` ++ QueryUints64 []uint64 `query:"uints64"` ++ QueryFloats32 []float32 `query:"floats32"` ++ QueryFloats64 []float64 `query:"floats64"` ++ HeaderString string `header:"String"` ++ HeaderInt int `header:"Int"` ++ HeaderDate time.Time `header:"Date"` + }) (*struct{}, error) { + assert.Equal(t, "foo", input.PathString) + assert.Equal(t, 123, input.PathInt) +@@ -110,11 +122,22 @@ func TestFeatures(t *testing.T) { + assert.Equal(t, []string{"foo", "bar"}, input.QueryStrings) + assert.Equal(t, "baz", input.HeaderString) + assert.Equal(t, 789, input.HeaderInt) ++ assert.Equal(t, []int{2, 3}, input.QueryInts) ++ assert.Equal(t, []int8{4, 5}, input.QueryInts8) ++ assert.Equal(t, []int16{4, 5}, input.QueryInts16) ++ assert.Equal(t, []int32{4, 5}, input.QueryInts32) ++ assert.Equal(t, []int64{4, 5}, input.QueryInts64) ++ assert.Equal(t, []uint{1, 2}, input.QueryUints) ++ assert.Equal(t, []uint16{10, 15}, input.QueryUints16) ++ assert.Equal(t, []uint32{10, 15}, input.QueryUints32) ++ assert.Equal(t, []uint64{10, 15}, input.QueryUints64) ++ assert.Equal(t, []float32{2.2, 2.3}, input.QueryFloats32) ++ assert.Equal(t, []float64{3.2, 3.3}, input.QueryFloats64) + return nil, nil + }) + }, + Method: http.MethodGet, +- URL: "/test-params/foo/123?string=bar&int=456&before=2023-01-01T12:00:00Z&date=2023-01-01&uint=1&bool=true&strings=foo,bar", ++ URL: "/test-params/foo/123?string=bar&int=456&before=2023-01-01T12:00:00Z&date=2023-01-01&uint=1&bool=true&strings=foo,bar&ints=2,3&ints8=4,5&ints16=4,5&ints32=4,5&ints64=4,5&uints=1,2&uints16=10,15&uints32=10,15&uints64=10,15&floats32=2.2,2.3&floats64=3.2,3.3", + Headers: map[string]string{ + "string": "baz", + "int": "789", +@@ -664,7 +687,8 @@ func TestFeatures(t *testing.T) { + if feature.Assert != nil { + feature.Assert(t, w) + } else { +- assert.Less(t, w.Code, 300, w.Body.String()) ++ cn := w.Body.String() ++ assert.Less(t, w.Code, 300, cn) + } + }) + } +diff --git a/validate_test.go b/validate_test.go +index 0f444c71..517fc9de 100644 +--- a/validate_test.go ++++ b/validate_test.go +@@ -532,6 +532,61 @@ var validateTests = []struct { + typ: reflect.TypeOf([]any{}), + input: []any{1, 2, 3}, + }, ++ { ++ name: "array success", ++ typ: reflect.TypeOf([]int{}), ++ input: []int{1, 2, 3}, ++ }, ++ { ++ name: "array success", ++ typ: reflect.TypeOf([]int8{}), ++ input: []int8{1, 2, 3}, ++ }, ++ { ++ name: "array success", ++ typ: reflect.TypeOf([]int16{}), ++ input: []int16{1, 2, 3}, ++ }, ++ { ++ name: "array success", ++ typ: reflect.TypeOf([]int32{}), ++ input: []int32{1, 2, 3}, ++ }, ++ { ++ name: "array success", ++ typ: reflect.TypeOf([]int64{}), ++ input: []int64{1, 2, 3}, ++ }, ++ { ++ name: "array success", ++ typ: reflect.TypeOf([]uint{}), ++ input: []uint{1, 2, 3}, ++ }, ++ { ++ name: "array success", ++ typ: reflect.TypeOf([]uint16{}), ++ input: []uint16{1, 2, 3}, ++ }, ++ { ++ name: "array success", ++ typ: reflect.TypeOf([]uint32{}), ++ input: []uint32{1, 2, 3}, ++ }, ++ { ++ name: "array success", ++ typ: reflect.TypeOf([]uint64{}), ++ input: []uint64{1, 2, 3}, ++ }, ++ { ++ name: "array success", ++ typ: reflect.TypeOf([]float32{}), ++ input: []float32{1.1, 2.3, 3.52}, ++ }, ++ { ++ name: "array success", ++ typ: reflect.TypeOf([]float64{}), ++ input: []float64{3.1, 2.3, 3.62}, ++ }, + { + name: "expected array", + typ: reflect.TypeOf([]any{}), +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3Rz2qEMBDHcc8+xUCv3dSkaqHQt+hdsiZ1BTWg0eeva+kfCu1edillv5/LhMlA ++JvzUfm47V/lhuUsuJVs9FMVWV9/rdtaFyUyp83uzzmldZjqR4mIbfTFP0Y4iyRhC/G3u1P0/pT7z ++j36KVR363g5OTYfzvXEqf23Kj/xNbtb881KbRLLzrfCzK8+/drIFv/cuvZFnOzY+yrEhL23np0c5 ++zL2tjg3VhFtZbNc6G/17J23C2/RukV0d5iE+aVHpX/8KAAAAAAAAAAAAAAAAuA6vyfzFpQAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000748/tests/test.sh b/tasks/format-code-task-000748/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e3fdad0f2b3bb0866ee7a59383aab28ad12829e1 --- /dev/null +++ b/tasks/format-code-task-000748/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +huma_test.go +validate_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000748/tests/test_command.sh b/tasks/format-code-task-000748/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000748/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000777/environment/Dockerfile b/tasks/format-code-task-000777/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ec59efbf084ffa8c56e95f2122e78bbda2cf944e --- /dev/null +++ b/tasks/format-code-task-000777/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e225b251fb8596459111a47ff18c8845317484e93b3c3c11105c24155047c10e diff --git a/tasks/format-code-task-000777/environment/setup/files/blocklist b/tasks/format-code-task-000777/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000777/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000777/environment/setup/setup.sh b/tasks/format-code-task-000777/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000777/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000777/tests/test.patch b/tasks/format-code-task-000777/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4a40b3fe8fddda2a4ef729996bd41c0aea0ddb4c --- /dev/null +++ b/tasks/format-code-task-000777/tests/test.patch @@ -0,0 +1,95 @@ +diff --git a/modules/140-user-authz/hooks/handle_manage_bindings_test.go b/modules/140-user-authz/hooks/handle_manage_bindings_test.go +index 2d6b8ce949d0..24e187806dff 100644 +--- a/modules/140-user-authz/hooks/handle_manage_bindings_test.go ++++ b/modules/140-user-authz/hooks/handle_manage_bindings_test.go +@@ -65,7 +65,8 @@ var _ = Describe("Modules :: user-authz :: hooks :: handle-scope-bindings ::", f + resources := []string{ + manageModuleRole("d8:manage:capability:module:test:edit", "others", "test-ns"), + manageModuleRole("d8:manage:capability:module:test2:edit", "others", "test2-ns"), +- manageScopeRole("d8:manage:all:admin", "all", ""), ++ manageScopeRole("d8:manage:others:admin", "scope", "others"), ++ manageScopeRole("d8:manage:all:admin", "all", "all"), + manageScopeBinding("test", "d8:manage:all:admin"), + } + f.BindingContexts.Set(f.KubeStateSet(strings.Join(resources, "\n---\n"))) +@@ -116,14 +117,22 @@ func manageScopeRole(name, level, scope string) string { + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Labels: map[string]string{ +- "heritage": "deckhouse", +- "rbac.deckhouse.io/level": level, +- "rbac.deckhouse.io/kind": "manage", ++ "rbac.deckhouse.io/use-role": "admin", ++ "rbac.deckhouse.io/level": level, ++ "rbac.deckhouse.io/kind": "manage", + }, + }, ++ AggregationRule: &rbacv1.AggregationRule{ClusterRoleSelectors: []metav1.LabelSelector{ ++ { ++ MatchLabels: map[string]string{ ++ "rbac.deckhouse.io/kind": "manage", ++ fmt.Sprintf("rbac.deckhouse.io/aggregate-to-%s-as", scope): "admin", ++ }, ++ }, ++ }}, + } +- if scope != "" { +- role.Labels["rbac.deckhouse.io/scope"] = scope ++ if level != "all" { ++ role.Labels["rbac.deckhouse.io/aggregate-to-all-as"] = "admin" + } + marshaled, _ := yaml.Marshal(&role) + return string(marshaled) +@@ -138,10 +147,9 @@ func manageModuleRole(name, scope, namespace string) string { + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Labels: map[string]string{ +- "heritage": "deckhouse", +- "rbac.deckhouse.io/level": "module", +- "rbac.deckhouse.io/kind": "manage", +- "rbac.deckhouse.io/namespace": namespace, ++ "rbac.deckhouse.io/level": "module", ++ "rbac.deckhouse.io/kind": "manage", ++ "rbac.deckhouse.io/namespace": namespace, + fmt.Sprintf("rbac.deckhouse.io/aggregate-to-%s-as", scope): "admin", + }, + }, +@@ -162,7 +170,7 @@ func manageScopeBinding(name, role string) string { + Subjects: []rbacv1.Subject{ + { + Kind: "User", +- APIGroup: "v1", ++ APIGroup: "rbac.authorization.k8s.io", + Name: "test", + }, + }, +@@ -194,7 +202,7 @@ func useBinding(relatedWith, namespace string) string { + Subjects: []rbacv1.Subject{ + { + Kind: "User", +- APIGroup: "v1", ++ APIGroup: "rbac.authorization.k8s.io", + Name: "test", + }, + }, +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SzW6EIBQFYNc+BZ2uEaGiK9+i+4kK/mTU2wjMok9fatK0adLOZibNpOfb3JtA ++uIRD1oZpNke7nkVyK3lUab3X6Hvde6mVVEo/SVUkuZS6KhOmb3ajL4LzzcZYshH53/ZdWr9T2Wf+ ++3jp/7GhZmtVkbrzejEv5Kyk/8leVLGP+RSlVwvLrXeFn/zz/xwfRTqtoGzemnWH7J2itSQdi7y3j ++flosBV9LvTB+tr6mvo8Ny8RCJszWCVnkPDi78Sb48VWMRCcnGN/Cyp73I4ZpPQ2U9dQFVx/G+L1m ++y11HL5bH2WZaB3dI//ohAAAAAAAAAAAAAAAAAAAAAADu0BtwnSWHACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000777/tests/test.sh b/tasks/format-code-task-000777/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9af8c89eb20b505aec0df3702b8eee61873719f8 --- /dev/null +++ b/tasks/format-code-task-000777/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +modules/140-user-authz/hooks/handle_manage_bindings_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000777/tests/test_command.sh b/tasks/format-code-task-000777/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000777/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000779/environment/Dockerfile b/tasks/format-code-task-000779/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c6b7036f71aa422b6bf4a82427038e526c5cf6ba --- /dev/null +++ b/tasks/format-code-task-000779/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4615245ec58fb8aa03b553d6d0b3107234ad18704cdbf7e9301b5ebdafc5747a diff --git a/tasks/format-code-task-000779/environment/setup/files/blocklist b/tasks/format-code-task-000779/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000779/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000779/environment/setup/setup.sh b/tasks/format-code-task-000779/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000779/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000779/tests/test.patch b/tasks/format-code-task-000779/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e6b099822bca1a10cbc44be9168369f4997d213b --- /dev/null +++ b/tasks/format-code-task-000779/tests/test.patch @@ -0,0 +1,471 @@ +diff --git a/usercase-test-coderl/instance_class_etcd_disk_test.go b/usercase-test-coderl/instance_class_etcd_disk_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/instance_class_etcd_disk_test.go +@@ -0,0 +1,442 @@ ++package usercase_test_coderl ++ ++import ( ++ "os" ++ "path/filepath" ++ "reflect" ++ "sort" ++ "testing" ++ ++ cpapi "github.com/deckhouse/deckhouse/go_lib/cloud-provider/api" ++ cpval "github.com/deckhouse/deckhouse/go_lib/cloud-provider/validation" ++) ++ ++ ++ ++ ++ ++ ++type resultSnapshot struct { ++ HasErrors bool ++ Errors []violationSnapshot ++} ++ ++type violationSnapshot struct { ++ Path string ++ Code string ++ Value any ++} ++ ++func TestValidateInstanceClassesEtcdDiskNilStateReturnsInternalStateNil(t *testing.T) { ++ ++ ++ ++ ++ ++ assertBlockingCode(t, cpval.ValidateInstanceClassesEtcdDisk(nil), "internal_state_nil") ++} ++ ++func TestValidateInstanceClassesEtcdDiskMasterReferenceRequiresEtcdDisk(t *testing.T) { ++ ++ ++ ++ ++ state := &cpval.State{ ++ InstanceClassKind: "DVPInstanceClass", ++ NodeGroups: []cpapi.NodeGroup{ ++ nodeGroupRef("master", "DVPInstanceClass", "master-dvp"), ++ }, ++ InstanceClasses: []cpapi.InstanceClass{ ++ instanceClass("DVPInstanceClass", "master-dvp", nil), ++ }, ++ } ++ ++ ++ assertSingleError(t, cpval.ValidateInstanceClassesEtcdDisk(state), "DVPInstanceClass/master-dvp.spec.etcdDisk", "master_etcd_disk_required", nil) ++} ++ ++func TestValidateInstanceClassesEtcdDiskEmptyInstanceClassKindIsAcceptedForMaster(t *testing.T) { ++ ++ ++ ++ ++ state := &cpval.State{ ++ InstanceClassKind: "DVPInstanceClass", ++ NodeGroups: []cpapi.NodeGroup{ ++ nodeGroupRef("master", "DVPInstanceClass", "empty-kind-master"), ++ }, ++ InstanceClasses: []cpapi.InstanceClass{ ++ instanceClass("", "empty-kind-master", nil), ++ }, ++ } ++ ++ ++ assertSingleError(t, cpval.ValidateInstanceClassesEtcdDisk(state), "DVPInstanceClass/empty-kind-master.spec.etcdDisk", "master_etcd_disk_required", nil) ++} ++ ++func TestValidateInstanceClassesEtcdDiskNonMasterReferenceForbidsEtcdDiskValue(t *testing.T) { ++ ++ ++ ++ ++ state := &cpval.State{ ++ InstanceClassKind: "DVPInstanceClass", ++ NodeGroups: []cpapi.NodeGroup{ ++ nodeGroupRef("worker", "DVPInstanceClass", "worker-dvp"), ++ }, ++ InstanceClasses: []cpapi.InstanceClass{ ++ instanceClass("DVPInstanceClass", "worker-dvp", map[string]any{"size": "50Gi", "type": "fast"}), ++ }, ++ } ++ ++ ++ assertSingleError(t, cpval.ValidateInstanceClassesEtcdDisk(state), "DVPInstanceClass/worker-dvp.spec.etcdDisk", "etcd_disk_forbidden_for_non_master", map[string]any{"size": "50Gi", "type": "fast"}) ++} ++ ++func TestValidateInstanceClassesEtcdDiskAcceptsValidMasterAndWorkerPlacement(t *testing.T) { ++ ++ ++ ++ ++ state := &cpval.State{ ++ InstanceClassKind: "DVPInstanceClass", ++ NodeGroups: []cpapi.NodeGroup{ ++ nodeGroupRef("master", "DVPInstanceClass", "master-ok"), ++ nodeGroupRef("worker", "DVPInstanceClass", "worker-ok"), ++ }, ++ InstanceClasses: []cpapi.InstanceClass{ ++ instanceClass("DVPInstanceClass", "master-ok", map[string]any{"size": "20Gi"}), ++ instanceClass("DVPInstanceClass", "worker-ok", nil), ++ }, ++ } ++ ++ ++ assertNoErrors(t, cpval.ValidateInstanceClassesEtcdDisk(state)) ++} ++ ++func TestValidateInstanceClassesEtcdDiskIgnoresUnrelatedReferencesAndClasses(t *testing.T) { ++ ++ ++ ++ ++ state := &cpval.State{ ++ InstanceClassKind: "DVPInstanceClass", ++ NodeGroups: []cpapi.NodeGroup{ ++ {ObjectMeta: cpapi.ObjectMeta{Name: "master"}}, ++ {ObjectMeta: cpapi.ObjectMeta{Name: "worker-nil"}, Spec: cpapi.NodeGroupSpec{CloudInstances: &cpapi.CloudInstances{}}}, ++ nodeGroupRef("worker-other-kind", "OtherInstanceClass", "worker-other"), ++ nodeGroupRef("worker-empty-name", "DVPInstanceClass", ""), ++ nodeGroupRef("master-unattached", "DVPInstanceClass", "missing-class"), ++ }, ++ InstanceClasses: []cpapi.InstanceClass{ ++ instanceClass("OtherInstanceClass", "worker-other", map[string]any{}), ++ instanceClass("DVPInstanceClass", "orphan-dvp", map[string]any{"size": "90Gi"}), ++ instanceClass("DVPInstanceClass", "worker-empty-name", map[string]any{"size": "30Gi"}), ++ }, ++ } ++ ++ ++ assertNoErrors(t, cpval.ValidateInstanceClassesEtcdDisk(state)) ++} ++ ++func TestValidateInstanceClassesEtcdDiskIsReferentiallyTransparentForEquivalentInput(t *testing.T) { ++ state := &cpval.State{ ++ InstanceClassKind: "DVPInstanceClass", ++ NodeGroups: []cpapi.NodeGroup{ ++ nodeGroupRef("worker", "DVPInstanceClass", "worker-dvp"), ++ }, ++ InstanceClasses: []cpapi.InstanceClass{ ++ instanceClass("DVPInstanceClass", "worker-dvp", map[string]any{"size": "50Gi", "type": "fast"}), ++ }, ++ } ++ ++ first := snapshot(cpval.ValidateInstanceClassesEtcdDisk(state)) ++ second := snapshot(cpval.ValidateInstanceClassesEtcdDisk(cloneState(state))) ++ expected := resultSnapshot{ ++ HasErrors: true, ++ Errors: []violationSnapshot{{ ++ Path: "DVPInstanceClass/worker-dvp.spec.etcdDisk", ++ Code: "etcd_disk_forbidden_for_non_master", ++ Value: map[string]any{"size": "50Gi", "type": "fast"}, ++ }}, ++ } ++ ++ ++ assertSnapshot(t, first, expected) ++ assertSnapshot(t, second, expected) ++ assertSnapshot(t, first, second) ++} ++ ++func TestValidateInstanceClassesEtcdDiskDoesNotMutateStateOrContainedResources(t *testing.T) { ++ state := &cpval.State{ ++ InstanceClassKind: "DVPInstanceClass", ++ NodeGroups: []cpapi.NodeGroup{ ++ nodeGroupRef("master", "DVPInstanceClass", "master-dvp"), ++ nodeGroupRef("worker", "DVPInstanceClass", "worker-dvp"), ++ }, ++ InstanceClasses: []cpapi.InstanceClass{ ++ instanceClass("DVPInstanceClass", "master-dvp", nil), ++ instanceClass("DVPInstanceClass", "worker-dvp", map[string]any{"size": "50Gi", "tags": []any{"hot", "admission"}}), ++ }, ++ } ++ before := cloneState(state) ++ ++ _ = cpval.ValidateInstanceClassesEtcdDisk(state) ++ ++ if !reflect.DeepEqual(state, before) { ++ t.Fatalf("ValidateInstanceClassesEtcdDisk mutated State:\nactual: %#v\nwant: %#v", state, before) ++ } ++} ++ ++func TestValidateInstanceClassesEtcdDiskDoesNotUseGlobalStateAcrossCalls(t *testing.T) { ++ state := &cpval.State{ ++ InstanceClassKind: "DVPInstanceClass", ++ NodeGroups: []cpapi.NodeGroup{ ++ nodeGroupRef("master", "DVPInstanceClass", "master-dvp"), ++ }, ++ InstanceClasses: []cpapi.InstanceClass{ ++ instanceClass("DVPInstanceClass", "master-dvp", nil), ++ }, ++ } ++ ++ first := snapshot(cpval.ValidateInstanceClassesEtcdDisk(state)) ++ _ = cpval.ValidateInstanceClassesEtcdDisk(&cpval.State{ ++ InstanceClassKind: "DVPInstanceClass", ++ NodeGroups: []cpapi.NodeGroup{nodeGroupRef("worker", "DVPInstanceClass", "worker-dvp")}, ++ InstanceClasses: []cpapi.InstanceClass{instanceClass("DVPInstanceClass", "worker-dvp", map[string]any{"size": "50Gi"})}, ++ }) ++ _ = cpval.ValidateInstanceClassesEtcdDisk(&cpval.State{ ++ InstanceClassKind: "DVPInstanceClass", ++ NodeGroups: []cpapi.NodeGroup{nodeGroupRef("master", "DVPInstanceClass", "master-ok")}, ++ InstanceClasses: []cpapi.InstanceClass{instanceClass("DVPInstanceClass", "master-ok", map[string]any{"size": "20Gi"})}, ++ }) ++ again := snapshot(cpval.ValidateInstanceClassesEtcdDisk(cloneState(state))) ++ expected := resultSnapshot{ ++ HasErrors: true, ++ Errors: []violationSnapshot{{ ++ Path: "DVPInstanceClass/master-dvp.spec.etcdDisk", ++ Code: "master_etcd_disk_required", ++ }}, ++ } ++ ++ ++ assertSnapshot(t, first, expected) ++ assertSnapshot(t, again, expected) ++ assertSnapshot(t, first, again) ++} ++ ++func TestValidateInstanceClassesEtcdDiskDoesNotCreateFilesystemSideEffects(t *testing.T) { ++ root := t.TempDir() ++ cwd := filepath.Join(root, "cwd") ++ home := filepath.Join(root, "home") ++ tmp := filepath.Join(root, "tmp") ++ cache := filepath.Join(root, "cache") ++ for _, dir := range []string{cwd, home, tmp, cache} { ++ if err := os.MkdirAll(dir, 0o755); err != nil { ++ t.Fatalf("MkdirAll(%q) error = %v", dir, err) ++ } ++ } ++ ++ originalWD, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("Getwd() error = %v", err) ++ } ++ t.Cleanup(func() { ++ if err := os.Chdir(originalWD); err != nil { ++ t.Fatalf("restore cwd: %v", err) ++ } ++ }) ++ if err := os.Chdir(cwd); err != nil { ++ t.Fatalf("Chdir(%q) error = %v", cwd, err) ++ } ++ t.Setenv("HOME", home) ++ t.Setenv("TMPDIR", tmp) ++ t.Setenv("XDG_CACHE_HOME", cache) ++ ++ before := treeSnapshot(t, root) ++ _ = cpval.ValidateInstanceClassesEtcdDisk(&cpval.State{ ++ InstanceClassKind: "DVPInstanceClass", ++ NodeGroups: []cpapi.NodeGroup{nodeGroupRef("master", "DVPInstanceClass", "master-ok")}, ++ InstanceClasses: []cpapi.InstanceClass{instanceClass("DVPInstanceClass", "master-ok", map[string]any{"size": "20Gi"})}, ++ }) ++ after := treeSnapshot(t, root) ++ ++ if !reflect.DeepEqual(after, before) { ++ t.Fatalf("ValidateInstanceClassesEtcdDisk changed filesystem state:\nafter: %#v\nbefore: %#v", after, before) ++ } ++} ++ ++func snapshot(result cpval.Result) resultSnapshot { ++ errors := make([]violationSnapshot, 0, len(result.Errors())) ++ for _, violation := range result.Errors() { ++ errors = append(errors, violationSnapshot{ ++ Path: violation.Path, ++ Code: violation.Code, ++ Value: violation.Value, ++ }) ++ } ++ sort.Slice(errors, func(i, j int) bool { ++ if errors[i].Path == errors[j].Path { ++ return errors[i].Code < errors[j].Code ++ } ++ return errors[i].Path < errors[j].Path ++ }) ++ if errors == nil { ++ errors = []violationSnapshot{} ++ } ++ ++ return resultSnapshot{ ++ HasErrors: result.HasErrors(), ++ Errors: errors, ++ } ++} ++ ++func assertSnapshot(t *testing.T, actual, expected resultSnapshot) { ++ t.Helper() ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("result snapshot mismatch:\nactual: %#v\nwant: %#v", actual, expected) ++ } ++} ++ ++func assertBlockingCode(t *testing.T, result cpval.Result, code string) { ++ t.Helper() ++ if !result.HasErrors() { ++ t.Fatalf("expected blocking result with code %q, got no errors", code) ++ } ++ for _, violation := range result.Errors() { ++ if violation.Code == code { ++ return ++ } ++ } ++ t.Fatalf("expected blocking result with code %q, got %#v", code, result.Errors()) ++} ++ ++func assertSingleError(t *testing.T, result cpval.Result, path, code string, value any) { ++ t.Helper() ++ expected := resultSnapshot{ ++ HasErrors: true, ++ Errors: []violationSnapshot{{ ++ Path: path, ++ Code: code, ++ Value: value, ++ }}, ++ } ++ assertSnapshot(t, snapshot(result), expected) ++} ++ ++func assertNoErrors(t *testing.T, result cpval.Result) { ++ t.Helper() ++ if result.HasErrors() || len(result.Errors()) != 0 { ++ t.Fatalf("expected no validation errors, got %#v", result.Errors()) ++ } ++} ++ ++func nodeGroupRef(name, kind, className string) cpapi.NodeGroup { ++ return cpapi.NodeGroup{ ++ ObjectMeta: cpapi.ObjectMeta{Name: name}, ++ Spec: cpapi.NodeGroupSpec{ ++ CloudInstances: &cpapi.CloudInstances{ ++ ClassReference: &cpapi.ClassReference{ ++ Kind: kind, ++ Name: className, ++ }, ++ }, ++ }, ++ } ++} ++ ++func instanceClass(kind, name string, etcdDisk map[string]any) cpapi.InstanceClass { ++ return cpapi.InstanceClass{ ++ TypeMeta: cpapi.TypeMeta{Kind: kind}, ++ ObjectMeta: cpapi.ObjectMeta{Name: name}, ++ Spec: cpapi.InstanceClassSpec{ ++ EtcdDisk: copyMap(etcdDisk), ++ }, ++ } ++} ++ ++func cloneState(state *cpval.State) *cpval.State { ++ if state == nil { ++ return nil ++ } ++ clone := *state ++ clone.NodeGroups = append([]cpapi.NodeGroup(nil), state.NodeGroups...) ++ for i := range clone.NodeGroups { ++ if state.NodeGroups[i].Spec.CloudInstances != nil { ++ cloudInstances := *state.NodeGroups[i].Spec.CloudInstances ++ clone.NodeGroups[i].Spec.CloudInstances = &cloudInstances ++ if state.NodeGroups[i].Spec.CloudInstances.ClassReference != nil { ++ classRef := *state.NodeGroups[i].Spec.CloudInstances.ClassReference ++ clone.NodeGroups[i].Spec.CloudInstances.ClassReference = &classRef ++ } ++ } ++ } ++ clone.InstanceClasses = append([]cpapi.InstanceClass(nil), state.InstanceClasses...) ++ for i := range clone.InstanceClasses { ++ clone.InstanceClasses[i].Spec.EtcdDisk = copyMap(state.InstanceClasses[i].Spec.EtcdDisk) ++ clone.InstanceClasses[i].Status.NodeGroupConsumers = copySlice(state.InstanceClasses[i].Status.NodeGroupConsumers) ++ } ++ clone.CredentialSecrets = append([]cpapi.CredentialSecret(nil), state.CredentialSecrets...) ++ clone.LegacyProviderClusterConfig = copyMap(state.LegacyProviderClusterConfig) ++ return &clone ++} ++ ++func copyMap(in map[string]any) map[string]any { ++ if in == nil { ++ return nil ++ } ++ out := make(map[string]any, len(in)) ++ for key, value := range in { ++ switch typed := value.(type) { ++ case map[string]any: ++ out[key] = copyMap(typed) ++ case []any: ++ out[key] = copySlice(typed) ++ default: ++ out[key] = value ++ } ++ } ++ return out ++} ++ ++func copySlice(in []any) []any { ++ if in == nil { ++ return nil ++ } ++ out := make([]any, len(in)) ++ for i, value := range in { ++ switch typed := value.(type) { ++ case map[string]any: ++ out[i] = copyMap(typed) ++ case []any: ++ out[i] = copySlice(typed) ++ default: ++ out[i] = value ++ } ++ } ++ return out ++} ++ ++func treeSnapshot(t *testing.T, root string) []string { ++ t.Helper() ++ var entries []string ++ if err := filepath.WalkDir(root, func(path string, entry os.DirEntry, err error) error { ++ if err != nil { ++ return err ++ } ++ rel, err := filepath.Rel(root, path) ++ if err != nil { ++ return err ++ } ++ info, err := entry.Info() ++ if err != nil { ++ return err ++ } ++ entries = append(entries, rel+"|"+info.Mode().String()) ++ return nil ++ }); err != nil { ++ t.Fatalf("WalkDir(%q) error = %v", root, err) ++ } ++ sort.Strings(entries) ++ return entries ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++exec go test -v ./usercase-test-coderl diff --git a/tasks/format-code-task-000779/tests/test.sh b/tasks/format-code-task-000779/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81e5968ffa03abcef1d3346eab29cdbd4550c2f5 --- /dev/null +++ b/tasks/format-code-task-000779/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/instance_class_etcd_disk_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000779/tests/test_command.sh b/tasks/format-code-task-000779/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000779/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000783/environment/Dockerfile b/tasks/format-code-task-000783/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..04eec170579f0219d86303f92104f21cdb066b60 --- /dev/null +++ b/tasks/format-code-task-000783/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fb84e67cd34235f76b6132b5be531cc836cfc08a491f7eb6a0d857966c1c872e diff --git a/tasks/format-code-task-000783/environment/setup/files/blocklist b/tasks/format-code-task-000783/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000783/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000783/environment/setup/setup.sh b/tasks/format-code-task-000783/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000783/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000783/tests/test.patch b/tasks/format-code-task-000783/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..155c527403cfdaa114f2b9a6043cdb23360912a5 --- /dev/null +++ b/tasks/format-code-task-000783/tests/test.patch @@ -0,0 +1,438 @@ +diff --git a/usercase-test-coderl/test_edu_rerank_context.py b/usercase-test-coderl/test_edu_rerank_context.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_edu_rerank_context.py +@@ -0,0 +1,412 @@ ++ ++ ++ ++import builtins ++import json ++import os ++import re ++import socket ++import subprocess ++import sys ++from pathlib import Path ++ ++sys.path.insert(0, "/workspace/repo") ++ ++from experiments.LongBench.edu_rerank_example import process_context_with_edu_rerank ++ ++ ++def spec_token_count(text): ++ try: ++ import tiktoken ++ ++ tokenizer = tiktoken.get_encoding("cl100k_base") ++ return len(tokenizer.encode(text, disallowed_special=())) ++ except Exception: ++ return len(text) // 4 ++ ++ ++def expected_success_stats(original_text, filtered_text): ++ orig_tokens = spec_token_count(original_text) ++ new_tokens = spec_token_count(filtered_text) ++ return { ++ "orig_tokens": orig_tokens, ++ "new_tokens": new_tokens, ++ "ratio": round(new_tokens / orig_tokens, 4) if orig_tokens else 0.0, ++ } ++ ++ ++def expected_fallback_stats(original_text): ++ orig_tokens = spec_token_count(original_text) ++ return {"orig_tokens": orig_tokens, "new_tokens": orig_tokens, "ratio": 1.0} ++ ++ ++def assert_success_result(actual, original_text, expected_text): ++ ++ assert actual == (expected_text, expected_success_stats(original_text, expected_text)) ++ ++ ++def assert_fallback_result(actual, original_text): ++ ++ assert actual == (original_text, expected_fallback_stats(original_text)) ++ ++ ++class FakeProcessor: ++ def __init__(self, parsed_data, filtered_text): ++ self.parsed_data = parsed_data ++ self.filtered_text = filtered_text ++ self.parse_paths = [] ++ self.semantic_calls = [] ++ ++ def parse_file(self, file_path): ++ self.parse_paths.append(file_path) ++ return self.parsed_data ++ ++ def semantic_filter(self, parsed_data, query, top_k_per_level=3): ++ self.semantic_calls.append( ++ { ++ "parsed_data": parsed_data, ++ "query": query, ++ "top_k_per_level": top_k_per_level, ++ } ++ ) ++ return self.filtered_text ++ ++ ++def test_success_returns_filtered_text_stats_and_custom_top_k(tmp_path): ++ ++ ++ ++ ++ parsed = {"sentences": [{"text": "Chapter 2: Methods", "level": 1}]} ++ processor = FakeProcessor(parsed, "Chapter 2: Methods") ++ temp_dir = tmp_path / "declared-temp" ++ ++ context = "Chapter 1: Introduction\nChapter 2: Methods\nChapter 3: Results" ++ actual = process_context_with_edu_rerank( ++ processor, ++ context, ++ "What methods are mentioned?", ++ temp_dir=str(temp_dir), ++ top_k_per_level=5, ++ ) ++ ++ assert_success_result(actual, context, "Chapter 2: Methods") ++ assert len(processor.parse_paths) == 1 ++ parse_path = Path(processor.parse_paths[0]) ++ ++ assert parse_path.is_relative_to(temp_dir) ++ assert parse_path.suffix == ".txt" ++ assert not parse_path.exists() ++ ++ assert not list(temp_dir.rglob("*.txt")) ++ assert processor.semantic_calls == [ ++ { ++ "parsed_data": {"sentences": [{"text": "Chapter 2: Methods", "level": 1}]}, ++ "query": "What methods are mentioned?", ++ "top_k_per_level": 5, ++ } ++ ] ++ ++ ++def test_success_uses_default_top_k_per_level(tmp_path): ++ ++ ++ ++ ++ processor = FakeProcessor({"markdown": "# One\n# Two"}, "Default top-k text") ++ ++ context = "Intro paragraph.\nDetails paragraph." ++ actual = process_context_with_edu_rerank( ++ processor, ++ context, ++ "Which paragraph?", ++ temp_dir=str(tmp_path / "temp"), ++ ) ++ ++ assert_success_result(actual, context, "Default top-k text") ++ assert processor.semantic_calls == [ ++ { ++ "parsed_data": {"markdown": "# One\n# Two"}, ++ "query": "Which paragraph?", ++ "top_k_per_level": 3, ++ } ++ ] ++ ++ ++def test_empty_context_returns_zero_stats_without_processor_calls(tmp_path): ++ ++ ++ ++ ++ processor = FakeProcessor({"sentences": [{"text": "unused"}]}, "unused") ++ temp_dir = tmp_path / "temp" ++ ++ actual = process_context_with_edu_rerank( ++ processor, ++ "", ++ "Any query", ++ temp_dir=str(temp_dir), ++ top_k_per_level=7, ++ ) ++ ++ assert actual == ("", {"orig_tokens": 0, "new_tokens": 0, "ratio": 0.0}) ++ assert processor.parse_paths == [] ++ assert processor.semantic_calls == [] ++ ++ assert not list(temp_dir.rglob("*.txt")) ++ ++ ++def test_parse_none_falls_back_to_original_context(tmp_path): ++ ++ ++ ++ ++ processor = FakeProcessor(None, "ignored") ++ ++ context = "Alpha beta gamma delta epsilon." ++ actual = process_context_with_edu_rerank( ++ processor, ++ context, ++ "Need gamma", ++ temp_dir=str(tmp_path / "temp"), ++ top_k_per_level=2, ++ ) ++ ++ assert_fallback_result(actual, context) ++ assert len(processor.parse_paths) == 1 ++ assert processor.semantic_calls == [] ++ ++ assert not list((tmp_path / "temp").rglob("*.txt")) ++ ++ ++def test_empty_semantic_filter_falls_back_to_original_context(tmp_path): ++ ++ ++ ++ ++ processor = FakeProcessor({"sentences": [{"text": "Only sentence", "level": 1}]}, "") ++ ++ context = "Keep this original context because filtering fails." ++ actual = process_context_with_edu_rerank( ++ processor, ++ context, ++ "Need answer", ++ temp_dir=str(tmp_path / "temp"), ++ top_k_per_level=4, ++ ) ++ ++ assert_fallback_result(actual, context) ++ assert processor.semantic_calls == [ ++ { ++ "parsed_data": {"sentences": [{"text": "Only sentence", "level": 1}]}, ++ "query": "Need answer", ++ "top_k_per_level": 4, ++ } ++ ] ++ ++ ++def test_temp_file_write_failure_falls_back_without_processor_calls(tmp_path, monkeypatch): ++ ++ ++ ++ ++ processor = FakeProcessor({"sentences": [{"text": "Should not parse", "level": 1}]}, "Should not filter") ++ temp_dir = tmp_path / "temp" ++ real_open = builtins.open ++ ++ def fail_declared_temp_write(path, mode="r", *args, **kwargs): ++ if str(path).startswith(str(temp_dir)) and "w" in mode: ++ raise OSError("blocked write for acceptance test") ++ return real_open(path, mode, *args, **kwargs) ++ ++ monkeypatch.setattr(builtins, "open", fail_declared_temp_write) ++ ++ context = "Writable path is denied by open." ++ actual = process_context_with_edu_rerank( ++ processor, ++ context, ++ "Need fallback", ++ temp_dir=str(temp_dir), ++ top_k_per_level=3, ++ ) ++ ++ assert_fallback_result(actual, context) ++ assert processor.parse_paths == [] ++ assert processor.semantic_calls == [] ++ ++ assert not list(temp_dir.rglob("*.txt")) ++ ++ ++def test_running_module_directly_prints_demo_output(tmp_path): ++ ++ ++ ++ ++ stub_pkg = tmp_path / "deeplang_parse" ++ stub_pkg.mkdir() ++ (stub_pkg / "__init__.py").write_text("", encoding="utf-8") ++ env = os.environ.copy() ++ env["PYTHONPATH"] = f"{tmp_path}:/workspace/repo:{env.get('PYTHONPATH', '')}" ++ ++ completed = subprocess.run( ++ [sys.executable, "/workspace/repo/experiments/LongBench/edu_rerank_example.py"], ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ check=True, ++ env=env, ++ ) ++ ++ stdout = completed.stdout ++ ++ assert stdout.strip() ++ assert re.search(r"original.*token.*\d", stdout, re.IGNORECASE | re.DOTALL) ++ assert re.search(r"filtered.*token.*\d", stdout, re.IGNORECASE | re.DOTALL) ++ assert re.search(r"compression.*ratio.*[0-9]", stdout, re.IGNORECASE | re.DOTALL) ++ assert "filtered text" in stdout.lower() ++ ++ assert "traceback" not in completed.stderr.lower() ++ ++ ++def test_empty_context_with_default_arguments_returns_zero_stats_without_processor_calls(tmp_path, monkeypatch): ++ processor = FakeProcessor({"sentences": [{"text": "unused"}]}, "unused") ++ ++ monkeypatch.chdir(tmp_path) ++ actual = process_context_with_edu_rerank(processor, "", "Empty context") ++ ++ ++ assert actual == ("", {"orig_tokens": 0, "new_tokens": 0, "ratio": 0.0}) ++ assert processor.parse_paths == [] ++ assert processor.semantic_calls == [] ++ ++ ++def test_referential_transparency_same_input_same_result(tmp_path): ++ processor = FakeProcessor({"sentences": [{"text": "Chapter 2: Methods", "level": 1}]}, "Chapter 2: Methods") ++ context = "Chapter 1: Introduction\nChapter 2: Methods\nChapter 3: Results" ++ first = process_context_with_edu_rerank( ++ processor, ++ context, ++ "What methods are mentioned?", ++ temp_dir=str(tmp_path / "first"), ++ top_k_per_level=5, ++ ) ++ second = process_context_with_edu_rerank( ++ processor, ++ context, ++ "What methods are mentioned?", ++ temp_dir=str(tmp_path / "second"), ++ top_k_per_level=5, ++ ) ++ ++ assert_success_result(first, context, "Chapter 2: Methods") ++ assert_success_result(second, context, "Chapter 2: Methods") ++ assert first == second ++ ++ ++def test_preserves_caller_visible_text_inputs_and_passes_filter_arguments(tmp_path): ++ parsed = {"sentences": [{"text": "Stable node", "level": 2, "meta": {"ids": [1, 2]}}]} ++ processor = FakeProcessor(parsed, "Stable node") ++ context = "Stable context for mutation guard." ++ query = "Stable?" ++ ++ actual = process_context_with_edu_rerank( ++ processor, ++ context, ++ query, ++ temp_dir=str(tmp_path / "temp"), ++ top_k_per_level=3, ++ ) ++ ++ assert_success_result(actual, context, "Stable node") ++ assert context == "Stable context for mutation guard." ++ assert query == "Stable?" ++ ++ assert processor.semantic_calls == [ ++ {"parsed_data": parsed, "query": query, "top_k_per_level": 3} ++ ] ++ ++ ++def test_no_global_state_matches_fresh_python_process(tmp_path): ++ processor = FakeProcessor({"sentences": [{"text": "Chapter 2: Methods", "level": 1}]}, "Chapter 2: Methods") ++ context = "Chapter 1: Introduction\nChapter 2: Methods\nChapter 3: Results" ++ in_process = process_context_with_edu_rerank( ++ processor, ++ context, ++ "What methods are mentioned?", ++ temp_dir=str(tmp_path / "in-process"), ++ top_k_per_level=5, ++ ) ++ ++ script = r''' ++import json ++import os ++import sys ++import tempfile ++sys.path.insert(0, "/workspace/repo") ++from experiments.LongBench.edu_rerank_example import process_context_with_edu_rerank ++ ++class FakeProcessor: ++ def parse_file(self, file_path): ++ return {"sentences": [{"text": "Chapter 2: Methods", "level": 1}]} ++ def semantic_filter(self, parsed_data, query, top_k_per_level=3): ++ return "Chapter 2: Methods" ++ ++with tempfile.TemporaryDirectory() as temp_dir: ++ result = process_context_with_edu_rerank( ++ FakeProcessor(), ++ "Chapter 1: Introduction\nChapter 2: Methods\nChapter 3: Results", ++ "What methods are mentioned?", ++ temp_dir=os.path.join(temp_dir, "fresh"), ++ top_k_per_level=5, ++ ) ++print(json.dumps(result, sort_keys=True)) ++''' ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ check=True, ++ ) ++ ++ assert_success_result(in_process, context, "Chapter 2: Methods") ++ ++ assert json.loads(completed.stdout) == [ ++ "Chapter 2: Methods", ++ expected_success_stats(context, "Chapter 2: Methods"), ++ ] ++ ++ assert "traceback" not in completed.stderr.lower() ++ ++ ++def test_no_undeclared_side_effects_outside_declared_temp_dir(tmp_path, monkeypatch): ++ temp_dir = tmp_path / "declared-temp" ++ temp_dir.mkdir() ++ cwd = tmp_path / "cwd" ++ cwd.mkdir() ++ before = sorted(p.relative_to(cwd).as_posix() for p in cwd.rglob("*")) ++ ++ def block_network(*args, **kwargs): ++ raise AssertionError("network access is not declared by the query") ++ ++ monkeypatch.setattr(socket, "socket", block_network) ++ old_cwd = os.getcwd() ++ try: ++ os.chdir(cwd) ++ processor = FakeProcessor({"sentences": [{"text": "Stable node", "level": 1}]}, "Stable node") ++ actual = process_context_with_edu_rerank( ++ processor, ++ "Side effect guard context.", ++ "Guard?", ++ temp_dir=str(temp_dir), ++ top_k_per_level=3, ++ ) ++ finally: ++ os.chdir(old_cwd) ++ ++ after = sorted(p.relative_to(cwd).as_posix() for p in cwd.rglob("*")) ++ assert_success_result(actual, "Side effect guard context.", "Stable node") ++ assert before == [] ++ assert after == [] ++ ++ assert not list(temp_dir.rglob("*.txt")) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export TIKTOKEN_CACHE_DIR=/opt/coderl_tiktoken_cache ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_edu_rerank_context.py -v diff --git a/tasks/format-code-task-000783/tests/test.sh b/tasks/format-code-task-000783/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..14fdf64140fa8063dc2b258f03565b92ff3374af --- /dev/null +++ b/tasks/format-code-task-000783/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_edu_rerank_context.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000783/tests/test_command.sh b/tasks/format-code-task-000783/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000783/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000784/environment/Dockerfile b/tasks/format-code-task-000784/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..94c8e4de99ec27a92c53c22dae11a02bd8338838 --- /dev/null +++ b/tasks/format-code-task-000784/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fee10f54428f5e37f48680276eac2255808920e86f4c03aa551128ff2b49b2b7 diff --git a/tasks/format-code-task-000784/environment/setup/files/blocklist b/tasks/format-code-task-000784/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000784/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000784/environment/setup/setup.sh b/tasks/format-code-task-000784/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000784/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000784/tests/test.patch b/tasks/format-code-task-000784/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..06ab38b444eb7df87ff84cf4430dfff4a3f3f10d --- /dev/null +++ b/tasks/format-code-task-000784/tests/test.patch @@ -0,0 +1,127 @@ +diff --git a/tests/test_basic.py b/tests/test_basic.py +index 09ce41a..36d4359 100755 +--- a/tests/test_basic.py ++++ b/tests/test_basic.py +@@ -364,6 +364,78 @@ class TestApplyTransformOnGroup(object): + assert group.transform == (1, 0, 0, 1, 10, 0) + + ++class TestStyleSheets(object): ++ def _leaf_shapes(self, node): ++ children = getattr(node, 'contents', None) ++ if children: ++ for child in children: ++ for leaf in self._leaf_shapes(child): ++ yield leaf ++ else: ++ yield node ++ ++ def test_style_rules_apply_to_id_class_and_element_selectors(self): ++ drawing = svglib.svg2rlg(io.StringIO(textwrap.dedent(u'''\ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ '''))) ++ ++ shapes = list(self._leaf_shapes(drawing)) ++ stylesheet_green = colors.Color(0, 128 / 255.0, 0) ++ ++ assert any(getattr(shape, 'fillColor', None) == colors.red ++ for shape in shapes) ++ assert any(getattr(shape, 'strokeColor', None) == colors.blue ++ for shape in shapes) ++ assert any(abs(getattr(shape, 'strokeWidth', 0) - 2.5) < 1e-9 ++ for shape in shapes) ++ assert any(getattr(shape, 'fillColor', None) == stylesheet_green ++ for shape in shapes) ++ ++ def test_explicit_presentation_attributes_override_stylesheet_rules(self): ++ drawing = svglib.svg2rlg(io.StringIO(textwrap.dedent(u'''\ ++ ++ ++ ++ ++ ++ '''))) ++ ++ shapes = list(self._leaf_shapes(drawing)) ++ stylesheet_green = colors.Color(0, 128 / 255.0, 0) ++ conflicted_shapes = [ ++ shape for shape in shapes ++ if getattr(shape, 'strokeColor', None) == stylesheet_green ++ ] ++ ++ assert conflicted_shapes ++ assert any(shape.fillColor == colors.blue for shape in conflicted_shapes) ++ assert any(abs(shape.strokeWidth - 1) < 1e-9 ++ for shape in conflicted_shapes) ++ ++ + class TestTextNode(object): + def test_font_family(self): + def font_config_available(): +diff --git a/tests/test_readme.py b/tests/test_readme.py +new file mode 100644 +index 0000000..93cf624 +--- /dev/null ++++ b/tests/test_readme.py +@@ -0,0 +1,12 @@ ++import os ++ ++ ++def test_readme_describes_stylesheet_support_as_experimental(): ++ root_dir = os.path.dirname(os.path.dirname(__file__)) ++ with open(os.path.join(root_dir, 'README.rst'), encoding='utf-8') as readme: ++ contents = readme.read().lower() ++ ++ assert 'stylesheets are not supported' not in contents ++ assert 'stylesheet' in contents or 'stylesheets' in contents ++ assert 'experimental' in contents ++ assert any(word in contents for word in ('bug', 'shortcoming', 'issue', 'tracker')) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++case "${1:-}" in ++ base) ++ python3 -m pytest tests/test_basic.py -v \ ++ --ignore=tests/test_readme.py \ ++ -k 'not TestStyleSheets' 2>&1 ++ ;; ++ new) ++ python3 -m pytest -v \ ++ tests/test_basic.py::TestStyleSheets::test_style_rules_apply_to_id_class_and_element_selectors \ ++ tests/test_basic.py::TestStyleSheets::test_explicit_presentation_attributes_override_stylesheet_rules \ ++ tests/test_readme.py::test_readme_describes_stylesheet_support_as_experimental 2>&1 ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000784/tests/test.sh b/tasks/format-code-task-000784/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e81c429994ee1dac0d39c4f8f0e5ef2d94131b61 --- /dev/null +++ b/tasks/format-code-task-000784/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_basic.py +tests/test_readme.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000784/tests/test_command.sh b/tasks/format-code-task-000784/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000784/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-000913/environment/Dockerfile b/tasks/format-code-task-000913/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6d8fd483d860e1f92d6960bf9250e5367efb481f --- /dev/null +++ b/tasks/format-code-task-000913/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c1a84a824d827571230679309875dab83db8840f1484e4c99c954c26c3f9387f diff --git a/tasks/format-code-task-000913/environment/setup/files/blocklist b/tasks/format-code-task-000913/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000913/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000913/environment/setup/setup.sh b/tasks/format-code-task-000913/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000913/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000913/tests/test.patch b/tasks/format-code-task-000913/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4238ce3e0cc4daeacc7b6bf6cbe1ea513ee2ab18 --- /dev/null +++ b/tasks/format-code-task-000913/tests/test.patch @@ -0,0 +1,166 @@ +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,144 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C LC_ALL=C TZ=UTC ++export PATH="/root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.8.linux-amd64/bin:$PATH" ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOCACHE=/workspace/repo/.coderl-go-build-cache ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++ ++ROOT=/workspace/repo ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++assert_convert_msg() { ++ local case_name=$1 contract=$2 amount=$3 receiver=$4 sender=$5 ++ python3 - "$case_name" "$contract" "$amount" "$receiver" "$sender" out <<'PY' ++import json ++import sys ++ ++case_name, contract, amount, receiver, sender, output_path = sys.argv[1:] ++try: ++ with open(output_path, encoding="utf-8") as fh: ++ tx = json.load(fh) ++except Exception as exc: ++ raise SystemExit(f"{case_name} stdout is not JSON: {exc}") ++ ++messages = tx.get("body", {}).get("messages") ++if not isinstance(messages, list) or len(messages) != 1: ++ raise SystemExit(f"{case_name} expected exactly one transaction message, got {messages!r}") ++ ++msg = messages[0] ++checks = { ++ "@type": "/evmos.erc20.v1.MsgConvertERC20", ++ "contract_address": contract, ++ "amount": amount, ++ "receiver": receiver, ++ "sender": sender, ++} ++for key, expected in checks.items(): ++ actual = msg.get(key) ++ if actual != expected: ++ raise SystemExit(f"{case_name} {key}: got {actual!r}, want {expected!r}") ++PY ++} ++ ++BIN="$TMP/evmosd" ++( cd "$ROOT" && go build -tags netgo -o "$BIN" ./cmd/evmosd ) \ ++ || fail "build evmosd" ++ ++FROM=evmos1xetwysj3rcf80qxgnfnqstkwggne3d0xn2v7d0 ++FROM_ETH=0x3656e242511e127780C89a66082EcE422798B5E6 ++RECEIVER=evmos1g6dnx540jxf7gg9d4xhpcnqlm2zylnt847m4f4 ++COMMON_FLAGS=(--from "$FROM" --generate-only --offline --account-number 7 --sequence 9) ++ ++cd "$TMP" || fail "cd tmp" ++ ++ ++ ++ ++"$BIN" tx erc20 convert-erc20 --help --home "$TMP/help-home" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F0 exit $ec; want 0" ++ ++[ -s out ] || fail "F0 expected non-empty help output" ++grep -qF 'convert-erc20' out || fail "F0 missing convert-erc20 command" ++grep -qF 'CONTRACT_ADDRESS' out || fail "F0 missing CONTRACT_ADDRESS argument" ++grep -qF 'AMOUNT' out || fail "F0 missing AMOUNT argument" ++grep -qF 'RECEIVER' out || fail "F0 missing RECEIVER argument" ++grep -q -- '--generate-only' out || fail "F0 missing --generate-only" ++grep -q -- '--dry-run' out || fail "F0 missing --dry-run" ++grep -q -- '--broadcast-mode' out || fail "F0 missing --broadcast-mode" ++ ++ ++ ++ ++"$BIN" tx erc20 convert-erc20 0x1111111111111111111111111111111111111111 1 "${COMMON_FLAGS[@]}" --home "$TMP/f1-home" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0; stderr: $(cat err)" ++ ++assert_convert_msg F1 0x1111111111111111111111111111111111111111 1 "$FROM" "$FROM_ETH" || fail "F1 stdout: $(cat out)" ++ ++ ++ ++ ++"$BIN" tx erc20 convert-erc20 0x2222222222222222222222222222222222222222 999999999999999999999999 "$RECEIVER" "${COMMON_FLAGS[@]}" --home "$TMP/f2-home" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0; stderr: $(cat err)" ++ ++assert_convert_msg F2 0x2222222222222222222222222222222222222222 999999999999999999999999 "$RECEIVER" "$FROM_ETH" || fail "F2 stdout: $(cat out)" ++ ++ ++ ++ ++"$BIN" tx erc20 convert-erc20 not-a-hex 123 "${COMMON_FLAGS[@]}" --home "$TMP/f3-home" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F3 want non-zero exit" ++[ ! -s out ] || fail "F3 unexpected stdout: $(cat out)" ++grep -q 'invalid ERC20 contract address' err || fail "F3 stderr missing invalid contract phrase: $(cat err)" ++ ++ ++ ++ ++"$BIN" tx erc20 convert-erc20 0x1234 123 "${COMMON_FLAGS[@]}" --home "$TMP/f4-home" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F4 want non-zero exit" ++[ ! -s out ] || fail "F4 unexpected stdout: $(cat out)" ++grep -q 'invalid ERC20 contract address' err || fail "F4 stderr missing invalid contract phrase: $(cat err)" ++ ++ ++ ++ ++"$BIN" tx erc20 convert-erc20 0x3333333333333333333333333333333333333333 12.34 "${COMMON_FLAGS[@]}" --home "$TMP/f5-home" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F5 want non-zero exit" ++[ ! -s out ] || fail "F5 unexpected stdout: $(cat out)" ++grep -q 'invalid amount 12.34' err || fail "F5 stderr missing invalid amount value: $(cat err)" ++ ++ ++ ++ ++"$BIN" tx erc20 convert-erc20 0x3333333333333333333333333333333333333333 123 evmos1bad "${COMMON_FLAGS[@]}" --home "$TMP/f6-home" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F6 want non-zero exit" ++[ ! -s out ] || fail "F6 unexpected stdout: $(cat out)" ++ ++[ -s err ] || fail "F6 expected receiver parse error on stderr" ++ ++ ++ ++ ++"$BIN" tx erc20 convert-erc20 0x3333333333333333333333333333333333333333 "${COMMON_FLAGS[@]}" --home "$TMP/f7-home" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F7 want non-zero exit" ++[ ! -s out ] || fail "F7 unexpected stdout: $(cat out)" ++ ++[ -s err ] || fail "F7 expected arity error on stderr" ++ ++ ++ ++ ++"$BIN" tx erc20 convert-erc20 0x3333333333333333333333333333333333333333 123 "$RECEIVER" extra "${COMMON_FLAGS[@]}" --home "$TMP/f8-home" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F8 want non-zero exit" ++[ ! -s out ] || fail "F8 unexpected stdout: $(cat out)" ++ ++[ -s err ] || fail "F8 expected arity error on stderr" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000913/tests/test.sh b/tasks/format-code-task-000913/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-000913/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000913/tests/test_command.sh b/tasks/format-code-task-000913/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000913/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000914/environment/Dockerfile b/tasks/format-code-task-000914/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5c9e94c50a6aef0eda47df282bf1fc77adaa629e --- /dev/null +++ b/tasks/format-code-task-000914/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d56b028c3fe02beb43285431088be43384b7e9761af1518bfb1aa2892fc4da7c diff --git a/tasks/format-code-task-000914/environment/setup/files/blocklist b/tasks/format-code-task-000914/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000914/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000914/environment/setup/setup.sh b/tasks/format-code-task-000914/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000914/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000914/tests/test.patch b/tasks/format-code-task-000914/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d46fb9c55ec099516b41caef321f81e93975efb5 --- /dev/null +++ b/tasks/format-code-task-000914/tests/test.patch @@ -0,0 +1,422 @@ +diff --git a/usercase-test-coderl/latex-entry-file.test.ts b/usercase-test-coderl/latex-entry-file.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/latex-entry-file.test.ts +@@ -0,0 +1,378 @@ ++ ++ ++import { execFileSync } from "node:child_process"; ++import fs from "node:fs"; ++import http from "node:http"; ++import https from "node:https"; ++import { createRequire } from "node:module"; ++import net from "node:net"; ++import os from "node:os"; ++import path from "node:path"; ++import type { MockInstance } from "vitest"; ++import { describe, expect, it, vi } from "vitest"; ++import type { FileNode } from "@lmms-lab/writer-shared"; ++import { findMainTexFile, findTexFiles } from "@/lib/latex"; ++ ++const requireFromHere = createRequire(import.meta.url); ++ ++function file(name: string, filePath = name): FileNode { ++ return { name, path: filePath, type: "file" }; ++} ++ ++function dir(name: string, children: FileNode[], dirPath = name): FileNode { ++ return { name, path: dirPath, type: "directory", children }; ++} ++ ++function cloneFiles(files: FileNode[]): FileNode[] { ++ return JSON.parse(JSON.stringify(files)) as FileNode[]; ++} ++ ++function runFreshProcessProbe(): { texFiles: string[]; mainFile: string | null } { ++ const testFile = "/workspace/repo/usercase-test-coderl/latex-entry-file.test.ts"; ++ const vitestPackage = requireFromHere.resolve("vitest/package.json", { ++ paths: ["/workspace/repo/apps/desktop"], ++ }); ++ const vitestBin = path.join(path.dirname(vitestPackage), "vitest.mjs"); ++ const output = execFileSync( ++ process.execPath, ++ [ ++ vitestBin, ++ "run", ++ "--config", ++ ++ "/workspace/repo/usercase-test-coderl/vitest.config.ts", ++ testFile, ++ "--reporter=verbose", ++ ], ++ { ++ cwd: "/workspace/repo/apps/desktop", ++ env: { ...process.env, TST_FRESH_PROCESS_PROBE: "1" }, ++ encoding: "utf8", ++ }, ++ ); ++ const markerLine = output ++ .split(/\r?\n/) ++ .find((line) => line.includes("TST_FRESH_PROCESS_RESULT=")); ++ ++ if (!markerLine) { ++ throw new Error(`Fresh-process probe did not print a result:\n${output}`); ++ } ++ ++ const json = markerLine.slice(markerLine.indexOf("TST_FRESH_PROCESS_RESULT=") + 25).trim(); ++ return JSON.parse(json) as { texFiles: string[]; mainFile: string | null }; ++} ++ ++if (process.env.TST_FRESH_PROCESS_PROBE === "1") { ++ it("prints a fresh-process result for the no-global-state check", () => { ++ const files = [ ++ file("notes.md"), ++ dir("src", [file("alpha.tex", "src/alpha.tex"), file("paper.tex", "src/paper.tex")]), ++ ]; ++ const result = { ++ texFiles: findTexFiles(files), ++ mainFile: findMainTexFile(files), ++ }; ++ console.log(`TST_FRESH_PROCESS_RESULT=${JSON.stringify(result)}`); ++ }); ++} else { ++ describe("findTexFiles", () => { ++ it("returns only root .tex file paths and skips non-tex root files", () => { ++ ++ ++ ++ ++ const files = [file("main.tex"), file("README.md"), file("refs.bib")]; ++ ++ expect(findTexFiles(files)).toEqual(["main.tex"]); ++ }); ++ ++ it("walks directories depth-first after earlier root files", () => { ++ ++ ++ ++ ++ const files = [ ++ file("main.tex"), ++ dir("chapters", [file("ch1.tex", "chapters/ch1.tex"), file("ch2.tex", "chapters/ch2.tex")]), ++ ]; ++ ++ expect(findTexFiles(files)).toEqual(["main.tex", "chapters/ch1.tex", "chapters/ch2.tex"]); ++ }); ++ ++ it("continues depth-first through nested directories before later siblings", () => { ++ ++ ++ ++ ++ const files = [ ++ dir("frontmatter", [ ++ file("abstract.tex", "frontmatter/abstract.tex"), ++ dir("deep", [file("notes.tex", "frontmatter/deep/notes.tex")], "frontmatter/deep"), ++ ]), ++ file("tail.tex"), ++ ]; ++ ++ expect(findTexFiles(files)).toEqual([ ++ "frontmatter/abstract.tex", ++ "frontmatter/deep/notes.tex", ++ "tail.tex", ++ ]); ++ }); ++ ++ it("ignores directories named with a .tex suffix and files whose names do not end with lowercase .tex", () => { ++ ++ ++ ++ ++ const files = [ ++ dir("fake.tex", [file("inside.tex", "fake.tex/inside.tex")]), ++ file("draft.tex.bak"), ++ file("UPPER.TEX"), ++ file("final.tex"), ++ ]; ++ ++ expect(findTexFiles(files)).toEqual(["fake.tex/inside.tex", "final.tex"]); ++ }); ++ ++ it("returns an empty array when there are no .tex file nodes", () => { ++ ++ ++ ++ ++ const files = [file("README.md"), file("Makefile")]; ++ ++ expect(findTexFiles(files)).toEqual([]); ++ }); ++ }); ++ ++ describe("findMainTexFile", () => { ++ it("prefers root main.tex over other root .tex files", () => { ++ ++ ++ ++ ++ const files = [file("intro.tex"), file("main.tex"), file("appendix.tex")]; ++ ++ expect(findMainTexFile(files)).toBe("main.tex"); ++ }); ++ ++ it("prefers root paper.tex when present", () => { ++ ++ ++ ++ ++ const files = [file("paper.tex"), file("appendix.tex")]; ++ ++ expect(findMainTexFile(files)).toBe("paper.tex"); ++ }); ++ ++ it("recognizes thesis.tex as a common root main file", () => { ++ ++ ++ ++ ++ const files = [file("notes.md"), file("thesis.tex"), file("appendix.tex")]; ++ ++ expect(findMainTexFile(files)).toBe("thesis.tex"); ++ }); ++ ++ it("recognizes document.tex as a common root main file", () => { ++ ++ ++ ++ ++ const files = [file("appendix.tex"), file("document.tex")]; ++ ++ expect(findMainTexFile(files)).toBe("document.tex"); ++ }); ++ ++ it("recognizes report.tex as a common root main file", () => { ++ ++ ++ ++ ++ const files = [file("README.md"), file("report.tex")]; ++ ++ expect(findMainTexFile(files)).toBe("report.tex"); ++ }); ++ ++ it("falls back to the first root-level .tex file", () => { ++ ++ ++ ++ ++ const files = [file("README.md"), file("myfile.tex")]; ++ ++ expect(findMainTexFile(files)).toBe("myfile.tex"); ++ }); ++ ++ it("uses a root-level arbitrary .tex file before a recursive common basename", () => { ++ ++ ++ ++ ++ const files = [file("zeta.tex"), dir("src", [file("main.tex", "src/main.tex")])]; ++ ++ expect(findMainTexFile(files)).toBe("zeta.tex"); ++ }); ++ ++ it("returns a recursive main.tex when no root .tex files exist", () => { ++ ++ ++ ++ ++ const files = [file("README.md"), dir("src", [file("main.tex", "src/main.tex")])]; ++ ++ expect(findMainTexFile(files)).toBe("src/main.tex"); ++ }); ++ ++ it("prefers recursive common basenames over the first recursive arbitrary .tex path", () => { ++ ++ ++ ++ ++ const files = [ ++ file("README.md"), ++ dir("src", [file("alpha.tex", "src/alpha.tex"), file("paper.tex", "src/paper.tex")]), ++ ]; ++ ++ expect(findMainTexFile(files)).toBe("src/paper.tex"); ++ }); ++ ++ it("falls back to the first recursive .tex path when no common basename exists", () => { ++ ++ ++ ++ ++ const files = [ ++ dir("src", [file("alpha.tex", "src/alpha.tex")]), ++ dir("appendix", [file("notes.tex", "appendix/notes.tex")]), ++ ]; ++ ++ expect(findMainTexFile(files)).toBe("src/alpha.tex"); ++ }); ++ ++ it("returns null when the tree contains no .tex files", () => { ++ ++ ++ ++ ++ const files = [file("README.md"), file("Makefile")]; ++ ++ expect(findMainTexFile(files)).toBeNull(); ++ }); ++ }); ++ ++ describe("Lib-Pure contract checks", () => { ++ it("handles an empty root file tree", () => { ++ ++ expect(findTexFiles([])).toEqual([]); ++ expect(findMainTexFile([])).toBeNull(); ++ }); ++ ++ it("is referentially transparent for repeated calls on the same tree", () => { ++ const files = [ ++ file("notes.md"), ++ dir("src", [file("alpha.tex", "src/alpha.tex"), file("paper.tex", "src/paper.tex")]), ++ ]; ++ ++ expect(findTexFiles(files)).toEqual(["src/alpha.tex", "src/paper.tex"]); ++ expect(findTexFiles(files)).toEqual(["src/alpha.tex", "src/paper.tex"]); ++ expect(findMainTexFile(files)).toBe("src/paper.tex"); ++ expect(findMainTexFile(files)).toBe("src/paper.tex"); ++ }); ++ ++ it("does not mutate the caller's file tree", () => { ++ const files = [ ++ file("README.md"), ++ dir("src", [ ++ file("alpha.tex", "src/alpha.tex"), ++ dir("deep", [file("report.tex", "src/deep/report.tex")], "src/deep"), ++ ]), ++ ]; ++ const before = cloneFiles(files); ++ ++ expect(findTexFiles(files)).toEqual(["src/alpha.tex", "src/deep/report.tex"]); ++ expect(findMainTexFile(files)).toBe("src/deep/report.tex"); ++ expect(files).toEqual(before); ++ expect(files).toEqual([ ++ { name: "README.md", path: "README.md", type: "file" }, ++ { ++ name: "src", ++ path: "src", ++ type: "directory", ++ children: [ ++ { name: "alpha.tex", path: "src/alpha.tex", type: "file" }, ++ { ++ name: "deep", ++ path: "src/deep", ++ type: "directory", ++ children: [{ name: "report.tex", path: "src/deep/report.tex", type: "file" }], ++ }, ++ ], ++ }, ++ ]); ++ }); ++ ++ it("does not depend on module-level state across noisy in-process calls or a fresh process", () => { ++ const target = [ ++ file("notes.md"), ++ dir("src", [file("alpha.tex", "src/alpha.tex"), file("paper.tex", "src/paper.tex")]), ++ ]; ++ const noise = [file("main.tex"), dir("chapters", [file("ch1.tex", "chapters/ch1.tex")])]; ++ ++ expect(findTexFiles(target)).toEqual(["src/alpha.tex", "src/paper.tex"]); ++ expect(findMainTexFile(target)).toBe("src/paper.tex"); ++ expect(findTexFiles(noise)).toEqual(["main.tex", "chapters/ch1.tex"]); ++ expect(findMainTexFile(noise)).toBe("main.tex"); ++ expect(findTexFiles(target)).toEqual(["src/alpha.tex", "src/paper.tex"]); ++ expect(findMainTexFile(target)).toBe("src/paper.tex"); ++ ++ expect(runFreshProcessProbe()).toEqual({ ++ texFiles: ["src/alpha.tex", "src/paper.tex"], ++ mainFile: "src/paper.tex", ++ }); ++ }); ++ ++ it("does not perform filesystem or network side effects", () => { ++ const originalCwd = process.cwd(); ++ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "latex-entry-file-pure-")); ++ const failIo = () => { ++ throw new Error("undeclared filesystem or network side effect"); ++ }; ++ let spies: MockInstance[] = []; ++ ++ try { ++ process.chdir(tempDir); ++ const before = fs.readdirSync(tempDir).sort(); ++ spies = [ ++ vi.spyOn(fs, "readFileSync").mockImplementation(failIo as never), ++ vi.spyOn(fs, "writeFileSync").mockImplementation(failIo as never), ++ vi.spyOn(fs, "appendFileSync").mockImplementation(failIo as never), ++ vi.spyOn(fs, "openSync").mockImplementation(failIo as never), ++ vi.spyOn(net, "connect").mockImplementation(failIo as never), ++ vi.spyOn(net, "createConnection").mockImplementation(failIo as never), ++ vi.spyOn(http, "request").mockImplementation(failIo as never), ++ vi.spyOn(https, "request").mockImplementation(failIo as never), ++ ]; ++ ++ const files = [file("README.md"), dir("src", [file("main.tex", "src/main.tex")])]; ++ expect(findTexFiles(files)).toEqual(["src/main.tex"]); ++ expect(findMainTexFile(files)).toBe("src/main.tex"); ++ ++ for (const spy of spies) { ++ spy.mockRestore(); ++ } ++ spies = []; ++ const after = fs.readdirSync(tempDir).sort(); ++ expect(after).toEqual(before); ++ } finally { ++ for (const spy of spies) { ++ spy.mockRestore(); ++ } ++ process.chdir(originalCwd); ++ fs.rmSync(tempDir, { recursive: true, force: true }); ++ } ++ }); ++ }); ++} +diff --git a/usercase-test-coderl/vitest.config.ts b/usercase-test-coderl/vitest.config.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/vitest.config.ts +@@ -0,0 +1,15 @@ ++import path from "node:path"; ++import { defineConfig } from "vitest/config"; ++ ++export default defineConfig({ ++ root: "/workspace/repo", ++ test: { ++ environment: "node", ++ include: ["usercase-test-coderl/**/*.test.ts"], ++ }, ++ resolve: { ++ alias: { ++ "@": path.resolve("/workspace/repo/apps/desktop/src"), ++ }, ++ }, ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,14 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo/apps/desktop ++exec node /workspace/repo/apps/desktop/node_modules/vitest/vitest.mjs run --config /workspace/repo/usercase-test-coderl/vitest.config.ts /workspace/repo/usercase-test-coderl/latex-entry-file.test.ts --reporter=verbose diff --git a/tasks/format-code-task-000914/tests/test.sh b/tasks/format-code-task-000914/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a57112375ae918d11992a015d2d341b42dc65868 --- /dev/null +++ b/tasks/format-code-task-000914/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/latex-entry-file.test.ts +usercase-test-coderl/vitest.config.ts +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000914/tests/test_command.sh b/tasks/format-code-task-000914/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000914/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000922/environment/Dockerfile b/tasks/format-code-task-000922/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5eeeb278e183851aced65b2b64ff507787f2e47d --- /dev/null +++ b/tasks/format-code-task-000922/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6c231d6fcd7ddcc4baf62220f9755187406c16e2b2c9fbae7c3897cc9e4440a9 diff --git a/tasks/format-code-task-000922/environment/setup/files/blocklist b/tasks/format-code-task-000922/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000922/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000922/environment/setup/setup.sh b/tasks/format-code-task-000922/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000922/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000922/tests/test.patch b/tasks/format-code-task-000922/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0bff27d9ea17dc35706b3ae62d1b22543b87f4d7 --- /dev/null +++ b/tasks/format-code-task-000922/tests/test.patch @@ -0,0 +1,291 @@ +diff --git a/packages/babel-plugin/__tests__/validation-error-messages-test.js b/packages/babel-plugin/__tests__/validation-error-messages-test.js +new file mode 100644 +index 0000000..7edeabb +--- /dev/null ++++ b/packages/babel-plugin/__tests__/validation-error-messages-test.js +@@ -0,0 +1,263 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++'use strict'; ++ ++jest.autoMockOff(); ++ ++import { transformSync } from '@babel/core'; ++import stylexPlugin from '../src/index'; ++ ++const defaultOpts = { ++ unstable_moduleResolution: { rootDir: '/stylex/packages/', type: 'commonJS' }, ++}; ++ ++function transform(source, opts = {}) { ++ return transformSync(source, { ++ filename: opts.filename || '/stylex/packages/TestTheme.stylex.js', ++ parserOpts: { flow: 'all' }, ++ babelrc: false, ++ plugins: [[stylexPlugin, { ...defaultOpts, ...opts }]], ++ }); ++} ++ ++function getErrorMessage(fn) { ++ try { ++ fn(); ++ } catch (e) { ++ return String(e.message); ++ } ++ throw new Error('expected the call to throw, but it did not'); ++} ++ ++describe('error messages reference the correct API', () => { ++ describe('stylex.defineConsts()', () => { ++ test('unbound call mentions defineConsts (not create/defineVars)', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ stylex.defineConsts({YELLOW: 'yellow'}); ++ `), ++ ); ++ expect(msg).toMatch(/defineConsts/); ++ expect(msg).not.toMatch(/\bdefineVars\b/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ expect(msg).not.toMatch(/stylex\.createTheme/); ++ }); ++ ++ test('not exported mentions defineConsts (not defineVars/create)', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ const constants = stylex.defineConsts({YELLOW: 'yellow'}); ++ `), ++ ); ++ expect(msg).toMatch(/defineConsts/); ++ expect(msg).not.toMatch(/\bdefineVars\b/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ }); ++ ++ test('zero arguments mentions defineConsts', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const constants = stylex.defineConsts(); ++ `), ++ ); ++ expect(msg).toMatch(/defineConsts/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ expect(msg).not.toMatch(/\bdefineVars\b/); ++ }); ++ ++ test('too many arguments mentions defineConsts', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const constants = stylex.defineConsts({}, {}); ++ `), ++ ); ++ expect(msg).toMatch(/defineConsts/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ expect(msg).not.toMatch(/\bdefineVars\b/); ++ }); ++ ++ test('non-object argument mentions defineConsts', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const constants = stylex.defineConsts(1); ++ `), ++ ); ++ expect(msg).toMatch(/defineConsts/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ expect(msg).not.toMatch(/\bdefineVars\b/); ++ }); ++ ++ test('non-static argument mentions defineConsts', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const constants = stylex.defineConsts(genStyles()); ++ `), ++ ); ++ expect(msg).toMatch(/defineConsts/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ expect(msg).not.toMatch(/\bdefineVars\b/); ++ }); ++ }); ++ ++ describe('stylex.defineVars()', () => { ++ test('unbound call mentions defineVars (not create/defineConsts)', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ stylex.defineVars({YELLOW: 'yellow'}); ++ `), ++ ); ++ expect(msg).toMatch(/defineVars/); ++ expect(msg).not.toMatch(/\bdefineConsts\b/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ }); ++ ++ test('not exported mentions defineVars (not create)', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ const vars = stylex.defineVars({YELLOW: 'yellow'}); ++ `), ++ ); ++ expect(msg).toMatch(/defineVars/); ++ expect(msg).not.toMatch(/\bdefineConsts\b/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ }); ++ ++ test('zero arguments mentions defineVars', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const vars = stylex.defineVars(); ++ `), ++ ); ++ expect(msg).toMatch(/defineVars/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ expect(msg).not.toMatch(/\bdefineConsts\b/); ++ }); ++ ++ test('non-object argument mentions defineVars', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const vars = stylex.defineVars(1); ++ `), ++ ); ++ expect(msg).toMatch(/defineVars/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ expect(msg).not.toMatch(/\bdefineConsts\b/); ++ }); ++ ++ test('non-static argument mentions defineVars', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const vars = stylex.defineVars(genStyles()); ++ `), ++ ); ++ expect(msg).toMatch(/defineVars/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ expect(msg).not.toMatch(/\bdefineConsts\b/); ++ }); ++ }); ++ ++ describe('stylex.keyframes()', () => { ++ test('zero arguments mentions keyframes (not create)', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const fade = stylex.keyframes(); ++ `), ++ ); ++ expect(msg).toMatch(/keyframes/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ }); ++ ++ test('non-static inside object mentions keyframes (not create)', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const fade = stylex.keyframes({ ++ from: { color: someValue }, ++ to: { color: 'blue' }, ++ }); ++ `), ++ ); ++ expect(msg).toMatch(/keyframes/); ++ expect(msg).not.toMatch(/stylex\.create\b/); ++ }); ++ }); ++ ++ describe('stylex.createTheme()', () => { ++ test('unbound call mentions createTheme (not create alone)', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ stylex.createTheme({__themeName__: 'x568ih9'}, {}); ++ `), ++ ); ++ expect(msg).toMatch(/createTheme/); ++ ++ expect(msg).not.toMatch(/stylex\.create\(\)/); ++ expect(msg).not.toMatch(/\bdefineVars\b/); ++ expect(msg).not.toMatch(/\bdefineConsts\b/); ++ }); ++ ++ test('wrong argument count mentions createTheme', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const t = stylex.createTheme({__themeName__: 'x568ih9'}); ++ `), ++ ); ++ expect(msg).toMatch(/createTheme/); ++ expect(msg).not.toMatch(/stylex\.create\(\)/); ++ }); ++ ++ test('non-object overrides mentions createTheme', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const t = stylex.createTheme({__themeName__: 'x568ih9'}, 1); ++ `), ++ ); ++ expect(msg).toMatch(/createTheme/); ++ expect(msg).not.toMatch(/stylex\.create\(\)/); ++ }); ++ }); ++ ++ describe('stylex.create() error messages still mention create', () => { ++ test('unbound call still mentions create', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ stylex.create({}); ++ `), ++ ); ++ expect(msg).toMatch(/\bcreate\b/); ++ }); ++ ++ test('too many args still mentions create', () => { ++ const msg = getErrorMessage(() => ++ transform(` ++ import * as stylex from '@stylexjs/stylex'; ++ export const s = stylex.create({}, {}); ++ `), ++ ); ++ expect(msg).toMatch(/\bcreate\b/); ++ }); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..fe210b6 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd packages/babel-plugin && npx jest __tests__/validation-error-messages-test.js"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++cd packages/babel-plugin && npx jest __tests__/validation-error-messages-test.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000922/tests/test.sh b/tasks/format-code-task-000922/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..16a21a51bbf8c48ce142cb9cec53f23ab743a81d --- /dev/null +++ b/tasks/format-code-task-000922/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/babel-plugin/__tests__/validation-error-messages-test.js +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000922/tests/test_command.sh b/tasks/format-code-task-000922/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000922/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000925/environment/Dockerfile b/tasks/format-code-task-000925/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7414393419e5fba0d0aa18cf10f2835027fd6601 --- /dev/null +++ b/tasks/format-code-task-000925/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:38927bac2ca041d41ef3f9ee38f191d6046af73163b3f771ba3e2719991a9fe9 diff --git a/tasks/format-code-task-000925/environment/setup/files/blocklist b/tasks/format-code-task-000925/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000925/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000925/environment/setup/setup.sh b/tasks/format-code-task-000925/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000925/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000925/tests/test.patch b/tasks/format-code-task-000925/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1c836a6759f3236fccacb571656396f61ee664fe --- /dev/null +++ b/tasks/format-code-task-000925/tests/test.patch @@ -0,0 +1,206 @@ +diff --git a/usercase-test-coderl/fixtures/streaming_eval_probe.py b/usercase-test-coderl/fixtures/streaming_eval_probe.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/streaming_eval_probe.py +@@ -0,0 +1,101 @@ ++#!/usr/bin/env python3 ++import json ++import pathlib ++import sys ++import types ++ ++ ++REPO = pathlib.Path("/workspace/repo") ++sys.path.insert(0, str(REPO / "src")) ++ ++ ++ ++ ++ ++simuleval = types.ModuleType("simuleval") ++simuleval_cli = types.ModuleType("simuleval.cli") ++ ++ ++def evaluate(agent_class, config, parser): ++ for name in ("--data-file", "--audio-root-dir", "--output", "--tgt-lang"): ++ parser.add_argument(name, required=True) ++ args, rest = parser.parse_known_args() ++ print( ++ json.dumps( ++ { ++ "agent": f"{agent_class.__module__}.{agent_class.__name__}", ++ "task": args.task, ++ "expressive": getattr(args, "expressive", None), ++ "data_file": args.data_file, ++ "audio_root_dir": args.audio_root_dir, ++ "output": args.output, ++ "tgt_lang": args.tgt_lang, ++ "config": {key: config[key] for key in sorted(config)}, ++ "unknown": rest, ++ }, ++ sort_keys=True, ++ ) ++ ) ++ ++ ++simuleval_cli.evaluate = evaluate ++sys.modules["simuleval"] = simuleval ++sys.modules["simuleval.cli"] = simuleval_cli ++ ++fairseq2 = types.ModuleType("fairseq2") ++fairseq2_assets = types.ModuleType("fairseq2.assets") ++ ++ ++class FileAssetMetadataProvider: ++ def __init__(self, *args, **kwargs): ++ pass ++ ++ ++class AssetStore: ++ def __init__(self): ++ self.metadata_providers = [] ++ ++ def retrieve_card(self, name): ++ raise RuntimeError("asset_store should not be used for s2st") ++ ++ ++fairseq2_assets.FileAssetMetadataProvider = FileAssetMetadataProvider ++fairseq2_assets.asset_store = AssetStore() ++fairseq2_assets.download_manager = object() ++sys.modules["fairseq2"] = fairseq2 ++sys.modules["fairseq2.assets"] = fairseq2_assets ++ ++scorer = types.ModuleType( ++ "seamless_communication.cli.streaming.scorers.seamless_quality_scorer" ++) ++ ++ ++class SeamlessQualityScorer: ++ pass ++ ++ ++scorer.SeamlessQualityScorer = SeamlessQualityScorer ++sys.modules[ ++ "seamless_communication.cli.streaming.scorers.seamless_quality_scorer" ++] = scorer ++ ++for module_name, class_name in [ ++ ("seamless_communication.streaming.agents.seamless_s2st", "SeamlessS2STAgent"), ++ ( ++ "seamless_communication.streaming.agents.seamless_streaming_s2st", ++ "SeamlessStreamingS2STAgent", ++ ), ++ ( ++ "seamless_communication.streaming.agents.seamless_streaming_s2t", ++ "SeamlessStreamingS2TAgent", ++ ), ++]: ++ mod = types.ModuleType(module_name) ++ cls = type(class_name, (), {"__module__": module_name}) ++ setattr(mod, class_name, cls) ++ sys.modules[module_name] = mod ++ ++from seamless_communication.cli.streaming.evaluate import main ++ ++ ++main() +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,78 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++export PYTHONDONTWRITEBYTECODE=1 ++ ++( cd /workspace/repo && python - <<'PY' ++from pathlib import Path ++path = Path("src/seamless_communication/cli/streaming/evaluate.py") ++compile(path.read_text(), str(path), "exec") ++PY ++) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++ ++BIN="python /workspace/repo/usercase-test-coderl/fixtures/streaming_eval_probe.py" ++TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || exit 1 ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++check_s2st_probe() { ++ local label="$1" ++ local expected_agent="$2" ++ local expected_expressive="$3" ++ python - "$label" "$expected_agent" "$expected_expressive" out <<'PY' \ ++ || fail "$label stdout: $(cat out)" ++import json ++import sys ++from pathlib import Path ++ ++label, expected_agent, expected_expressive, path = sys.argv[1:5] ++payload = json.loads(Path(path).read_text()) ++ ++assert payload["agent"] == expected_agent, payload ++assert payload["task"] == "s2st", payload ++assert payload["expressive"] is (expected_expressive == "true"), payload ++assert payload["data_file"] == "data.tsv", payload ++assert payload["audio_root_dir"] == "audio", payload ++assert payload["output"] == "out", payload ++assert payload["tgt_lang"] == "fra", payload ++ ++config = payload["config"] ++assert config["min_unit_chunk_size"] == 50, payload ++assert config["latency_metrics"] == "StartOffset EndOffset", payload ++PY ++} ++ ++ ++ ++ ++$BIN --task s2st --data-file data.tsv --audio-root-dir audio --output out --tgt-lang fra >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++check_s2st_probe F1 "seamless_communication.streaming.agents.seamless_streaming_s2st.SeamlessStreamingS2STAgent" false ++ ++! grep -qi "invalid choice" err || fail "F1 parser error stderr: $(cat err)" ++ ++ ++ ++ ++$BIN --task s2st --expressive --data-file data.tsv --audio-root-dir audio --output out --tgt-lang fra >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++ ++check_s2st_probe F2 "seamless_communication.streaming.agents.seamless_s2st.SeamlessS2STAgent" true ++ ++! grep -qi "invalid choice" err || fail "F2 parser error stderr: $(cat err)" ++ ++ ++ ++ ++$BIN --task text --data-file data.tsv --audio-root-dir audio --output out --tgt-lang fra >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F3 exit $ec; want non-zero parser error" ++[ ! -s out ] || fail "F3 unexpected stdout: $(cat out)" ++ ++grep -qi "error:" err || fail "F3 stderr is not an argparse parser error: $(cat err)" ++grep -q "text" err || fail "F3 stderr does not mention rejected task: $(cat err)" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-000925/tests/test.sh b/tasks/format-code-task-000925/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f718fbd73207f1a040fa6389b08ed179e4f670db --- /dev/null +++ b/tasks/format-code-task-000925/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/streaming_eval_probe.py +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000925/tests/test_command.sh b/tasks/format-code-task-000925/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000925/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000940/environment/Dockerfile b/tasks/format-code-task-000940/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2a70d6d14c03452e655a5f0879e098503e466911 --- /dev/null +++ b/tasks/format-code-task-000940/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:40f5c4a485329407ed0e625079512b9bece215e9e3c8d2beeab6ca8394aaade0 diff --git a/tasks/format-code-task-000940/environment/setup/files/blocklist b/tasks/format-code-task-000940/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000940/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000940/environment/setup/setup.sh b/tasks/format-code-task-000940/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000940/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000940/tests/test.patch b/tasks/format-code-task-000940/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8af68acbc34dc3431ae0130fe30f85b2026aed1a --- /dev/null +++ b/tasks/format-code-task-000940/tests/test.patch @@ -0,0 +1,541 @@ +diff --git a/usercase-test-coderl/fixtures/project/app/models/account_spec.rb b/usercase-test-coderl/fixtures/project/app/models/account_spec.rb +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/project/app/models/account_spec.rb +@@ -0,0 +1,2 @@ ++class AccountSpec ++end +diff --git a/usercase-test-coderl/fixtures/project/app/models/account_test.rb b/usercase-test-coderl/fixtures/project/app/models/account_test.rb +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/project/app/models/account_test.rb +@@ -0,0 +1,2 @@ ++class AccountTest ++end +diff --git a/usercase-test-coderl/fixtures/project/engines/orders/spec/nested_sample.rb b/usercase-test-coderl/fixtures/project/engines/orders/spec/nested_sample.rb +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/project/engines/orders/spec/nested_sample.rb +@@ -0,0 +1,2 @@ ++class NestedSpecSample ++end +diff --git a/usercase-test-coderl/fixtures/project/lib/a.rb b/usercase-test-coderl/fixtures/project/lib/a.rb +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/project/lib/a.rb +@@ -0,0 +1,2 @@ ++class A ++end +diff --git a/usercase-test-coderl/fixtures/project/lib/b.rb b/usercase-test-coderl/fixtures/project/lib/b.rb +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/project/lib/b.rb +@@ -0,0 +1,2 @@ ++class B ++end +diff --git a/usercase-test-coderl/fixtures/project/spec/b_spec.rb b/usercase-test-coderl/fixtures/project/spec/b_spec.rb +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/project/spec/b_spec.rb +@@ -0,0 +1,2 @@ ++class BSpec ++end +diff --git a/usercase-test-coderl/fixtures/project/test/a_test.rb b/usercase-test-coderl/fixtures/project/test/a_test.rb +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/project/test/a_test.rb +@@ -0,0 +1,2 @@ ++class ATest ++end +diff --git a/usercase-test-coderl/skunk_score_acceptance_test.rb b/usercase-test-coderl/skunk_score_acceptance_test.rb +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/skunk_score_acceptance_test.rb +@@ -0,0 +1,452 @@ ++# frozen_string_literal: true ++ ++ ++ ++ ++ ++ ++ ++ ++ ++require "fileutils" ++require "json" ++require "minitest/autorun" ++require "open3" ++require "pathname" ++require "rbconfig" ++require "tmpdir" ++ ++require "rubycritic/configuration" ++require "skunk/rubycritic/analysed_module" ++require "skunk/rubycritic/analysed_modules_collection" ++ ++class SkunkScoreAcceptanceTest < Minitest::Test ++ FIXTURE_ROOT = "usercase-test-coderl/fixtures/project" ++ ++ def setup ++ RubyCritic::Config.ruby_extensions = [".rb"] ++ end ++ ++ def test_skunk_score_uses_rounded_cost_at_perfect_coverage ++ ++ ++ analysed_module = module_fixture("lib/rounded.rb", cost: 2.345, coverage: 100, churn: 1) ++ ++ assert_equal 2.35, analysed_module.skunk_score ++ end ++ ++ def test_skunk_score_for_cost_100_and_full_coverage ++ ++ ++ analysed_module = module_fixture("lib/full.rb", cost: 100, coverage: 100, churn: 1) ++ ++ assert_equal 100.0, analysed_module.skunk_score ++ end ++ ++ def test_skunk_score_for_cost_100_and_zero_coverage ++ ++ ++ analysed_module = module_fixture("lib/none.rb", cost: 100, coverage: 0, churn: 1) ++ ++ assert_equal 10_000.0, analysed_module.skunk_score ++ end ++ ++ def test_skunk_score_and_penalty_factor_for_partial_coverage ++ ++ ++ analysed_module = module_fixture("lib/partial.rb", cost: 100, coverage: 75, churn: 1) ++ ++ assert_equal 25, analysed_module.penalty_factor ++ assert_equal 2_500.0, analysed_module.skunk_score ++ end ++ ++ def test_penalty_factor_truncates_fractional_coverage_to_integer ++ ++ ++ analysed_module = module_fixture("lib/fractional.rb", cost: 12.345, coverage: 87.65, churn: 4) ++ ++ assert_equal 13, analysed_module.penalty_factor ++ assert_equal 160.49, analysed_module.skunk_score ++ end ++ ++ def test_churn_times_cost_with_positive_churn ++ ++ ++ analysed_module = module_fixture("lib/churn_three.rb", cost: 2.34, coverage: 100, churn: 3) ++ ++ assert_equal 7.02, analysed_module.churn_times_cost ++ end ++ ++ def test_churn_times_cost_treats_zero_churn_as_one ++ ++ ++ analysed_module = module_fixture("lib/churn_zero.rb", cost: 2.34, coverage: 100, churn: 0) ++ ++ assert_equal 2.34, analysed_module.churn_times_cost ++ end ++ ++ def test_churn_times_cost_treats_negative_churn_as_one ++ ++ ++ analysed_module = module_fixture("lib/churn_negative.rb", cost: 2.34, coverage: 100, churn: -4) ++ ++ assert_equal 2.34, analysed_module.churn_times_cost ++ end ++ ++ def test_module_to_hash_exports_all_rounded_skunk_fields ++ ++ ++ analysed_module = module_fixture("app/models/order.rb", cost: 12.345, coverage: 87.65, churn: 4) ++ ++ ++ assert_hash_fields( ++ { ++ file: "app/models/order.rb", ++ skunk_score: 160.49, ++ churn_times_cost: 49.38, ++ churn: 4, ++ cost: 12.35, ++ coverage: 87.65 ++ }, ++ analysed_module.to_hash ++ ) ++ end ++ ++ def test_collection_metrics_ignore_test_files_and_rank_worst_first ++ ++ ++ collection = fixture_collection ++ ++ assert_equal 2, collection.analysed_modules_count ++ assert_equal 30.0, collection.skunk_score_total ++ assert_equal 15.0, collection.skunk_score_average ++ assert_equal 12.0, collection.total_churn_times_cost ++ assert_equal( ++ [ ++ "usercase-test-coderl/fixtures/project/lib/b.rb", ++ "usercase-test-coderl/fixtures/project/lib/a.rb" ++ ], ++ collection.sorted_modules.map { |analysed_module| analysed_module.pathname.to_s } ++ ) ++ ++ ++ assert_equal "usercase-test-coderl/fixtures/project/lib/b.rb", collection.worst_module.pathname.to_s ++ end ++ ++ def test_collection_excludes_every_declared_test_path_shape_from_public_lists ++ ++ ++ collection = fixture_collection ++ ++ ++ ++ assert_equal( ++ [ ++ "usercase-test-coderl/fixtures/project/lib/a.rb", ++ "usercase-test-coderl/fixtures/project/lib/b.rb" ++ ], ++ collection.non_test_modules.map { |analysed_module| analysed_module.pathname.to_s }.sort ++ ) ++ ++ ++ assert_equal( ++ [ ++ { ++ file: "usercase-test-coderl/fixtures/project/lib/b.rb", ++ skunk_score: 20.0, ++ churn_times_cost: 7.0, ++ churn: 35, ++ cost: 0.2, ++ coverage: 0.0 ++ }, ++ { ++ file: "usercase-test-coderl/fixtures/project/lib/a.rb", ++ skunk_score: 10.0, ++ churn_times_cost: 5.0, ++ churn: 50, ++ cost: 0.1, ++ coverage: 0.0 ++ } ++ ], ++ spec_file_hashes(collection.files_as_hash) ++ ) ++ end ++ ++ def test_collection_excludes_paths_under_directories_beginning_with_test_or_spec ++ ++ ++ Dir.mktmpdir do |directory| ++ Dir.chdir(directory) do ++ FileUtils.mkdir_p(["spec", "test", "source"]) ++ File.write("spec/starts_spec.rb", "class StartsSpec\nend\n") ++ File.write("test/starts_test.rb", "class StartsTest\nend\n") ++ File.write("source/live.rb", "class Live\nend\n") ++ ++ modules = [ ++ module_fixture("spec/starts_spec.rb", cost: 1.11, coverage: 0, churn: 1), ++ module_fixture("test/starts_test.rb", cost: 2.22, coverage: 0, churn: 1), ++ module_fixture("source/live.rb", cost: 0.44, coverage: 0, churn: 2) ++ ] ++ collection = RubyCritic::AnalysedModulesCollection.new( ++ ["spec/starts_spec.rb", "test/starts_test.rb", "source/live.rb"], ++ modules ++ ) ++ ++ assert_equal ["source/live.rb"], collection.non_test_modules.map { |analysed_module| analysed_module.pathname.to_s } ++ assert_equal 1, collection.analysed_modules_count ++ assert_equal 44.0, collection.skunk_score_total ++ assert_equal 0.88, collection.total_churn_times_cost ++ end ++ end ++ end ++ ++ def test_empty_collection_returns_zero_average_and_nil_worst_module ++ ++ ++ collection = RubyCritic::AnalysedModulesCollection.new([], []) ++ ++ assert_equal 0, collection.analysed_modules_count ++ assert_equal 0, collection.skunk_score_total ++ assert_equal 0.0, collection.skunk_score_average ++ assert_equal 0, collection.total_churn_times_cost ++ assert_nil collection.worst_module ++ assert_equal [], collection.sorted_modules ++ assert_equal [], collection.files_as_hash ++ end ++ ++ def test_collection_to_hash_exports_summary_and_sorted_file_hashes ++ ++ ++ collection = fixture_collection ++ ++ actual = collection.to_hash ++ ++ ++ ++ assert_hash_fields( ++ { ++ analysed_modules_count: 2, ++ skunk_score_total: 30.0, ++ skunk_score_average: 15.0, ++ total_churn_times_cost: 12.0, ++ worst_score: 20.0 ++ }, ++ actual ++ ) ++ assert_equal "usercase-test-coderl/fixtures/project/lib/b.rb", hash_value(actual, :worst_pathname).to_s ++ assert_equal( ++ [ ++ { ++ file: "usercase-test-coderl/fixtures/project/lib/b.rb", ++ skunk_score: 20.0, ++ churn_times_cost: 7.0, ++ churn: 35, ++ cost: 0.2, ++ coverage: 0.0 ++ }, ++ { ++ file: "usercase-test-coderl/fixtures/project/lib/a.rb", ++ skunk_score: 10.0, ++ churn_times_cost: 5.0, ++ churn: 50, ++ cost: 0.1, ++ coverage: 0.0 ++ } ++ ], ++ spec_file_hashes(hash_value(actual, :files)) ++ ) ++ end ++ ++ def test_metric_methods_are_public_zero_argument_methods ++ analysed_module = module_fixture("lib/zero_argument.rb", cost: 1.0, coverage: 100, churn: 1) ++ collection = RubyCritic::AnalysedModulesCollection.new(["lib/zero_argument.rb"], [analysed_module]) ++ ++ ++ ++ %i[skunk_score penalty_factor churn_times_cost to_hash].each do |method_name| ++ assert analysed_module.respond_to?(method_name), "#{method_name} should be public" ++ assert_equal 0, analysed_module.method(method_name).arity ++ end ++ %i[ ++ analysed_modules_count ++ skunk_score_total ++ skunk_score_average ++ total_churn_times_cost ++ worst_module ++ sorted_modules ++ non_test_modules ++ files_as_hash ++ to_hash ++ ].each do |method_name| ++ assert collection.respond_to?(method_name), "#{method_name} should be public" ++ assert_equal 0, collection.method(method_name).arity ++ end ++ end ++ ++ def test_referential_transparency_for_same_module_metrics ++ analysed_module = module_fixture("lib/repeatable.rb", cost: 3.21, coverage: 45.5, churn: 6) ++ ++ ++ ++ assert_equal spec_file_hashes([analysed_module.to_hash]), spec_file_hashes([analysed_module.to_hash]) ++ end ++ ++ def test_metric_methods_do_not_mutate_caller_visible_module_attributes ++ analysed_module = module_fixture("lib/no_mutation.rb", cost: 4.56, coverage: 78.9, churn: 2) ++ before = visible_module_attributes(analysed_module) ++ ++ analysed_module.skunk_score ++ analysed_module.penalty_factor ++ analysed_module.churn_times_cost ++ analysed_module.to_hash ++ ++ assert_equal before, visible_module_attributes(analysed_module) ++ end ++ ++ def test_same_input_matches_fresh_ruby_process_after_in_process_noise ++ analysed_module = module_fixture("lib/fresh_process.rb", cost: 6.78, coverage: 91.2, churn: 3) ++ in_process = analysed_module.to_hash ++ ++ module_fixture("lib/noise_a.rb", cost: 100, coverage: 0, churn: 1).to_hash ++ module_fixture("lib/noise_b.rb", cost: 2.34, coverage: 100, churn: 0).to_hash ++ ++ stdout, stderr, status = Open3.capture3( ++ RbConfig.ruby, ++ "-I/workspace/repo/lib", ++ "-e", ++ fresh_process_script ++ ) ++ ++ assert status.success?, stderr ++ ++ ++ assert_hash_fields( ++ { ++ file: "lib/fresh_process.rb", ++ skunk_score: 61.02, ++ churn_times_cost: 20.34, ++ churn: 3, ++ cost: 6.78, ++ coverage: 91.2 ++ }, ++ in_process ++ ) ++ assert_hash_fields( ++ { ++ file: "lib/fresh_process.rb", ++ skunk_score: 61.02, ++ churn_times_cost: 20.34, ++ churn: 3, ++ cost: 6.78, ++ coverage: 91.2 ++ }, ++ JSON.parse(stdout, symbolize_names: true) ++ ) ++ end ++ ++ def test_metric_methods_return_spec_fields_for_relative_path ++ Dir.mktmpdir do |directory| ++ Dir.chdir(directory) do ++ analysed_module = module_fixture("side_effect_probe.rb", cost: 1.25, coverage: 70, churn: 4) ++ ++ assert_equal 37.5, analysed_module.skunk_score ++ assert_equal 5.0, analysed_module.churn_times_cost ++ ++ ++ assert_hash_fields( ++ { ++ file: "side_effect_probe.rb", ++ skunk_score: 37.5, ++ churn_times_cost: 5.0, ++ churn: 4, ++ cost: 1.25, ++ coverage: 70.0 ++ }, ++ analysed_module.to_hash ++ ) ++ end ++ end ++ end ++ ++ private ++ ++ def module_fixture(path, cost:, coverage:, churn:) ++ RubyCritic::AnalysedModule.new( ++ pathname: Pathname.new(path), ++ complexity: cost * 25.0, ++ coverage: coverage, ++ churn: churn, ++ methods_count: 1, ++ name: path ++ ) ++ end ++ ++ def fixture_collection ++ modules = [ ++ module_fixture("#{FIXTURE_ROOT}/lib/a.rb", cost: 0.10, coverage: 0, churn: 50), ++ module_fixture("#{FIXTURE_ROOT}/lib/b.rb", cost: 0.20, coverage: 0, churn: 35), ++ module_fixture("#{FIXTURE_ROOT}/test/a_test.rb", cost: 9.99, coverage: 0, churn: 1), ++ module_fixture("#{FIXTURE_ROOT}/spec/b_spec.rb", cost: 8.88, coverage: 0, churn: 1), ++ module_fixture("#{FIXTURE_ROOT}/engines/orders/spec/nested_sample.rb", cost: 7.77, coverage: 0, churn: 1), ++ module_fixture("#{FIXTURE_ROOT}/app/models/account_spec.rb", cost: 6.66, coverage: 0, churn: 1), ++ module_fixture("#{FIXTURE_ROOT}/app/models/account_test.rb", cost: 5.55, coverage: 0, churn: 1) ++ ] ++ ++ RubyCritic::AnalysedModulesCollection.new([FIXTURE_ROOT], modules) ++ end ++ ++ def visible_module_attributes(analysed_module) ++ { ++ pathname: analysed_module.pathname, ++ coverage: analysed_module.coverage, ++ churn: analysed_module.churn, ++ cost: analysed_module.cost ++ } ++ end ++ ++ def assert_hash_fields(expected, actual) ++ assert_kind_of Hash, actual ++ expected.each do |key, expected_value| ++ assert_equal expected_value, hash_value(actual, key) ++ end ++ end ++ ++ def spec_file_hashes(files) ++ files.map do |file_hash| ++ { ++ file: hash_value(file_hash, :file), ++ skunk_score: hash_value(file_hash, :skunk_score), ++ churn_times_cost: hash_value(file_hash, :churn_times_cost), ++ churn: hash_value(file_hash, :churn), ++ cost: hash_value(file_hash, :cost), ++ coverage: hash_value(file_hash, :coverage) ++ } ++ end ++ end ++ ++ def hash_value(hash, key) ++ return hash.fetch(key) if hash.key?(key) ++ ++ hash.fetch(key.to_s) ++ end ++ ++ def fresh_process_script ++ <<~RUBY ++ require "json" ++ require "pathname" ++ require "skunk/rubycritic/analysed_module" ++ ++ analysed_module = RubyCritic::AnalysedModule.new( ++ pathname: Pathname.new("lib/fresh_process.rb"), ++ complexity: 6.78 * 25.0, ++ coverage: 91.2, ++ churn: 3, ++ methods_count: 1, ++ name: "lib/fresh_process.rb" ++ ) ++ ++ STDOUT.write(JSON.generate(analysed_module.to_hash)) ++ RUBY ++ end ++ ++end +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,30 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++export BUNDLE_APP_CONFIG="${BUNDLE_APP_CONFIG:-/usr/local/bundle}" ++export BUNDLE_GEMFILE=/workspace/repo/Gemfile ++unset BUNDLE_PATH ++unset BUNDLE_DEPLOYMENT ++unset BUNDLE_WITHOUT ++unset BUNDLE_ONLY ++export BUNDLE_FROZEN=true ++export BUNDLE_DISABLE_VERSION_CHECK=true ++export GEM_HOME="${GEM_HOME:-/usr/local/bundle}" ++export GEM_PATH="${GEM_PATH:-/usr/local/bundle:/usr/local/lib/ruby/gems/3.3.0}" ++ ++if ! bundle check >/dev/null 2>&1; then ++ echo "Bundled gems are not installed locally; refusing to install during offline test run." >&2 ++ exit 1 ++fi ++exec bundle exec ruby /workspace/repo/usercase-test-coderl/skunk_score_acceptance_test.rb diff --git a/tasks/format-code-task-000940/tests/test.sh b/tasks/format-code-task-000940/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..33a8898f0b89194ef569f4619eddd4da53349a3b --- /dev/null +++ b/tasks/format-code-task-000940/tests/test.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/project/app/models/account_spec.rb +usercase-test-coderl/fixtures/project/app/models/account_test.rb +usercase-test-coderl/fixtures/project/engines/orders/spec/nested_sample.rb +usercase-test-coderl/fixtures/project/lib/a.rb +usercase-test-coderl/fixtures/project/lib/b.rb +usercase-test-coderl/fixtures/project/spec/b_spec.rb +usercase-test-coderl/fixtures/project/test/a_test.rb +usercase-test-coderl/skunk_score_acceptance_test.rb +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000940/tests/test_command.sh b/tasks/format-code-task-000940/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000940/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000941/environment/Dockerfile b/tasks/format-code-task-000941/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c6166a22a01421bc2a67d9b8834c10fe25e170b3 --- /dev/null +++ b/tasks/format-code-task-000941/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:339a98d5eaa623631bab153df79bc72dd7e7f0a53ad64e2564336a95c5484d96 diff --git a/tasks/format-code-task-000941/environment/setup/files/blocklist b/tasks/format-code-task-000941/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000941/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000941/environment/setup/setup.sh b/tasks/format-code-task-000941/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000941/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000941/tests/test.patch b/tasks/format-code-task-000941/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a4714551e01096d5ce374e11b733929511cd6743 --- /dev/null +++ b/tasks/format-code-task-000941/tests/test.patch @@ -0,0 +1,142 @@ +diff --git a/pooch/tests/test_utils.py b/pooch/tests/test_utils.py +index a8d59c4..ce695d1 100644 +--- a/pooch/tests/test_utils.py ++++ b/pooch/tests/test_utils.py +@@ -24,6 +24,7 @@ from ..utils import ( + parse_url, + make_local_storage, + file_hash, ++ hash_algorithm, + hash_matches, + temporary_file, + unique_file_name, +@@ -266,6 +267,107 @@ def test_hash_matches_none(): + assert hash_matches(fname, known_hash=None, strict=True) + + ++TINY_DATA_HASH = "baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2d" ++ ++ ++def test_hash_matches_uppercase_known_hash(): ++ "PowerShell Get-FileHash produces uppercase; should still match (no re-download)" ++ fname = os.path.join(DATA_DIR, "tiny-data.txt") ++ check_tiny_data(fname) ++ upper_hash = TINY_DATA_HASH.upper() ++ assert upper_hash != TINY_DATA_HASH ++ assert hash_matches(fname, upper_hash) ++ ++ ++def test_hash_matches_uppercase_known_hash_strict(): ++ "Strict mode should not raise when uppercase hash matches" ++ fname = os.path.join(DATA_DIR, "tiny-data.txt") ++ check_tiny_data(fname) ++ upper_hash = TINY_DATA_HASH.upper() ++ assert hash_matches(fname, upper_hash, strict=True) ++ ++ ++def test_hash_matches_uppercase_with_algorithm_prefix(): ++ "Uppercase algorithm prefix + uppercase hash should match" ++ fname = os.path.join(DATA_DIR, "tiny-data.txt") ++ check_tiny_data(fname) ++ known = "SHA256:" + TINY_DATA_HASH.upper() ++ assert hash_matches(fname, known) ++ assert hash_matches(fname, known, strict=True) ++ ++ ++def test_hash_matches_mixed_case_hash(): ++ "Mixed case hashes (some caps, some not) should match" ++ fname = os.path.join(DATA_DIR, "tiny-data.txt") ++ check_tiny_data(fname) ++ mixed = TINY_DATA_HASH[:20].upper() + TINY_DATA_HASH[20:] ++ assert mixed != TINY_DATA_HASH ++ assert mixed != TINY_DATA_HASH.upper() ++ assert hash_matches(fname, mixed) ++ ++ ++def test_hash_matches_lowercase_preserved(): ++ "Preservation: lowercase hashes (original behavior) still work" ++ fname = os.path.join(DATA_DIR, "tiny-data.txt") ++ check_tiny_data(fname) ++ assert hash_matches(fname, TINY_DATA_HASH) ++ assert hash_matches(fname, "sha256:" + TINY_DATA_HASH) ++ assert hash_matches(fname, TINY_DATA_HASH, strict=True) ++ ++ ++def test_hash_matches_uppercase_wrong_hash_still_fails(): ++ "An uppercase but actually wrong hash should still NOT match" ++ fname = os.path.join(DATA_DIR, "tiny-data.txt") ++ check_tiny_data(fname) ++ bad_hash = ("0" * 64).upper() ++ assert not hash_matches(fname, bad_hash) ++ with pytest.raises(ValueError): ++ hash_matches(fname, bad_hash, strict=True) ++ ++ ++def test_hash_algorithm_uppercase_prefix(): ++ "hash_algorithm should return lowercase algorithm name for uppercase prefix" ++ assert hash_algorithm("SHA256:abc123") == "sha256" ++ assert hash_algorithm("MD5:abc123") == "md5" ++ assert hash_algorithm("SHA512:abc123") == "sha512" ++ ++ ++def test_hash_algorithm_mixed_case_prefix(): ++ "hash_algorithm should return lowercase even for mixed case prefix" ++ assert hash_algorithm("Sha256:abc123") == "sha256" ++ assert hash_algorithm("Md5:abc123") == "md5" ++ ++ ++def test_hash_algorithm_lowercase_preserved(): ++ "Preservation: existing lowercase behavior unchanged" ++ assert hash_algorithm("sha256:abc") == "sha256" ++ assert hash_algorithm("md5:abc") == "md5" ++ assert hash_algorithm("abc") == "sha256" ++ assert hash_algorithm(None) == "sha256" ++ ++ ++def test_pooch_load_registry_uppercase_hash(): ++ "Loading a registry with PowerShell-style uppercase hash should match the file" ++ pup = Pooch(path=DATA_DIR, base_url="") ++ tiny_hash_lower = ( ++ "baee0894dba14b12085eacb204284b97e362f4f3e5a5807693cc90ef415c1b2d" ++ ) ++ content = f"tiny-data.txt {tiny_hash_lower.upper()}\n" ++ tmp = NamedTemporaryFile(mode="w", delete=False, suffix=".txt") ++ try: ++ tmp.write(content) ++ tmp.close() ++ pup.load_registry(tmp.name) ++ ++ ++ stored_hash = pup.registry["tiny-data.txt"] ++ fname = os.path.join(DATA_DIR, "tiny-data.txt") ++ assert hash_matches(fname, stored_hash) ++ assert hash_matches(fname, stored_hash, strict=True) ++ finally: ++ os.remove(tmp.name) ++ ++ + def test_temporary_file(): + "Make sure the file is writable and cleaned up in the end" + with temporary_file() as tmp: +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..ca59fea +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pooch/tests/test_utils.py -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -v -rA pooch/tests/test_utils.py::test_hash_matches_uppercase_known_hash pooch/tests/test_utils.py::test_hash_matches_uppercase_known_hash_strict pooch/tests/test_utils.py::test_hash_matches_uppercase_with_algorithm_prefix pooch/tests/test_utils.py::test_hash_matches_mixed_case_hash pooch/tests/test_utils.py::test_hash_matches_lowercase_preserved pooch/tests/test_utils.py::test_hash_matches_uppercase_wrong_hash_still_fails pooch/tests/test_utils.py::test_hash_algorithm_uppercase_prefix pooch/tests/test_utils.py::test_hash_algorithm_mixed_case_prefix pooch/tests/test_utils.py::test_hash_algorithm_lowercase_preserved pooch/tests/test_utils.py::test_pooch_load_registry_uppercase_hash ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000941/tests/test.sh b/tasks/format-code-task-000941/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5e562dbf4b331960559864564a68db881511b946 --- /dev/null +++ b/tasks/format-code-task-000941/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pooch/tests/test_utils.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000941/tests/test_command.sh b/tasks/format-code-task-000941/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000941/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000949/environment/Dockerfile b/tasks/format-code-task-000949/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bed7514830f41d943f935ec41438571c950eed55 --- /dev/null +++ b/tasks/format-code-task-000949/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:16213447647641d35b524a1519c998b3fb90e8ff61d56cae245fd18c87e4829a diff --git a/tasks/format-code-task-000949/environment/setup/files/blocklist b/tasks/format-code-task-000949/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000949/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000949/environment/setup/setup.sh b/tasks/format-code-task-000949/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000949/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000949/tests/test.patch b/tasks/format-code-task-000949/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ffb23743d1e35ff7fe715008d0cb3108b4d9f3f2 --- /dev/null +++ b/tasks/format-code-task-000949/tests/test.patch @@ -0,0 +1,440 @@ +diff --git a/usercase-test-coderl/security_browser.test.js b/usercase-test-coderl/security_browser.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/security_browser.test.js +@@ -0,0 +1,32 @@ ++ ++ ++ ++ ++const { getSecurity, validateWebhookSignature } = require('../build/main'); ++ ++describe('top-level browser security helpers', () => { ++ test('browser getSecurity export throws the Node-only guard message', () => { ++ ++ ++ ++ ++ expect(typeof getSecurity).toBe('function'); ++ expect(() => getSecurity({ expiry: 1523595600 }, 'testAppSecret')).toThrow( ++ 'getSecurity is only supported in nodejs', ++ ); ++ }); ++ ++ test('browser validateWebhookSignature export throws the Node-only guard message', () => { ++ ++ ++ ++ ++ expect(typeof validateWebhookSignature).toBe('function'); ++ expect(() => ++ validateWebhookSignature('abc123', '{"event":"test"}', { ++ timestamp: '42', ++ signature: 'e9e2082b689b165cfcde5e0f3e3b146afece84e0c4d5e8b466d9b598e6a146d3', ++ }), ++ ).toThrow('validateWebhookSignature is only supported in nodejs'); ++ }); ++}); +diff --git a/usercase-test-coderl/security_node.test.js b/usercase-test-coderl/security_node.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/security_node.test.js +@@ -0,0 +1,264 @@ ++ ++ ++ ++ ++ ++const childProcess = require('child_process'); ++const fs = require('fs'); ++const http = require('http'); ++const https = require('https'); ++const net = require('net'); ++const os = require('os'); ++const path = require('path'); ++const tls = require('tls'); ++ ++const { ++ FilestackError, ++ getSecurity, ++ validateWebhookSignature, ++} = require('../build/main'); ++ ++const expectValidationDetailsToMention = (details, fragments) => { ++ expect(details).toBeDefined(); ++ const serialized = typeof details === 'string' ? details : JSON.stringify(details); ++ expect(serialized).toEqual(expect.any(String)); ++ expect(serialized.length).toBeGreaterThan(0); ++ const normalized = serialized.toLowerCase(); ++ fragments.forEach((fragment) => { ++ expect(normalized).toContain(fragment.toLowerCase()); ++ }); ++}; ++ ++describe('top-level Node security helpers', () => { ++ test('getSecurity signs the expiry-only policy fixture', () => { ++ ++ ++ ++ ++ const policyOptions = { expiry: 253381964415 }; ++ ++ const actual = getSecurity(policyOptions, 'abc123'); ++ ++ expect(actual).toEqual({ ++ policy: 'eyJleHBpcnkiOjI1MzM4MTk2NDQxNX0=', ++ signature: '73f7e2f282432af9853e66237e78a6bbe3131091c0c8163c87a88a8e562818cd', ++ }); ++ }); ++ ++ test('getSecurity signs the expiry-and-handle policy fixture', () => { ++ ++ ++ ++ ++ const policyOptions = { expiry: 1523595600, handle: 'TEST_HANDLE' }; ++ ++ const actual = getSecurity(policyOptions, 'testAppSecret'); ++ ++ expect(actual).toEqual({ ++ policy: 'eyJleHBpcnkiOjE1MjM1OTU2MDAsImhhbmRsZSI6IlRFU1RfSEFORExFIn0=', ++ signature: '4c4103f55de507b5d51f595163c3f8759d04b663d0f5bb172b74c689804f35c8', ++ }); ++ }); ++ ++ test('getSecurity preserves provided JSON key order for every allowed optional key', () => { ++ ++ ++ ++ ++ const policyOptions = { ++ expiry: 1700000000, ++ call: ['pick', 'store', 'read'], ++ handle: 'A_HANDLE_123', ++ url: 'https://cdn.example.test/input.png', ++ maxSize: 1048576, ++ minSize: 12, ++ path: '/uploads/2026/', ++ container: 'media-bucket', ++ }; ++ ++ const actual = getSecurity(policyOptions, 'complexSecret!'); ++ ++ expect(actual).toEqual({ ++ policy: ++ 'eyJleHBpcnkiOjE3MDAwMDAwMDAsImNhbGwiOlsicGljayIsInN0b3JlIiwicmVhZCJdLCJoYW5kbGUiOiJBX0hBTkRMRV8xMjMiLCJ1cmwiOiJodHRwczovL2Nkbi5leGFtcGxlLnRlc3QvaW5wdXQucG5nIiwibWF4U2l6ZSI6MTA0ODU3NiwibWluU2l6ZSI6MTIsInBhdGgiOiIvdXBsb2Fkcy8yMDI2LyIsImNvbnRhaW5lciI6Im1lZGlhLWJ1Y2tldCJ9', ++ signature: '0d40f64760778c3ef3fc793dea3c20a7338281541738d019abf15a334c6d7b97', ++ }); ++ }); ++ ++ test('getSecurity rejects a non-number expiry with FilestackError validation details', () => { ++ ++ ++ ++ ++ let thrown; ++ ++ try { ++ getSecurity({ expiry: 'test', handle: 'TEST_HANDLE' }, 'testAppSecret'); ++ } catch (error) { ++ thrown = error; ++ } ++ ++ expect(thrown).toBeInstanceOf(FilestackError); ++ expect(thrown.message).toBe('Invalid security params'); ++ ++ expectValidationDetailsToMention(thrown.details, ['expiry', 'number']); ++ }); ++ ++ test('getSecurity rejects policy keys outside the declared allow-list', () => { ++ ++ ++ ++ ++ let thrown; ++ ++ try { ++ getSecurity({ expiry: 1, unexpected: 'nope' }, 'testAppSecret'); ++ } catch (error) { ++ thrown = error; ++ } ++ ++ expect(thrown).toBeInstanceOf(FilestackError); ++ expect(thrown.message).toBe('Invalid security params'); ++ ++ expectValidationDetailsToMention(thrown.details, ['unexpected']); ++ }); ++ ++ test('validateWebhookSignature returns true for the matching signature fixture', () => { ++ ++ ++ ++ ++ const actual = validateWebhookSignature('abc123', '{"event":"test"}', { ++ timestamp: '42', ++ signature: 'e9e2082b689b165cfcde5e0f3e3b146afece84e0c4d5e8b466d9b598e6a146d3', ++ }); ++ ++ expect(actual).toBe(true); ++ }); ++ ++ test('validateWebhookSignature returns false for a different signature fixture', () => { ++ ++ ++ ++ ++ const actual = validateWebhookSignature('abc123', '{"event":"test"}', { ++ timestamp: '42', ++ signature: '0000000000000000000000000000000000000000000000000000000000000000', ++ }); ++ ++ expect(actual).toBe(false); ++ }); ++ ++ test('security helpers are referentially transparent for repeated equal inputs', () => { ++ const policyOptions = { expiry: 253381964415 }; ++ const webhookPayload = { ++ timestamp: '42', ++ signature: 'e9e2082b689b165cfcde5e0f3e3b146afece84e0c4d5e8b466d9b598e6a146d3', ++ }; ++ ++ expect(getSecurity(policyOptions, 'abc123')).toEqual(getSecurity(policyOptions, 'abc123')); ++ expect(validateWebhookSignature('abc123', '{"event":"test"}', webhookPayload)).toBe( ++ validateWebhookSignature('abc123', '{"event":"test"}', webhookPayload), ++ ); ++ }); ++ ++ test('security helpers do not mutate caller-provided policy or webhook payload objects', () => { ++ const policyOptions = { ++ expiry: 1700000000, ++ call: ['pick', 'store', 'read'], ++ handle: 'A_HANDLE_123', ++ url: 'https://cdn.example.test/input.png', ++ maxSize: 1048576, ++ minSize: 12, ++ path: '/uploads/2026/', ++ container: 'media-bucket', ++ }; ++ const webhookPayload = { ++ timestamp: '42', ++ signature: 'e9e2082b689b165cfcde5e0f3e3b146afece84e0c4d5e8b466d9b598e6a146d3', ++ }; ++ const policyBefore = JSON.parse(JSON.stringify(policyOptions)); ++ const webhookBefore = JSON.parse(JSON.stringify(webhookPayload)); ++ ++ getSecurity(policyOptions, 'complexSecret!'); ++ validateWebhookSignature('abc123', '{"event":"test"}', webhookPayload); ++ ++ expect(policyOptions).toEqual(policyBefore); ++ expect(webhookPayload).toEqual(webhookBefore); ++ }); ++ ++ test('security helpers return the same literals in a fresh Node process', () => { ++ const inProcess = { ++ security: getSecurity({ expiry: 1523595600, handle: 'TEST_HANDLE' }, 'testAppSecret'), ++ webhook: validateWebhookSignature('abc123', '{"event":"test"}', { ++ timestamp: '42', ++ signature: 'e9e2082b689b165cfcde5e0f3e3b146afece84e0c4d5e8b466d9b598e6a146d3', ++ }), ++ }; ++ const script = ` ++ const { getSecurity, validateWebhookSignature } = require('/workspace/repo/build/main'); ++ const out = { ++ security: getSecurity({ expiry: 1523595600, handle: 'TEST_HANDLE' }, 'testAppSecret'), ++ webhook: validateWebhookSignature('abc123', '{"event":"test"}', { ++ timestamp: '42', ++ signature: 'e9e2082b689b165cfcde5e0f3e3b146afece84e0c4d5e8b466d9b598e6a146d3', ++ }), ++ }; ++ process.stdout.write(JSON.stringify(out)); ++ `; ++ ++ const freshProcess = JSON.parse(childProcess.execFileSync(process.execPath, ['-e', script], { encoding: 'utf8' })); ++ ++ expect(inProcess).toEqual({ ++ security: { ++ policy: 'eyJleHBpcnkiOjE1MjM1OTU2MDAsImhhbmRsZSI6IlRFU1RfSEFORExFIn0=', ++ signature: '4c4103f55de507b5d51f595163c3f8759d04b663d0f5bb172b74c689804f35c8', ++ }, ++ webhook: true, ++ }); ++ expect(freshProcess).toEqual({ ++ security: { ++ policy: 'eyJleHBpcnkiOjE1MjM1OTU2MDAsImhhbmRsZSI6IlRFU1RfSEFORExFIn0=', ++ signature: '4c4103f55de507b5d51f595163c3f8759d04b663d0f5bb172b74c689804f35c8', ++ }, ++ webhook: true, ++ }); ++ }); ++ ++ test('security helpers do not write cwd files or open network connections', () => { ++ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'filestack-security-')); ++ const originalCwd = process.cwd(); ++ const before = fs.readdirSync(tmpDir).sort(); ++ const unexpectedNetwork = () => { ++ throw new Error('unexpected network access'); ++ }; ++ const spies = [ ++ jest.spyOn(http, 'request').mockImplementation(unexpectedNetwork), ++ jest.spyOn(http, 'get').mockImplementation(unexpectedNetwork), ++ jest.spyOn(https, 'request').mockImplementation(unexpectedNetwork), ++ jest.spyOn(https, 'get').mockImplementation(unexpectedNetwork), ++ jest.spyOn(net, 'connect').mockImplementation(unexpectedNetwork), ++ jest.spyOn(tls, 'connect').mockImplementation(unexpectedNetwork), ++ ]; ++ ++ try { ++ process.chdir(tmpDir); ++ ++ expect(getSecurity({ expiry: 253381964415 }, 'abc123')).toEqual({ ++ policy: 'eyJleHBpcnkiOjI1MzM4MTk2NDQxNX0=', ++ signature: '73f7e2f282432af9853e66237e78a6bbe3131091c0c8163c87a88a8e562818cd', ++ }); ++ expect( ++ validateWebhookSignature('abc123', '{"event":"test"}', { ++ timestamp: '42', ++ signature: 'e9e2082b689b165cfcde5e0f3e3b146afece84e0c4d5e8b466d9b598e6a146d3', ++ }), ++ ).toBe(true); ++ expect(fs.readdirSync(tmpDir).sort()).toEqual(before); ++ } finally { ++ process.chdir(originalCwd); ++ spies.forEach((spy) => spy.mockRestore()); ++ fs.rmSync(tmpDir, { recursive: true, force: true }); ++ } ++ }); ++}); +diff --git a/usercase-test-coderl/security_types.test.ts b/usercase-test-coderl/security_types.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/security_types.test.ts +@@ -0,0 +1,47 @@ ++import { ++ getSecurity, ++ validateWebhookSignature, ++ SecurityOptions, ++ WebhookValidatePayload, ++} from '../src'; ++ ++const policyWithEveryAllowedKey: SecurityOptions = { ++ expiry: 1700000000, ++ call: ['pick', 'store', 'read'], ++ handle: 'A_HANDLE_123', ++ url: 'https://cdn.example.test/input.png', ++ maxSize: 1048576, ++ minSize: 12, ++ path: '/uploads/2026/', ++ container: 'media-bucket', ++}; ++const webhookPayload: WebhookValidatePayload = { ++ timestamp: '42', ++ signature: 'e9e2082b689b165cfcde5e0f3e3b146afece84e0c4d5e8b466d9b598e6a146d3', ++}; ++ ++getSecurity(policyWithEveryAllowedKey, 'complexSecret!'); ++validateWebhookSignature('abc123', '{"event":"test"}', webhookPayload); ++ ++ ++// @ts-expect-error expiry is required. ++const missingExpiry: SecurityOptions = { handle: 'TEST_HANDLE' }; ++void missingExpiry; ++ ++ ++// @ts-expect-error expiry must be a number. ++getSecurity({ expiry: 'test', handle: 'TEST_HANDLE' }, 'testAppSecret'); ++ ++ ++// @ts-expect-error extra policy keys are not part of SecurityOptions. ++const extraPolicyKey: SecurityOptions = { expiry: 1, unexpected: 'nope' }; ++void extraPolicyKey; ++ ++ ++// @ts-expect-error timestamp is required. ++const missingTimestamp: WebhookValidatePayload = { signature: 'abc' }; ++void missingTimestamp; ++ ++ ++// @ts-expect-error signature must be a string. ++validateWebhookSignature('abc123', '{"event":"test"}', { timestamp: '42', signature: 123 }); +diff --git a/usercase-test-coderl/tsconfig.security-types.json b/usercase-test-coderl/tsconfig.security-types.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/tsconfig.security-types.json +@@ -0,0 +1,14 @@ ++{ ++ "extends": "../tsconfig.json", ++ "compilerOptions": { ++ "noEmit": true, ++ "rootDir": "..", ++ "noUnusedLocals": false, ++ "noUnusedParameters": false, ++ "pretty": false ++ }, ++ "include": [ ++ "security_types.test.ts", ++ "../src/**/*.ts" ++ ] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,58 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export npm_config_audit=false ++export npm_config_fund=false ++export npm_config_offline=true ++export npm_config_update_notifier=false ++ ++if [ ! -x node_modules/.bin/gulp ] || [ ! -x node_modules/.bin/tsc ] || [ ! -x node_modules/.bin/jest ]; then ++ echo "Required local node_modules binaries are missing; refusing to install dependencies in offline test command." >&2 ++ exit 1 ++fi ++ ++./node_modules/.bin/gulp typescript:main ++ ++./node_modules/.bin/tsc -p /workspace/repo/usercase-test-coderl/tsconfig.security-types.json ++ ++./node_modules/.bin/jest --runInBand --config '{ ++ "testEnvironment": "node", ++ "testMatch": ["**/usercase-test-coderl/security_node.test.js"], ++ "collectCoverage": false, ++ "transform": { ++ "^.+\\.js$": ["babel-jest", { "presets": [["@babel/preset-env", { "targets": { "node": "current" } }]] }] ++ }, ++ "transformIgnorePatterns": [ ++ "node_modules/(?!(file-type|strtok3|token-types|uint8array-extras|@tokenizer/inflate|@borewit/text-codec)/)" ++ ] ++}' ++ ++./node_modules/.bin/jest --runInBand --config '{ ++ "testEnvironment": "jsdom", ++ "testMatch": ["**/usercase-test-coderl/security_browser.test.js"], ++ "collectCoverage": false, ++ "setupFilesAfterEnv": ["/build/main/jest_browser_setup.js"], ++ "setupFiles": ["jest-localstorage-mock"], ++ "moduleFileExtensions": ["js"], ++ "moduleNameMapper": { ++ "(.*)\\.node": "$1.browser" ++ }, ++ "transform": { ++ "^.+\\.js$": ["babel-jest", { "presets": [["@babel/preset-env", { "targets": { "node": "current" } }]] }] ++ }, ++ "transformIgnorePatterns": [ ++ "node_modules/(?!(file-type|strtok3|token-types|uint8array-extras|@tokenizer/inflate|@borewit/text-codec)/)" ++ ] ++}' diff --git a/tasks/format-code-task-000949/tests/test.sh b/tasks/format-code-task-000949/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ce4dc14c49788f7242dee361c2cb9883bd7fda7a --- /dev/null +++ b/tasks/format-code-task-000949/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/security_browser.test.js +usercase-test-coderl/security_node.test.js +usercase-test-coderl/security_types.test.ts +usercase-test-coderl/tsconfig.security-types.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000949/tests/test_command.sh b/tasks/format-code-task-000949/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000949/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000979/environment/Dockerfile b/tasks/format-code-task-000979/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7135015fa68dd3f9568a6cc68d55c8d6d6a9bc40 --- /dev/null +++ b/tasks/format-code-task-000979/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5ab8cb139eb3b5594cca678f48fafed4aa1a3040eb584353eccfe90022e104cf diff --git a/tasks/format-code-task-000979/environment/setup/files/blocklist b/tasks/format-code-task-000979/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000979/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000979/environment/setup/setup.sh b/tasks/format-code-task-000979/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000979/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000979/tests/test.patch b/tasks/format-code-task-000979/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..40482ec03c25285b4c4b91445df883bf03166bde --- /dev/null +++ b/tasks/format-code-task-000979/tests/test.patch @@ -0,0 +1,179 @@ +diff --git a/pkg/protocol/trailer_contract_test.go b/pkg/protocol/trailer_contract_test.go +new file mode 100644 +index 0000000..7be3511 +--- /dev/null ++++ b/pkg/protocol/trailer_contract_test.go +@@ -0,0 +1,163 @@ ++package protocol_test ++ ++import ( ++ "strings" ++ "testing" ++ ++ "github.com/cloudwego/hertz/pkg/common/test/mock" ++ "github.com/cloudwego/hertz/pkg/protocol" ++ "github.com/cloudwego/hertz/pkg/protocol/http1/ext" ++) ++ ++func trailerNames(t *testing.T, tr *protocol.Trailer) []string { ++ t.Helper() ++ var names []string ++ tr.VisitAll(func(k, _ []byte) { names = append(names, string(k)) }) ++ return names ++} ++ ++func TestTrailerDeclarationNormalizesAndIgnoresEmptySegments(t *testing.T) { ++ var tr protocol.Trailer ++ if err := tr.SetTrailers([]byte(" \tfoo\t, Bar ,\tbaz \t")); err != nil { ++ t.Fatalf("SetTrailers returned unexpected error: %v", err) ++ } ++ if got := strings.Join(trailerNames(t, &tr), ","); got != "Foo,Bar,Baz" { ++ t.Fatalf("unexpected declared trailer names %q", got) ++ } ++ if got := string(tr.GetBytes()); got != "Foo, Bar, Baz" { ++ t.Fatalf("unexpected Trailer header value %q", got) ++ } ++} ++ ++func TestTrailerDeclarationInvalidUpdateIsAtomic(t *testing.T) { ++ for _, declaration := range []string{"Foo, Bad Key, Bar", "Foo, Content-Type, Bar"} { ++ var tr protocol.Trailer ++ if err := tr.Set("Existing", "old"); err != nil { ++ t.Fatal(err) ++ } ++ if err := tr.SetTrailers([]byte(declaration)); err == nil { ++ t.Fatalf("expected invalid declaration %q to return an error", declaration) ++ } ++ if got := string(tr.Peek("Existing")); got != "old" { ++ t.Fatalf("existing trailer was lost after rejected update: %q", got) ++ } ++ if tr.Peek("Foo") != nil || tr.Peek("Bar") != nil { ++ t.Fatal("partially accepted declarations remain after rejected update") ++ } ++ } ++} ++ ++func TestTrailerDeclarationEmptyInputDoesNotPanic(t *testing.T) { ++ var tr protocol.Trailer ++ if err := tr.Set("Existing", "old"); err != nil { ++ t.Fatal(err) ++ } ++ panicked := false ++ func() { ++ defer func() { ++ if recover() != nil { ++ panicked = true ++ } ++ }() ++ if err := tr.SetTrailers([]byte(" ,\t , ")); err != nil { ++ t.Fatalf("empty declaration returned unexpected error: %v", err) ++ } ++ }() ++ if panicked { ++ t.Fatal("SetTrailers panicked on empty list elements") ++ } ++ if got := string(tr.Peek("Existing")); got != "old" { ++ t.Fatalf("empty declaration changed prior trailer state: %q", got) ++ } ++} ++ ++func TestTrailerRejectsInvalidFieldNames(t *testing.T) { ++ for _, key := range []string{"Bad Key", "Bad\tKey", "Bad\r\nX"} { ++ var tr protocol.Trailer ++ if err := tr.Set(key, "value"); err == nil { ++ t.Errorf("Set accepted invalid trailer field name %q", key) ++ } ++ if err := tr.Add(key, "value"); err == nil { ++ t.Errorf("Add accepted invalid trailer field name %q", key) ++ } ++ if !tr.Empty() { ++ t.Errorf("invalid trailer field name %q mutated trailer state", key) ++ } ++ } ++ for _, key := range []string{"Content-Type", "Transfer-Encoding", "Host"} { ++ var tr protocol.Trailer ++ if err := tr.Set(key, "value"); err == nil { ++ t.Errorf("Set accepted forbidden trailer field %q", key) ++ } ++ if err := tr.Add(key, "value"); err == nil { ++ t.Errorf("Add accepted forbidden trailer field %q", key) ++ } ++ if !tr.Empty() { ++ t.Errorf("forbidden trailer field %q mutated trailer state", key) ++ } ++ } ++} ++ ++func TestChunkedTrailersUpdateOnlyDeclaredNames(t *testing.T) { ++ var tr protocol.Trailer ++ if err := tr.SetTrailers([]byte("Foo, Bar")); err != nil { ++ t.Fatal(err) ++ } ++ rd := mock.NewZeroCopyReader("0\r\nFoo: one\r\nBar: two\r\nBaz: ignored\r\n\r\n") ++ if err := ext.ReadTrailer(&tr, rd); err != nil { ++ t.Fatalf("ReadTrailer returned unexpected error: %v", err) ++ } ++ if got := string(tr.Peek("Foo")); got != "one" { ++ t.Fatalf("unexpected Foo trailer value %q", got) ++ } ++ if got := string(tr.Peek("Bar")); got != "two" { ++ t.Fatalf("unexpected Bar trailer value %q", got) ++ } ++ if tr.Peek("Baz") != nil { ++ t.Fatal("undeclared Baz trailer was accepted") ++ } ++} ++ ++func TestChunkedMalformedTrailerReturnsErrorAndClearsState(t *testing.T) { ++ var tr protocol.Trailer ++ if err := tr.SetTrailers([]byte("Foo")); err != nil { ++ t.Fatal(err) ++ } ++ rd := mock.NewZeroCopyReader("0\r\nFoo: one\r\nBad Key: value\r\n\r\n") ++ if err := ext.ReadTrailer(&tr, rd); err == nil { ++ t.Fatal("expected malformed trailer field to return an error") ++ } ++ if !tr.Empty() { ++ t.Fatal("trailer declarations were retained after malformed wire data") ++ } ++} ++ ++func TestChunkedForbiddenTrailerReturnsErrorAndClearsState(t *testing.T) { ++ var tr protocol.Trailer ++ if err := tr.SetTrailers([]byte("Foo")); err != nil { ++ t.Fatal(err) ++ } ++ rd := mock.NewZeroCopyReader("0\r\nFoo: one\r\nContent-Type: text/plain\r\n\r\n") ++ if err := ext.ReadTrailer(&tr, rd); err == nil { ++ t.Fatal("expected forbidden trailer field to return an error") ++ } ++ if !tr.Empty() { ++ t.Fatal("trailer state was retained after forbidden wire data") ++ } ++} ++ ++func TestTrailerCopyPreservesDeclarationState(t *testing.T) { ++ var src, dst protocol.Trailer ++ src.DisableNormalizing() ++ if err := src.SetTrailers([]byte("x-custom")); err != nil { ++ t.Fatal(err) ++ } ++ src.UpdateArgBytes([]byte("x-custom"), []byte("value")) ++ src.CopyTo(&dst) ++ if !dst.IsDisableNormalizing() { ++ t.Fatal("copy lost DisableNormalizing state") ++ } ++ if got := string(dst.Peek("x-custom")); got != "value" { ++ t.Fatalf("copy lost trailer value: %q", got) ++ } ++} + +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++go test ./pkg/protocol ./pkg/protocol/http1/ext diff --git a/tasks/format-code-task-000979/tests/test.sh b/tasks/format-code-task-000979/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7e822afee13d733a264d90fd752a03babc0d7d75 --- /dev/null +++ b/tasks/format-code-task-000979/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/protocol/trailer_contract_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000979/tests/test_command.sh b/tasks/format-code-task-000979/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000979/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000982/environment/Dockerfile b/tasks/format-code-task-000982/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7262c895ab43c91e705dc71a370ae71079109b83 --- /dev/null +++ b/tasks/format-code-task-000982/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f3612b1ccff51525615d1ee1c1a67e5aa651cc81a4cf020da0d3c5d21b596f19 diff --git a/tasks/format-code-task-000982/environment/setup/files/blocklist b/tasks/format-code-task-000982/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000982/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000982/environment/setup/setup.sh b/tasks/format-code-task-000982/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000982/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000982/tests/test.patch b/tasks/format-code-task-000982/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..98d798e15ab5277b7128ad618957cf3f6bad0268 --- /dev/null +++ b/tasks/format-code-task-000982/tests/test.patch @@ -0,0 +1,441 @@ +diff --git a/codespec_transport_machine_contract_test.go b/codespec_transport_machine_contract_test.go +new file mode 100644 +index 0000000..56fb486 +--- /dev/null ++++ b/codespec_transport_machine_contract_test.go +@@ -0,0 +1,426 @@ ++package syslog_test ++ ++import ( ++ "os" ++ "os/exec" ++ "path/filepath" ++ "strings" ++ "testing" ++ ++ syslog "github.com/influxdata/go-syslog/v2" ++ "github.com/influxdata/go-syslog/v2/nontransparent" ++ "github.com/influxdata/go-syslog/v2/rfc5424" ++) ++ ++func TestCodespecTransportMachineContract(t *testing.T) { ++ doc := exec.Command("go", "doc", ".", "WithMachine") ++ doc.Env = append(os.Environ(), "GOTOOLCHAIN=local") ++ if output, err := doc.CombinedOutput(); err != nil { ++ t.Fatalf("public syslog.WithMachine option is missing: %v\n%s", err, output) ++ } ++ ++ var baseline []syslog.Result ++ parser := nontransparent.NewParser(syslog.WithListener(func(result *syslog.Result) { ++ baseline = append(baseline, *result) ++ })) ++ parser.Parse(strings.NewReader("<1>1 - - - - - - body \n")) ++ if len(baseline) != 1 || baseline[0].Error != nil { ++ t.Fatalf("embedded '<' split an LF-delimited frame: results = %#v", baseline) ++ } ++ message, ok := baseline[0].Message.(*rfc5424.SyslogMessage) ++ if !ok || message.Message == nil || *message.Message != "body " { ++ t.Fatalf("embedded '<' was not preserved in the RFC5424 payload: message = %#v", baseline[0].Message) ++ } ++ ++ var reused []syslog.Result ++ reusable := nontransparent.NewParser(syslog.WithListener(func(result *syslog.Result) { ++ reused = append(reused, *result) ++ })) ++ reusable.Parse(strings.NewReader("<1>1 - - - - - - first")) ++ reusable.Parse(strings.NewReader("<2>1 - - - - - - second\n")) ++ if len(reused) != 2 || reused[1].Error != nil { ++ t.Fatalf("reusing a non-transparent parser replayed prior state: results = %#v", reused) ++ } ++ second, ok := reused[1].Message.(*rfc5424.SyslogMessage) ++ if !ok || second.Message == nil || *second.Message != "second" { ++ t.Fatalf("reused parser did not decode only the fresh stream: message = %#v", reused[1].Message) ++ } ++ ++ repo, err := os.Getwd() ++ if err != nil { ++ t.Fatal(err) ++ } ++ dir, err := os.MkdirTemp(repo, "codespec_transport_contract_") ++ if err != nil { ++ t.Fatal(err) ++ } ++ defer os.RemoveAll(dir) ++ ++ source := `package contract ++ ++import ( ++ "errors" ++ "fmt" ++ "io" ++ "strings" ++ "testing" ++ "time" ++ ++ syslog "github.com/influxdata/go-syslog/v2" ++ "github.com/influxdata/go-syslog/v2/nontransparent" ++ "github.com/influxdata/go-syslog/v2/octetcounting" ++ "github.com/influxdata/go-syslog/v2/rfc3164" ++ "github.com/influxdata/go-syslog/v2/rfc5424" ++) ++ ++var errRejectedPayload = errors.New("contract decoder rejected payload") ++ ++type recordingMachine struct { ++ inputs []string ++ failOn string ++ bestEffort bool ++} ++ ++func (m *recordingMachine) Parse(input []byte) (syslog.Message, error) { ++ value := string(append([]byte(nil), input...)) ++ m.inputs = append(m.inputs, value) ++ message := decodedMessage(value) ++ if value == m.failOn { ++ return message, errRejectedPayload ++ } ++ return message, nil ++} ++ ++func (m *recordingMachine) WithBestEffort() { ++ m.bestEffort = true ++} ++ ++func (m *recordingMachine) HasBestEffort() bool { ++ return m.bestEffort ++} ++ ++func decodedMessage(value string) *rfc3164.SyslogMessage { ++ message := &rfc3164.SyslogMessage{} ++ message.ComputeFromPriority(13) ++ message.Message = &value ++ return message ++} ++ ++type legacyParser struct { ++ bestEffort bool ++ listener syslog.ParserListener ++} ++ ++func (p *legacyParser) Parse(_ io.Reader) {} ++ ++func (p *legacyParser) WithListener(listener syslog.ParserListener) { ++ p.listener = listener ++} ++ ++func (p *legacyParser) WithBestEffort() { ++ p.bestEffort = true ++} ++ ++func (p *legacyParser) HasBestEffort() bool { ++ return p.bestEffort ++} ++ ++func framed(payload string) string { ++ return fmt.Sprintf("%d %s", len([]byte(payload)), payload) ++} ++ ++func listenerFor(results *[]syslog.Result) syslog.ParserListener { ++ return func(result *syslog.Result) { ++ *results = append(*results, *result) ++ } ++} ++ ++func requireInputs(t *testing.T, got, want []string) { ++ t.Helper() ++ if fmt.Sprint(got) != fmt.Sprint(want) { ++ t.Fatalf("machine inputs = %#v, want %#v", got, want) ++ } ++} ++ ++func requireDecoded(t *testing.T, result syslog.Result, want string) { ++ t.Helper() ++ message, ok := result.Message.(*rfc3164.SyslogMessage) ++ if !ok { ++ t.Fatalf("message type = %T, want *rfc3164.SyslogMessage", result.Message) ++ } ++ if message.Message == nil || *message.Message != want { ++ t.Fatalf("decoded message = %#v, want %q", message.Message, want) ++ } ++} ++ ++func TestParserInterfaceCompatibilityAndUnsupportedParser(t *testing.T) { ++ var parser syslog.Parser = &legacyParser{} ++ machine := &recordingMachine{} ++ got := syslog.WithMachine(machine)(parser) ++ if got != parser { ++ t.Fatalf("option replaced unsupported parser: got %T", got) ++ } ++ if parser.HasBestEffort() { ++ t.Fatal("WithMachine changed unsupported parser state") ++ } ++} ++ ++func TestOctetCountingUsesConfiguredRFC3164Machine(t *testing.T) { ++ payloads := []string{ ++ "<13>Dec 2 16:31:03 host app: first", ++ "<14>Dec 3 17:32:04 host app: cafe", ++ } ++ for _, options := range []struct { ++ name string ++ build func(syslog.Machine, syslog.ParserListener) syslog.Parser ++ }{ ++ { ++ name: "machine-before-listener", ++ build: func(machine syslog.Machine, listener syslog.ParserListener) syslog.Parser { ++ return octetcounting.NewParser(syslog.WithMachine(machine), syslog.WithListener(listener)) ++ }, ++ }, ++ { ++ name: "machine-after-best-effort", ++ build: func(machine syslog.Machine, listener syslog.ParserListener) syslog.Parser { ++ return octetcounting.NewParser(syslog.WithListener(listener), syslog.WithBestEffort(), syslog.WithMachine(machine)) ++ }, ++ }, ++ } { ++ t.Run(options.name, func(t *testing.T) { ++ var results []syslog.Result ++ machine := rfc3164.NewParser(rfc3164.WithYear(rfc3164.Year{YYYY: 1987})) ++ parser := options.build(machine, listenerFor(&results)) ++ parser.Parse(strings.NewReader(framed(payloads[0]) + framed(payloads[1]))) ++ if len(results) != 2 { ++ t.Fatalf("result count = %d, want 2: %#v", len(results), results) ++ } ++ for i, result := range results { ++ if result.Error != nil { ++ t.Fatalf("result %d error = %v", i, result.Error) ++ } ++ message, ok := result.Message.(*rfc3164.SyslogMessage) ++ if !ok { ++ t.Fatalf("result %d type = %T, want *rfc3164.SyslogMessage", i, result.Message) ++ } ++ if message.Timestamp == nil || message.Timestamp.Year() != 1987 { ++ t.Fatalf("result %d timestamp = %v, want year 1987", i, message.Timestamp) ++ } ++ } ++ }) ++ } ++} ++ ++func TestOctetCountingPassesExactByteCountedPayloads(t *testing.T) { ++ payloads := []string{"<13>legacy cafe", "<14>unicode: κόσμε"} ++ machine := &recordingMachine{} ++ var results []syslog.Result ++ parser := octetcounting.NewParser( ++ syslog.WithMachine(machine), ++ syslog.WithListener(listenerFor(&results)), ++ ) ++ parser.Parse(strings.NewReader(framed(payloads[0]) + framed(payloads[1]))) ++ requireInputs(t, machine.inputs, payloads) ++ if len(results) != len(payloads) { ++ t.Fatalf("result count = %d, want %d", len(results), len(payloads)) ++ } ++ for i := range payloads { ++ requireDecoded(t, results[i], payloads[i]) ++ } ++} ++ ++func TestNonTransparentUsesOnlyConfiguredTrailerAsBoundary(t *testing.T) { ++ t.Run("LF with embedded less-than", func(t *testing.T) { ++ payloads := []string{"<13>body contains ", "<14>second"} ++ machine := &recordingMachine{} ++ var results []syslog.Result ++ parser := nontransparent.NewParser( ++ syslog.WithListener(listenerFor(&results)), ++ syslog.WithMachine(machine), ++ ) ++ parser.Parse(strings.NewReader(strings.Join(payloads, "\n") + "\n")) ++ requireInputs(t, machine.inputs, payloads) ++ if len(results) != 2 { ++ t.Fatalf("result count = %d, want 2", len(results)) ++ } ++ }) ++ ++ t.Run("NUL preserves line feed", func(t *testing.T) { ++ payloads := []string{"<15>line one\nline two", "<16>last"} ++ machine := &recordingMachine{} ++ var results []syslog.Result ++ parser := nontransparent.NewParser( ++ nontransparent.WithTrailer(nontransparent.NUL), ++ syslog.WithMachine(machine), ++ syslog.WithListener(listenerFor(&results)), ++ ) ++ parser.Parse(strings.NewReader(strings.Join(payloads, "\x00") + "\x00")) ++ requireInputs(t, machine.inputs, payloads) ++ if len(results) != 2 { ++ t.Fatalf("result count = %d, want 2", len(results)) ++ } ++ }) ++} ++ ++func TestConfiguredMachineErrorSemantics(t *testing.T) { ++ payloads := []string{"<13>ok", "<14>bad", "<15>after"} ++ stream := framed(payloads[0]) + framed(payloads[1]) + framed(payloads[2]) ++ ++ t.Run("octet-counting strict stops and omits partial", func(t *testing.T) { ++ machine := &recordingMachine{failOn: payloads[1]} ++ var results []syslog.Result ++ parser := octetcounting.NewParser( ++ syslog.WithMachine(machine), ++ syslog.WithListener(listenerFor(&results)), ++ ) ++ parser.Parse(strings.NewReader(stream)) ++ requireInputs(t, machine.inputs, payloads[:2]) ++ if len(results) != 2 || !errors.Is(results[1].Error, errRejectedPayload) { ++ t.Fatalf("strict results = %#v, want success then decoder error", results) ++ } ++ if results[1].Message != nil { ++ t.Fatalf("strict error exposed partial message %T", results[1].Message) ++ } ++ }) ++ ++ t.Run("octet-counting best effort keeps partial and continues", func(t *testing.T) { ++ machine := &recordingMachine{failOn: payloads[1]} ++ var results []syslog.Result ++ parser := octetcounting.NewParser( ++ syslog.WithMachine(machine), ++ syslog.WithBestEffort(), ++ syslog.WithListener(listenerFor(&results)), ++ ) ++ if machine.HasBestEffort() { ++ t.Fatal("framing option mutated caller-supplied machine") ++ } ++ parser.Parse(strings.NewReader(stream)) ++ requireInputs(t, machine.inputs, payloads) ++ if len(results) != 3 || !errors.Is(results[1].Error, errRejectedPayload) { ++ t.Fatalf("best-effort results = %#v, want three results with middle decoder error", results) ++ } ++ requireDecoded(t, results[1], payloads[1]) ++ }) ++ ++ for _, bestEffort := range []bool{false, true} { ++ name := "strict" ++ if bestEffort { ++ name = "best-effort" ++ } ++ t.Run("non-transparent "+name+" forwards pair and continues", func(t *testing.T) { ++ machine := &recordingMachine{failOn: payloads[1]} ++ var results []syslog.Result ++ options := []syslog.ParserOption{ ++ syslog.WithListener(listenerFor(&results)), ++ syslog.WithMachine(machine), ++ } ++ if bestEffort { ++ options = append(options, syslog.WithBestEffort()) ++ } ++ parser := nontransparent.NewParser(options...) ++ if machine.HasBestEffort() { ++ t.Fatal("framing option mutated caller-supplied machine") ++ } ++ parser.Parse(strings.NewReader(strings.Join(payloads, "\n") + "\n")) ++ requireInputs(t, machine.inputs, payloads) ++ if len(results) != 3 || !errors.Is(results[1].Error, errRejectedPayload) { ++ t.Fatalf("non-transparent results = %#v, want three forwarded results", results) ++ } ++ requireDecoded(t, results[1], payloads[1]) ++ }) ++ } ++} ++ ++func TestNilMachineKeepsRFC5424Default(t *testing.T) { ++ for _, tc := range []struct { ++ name string ++ parse func(syslog.Parser) ++ new func(syslog.ParserListener) syslog.Parser ++ }{ ++ { ++ name: "octet-counting", ++ parse: func(parser syslog.Parser) { parser.Parse(strings.NewReader(framed("<1>1 - - - - - -"))) }, ++ new: func(listener syslog.ParserListener) syslog.Parser { ++ return octetcounting.NewParser(syslog.WithMachine(nil), syslog.WithListener(listener)) ++ }, ++ }, ++ { ++ name: "non-transparent", ++ parse: func(parser syslog.Parser) { parser.Parse(strings.NewReader("<1>1 - - - - - -\n")) }, ++ new: func(listener syslog.ParserListener) syslog.Parser { ++ return nontransparent.NewParser(syslog.WithListener(listener), syslog.WithMachine(nil)) ++ }, ++ }, ++ } { ++ t.Run(tc.name, func(t *testing.T) { ++ var results []syslog.Result ++ parser := tc.new(listenerFor(&results)) ++ tc.parse(parser) ++ if len(results) != 1 || results[0].Error != nil { ++ t.Fatalf("default results = %#v, want one success", results) ++ } ++ if _, ok := results[0].Message.(*rfc5424.SyslogMessage); !ok { ++ t.Fatalf("default message type = %T, want *rfc5424.SyslogMessage", results[0].Message) ++ } ++ }) ++ } ++} ++ ++func TestConfiguredParsersAreReusableWithoutReplay(t *testing.T) { ++ t.Run("octet-counting", func(t *testing.T) { ++ machine := &recordingMachine{} ++ var results []syslog.Result ++ parser := octetcounting.NewParser(syslog.WithMachine(machine), syslog.WithListener(listenerFor(&results))) ++ parser.Parse(strings.NewReader(framed("<13>first"))) ++ parser.Parse(strings.NewReader(framed("<14>second"))) ++ requireInputs(t, machine.inputs, []string{"<13>first", "<14>second"}) ++ if len(results) != 2 { ++ t.Fatalf("result count after reuse = %d, want 2", len(results)) ++ } ++ }) ++ ++ t.Run("non-transparent after unterminated input", func(t *testing.T) { ++ machine := &recordingMachine{} ++ var results []syslog.Result ++ parser := nontransparent.NewParser(syslog.WithMachine(machine), syslog.WithListener(listenerFor(&results))) ++ parser.Parse(strings.NewReader("<13>unfinished")) ++ parser.Parse(strings.NewReader("<14>fresh\n")) ++ requireInputs(t, machine.inputs, []string{"<13>unfinished", "<14>fresh"}) ++ if len(results) != 2 { ++ t.Fatalf("result count after reuse = %d, want 2: %#v", len(results), results) ++ } ++ if results[1].Error != nil { ++ t.Fatalf("fresh session inherited error: %v", results[1].Error) ++ } ++ requireDecoded(t, results[1], "<14>fresh") ++ }) ++} ++ ++func TestConfiguredMachineDoesNotChangeTimestampStrategy(t *testing.T) { ++ machine := rfc3164.NewParser(rfc3164.WithYear(rfc3164.Year{YYYY: 2001})) ++ var results []syslog.Result ++ parser := nontransparent.NewParser(syslog.WithMachine(machine), syslog.WithListener(listenerFor(&results))) ++ parser.Parse(strings.NewReader("<13>Dec 2 16:31:03 host app: message\n")) ++ if len(results) != 1 || results[0].Error != nil { ++ t.Fatalf("results = %#v, want one success", results) ++ } ++ message, ok := results[0].Message.(*rfc3164.SyslogMessage) ++ if !ok || message.Timestamp == nil || !message.Timestamp.Equal(time.Date(2001, 12, 2, 16, 31, 3, 0, time.UTC)) { ++ t.Fatalf("configured RFC3164 timestamp = %#v, want fixed 2001 UTC timestamp", message) ++ } ++} ++` ++ ++ testFile := filepath.Join(dir, "contract_test.go") ++ if err := os.WriteFile(testFile, []byte(source), 0600); err != nil { ++ t.Fatal(err) ++ } ++ ++ command := exec.Command("go", "test", "-vet=off", "./"+filepath.Base(dir)) ++ command.Dir = repo ++ command.Env = append(os.Environ(), "GOPROXY=off", "GOSUMDB=off", "GOTOOLCHAIN=local") ++ output, err := command.CombinedOutput() ++ if err != nil { ++ t.Fatalf("public transport-machine contract failed: %v\n%s", err, output) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++GOTOOLCHAIN=local GOPROXY=off GOSUMDB=off go test -vet=off . ./octetcounting ./nontransparent -run '^(TestCodespecTransportMachineContract|TestParse|TestParserBestEffortOption)$' -count=1 diff --git a/tasks/format-code-task-000982/tests/test.sh b/tasks/format-code-task-000982/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..14d6ba88c900342753f72d83659ceff928b41845 --- /dev/null +++ b/tasks/format-code-task-000982/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +codespec_transport_machine_contract_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000982/tests/test_command.sh b/tasks/format-code-task-000982/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000982/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001000/environment/Dockerfile b/tasks/format-code-task-001000/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f6de0dfebeaff45f2c30202d94535c97c170f1de --- /dev/null +++ b/tasks/format-code-task-001000/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8e851d78610b3e500e08c6e75670a96aca582078f7264174721766132ce6f322 diff --git a/tasks/format-code-task-001000/environment/setup/files/blocklist b/tasks/format-code-task-001000/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001000/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001000/environment/setup/setup.sh b/tasks/format-code-task-001000/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001000/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001000/tests/test.patch b/tasks/format-code-task-001000/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..31d1a4f0f9401deaaa7f57a3e485d37b2760739c --- /dev/null +++ b/tasks/format-code-task-001000/tests/test.patch @@ -0,0 +1,138 @@ +diff --git a/porch/repository/pkg/git/resource_update_contract_test.go b/porch/repository/pkg/git/resource_update_contract_test.go +new file mode 100644 +index 000000000..e752e2bbd +--- /dev/null ++++ b/porch/repository/pkg/git/resource_update_contract_test.go +@@ -0,0 +1,122 @@ ++package git ++ ++import ( ++ "context" ++ "path/filepath" ++ "testing" ++ ++ "github.com/GoogleContainerTools/kpt/porch/api/porch/v1alpha1" ++ configapi "github.com/GoogleContainerTools/kpt/porch/api/porchconfig/v1alpha1" ++ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ++) ++ ++func TestResourceUpdateReplacesSnapshotAndValidatesPaths(t *testing.T) { ++ ctx := context.Background() ++ root := t.TempDir() ++ _, address := ServeGitRepository(t, filepath.Join("testdata", "trivial-repository.tar"), root) ++ repo, err := OpenRepository(ctx, "contract", "default", &configapi.GitRepository{Repo: address}, filepath.Join(root, "cache"), GitRepositoryOptions{}) ++ if err != nil { ++ t.Fatalf("OpenRepository failed: %v", err) ++ } ++ ++ invalidCases := []struct { ++ name string ++ packageID string ++ resources map[string]string ++ }{ ++ {name: "parent traversal", packageID: "parent", resources: map[string]string{"../escape.yaml": "bad"}}, ++ {name: "absolute path", packageID: "absolute", resources: map[string]string{"/escape.yaml": "bad"}}, ++ {name: "parent segment", packageID: "parent-segment", resources: map[string]string{"nested/../escape.yaml": "bad"}}, ++ {name: "current segment", packageID: "current-segment", resources: map[string]string{"./escape.yaml": "bad"}}, ++ {name: "empty path", packageID: "empty", resources: map[string]string{"": "bad"}}, ++ {name: "file and child conflict", packageID: "conflict", resources: map[string]string{"a": "file", "a/b": "child"}}, ++ } ++ for _, tc := range invalidCases { ++ t.Run(tc.name, func(t *testing.T) { ++ packageName := "invalid-" + tc.packageID ++ draft, err := repo.CreatePackageRevision(ctx, &v1alpha1.PackageRevision{ ++ ObjectMeta: metav1.ObjectMeta{Name: "contract:" + packageName + ":v1", Namespace: "default"}, ++ Spec: v1alpha1.PackageRevisionSpec{PackageName: packageName, Revision: "v1", RepositoryName: "contract"}, ++ }) ++ if err != nil { ++ t.Fatalf("CreatePackageRevision failed: %v", err) ++ } ++ original := map[string]string{"Kptfile": "kind: Kptfile\n", "keep.txt": "keep"} ++ if err := draft.UpdateResources(ctx, &v1alpha1.PackageRevisionResources{Spec: v1alpha1.PackageRevisionResourcesSpec{Resources: original}}, &v1alpha1.Task{}); err != nil { ++ t.Fatalf("initial UpdateResources failed: %v", err) ++ } ++ created, err := draft.Close(ctx) ++ if err != nil { ++ t.Fatalf("initial Close failed: %v", err) ++ } ++ update, err := repo.UpdatePackage(ctx, created) ++ if err != nil { ++ t.Fatalf("UpdatePackage failed: %v", err) ++ } ++ err = update.UpdateResources(ctx, &v1alpha1.PackageRevisionResources{Spec: v1alpha1.PackageRevisionResourcesSpec{Resources: tc.resources}}, &v1alpha1.Task{}) ++ if err == nil { ++ t.Fatalf("UpdateResources accepted invalid resource paths: %#v", tc.resources) ++ } ++ unchanged, err := update.Close(ctx) ++ if err != nil { ++ t.Fatalf("Close after rejected update failed: %v", err) ++ } ++ resources, err := unchanged.GetResources(ctx) ++ if err != nil { ++ t.Fatalf("GetResources after rejected update failed: %v", err) ++ } ++ if len(resources.Spec.Resources) != len(original) { ++ t.Fatalf("rejected update changed resource count: got %#v, want %#v", resources.Spec.Resources, original) ++ } ++ for key, want := range original { ++ if got := resources.Spec.Resources[key]; got != want { ++ t.Errorf("rejected update changed %q: got %q, want %q", key, got, want) ++ } ++ } ++ }) ++ } ++ ++ draft, err := repo.CreatePackageRevision(ctx, &v1alpha1.PackageRevision{ ++ ObjectMeta: metav1.ObjectMeta{Name: "contract:replace:v1", Namespace: "default"}, ++ Spec: v1alpha1.PackageRevisionSpec{PackageName: "replace", Revision: "v1", RepositoryName: "contract"}, ++ }) ++ if err != nil { ++ t.Fatalf("CreatePackageRevision failed: %v", err) ++ } ++ initial := map[string]string{"Kptfile": "kind: Kptfile\n", "old.yaml": "old", "nested/keep.txt": "keep"} ++ if err := draft.UpdateResources(ctx, &v1alpha1.PackageRevisionResources{Spec: v1alpha1.PackageRevisionResourcesSpec{Resources: initial}}, &v1alpha1.Task{}); err != nil { ++ t.Fatalf("initial UpdateResources failed: %v", err) ++ } ++ revision, err := draft.Close(ctx) ++ if err != nil { ++ t.Fatalf("initial Close failed: %v", err) ++ } ++ ++ update, err := repo.UpdatePackage(ctx, revision) ++ if err != nil { ++ t.Fatalf("UpdatePackage failed: %v", err) ++ } ++ replacement := map[string]string{"Kptfile": "kind: Kptfile\n", "new.yaml": "new", "nested/keep.txt": "updated"} ++ if err := update.UpdateResources(ctx, &v1alpha1.PackageRevisionResources{Spec: v1alpha1.PackageRevisionResourcesSpec{Resources: replacement}}, &v1alpha1.Task{}); err != nil { ++ t.Fatalf("replacement UpdateResources failed: %v", err) ++ } ++ updated, err := update.Close(ctx) ++ if err != nil { ++ t.Fatalf("replacement Close failed: %v", err) ++ } ++ resources, err := updated.GetResources(ctx) ++ if err != nil { ++ t.Fatalf("GetResources failed: %v", err) ++ } ++ if got := resources.Spec.Resources; len(got) != len(replacement) { ++ t.Fatalf("resource snapshot retained omitted files: got %#v, want %#v", got, replacement) ++ } ++ for key, want := range replacement { ++ if got := resources.Spec.Resources[key]; got != want { ++ t.Errorf("resource %q: got %q, want %q", key, got, want) ++ } ++ } ++ if _, ok := resources.Spec.Resources["old.yaml"]; ok { ++ t.Errorf("omitted old.yaml was retained in replacement snapshot") ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++(cd porch && go test ./repository/pkg/git -run '^TestResourceUpdateReplacesSnapshotAndValidatesPaths$' -count=1) diff --git a/tasks/format-code-task-001000/tests/test.sh b/tasks/format-code-task-001000/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0bfd4a73edaba8b5121d8288a4857f868da03b2e --- /dev/null +++ b/tasks/format-code-task-001000/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +porch/repository/pkg/git/resource_update_contract_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001000/tests/test_command.sh b/tasks/format-code-task-001000/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001000/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001007/environment/Dockerfile b/tasks/format-code-task-001007/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..58d4b3d8fe0809b8879c67bb64cdb183edb26100 --- /dev/null +++ b/tasks/format-code-task-001007/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:30d513127ab0353d184404efea16717522515dffe8742240ddc65373a4120c85 diff --git a/tasks/format-code-task-001007/environment/setup/files/blocklist b/tasks/format-code-task-001007/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001007/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001007/environment/setup/setup.sh b/tasks/format-code-task-001007/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001007/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001007/tests/test.patch b/tasks/format-code-task-001007/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3d77ad06c56e952ef5e11e1d304a710eefd6cddf --- /dev/null +++ b/tasks/format-code-task-001007/tests/test.patch @@ -0,0 +1,188 @@ +diff --git a/test/builder/clause/with.codespec.test.js b/test/builder/clause/with.codespec.test.js +new file mode 100644 +index 0000000..85c182a +--- /dev/null ++++ b/test/builder/clause/with.codespec.test.js +@@ -0,0 +1,172 @@ ++const sqorn = require('../../../packages/sqorn-pg') ++ ++describe('common table expressions', () => { ++ const sq = sqorn() ++ ++ test('a builder-valued tagged-template CTE precedes a select', () => { ++ const active = sq.from`account`.where`status = ${'active'}`.return`id` ++ const query = sq.with`recent_account as (${active})`.from`recent_account`.return`id` ++ ++ expect(query.query).toEqual({ ++ text: ++ 'with recent_account as (select id from account where (status = $1)) select id from recent_account', ++ args: ['active'] ++ }) ++ }) ++ ++ test('direct CTE template values are parameterized', () => { ++ const query = sq.with`chosen(label) as (values (${"Ada"}))`.from`chosen` ++ ++ expect(query.query).toEqual({ ++ text: 'with chosen(label) as (values ($1)) select * from chosen', ++ args: ['Ada'] ++ }) ++ }) ++ ++ test('dollar-prefixed CTE template values stay raw', () => { ++ const query = sq.with`$${'chosen'} as (select 1)`.from`chosen` ++ ++ expect(query.query).toEqual({ ++ text: 'with chosen as (select 1) select * from chosen', ++ args: [] ++ }) ++ }) ++ ++ test('CTE parameters precede main-query parameters regardless of call order', () => { ++ const query = sq ++ .from`recent_account` ++ .where`id > ${40}` ++ .with`recent_account as (select id from account where status = ${'active'})` ++ ++ expect(query.query).toEqual({ ++ text: ++ 'with recent_account as (select id from account where status = $1) select * from recent_account where (id > $2)', ++ args: ['active', 40] ++ }) ++ }) ++ ++ test('multiple definitions retain call order under one WITH keyword', () => { ++ const query = sq ++ .with`first_value as (select ${1} as n)` ++ .with`second_value as (select ${2} as n)` ++ .from`first_value, second_value` ++ ++ expect(query.query).toEqual({ ++ text: ++ 'with first_value as (select $1 as n), second_value as (select $2 as n) select * from first_value, second_value', ++ args: [1, 2] ++ }) ++ }) ++ ++ test('recursive before WITH marks the clause exactly once', () => { ++ const body = sq.l`select ${1} as n union all select n + ${1} from nums where n < ${3}` ++ const query = sq.recursive.with`nums(n) as (${body})`.from`nums` ++ ++ expect(query.query).toEqual({ ++ text: ++ 'with recursive nums(n) as (select $1 as n union all select n + $2 from nums where n < $3) select * from nums', ++ args: [1, 1, 3] ++ }) ++ }) ++ ++ test('recursive after WITH produces the same clause placement', () => { ++ const query = sq.with`nums(n) as (select ${1})`.from`nums`.recursive ++ ++ expect(query.query).toEqual({ ++ text: 'with recursive nums(n) as (select $1) select * from nums', ++ args: [1] ++ }) ++ }) ++ ++ test('recursive without a CTE emits no stray SQL', () => { ++ expect(sq.recursive.from`book`.query).toEqual({ ++ text: 'select * from book', ++ args: [] ++ }) ++ }) ++ ++ test('adding a recursive CTE does not mutate its sibling builder', () => { ++ const base = sq.from`book` ++ const recursiveBranch = base.recursive.with`picked as (select ${7} as id)`.from`picked` ++ ++ expect(base.query).toEqual({ text: 'select * from book', args: [] }) ++ expect(recursiveBranch.query).toEqual({ ++ text: 'with recursive picked as (select $1 as id) select * from book, picked', ++ args: [7] ++ }) ++ }) ++ ++ test('nested CTE builders preserve nesting and global SQL-order parameters', () => { ++ const inner = sq.with`seed as (select ${10} as n)`.from`seed`.where`n < ${20}` ++ const query = sq ++ .from`outer_rows` ++ .where`n <> ${15}` ++ .with`outer_rows as (${inner})` ++ ++ expect(query.query).toEqual({ ++ text: ++ 'with outer_rows as (with seed as (select $1 as n) select * from seed where (n < $2)) select * from outer_rows where (n <> $3)', ++ args: [10, 20, 15] ++ }) ++ }) ++ ++ test('WITH composes through extend', () => { ++ const definition = sq.with`eligible as (select id from person where age >= ${18})` ++ const source = sq.from`eligible`.where`id < ${100}` ++ const query = sq.extend(definition, source).return`id` ++ ++ expect(query.query).toEqual({ ++ text: ++ 'with eligible as (select id from person where age >= $1) select id from eligible where (id < $2)', ++ args: [18, 100] ++ }) ++ }) ++ ++ test('extend leaves its source builders unchanged', () => { ++ const definition = sq.with`eligible as (select id from person where age >= ${18})` ++ const source = sq.from`eligible`.where`id < ${100}` ++ sq.extend(definition, source).return`id`.query ++ ++ expect(definition.query).toEqual({ ++ text: 'with eligible as (select id from person where age >= $1) select *', ++ args: [18] ++ }) ++ expect(source.query).toEqual({ ++ text: 'select * from eligible where (id < $1)', ++ args: [100] ++ }) ++ }) ++ ++ test('WITH is available to delete query builders', () => { ++ const doomed = sq.from`person`.where`disabled = ${true}`.return`id` ++ expect( ++ sq.with`doomed as (${doomed})`.delete.from`session`.where`person_id in (select id from doomed)`.return`id`.query ++ ).toEqual({ ++ text: ++ 'with doomed as (select id from person where (disabled = $1)) delete from session where (person_id in (select id from doomed)) returning id', ++ args: [true] ++ }) ++ }) ++ ++ test('WITH is available to insert query builders', () => { ++ const incoming = sq.l`select ${7} as id` ++ expect( ++ sq.with`incoming as (${incoming})`.from`archive`.insert({ id: 9, state: 'new' }).query ++ ).toEqual({ ++ text: ++ 'with incoming as (select $1 as id) insert into archive (id, state) values ($2, $3)', ++ args: [7, 9, 'new'] ++ }) ++ }) ++ ++ test('WITH is available to update query builders', () => { ++ const threshold = sq.l`select ${5} as n` ++ expect( ++ sq.with`threshold as (${threshold})`.from`job`.set`priority = priority + ${1}`.where`priority < (select n from threshold)`.query ++ ).toEqual({ ++ text: ++ 'with threshold as (select $1 as n) update job set priority = priority + $2 where (priority < (select n from threshold))', ++ args: [5, 1] ++ }) ++ }) ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++./node_modules/.bin/jest --runInBand test/builder/clause/with.codespec.test.js diff --git a/tasks/format-code-task-001007/tests/test.sh b/tasks/format-code-task-001007/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4130dfa308602178e369351c3f13c5f750d5a16 --- /dev/null +++ b/tasks/format-code-task-001007/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/builder/clause/with.codespec.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001007/tests/test_command.sh b/tasks/format-code-task-001007/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001007/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001009/environment/Dockerfile b/tasks/format-code-task-001009/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2057c4ce125a51e13fb7a83fe15ceebaf185b272 --- /dev/null +++ b/tasks/format-code-task-001009/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f5a79fe3381a8fc28157b10b0c25d427ae2010e0d27b6094d161b1d983c11cf9 diff --git a/tasks/format-code-task-001009/environment/setup/files/blocklist b/tasks/format-code-task-001009/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001009/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001009/environment/setup/setup.sh b/tasks/format-code-task-001009/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001009/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001009/tests/test.patch b/tasks/format-code-task-001009/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7981b056acbacd2545e43336e527fddd3d2c0484 --- /dev/null +++ b/tasks/format-code-task-001009/tests/test.patch @@ -0,0 +1,136 @@ +diff --git a/static/app/utils/parseLinkHeader.codespec.spec.ts b/static/app/utils/parseLinkHeader.codespec.spec.ts +new file mode 100644 +index 0000000000..13252341d5 +--- /dev/null ++++ b/static/app/utils/parseLinkHeader.codespec.spec.ts +@@ -0,0 +1,121 @@ ++import parseLinkHeader from 'sentry/utils/parseLinkHeader'; ++ ++describe('parseLinkHeader robust pagination parsing', () => { ++ it('keeps commas inside link targets and quoted parameter values', () => { ++ const parsed = parseLinkHeader( ++ '; rel="next"; results="true"; cursor="page,2", ' + ++ '; rel="previous"; results="false"; cursor="page,0"' ++ ); ++ ++ expect(parsed).toEqual({ ++ next: { ++ href: 'https://sentry.example/api/items?labels=frontend,backend&cursor=a,b', ++ results: true, ++ cursor: 'page,2', ++ }, ++ previous: { ++ href: 'https://sentry.example/api/items?cursor=previous', ++ results: false, ++ cursor: 'page,0', ++ }, ++ }); ++ }); ++ ++ it('accepts parameters in any order with OWS, case-insensitive names, and token values', () => { ++ const parsed = parseLinkHeader( ++ ' ; CURSOR = first ; RESULTS = FALSE ; REL = previous, ' + ++ ';results=TrUe;rel=next;cursor=third' ++ ); ++ ++ expect(parsed).toEqual({ ++ previous: { ++ href: 'https://sentry.example/api/items?page=1', ++ results: false, ++ cursor: 'first', ++ }, ++ next: { ++ href: 'https://sentry.example/api/items?page=3', ++ results: true, ++ cursor: 'third', ++ }, ++ }); ++ }); ++ ++ it('unescapes quoted-pairs and expands a relation list', () => { ++ const parsed = parseLinkHeader( ++ '; cursor="page\\\\2"; rel="next alternate"; results="true"' ++ ); ++ ++ const expected = { ++ href: 'https://sentry.example/api/items', ++ results: true, ++ cursor: 'page\\2', ++ }; ++ expect(parsed.next).toEqual(expected); ++ expect(parsed.alternate).toEqual(expected); ++ }); ++ ++ it('normalizes results while preserving href and optional cursor semantics', () => { ++ const parsed = parseLinkHeader( ++ '<../events?scope=all>; rel="next"; results="unknown", ' + ++ '; rel="previous"; cursor=opaque%3Avalue' ++ ); ++ ++ expect(parsed.next).toEqual({ ++ href: '../events?scope=all', ++ results: null, ++ cursor: undefined, ++ }); ++ expect(parsed.previous).toEqual({ ++ href: 'https://sentry.example/api/items', ++ results: null, ++ cursor: 'opaque%3Avalue', ++ }); ++ }); ++ ++ it('isolates unusable entries and lets the later usable relation win', () => { ++ const parsed = parseLinkHeader( ++ 'not a link, ' + ++ '; cursor=ignored, ' + ++ '; rel=next; cursor=old; results=false, ' + ++ '; rel="next"; cursor="new"; results="true", ' + ++ '; rel="previous"; cursor="prev"' ++ ); ++ ++ expect(parsed).toEqual({ ++ next: { ++ href: 'https://sentry.example/new', ++ results: true, ++ cursor: 'new', ++ }, ++ previous: { ++ href: 'https://sentry.example/previous', ++ results: null, ++ cursor: 'prev', ++ }, ++ }); ++ expect(parseLinkHeader(null)).toEqual({}); ++ expect(parseLinkHeader('')).toEqual({}); ++ expect(parseLinkHeader('not a link')).toEqual({}); ++ }); ++ ++ it('returns reserved JavaScript property names as ordinary own relation keys', () => { ++ const parsed = parseLinkHeader( ++ '; rel="__proto__"; cursor="safe"; results="true", ' + ++ '; rel="constructor"; cursor="also-safe"; results="false"' ++ ); ++ ++ expect(Object.prototype.hasOwnProperty.call(parsed, '__proto__')).toBe(true); ++ expect(Reflect.get(parsed, '__proto__')).toEqual({ ++ href: 'https://sentry.example/prototype', ++ results: true, ++ cursor: 'safe', ++ }); ++ expect(Object.prototype.hasOwnProperty.call(parsed, 'constructor')).toBe(true); ++ expect(parsed.constructor).toEqual({ ++ href: 'https://sentry.example/constructor', ++ results: false, ++ cursor: 'also-safe', ++ }); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++node scripts/test.js --ci --runInBand static/app/utils/parseLinkHeader.codespec.spec.ts diff --git a/tasks/format-code-task-001009/tests/test.sh b/tasks/format-code-task-001009/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6e96d214a3c2f12565bbeea0044353c911ee66f9 --- /dev/null +++ b/tasks/format-code-task-001009/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +static/app/utils/parseLinkHeader.codespec.spec.ts +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001009/tests/test_command.sh b/tasks/format-code-task-001009/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001009/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001031/environment/Dockerfile b/tasks/format-code-task-001031/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8e06d62930d6d61fe64f69ed248d63b096ba6e26 --- /dev/null +++ b/tasks/format-code-task-001031/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ee3c3f698d1cbc2480350b5b6d2015a50ee9258b9943648b4c417052c10572bb diff --git a/tasks/format-code-task-001031/environment/setup/files/blocklist b/tasks/format-code-task-001031/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001031/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001031/environment/setup/setup.sh b/tasks/format-code-task-001031/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001031/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001031/tests/test.patch b/tasks/format-code-task-001031/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..139d8982db12ef663356adee290056fe01103ecd --- /dev/null +++ b/tasks/format-code-task-001031/tests/test.patch @@ -0,0 +1,428 @@ +diff --git a/test/tape/codespec-cte.js b/test/tape/codespec-cte.js +new file mode 100644 +index 0000000..49b2369 +--- /dev/null ++++ b/test/tape/codespec-cte.js +@@ -0,0 +1,411 @@ ++'use strict'; ++ ++var test = require('tape'); ++var Knex = require('../../knex'); ++var Client = require('../../lib/client'); ++var PGClient = require('../../lib/dialects/postgres'); ++var SQLiteClient = require('../../lib/dialects/sqlite3'); ++var MySQLClient = require('../../lib/dialects/mysql'); ++var MSSQLClient = require('../../lib/dialects/mssql'); ++ ++function clients() { ++ return { ++ generic: new Client({}), ++ pg: new PGClient({}), ++ sqlite: new SQLiteClient({useNullAsDefault: true}), ++ mysql: new MySQLClient({}), ++ mssql: new MSSQLClient({}) ++ }; ++} ++ ++function requireMethod(t, target, method) { ++ var available = typeof target[method] === 'function'; ++ if (!available) { ++ t.fail('public .' + method + '() method is missing'); ++ t.end(); ++ } ++ return available; ++} ++ ++function compileOrFail(t, factory) { ++ try { ++ return factory().toSQL(); ++ } catch (error) { ++ t.fail('CTE query should compile: ' + error.message); ++ return null; ++ } ++} ++ ++function expectTypeError(t, callback, messagePattern, label) { ++ try { ++ callback(); ++ t.fail(label + ': did not throw'); ++ } catch (error) { ++ t.ok(error instanceof TypeError, label + ': throws TypeError'); ++ t.ok(messagePattern.test(error.message), label + ': identifies the invalid field'); ++ } ++} ++ ++test('codespec CTE methods are available on builders and the root knex object', function(t) { ++ var c = clients(); ++ var knex = Knex({client: 'pg'}); ++ ++ t.equal(typeof c.generic.queryBuilder().with, 'function', 'builder exposes .with()'); ++ t.equal(typeof c.generic.queryBuilder().withRecursive, 'function', 'builder exposes .withRecursive()'); ++ t.equal(typeof knex.with, 'function', 'root knex exposes .with()'); ++ t.equal(typeof knex.withRecursive, 'function', 'root knex exposes .withRecursive()'); ++ ++ if (typeof knex.with === 'function' && typeof knex.withRecursive === 'function') { ++ var compiled = compileOrFail(t, function() { ++ return knex ++ .with('cap', knex.raw('select ? as id', [3])) ++ .withRecursive('seed', ['id'], knex.raw('select ? as id', [1])) ++ .select('id') ++ .from('seed'); ++ }); ++ if (compiled) { ++ t.equal(compiled.sql, 'with recursive "cap" as (select ? as id), "seed"("id") as (select ? as id) select "id" from "seed"'); ++ t.deepEqual(compiled.bindings, [3, 1]); ++ } ++ } ++ t.end(); ++}); ++ ++test('codespec callback CTE quotes aliases and columns and binds before the main query', function(t) { ++ var pg = clients().pg; ++ var callbackThis; ++ var callbackArgument; ++ var builder = pg.queryBuilder(); ++ if (!requireMethod(t, builder, 'with')) return; ++ ++ var compiled = compileOrFail(t, function() { ++ return builder ++ .with('active_users', ['id', 'display_name'], function(qb) { ++ callbackThis = this; ++ callbackArgument = qb; ++ qb.select('id', 'display_name').from('users').where('active', true); ++ }) ++ .select('*') ++ .from('active_users') ++ .where('id', '>', 10); ++ }); ++ if (!compiled) return t.end(); ++ ++ t.equal(callbackThis, callbackArgument, 'callback receives the same builder as this and its argument'); ++ t.equal( ++ compiled.sql, ++ 'with "active_users"("id", "display_name") as (select "id", "display_name" from "users" where "active" = ?) select * from "active_users" where "id" > ?' ++ ); ++ t.deepEqual(compiled.bindings, [true, 10], 'CTE bindings precede outer-query bindings'); ++ t.end(); ++}); ++ ++test('codespec raw and query-builder CTE bodies preserve declaration and binding order', function(t) { ++ var pg = clients().pg; ++ var builder = pg.queryBuilder(); ++ if (!requireMethod(t, builder, 'with')) return; ++ ++ var staff = pg.queryBuilder() ++ .select('id') ++ .from('accounts') ++ .where('kind', 'staff'); ++ var compiled = compileOrFail(t, function() { ++ return builder ++ .with('constants', pg.raw('select ? as ??', [7, 'rank'])) ++ .with('staff', staff) ++ .select('*') ++ .from('staff') ++ .where('id', '>', 3); ++ }); ++ if (!compiled) return t.end(); ++ ++ t.equal( ++ compiled.sql, ++ 'with "constants" as (select ? as "rank"), "staff" as (select "id" from "accounts" where "kind" = ?) select * from "staff" where "id" > ?' ++ ); ++ t.deepEqual(compiled.bindings, [7, 'staff', 3]); ++ t.end(); ++}); ++ ++test('codespec recursive CTE uses one recursive prefix on PostgreSQL SQLite and MySQL', function(t) { ++ var c = clients(); ++ var cases = [ ++ { ++ name: 'postgres', ++ client: c.pg, ++ sql: 'with recursive "cap" as (select ? as n), "walk"("n") as (select ? union all select n + ? from walk where n < ?) select "n" from "walk" where "n" > ?' ++ }, ++ { ++ name: 'sqlite', ++ client: c.sqlite, ++ sql: 'with recursive "cap" as (select ? as n), "walk"("n") as (select ? union all select n + ? from walk where n < ?) select "n" from "walk" where "n" > ?' ++ }, ++ { ++ name: 'mysql', ++ client: c.mysql, ++ sql: 'with recursive `cap` as (select ? as n), `walk`(`n`) as (select ? union all select n + ? from walk where n < ?) select `n` from `walk` where `n` > ?' ++ } ++ ]; ++ ++ cases.forEach(function(item) { ++ var builder = item.client.queryBuilder(); ++ if (typeof builder.with !== 'function' || typeof builder.withRecursive !== 'function') { ++ t.fail(item.name + ' CTE methods are missing'); ++ return; ++ } ++ var compiled = compileOrFail(t, function() { ++ return builder ++ .with('cap', item.client.raw('select ? as n', [4])) ++ .withRecursive( ++ 'walk', ++ ['n'], ++ item.client.raw('select ? union all select n + ? from walk where n < ?', [1, 1, 4]) ++ ) ++ .select('n') ++ .from('walk') ++ .where('n', '>', 0); ++ }); ++ if (!compiled) return; ++ t.equal(compiled.sql, item.sql, item.name + ' recursive SQL'); ++ t.deepEqual(compiled.bindings, [4, 1, 1, 4, 0], item.name + ' binding order'); ++ }); ++ t.end(); ++}); ++ ++test('codespec recursive CTE accepts callback and query-builder bodies', function(t) { ++ var pg = clients().pg; ++ var builder = pg.queryBuilder(); ++ var callbackThis; ++ var callbackArgument; ++ if (!requireMethod(t, builder, 'withRecursive')) return; ++ ++ var bodyBuilder = pg.queryBuilder() ++ .select('id') ++ .from('edges') ++ .where('depth', '<', 3); ++ var compiled = compileOrFail(t, function() { ++ return builder ++ .withRecursive('from_callback', function(qb) { ++ callbackThis = this; ++ callbackArgument = qb; ++ qb.select('id').from('roots').where('enabled', true); ++ }) ++ .withRecursive('from_builder', ['id'], bodyBuilder) ++ .select('id') ++ .from('from_builder') ++ .where('id', '>', 1); ++ }); ++ if (!compiled) return t.end(); ++ ++ t.equal(callbackThis, callbackArgument, 'recursive callback receives the body builder'); ++ t.equal( ++ compiled.sql, ++ 'with recursive "from_callback" as (select "id" from "roots" where "enabled" = ?), "from_builder"("id") as (select "id" from "edges" where "depth" < ?) select "id" from "from_builder" where "id" > ?' ++ ); ++ t.deepEqual(compiled.bindings, [true, 3, 1]); ++ t.end(); ++}); ++ ++test('codespec recursive CTE omits the recursive keyword on MSSQL', function(t) { ++ var mssql = clients().mssql; ++ var builder = mssql.queryBuilder(); ++ if (!requireMethod(t, builder, 'withRecursive')) return; ++ ++ var compiled = compileOrFail(t, function() { ++ return builder ++ .withRecursive('walk', ['n'], mssql.raw('select ? union all select n + ? from walk where n < ?', [1, 1, 4])) ++ .select('n') ++ .from('walk') ++ .where('n', '>', 0); ++ }); ++ if (!compiled) return t.end(); ++ ++ t.equal( ++ compiled.sql, ++ 'with [walk]([n]) as (select ? union all select n + ? from walk where n < ?) select [n] from [walk] where [n] > ?' ++ ); ++ t.deepEqual(compiled.bindings, [1, 1, 4, 0]); ++ t.end(); ++}); ++ ++test('codespec CTE prefixes PostgreSQL inserts without losing result metadata', function(t) { ++ var pg = clients().pg; ++ var builder = pg.queryBuilder(); ++ if (!requireMethod(t, builder, 'with')) return; ++ ++ var compiled = compileOrFail(t, function() { ++ return builder ++ .with('source', pg.raw('select ? as id', [9])) ++ .insert({name: 'archived'}) ++ .into('archive') ++ .returning('id'); ++ }); ++ if (!compiled) return t.end(); ++ ++ t.equal( ++ compiled.sql, ++ 'with "source" as (select ? as id) insert into "archive" ("name") values (?) returning "id"' ++ ); ++ t.deepEqual(compiled.bindings, [9, 'archived']); ++ t.equal(compiled.returning, 'id', 'dialect result metadata is preserved'); ++ t.equal(compiled.method, 'insert'); ++ t.end(); ++}); ++ ++test('codespec CTE prefixes updates and orders CTE bindings first', function(t) { ++ var pg = clients().pg; ++ var builder = pg.queryBuilder(); ++ if (!requireMethod(t, builder, 'with')) return; ++ ++ var compiled = compileOrFail(t, function() { ++ return builder ++ .with('target', pg.raw('select ? as id', [5])) ++ .table('users') ++ .update({flag: true}) ++ .whereIn('id', function() { ++ this.select('id').from('target'); ++ }); ++ }); ++ if (!compiled) return t.end(); ++ ++ t.equal( ++ compiled.sql, ++ 'with "target" as (select ? as id) update "users" set "flag" = ? where "id" in (select "id" from "target")' ++ ); ++ t.deepEqual(compiled.bindings, [5, true]); ++ t.end(); ++}); ++ ++test('codespec CTE prefixes deletes and orders outer predicates after CTE bindings', function(t) { ++ var sqlite = clients().sqlite; ++ var builder = sqlite.queryBuilder(); ++ if (!requireMethod(t, builder, 'with')) return; ++ ++ var compiled = compileOrFail(t, function() { ++ return builder ++ .with('doomed', sqlite.raw('select ? as id', [2])) ++ .from('users') ++ .whereIn('id', function() { ++ this.select('id').from('doomed'); ++ }) ++ .where('status', 'stale') ++ .del(); ++ }); ++ if (!compiled) return t.end(); ++ ++ t.equal( ++ compiled.sql, ++ 'with "doomed" as (select ? as id) delete from "users" where "id" in (select "id" from "doomed") and "status" = ?' ++ ); ++ t.deepEqual(compiled.bindings, [2, 'stale']); ++ t.end(); ++}); ++ ++test('codespec query-builder CTE bodies may contain nested CTEs', function(t) { ++ var pg = clients().pg; ++ var inner = pg.queryBuilder(); ++ var outer = pg.queryBuilder(); ++ if (!requireMethod(t, inner, 'with')) return; ++ if (!requireMethod(t, outer, 'with')) return; ++ ++ inner ++ .with('seed', pg.raw('select ? as id', [1])) ++ .select('id') ++ .from('seed') ++ .where('id', '<', 8); ++ var compiled = compileOrFail(t, function() { ++ return outer ++ .with('nested_values', inner) ++ .select('id') ++ .from('nested_values') ++ .where('id', '>', 2); ++ }); ++ if (!compiled) return t.end(); ++ ++ t.equal( ++ compiled.sql, ++ 'with "nested_values" as (with "seed" as (select ? as id) select "id" from "seed" where "id" < ?) select "id" from "nested_values" where "id" > ?' ++ ); ++ t.deepEqual(compiled.bindings, [1, 8, 2]); ++ t.end(); ++}); ++ ++test('codespec CTE declarations validate aliases columns and bodies immediately', function(t) { ++ var pg = clients().pg; ++ var builder = pg.queryBuilder(); ++ if (!requireMethod(t, builder, 'with')) return; ++ if (!requireMethod(t, builder, 'withRecursive')) return; ++ ++ expectTypeError(t, function() { builder.with('', pg.raw('select 1')); }, /CTE alias/i, 'empty alias'); ++ expectTypeError(t, function() { builder.with(42, pg.raw('select 1')); }, /CTE alias/i, 'non-string alias'); ++ expectTypeError(t, function() { builder.with('x', [], pg.raw('select 1')); }, /CTE columns/i, 'empty column list'); ++ expectTypeError(t, function() { builder.with('x', 'id', pg.raw('select 1')); }, /CTE columns/i, 'non-array column list'); ++ expectTypeError(t, function() { builder.with('x', ['ok', ''], pg.raw('select 1')); }, /CTE columns/i, 'empty column name'); ++ expectTypeError(t, function() { builder.with('x', [1], pg.raw('select 1')); }, /CTE columns/i, 'non-string column name'); ++ expectTypeError(t, function() { builder.with('x', 'select 1'); }, /CTE body/i, 'plain-string body'); ++ expectTypeError(t, function() { builder.with('x', {}); }, /CTE body/i, 'plain-object body'); ++ expectTypeError(t, function() { builder.withRecursive('', pg.raw('select 1')); }, /CTE alias/i, 'recursive alias'); ++ expectTypeError(t, function() { builder.withRecursive(42, pg.raw('select 1')); }, /CTE alias/i, 'recursive non-string alias'); ++ expectTypeError(t, function() { builder.withRecursive('x', [], pg.raw('select 1')); }, /CTE columns/i, 'recursive column list'); ++ expectTypeError(t, function() { builder.withRecursive('x', 'id', pg.raw('select 1')); }, /CTE columns/i, 'recursive non-array column list'); ++ expectTypeError(t, function() { builder.withRecursive('x', ['ok', ''], pg.raw('select 1')); }, /CTE columns/i, 'recursive empty column name'); ++ expectTypeError(t, function() { builder.withRecursive('x', [1], pg.raw('select 1')); }, /CTE columns/i, 'recursive non-string column name'); ++ expectTypeError(t, function() { builder.withRecursive('x', 'select 1'); }, /CTE body/i, 'recursive body'); ++ expectTypeError(t, function() { builder.withRecursive('x', {}); }, /CTE body/i, 'recursive plain-object body'); ++ t.end(); ++}); ++ ++test('codespec cloned CTE builders keep independent declaration lists', function(t) { ++ var c = clients(); ++ var original = c.pg.queryBuilder(); ++ if (!requireMethod(t, original, 'with')) return; ++ ++ original ++ .with('seed', ['n'], c.pg.raw('select ? as n', [1])) ++ .select('n') ++ .from('seed') ++ .where('n', '>', 0); ++ ++ var clone = original.clone(); ++ clone.with('extra', c.pg.raw('select ? as n', [2])); ++ ++ var cloneCompiled = compileOrFail(t, function() { return clone; }); ++ var pgCompiled = compileOrFail(t, function() { return original; }); ++ var pgCompiledAgain = compileOrFail(t, function() { return original; }); ++ if (!cloneCompiled || !pgCompiled || !pgCompiledAgain) return t.end(); ++ ++ t.equal( ++ cloneCompiled.sql, ++ 'with "seed"("n") as (select ? as n), "extra" as (select ? as n) select "n" from "seed" where "n" > ?' ++ ); ++ t.deepEqual(cloneCompiled.bindings, [1, 2, 0]); ++ t.equal( ++ pgCompiled.sql, ++ 'with "seed"("n") as (select ? as n) select "n" from "seed" where "n" > ?' ++ ); ++ t.deepEqual(pgCompiled.bindings, [1, 0]); ++ t.deepEqual(pgCompiledAgain, pgCompiled, 'repeated compilation is stable'); ++ t.end(); ++}); ++ ++test('codespec raw CTE bodies compile with the active enclosing dialect', function(t) { ++ var c = clients(); ++ var sharedBody = c.pg.raw('select ? as ??', [1, 'n']); ++ var mysqlBuilder = c.mysql.queryBuilder(); ++ var pgBuilder = c.pg.queryBuilder(); ++ if (!requireMethod(t, mysqlBuilder, 'with')) return; ++ if (!requireMethod(t, pgBuilder, 'with')) return; ++ ++ mysqlBuilder.with('seed', ['n'], sharedBody).select('n').from('seed'); ++ pgBuilder.with('seed', ['n'], sharedBody).select('n').from('seed'); ++ ++ var mysqlCompiled = compileOrFail(t, function() { return mysqlBuilder; }); ++ var pgCompiled = compileOrFail(t, function() { return pgBuilder; }); ++ if (!mysqlCompiled || !pgCompiled) return t.end(); ++ ++ t.equal(mysqlCompiled.sql, 'with `seed`(`n`) as (select ? as `n`) select `n` from `seed`'); ++ t.deepEqual(mysqlCompiled.bindings, [1]); ++ t.equal(pgCompiled.sql, 'with "seed"("n") as (select ? as "n") select "n" from "seed"'); ++ t.deepEqual(pgCompiled.bindings, [1]); ++ t.end(); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++./node_modules/.bin/babel -L -D src/ --out-dir lib/ ++node test/tape/codespec-cte.js diff --git a/tasks/format-code-task-001031/tests/test.sh b/tasks/format-code-task-001031/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6138f0bc957fea1f53fff38b7059388de9f525fd --- /dev/null +++ b/tasks/format-code-task-001031/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/tape/codespec-cte.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001031/tests/test_command.sh b/tasks/format-code-task-001031/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001031/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001036/environment/Dockerfile b/tasks/format-code-task-001036/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7f6cc03a9bd70ad1431d79fef66974e082c9c2f1 --- /dev/null +++ b/tasks/format-code-task-001036/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:04b58aa91ba51ffeaf94408a2d8a09854ee662fc0222154afa31cba827c145ed diff --git a/tasks/format-code-task-001036/environment/setup/files/blocklist b/tasks/format-code-task-001036/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001036/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001036/environment/setup/setup.sh b/tasks/format-code-task-001036/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001036/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001036/tests/test.patch b/tasks/format-code-task-001036/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3e69255379e82c392b50faaaf38175cd175310e8 --- /dev/null +++ b/tasks/format-code-task-001036/tests/test.patch @@ -0,0 +1,290 @@ +diff --git a/internal/cmd/config/sanitized_contract_test.go b/internal/cmd/config/sanitized_contract_test.go +new file mode 100644 +index 000000000..3880632ab +--- /dev/null ++++ b/internal/cmd/config/sanitized_contract_test.go +@@ -0,0 +1,274 @@ ++package config ++ ++import ( ++ "encoding/json" ++ "testing" ++ "time" ++ ++ "github.com/stretchr/testify/require" ++) ++ ++const sanitizedContractHCL = ` ++disable_mlock = true ++default_max_request_duration = "7s" ++log_level = "debug" ++log_format = "json" ++pid_file = "/tmp/boundary.pid" ++cluster_name = "cluster-a" ++ ++listener "tcp" { ++ purpose = "api" ++ address = "127.0.0.1:9200" ++ tls_disable = true ++} ++ ++controller { ++ name = "controller-a" ++ description = "controller description" ++ public_cluster_addr = "127.0.0.1:9201" ++ auth_token_time_to_live = "10m" ++ auth_token_time_to_stale = "2m" ++ database { ++ url = "postgresql://boundary:database-secret@db.example/boundary" ++ migration_url = "postgresql://boundary:migration-secret@db.example/boundary" ++ max_open_connections = 12 ++ } ++} ++ ++worker { ++ name = "worker-a" ++ description = "worker description" ++ controllers = ["127.0.0.1:9201"] ++ public_addr = "worker.example:9202" ++ tags { ++ region = ["us-east"] ++ } ++} ++ ++plugins { ++ execution_dir = "/var/lib/boundary/plugins" ++} ++ ++events { ++ audit_enabled = true ++ observations_enabled = true ++ sysevents_enabled = true ++ sink "stderr" { ++ format = "cloudevents-json" ++ name = "audit-sink" ++ event_types = ["audit"] ++ } ++ sink "file" { ++ name = "observation-sink" ++ description = "local observation archive" ++ event_types = ["observation", "system"] ++ event_source_url = "https://boundary.example/events" ++ allow_filters = ["source contains boundary"] ++ deny_filters = ["data contains private"] ++ format = "cloudevents-json" ++ file { ++ path = "/var/log/boundary" ++ file_name = "events.log" ++ rotate_bytes = 4096 ++ rotate_duration = "3m" ++ rotate_max_files = 5 ++ } ++ } ++} ++ ++kms "aead" { ++ purpose = "root" ++ aead_type = "aes-gcm" ++ key = "do-not-leak-this-key" ++ key_id = "root-key" ++} ++` ++ ++func TestSanitizedContractPreservesBoundaryConfiguration(t *testing.T) { ++ c, err := Parse(sanitizedContractHCL) ++ require.NoError(t, err) ++ c.DevController = true ++ c.DevUiPassthroughDir = "/tmp/boundary-ui" ++ c.DevControllerKey = "controller-secret" ++ c.DevWorkerAuthKey = "worker-secret" ++ c.DevRecoveryKey = "recovery-secret" ++ ++ got := c.Sanitized() ++ require.Equal(t, true, got["disable_mlock"]) ++ require.Equal(t, "debug", got["log_level"]) ++ require.Equal(t, "json", got["log_format"]) ++ require.Equal(t, "cluster-a", got["cluster_name"]) ++ controller, ok := got["controller"].(map[string]interface{}) ++ require.True(t, ok, "controller must be a map") ++ require.Equal(t, "controller-a", controller["name"]) ++ require.Equal(t, "controller description", controller["description"]) ++ require.Equal(t, "127.0.0.1:9201", controller["public_cluster_addr"]) ++ require.Equal(t, 10*time.Minute, controller["auth_token_time_to_live"]) ++ require.Equal(t, 2*time.Minute, controller["auth_token_time_to_stale"]) ++ database, ok := controller["database"].(map[string]interface{}) ++ require.True(t, ok, "controller database must be a map") ++ require.Equal(t, 12, database["max_open_connections"]) ++ require.NotContains(t, database, "url") ++ require.NotContains(t, database, "migration_url") ++ ++ worker, ok := got["worker"].(map[string]interface{}) ++ require.True(t, ok, "worker must be a map") ++ require.Equal(t, "worker-a", worker["name"]) ++ require.Equal(t, "worker description", worker["description"]) ++ require.Equal(t, []string{"127.0.0.1:9201"}, worker["controllers"]) ++ require.Equal(t, "worker.example:9202", worker["public_addr"]) ++ require.Equal(t, map[string][]string{"region": {"us-east"}}, worker["tags"]) ++ ++ plugins, ok := got["plugins"].(map[string]interface{}) ++ require.True(t, ok, "plugins must be a map") ++ require.Equal(t, "/var/lib/boundary/plugins", plugins["execution_dir"]) ++ require.Equal(t, true, got["dev_controller"]) ++ require.Equal(t, "/tmp/boundary-ui", got["dev_ui_passthrough_dir"]) ++ ++ events, ok := got["events"].(map[string]interface{}) ++ require.True(t, ok, "events must be a map") ++ require.Equal(t, true, events["audit_enabled"]) ++ require.Equal(t, true, events["observations_enabled"]) ++ require.Equal(t, true, events["sysevents_enabled"]) ++ sinks, ok := events["sinks"].([]interface{}) ++ require.True(t, ok, "event sinks must be a slice") ++ require.Len(t, sinks, 2) ++ sink, ok := sinks[0].(map[string]interface{}) ++ require.True(t, ok, "each event sink must be a map") ++ require.Equal(t, "audit-sink", sink["name"]) ++ require.Equal(t, "stderr", sink["type"]) ++ require.Equal(t, "cloudevents-json", sink["format"]) ++ require.Equal(t, []string{"audit"}, sink["event_types"]) ++ require.Equal(t, map[string]interface{}{}, sink["stderr"]) ++ ++ fileSink, ok := sinks[1].(map[string]interface{}) ++ require.True(t, ok, "each event sink must be a map") ++ require.Equal(t, "observation-sink", fileSink["name"]) ++ require.Equal(t, "local observation archive", fileSink["description"]) ++ require.Equal(t, []string{"observation", "system"}, fileSink["event_types"]) ++ require.Equal(t, "https://boundary.example/events", fileSink["event_source_url"]) ++ require.Equal(t, []string{"source contains boundary"}, fileSink["allow_filters"]) ++ require.Equal(t, []string{"data contains private"}, fileSink["deny_filters"]) ++ require.Equal(t, "file", fileSink["type"]) ++ fileConfig, ok := fileSink["file"].(map[string]interface{}) ++ require.True(t, ok, "file sink configuration must be a map") ++ require.Equal(t, "/var/log/boundary", fileConfig["path"]) ++ require.Equal(t, "events.log", fileConfig["file_name"]) ++ require.Equal(t, 4096, fileConfig["rotate_bytes"]) ++ require.Equal(t, 3*time.Minute, fileConfig["rotate_duration"]) ++ require.Equal(t, 5, fileConfig["rotate_max_files"]) ++ ++ seals := got["seals"].([]interface{}) ++ require.Len(t, seals, 1) ++ require.NotContains(t, seals[0].(map[string]interface{}), "config") ++ require.NotContains(t, got, "dev_controller_key") ++ require.NotContains(t, got, "dev_worker_auth_key") ++ require.NotContains(t, got, "dev_recovery_key") ++ require.NotContains(t, got, "worker_tags_raw") ++ requireNoRawKeys(t, got) ++ ++ encoded, err := json.Marshal(got) ++ require.NoError(t, err) ++ require.NotContains(t, string(encoded), "do-not-leak-this-key") ++ require.NotContains(t, string(encoded), "controller-secret") ++ require.NotContains(t, string(encoded), "worker-secret") ++ require.NotContains(t, string(encoded), "recovery-secret") ++ require.NotContains(t, string(encoded), "database-secret") ++ require.NotContains(t, string(encoded), "migration-secret") ++} ++ ++func TestSanitizedContractReturnsIndependentCopy(t *testing.T) { ++ c, err := Parse(sanitizedContractHCL) ++ require.NoError(t, err) ++ ++ got := c.Sanitized() ++ controller, ok := got["controller"].(map[string]interface{}) ++ require.True(t, ok, "controller must be a map") ++ worker, ok := got["worker"].(map[string]interface{}) ++ require.True(t, ok, "worker must be a map") ++ events, ok := got["events"].(map[string]interface{}) ++ require.True(t, ok, "events must be a map") ++ ++ controller["name"] = "changed" ++ worker["controllers"].([]string)[0] = "changed" ++ worker["tags"].(map[string][]string)["region"][0] = "changed" ++ events["sinks"].([]interface{})[0].(map[string]interface{})["name"] = "changed" ++ events["sinks"].([]interface{})[1].(map[string]interface{})["allow_filters"].([]string)[0] = "changed" ++ events["sinks"].([]interface{})[1].(map[string]interface{})["file"].(map[string]interface{})["path"] = "changed" ++ got["listeners"].([]interface{})[0].(map[string]interface{})["config"].(map[string]interface{})["address"] = "changed" ++ ++ require.Equal(t, "controller-a", c.Controller.Name) ++ require.Equal(t, "127.0.0.1:9201", c.Worker.Controllers[0]) ++ require.Equal(t, "us-east", c.Worker.Tags["region"][0]) ++ require.Equal(t, "audit-sink", c.Eventing.Sinks[0].Name) ++ require.Equal(t, "source contains boundary", c.Eventing.Sinks[1].AllowFilters[0]) ++ require.Equal(t, "/var/log/boundary", c.Eventing.Sinks[1].FileConfig.Path) ++ require.NotEqual(t, "changed", c.Listeners[0].RawConfig["address"]) ++} ++ ++func TestSanitizedContractReflectsCurrentConfiguration(t *testing.T) { ++ c, err := Parse(` ++ controller { ++ name = "controller-b" ++ description = "second controller" ++ } ++ worker { ++ name = "worker-b" ++ controllers = ["10.0.0.2:9201", "10.0.0.3:9201"] ++ tags { tier = "edge" } ++ } ++ plugins { execution_dir = "/opt/plugins-b" } ++ `) ++ require.NoError(t, err) ++ ++ got := c.Sanitized() ++ controller, ok := got["controller"].(map[string]interface{}) ++ require.True(t, ok, "controller must be a map") ++ worker, ok := got["worker"].(map[string]interface{}) ++ require.True(t, ok, "worker must be a map") ++ plugins, ok := got["plugins"].(map[string]interface{}) ++ require.True(t, ok, "plugins must be a map") ++ ++ require.Equal(t, "controller-b", controller["name"]) ++ require.Equal(t, "second controller", controller["description"]) ++ require.Equal(t, "worker-b", worker["name"]) ++ require.Equal(t, []string{"10.0.0.2:9201", "10.0.0.3:9201"}, worker["controllers"]) ++ require.Equal(t, map[string][]string{"tier": {"edge"}}, worker["tags"]) ++ require.Equal(t, "/opt/plugins-b", plugins["execution_dir"]) ++} ++ ++func TestSanitizedContractDoesNotInitializeSharedConfig(t *testing.T) { ++ c := &Config{} ++ require.Nil(t, c.SharedConfig) ++ require.NotPanics(t, func() { require.NotNil(t, c.Sanitized()) }) ++ require.Nil(t, c.SharedConfig) ++ ++ var nilConfig *Config ++ require.Nil(t, nilConfig.Sanitized()) ++} ++ ++func TestSanitizedContractOmitsAbsentBoundarySections(t *testing.T) { ++ c := &Config{} ++ got := c.Sanitized() ++ require.NotContains(t, got, "controller") ++ require.NotContains(t, got, "worker") ++ require.NotContains(t, got, "plugins") ++ require.NotContains(t, got, "events") ++ require.NotContains(t, got, "dev_controller") ++ require.NotContains(t, got, "dev_ui_passthrough_dir") ++} ++ ++func requireNoRawKeys(t *testing.T, value interface{}) { ++ t.Helper() ++ switch value := value.(type) { ++ case map[string]interface{}: ++ for key, nested := range value { ++ require.NotRegexp(t, `(?i)_?raw$`, key) ++ requireNoRawKeys(t, nested) ++ } ++ case []interface{}: ++ for _, nested := range value { ++ requireNoRawKeys(t, nested) ++ } ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++GOPROXY=off go test ./internal/cmd/config -run '^TestSanitizedContract' -count=1 diff --git a/tasks/format-code-task-001036/tests/test.sh b/tasks/format-code-task-001036/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..87fd76d90a5906b5b6c6bac679301f0272bf1719 --- /dev/null +++ b/tasks/format-code-task-001036/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +internal/cmd/config/sanitized_contract_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001036/tests/test_command.sh b/tasks/format-code-task-001036/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001036/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001038/environment/Dockerfile b/tasks/format-code-task-001038/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3d883ad58b9576dcb664208774579de9c0333ba1 --- /dev/null +++ b/tasks/format-code-task-001038/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:443c395feb3732a0b60de65d11a5ebf432a638e6a61c11e50d3d64beeb63d1ee diff --git a/tasks/format-code-task-001038/environment/setup/files/blocklist b/tasks/format-code-task-001038/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001038/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001038/environment/setup/setup.sh b/tasks/format-code-task-001038/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001038/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001038/tests/test.patch b/tasks/format-code-task-001038/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b58d8f8ab99fa6514589ea22bc748596e69d693e --- /dev/null +++ b/tasks/format-code-task-001038/tests/test.patch @@ -0,0 +1,335 @@ +diff --git a/tests/unit/lib/intrinsic_resolver/test_condition_projection_codespec.py b/tests/unit/lib/intrinsic_resolver/test_condition_projection_codespec.py +new file mode 100644 +index 000000000..1e0b98a9d +--- /dev/null ++++ b/tests/unit/lib/intrinsic_resolver/test_condition_projection_codespec.py +@@ -0,0 +1,317 @@ ++from copy import deepcopy ++from unittest import TestCase ++ ++from samcli.commands.local.lib.sam_base_provider import SamBaseProvider ++from samcli.lib.intrinsic_resolver.intrinsic_property_resolver import IntrinsicResolver ++from samcli.lib.intrinsic_resolver.intrinsics_symbol_table import IntrinsicsSymbolTable ++from samcli.lib.intrinsic_resolver.invalid_intrinsic_exception import InvalidIntrinsicException ++ ++ ++class ConditionProjectionContractTest(TestCase): ++ @staticmethod ++ def resolve(template, values=None, ignore_errors=False): ++ symbols = IntrinsicsSymbolTable(template=template, logical_id_translator=values or {}) ++ return IntrinsicResolver(template=template, symbol_resolver=symbols).resolve_template( ++ ignore_errors=ignore_errors ++ ) ++ ++ def test_resource_conditions_filter_before_resolving_resource_bodies(self): ++ template = { ++ "Conditions": { ++ "Enabled": {"Fn::Equals": [{"Ref": "Mode"}, "on"]}, ++ "Disabled": {"Fn::Not": [{"Condition": "Enabled"}]}, ++ }, ++ "Resources": { ++ "Included": { ++ "Type": "Custom::Thing", ++ "Condition": "Enabled", ++ "Properties": {"State": "ready"}, ++ }, ++ "Excluded": { ++ "Type": "Custom::Thing", ++ "Condition": "Disabled", ++ "Properties": {"Unresolvable": {"Fn::Select": [9, ["invalid"]]}}, ++ }, ++ "Unconditional": {"Type": "Custom::Thing", "Properties": {"State": "always"}}, ++ }, ++ } ++ ++ result = self.resolve(template, {"Mode": "on"}) ++ ++ self.assertEqual(set(result["Resources"]), {"Included", "Unconditional"}) ++ ++ def test_included_resources_do_not_retain_condition_metadata(self): ++ template = { ++ "Conditions": {"Enabled": {"Fn::Equals": [1, 1]}}, ++ "Resources": { ++ "Included": { ++ "Type": "Custom::Thing", ++ "Condition": "Enabled", ++ "Properties": {"State": "ready"}, ++ } ++ }, ++ } ++ ++ result = self.resolve(template) ++ ++ self.assertNotIn("Condition", result["Resources"]["Included"]) ++ self.assertEqual(result["Resources"]["Included"]["Properties"], {"State": "ready"}) ++ ++ def test_output_conditions_filter_before_resolving_output_values(self): ++ template = { ++ "Conditions": { ++ "Enabled": {"Fn::Equals": [1, 1]}, ++ "Disabled": {"Fn::Not": [{"Condition": "Enabled"}]}, ++ }, ++ "Outputs": { ++ "IncludedOutput": {"Condition": "Enabled", "Value": "visible"}, ++ "ExcludedOutput": { ++ "Condition": "Disabled", ++ "Value": {"Fn::Select": [9, ["invalid"]]}, ++ }, ++ }, ++ } ++ ++ result = self.resolve(template) ++ ++ self.assertEqual(set(result["Outputs"]), {"IncludedOutput"}) ++ self.assertEqual(result["Outputs"]["IncludedOutput"]["Value"], "visible") ++ ++ def test_included_outputs_do_not_retain_condition_metadata(self): ++ template = { ++ "Conditions": {"Enabled": {"Fn::Equals": [1, 1]}}, ++ "Outputs": {"IncludedOutput": {"Condition": "Enabled", "Value": "visible"}}, ++ } ++ ++ result = self.resolve(template) ++ ++ self.assertNotIn("Condition", result["Outputs"]["IncludedOutput"]) ++ ++ def test_fn_if_does_not_resolve_its_false_branch_when_condition_is_true(self): ++ template = { ++ "Conditions": { ++ "UsePrimary": {"Fn::Equals": [{"Ref": "Mode"}, "primary"]}, ++ }, ++ "Resources": { ++ "Thing": { ++ "Type": "Custom::Thing", ++ "Properties": { ++ "Choice": { ++ "Fn::If": [ ++ "UsePrimary", ++ {"Fn::Join": ["-", ["selected", {"Ref": "Mode"}]]}, ++ {"Fn::Select": [8, ["invalid-dead-branch"]]}, ++ ] ++ } ++ }, ++ } ++ }, ++ } ++ ++ result = self.resolve(template, {"Mode": "primary"}) ++ ++ self.assertEqual(result["Resources"]["Thing"]["Properties"]["Choice"], "selected-primary") ++ ++ def test_fn_if_does_not_resolve_its_true_branch_when_condition_is_false(self): ++ template = { ++ "Conditions": { ++ "UsePrimary": {"Fn::Equals": [{"Ref": "Mode"}, "primary"]}, ++ }, ++ "Resources": { ++ "Thing": { ++ "Type": "Custom::Thing", ++ "Properties": { ++ "Choice": { ++ "Fn::If": [ ++ "UsePrimary", ++ {"Fn::Select": [8, ["invalid-dead-branch"]]}, ++ {"Fn::Join": ["-", ["selected", {"Ref": "Mode"}]]}, ++ ] ++ }, ++ }, ++ } ++ }, ++ } ++ ++ result = self.resolve(template, {"Mode": "fallback"}) ++ ++ self.assertEqual(result["Resources"]["Thing"]["Properties"]["Choice"], "selected-fallback") ++ ++ def test_literal_boolean_condition_definitions_gate_entries(self): ++ template = { ++ "Conditions": {"Always": True, "Never": False}, ++ "Resources": { ++ "Included": {"Type": "Custom::Thing", "Condition": "Always", "Properties": {}}, ++ "Excluded": {"Type": "Custom::Thing", "Condition": "Never", "Properties": {}}, ++ }, ++ } ++ ++ result = self.resolve(template) ++ ++ self.assertEqual(set(result["Resources"]), {"Included"}) ++ ++ def test_no_value_prunes_mapping_members_at_multiple_depths(self): ++ template = { ++ "Conditions": {"Enabled": {"Fn::Equals": ["same", "same"]}}, ++ "Resources": { ++ "Thing": { ++ "Type": "Custom::Thing", ++ "Properties": { ++ "RemovedProperty": {"Fn::If": ["Enabled", {"Ref": "AWS::NoValue"}, "kept"]}, ++ "Nested": { ++ "Keep": "value", ++ "Drop": {"Fn::If": ["Enabled", {"Ref": "AWS::NoValue"}, "kept"]}, ++ }, ++ }, ++ } ++ }, ++ } ++ ++ result = self.resolve(template) ++ properties = result["Resources"]["Thing"]["Properties"] ++ ++ self.assertNotIn("RemovedProperty", properties) ++ self.assertEqual(properties["Nested"], {"Keep": "value"}) ++ ++ def test_no_value_prunes_list_elements_without_reordering_neighbors(self): ++ template = { ++ "Resources": { ++ "Thing": { ++ "Type": "Custom::Thing", ++ "Properties": {"Items": ["first", {"Ref": "AWS::NoValue"}, "last"]}, ++ } ++ } ++ } ++ ++ result = self.resolve(template) ++ ++ self.assertEqual(result["Resources"]["Thing"]["Properties"]["Items"], ["first", "last"]) ++ ++ def test_literal_null_values_are_not_treated_as_no_value(self): ++ template = { ++ "Conditions": {"Enabled": {"Fn::Equals": [1, 1]}}, ++ "Resources": { ++ "Thing": { ++ "Type": "Custom::Thing", ++ "Properties": { ++ "LiteralNull": None, ++ "ConditionalNull": {"Fn::If": ["Enabled", None, "not-selected"]}, ++ "Items": [None, {"NestedNull": None}], ++ }, ++ } ++ } ++ } ++ ++ result = self.resolve(template) ++ properties = result["Resources"]["Thing"]["Properties"] ++ ++ self.assertIn("LiteralNull", properties) ++ self.assertIsNone(properties["LiteralNull"]) ++ self.assertIn("ConditionalNull", properties) ++ self.assertIsNone(properties["ConditionalNull"]) ++ self.assertEqual(properties["Items"], [None, {"NestedNull": None}]) ++ ++ def test_missing_named_condition_is_a_template_error(self): ++ template = { ++ "Resources": { ++ "Thing": {"Type": "Custom::Thing", "Condition": "Unknown", "Properties": {}} ++ } ++ } ++ ++ with self.assertRaises(InvalidIntrinsicException): ++ self.resolve(template) ++ ++ def test_non_boolean_named_condition_is_a_template_error(self): ++ template = { ++ "Conditions": {"Bad": {"Fn::Join": ["", ["not", "boolean"]]}}, ++ "Resources": {"Thing": {"Type": "Custom::Thing", "Condition": "Bad", "Properties": {}}}, ++ } ++ ++ with self.assertRaises(InvalidIntrinsicException): ++ self.resolve(template) ++ ++ def test_cyclic_condition_references_are_reported_as_template_errors(self): ++ template = { ++ "Conditions": { ++ "First": {"Fn::Not": [{"Condition": "Second"}]}, ++ "Second": {"Fn::Not": [{"Condition": "First"}]}, ++ }, ++ "Resources": {"Thing": {"Type": "Custom::Thing", "Condition": "First", "Properties": {}}}, ++ } ++ ++ with self.assertRaises(InvalidIntrinsicException): ++ self.resolve(template) ++ ++ def test_resolution_does_not_mutate_the_source_template(self): ++ template = { ++ "Conditions": {"Enabled": {"Fn::Equals": [1, 1]}}, ++ "Resources": { ++ "Thing": { ++ "Type": "Custom::Thing", ++ "Condition": "Enabled", ++ "Properties": {"Value": {"Fn::If": ["Enabled", "resolved", "other"]}}, ++ } ++ }, ++ } ++ original = deepcopy(template) ++ ++ first = self.resolve(template) ++ second = self.resolve(template) ++ ++ self.assertEqual(template, original) ++ self.assertEqual(first, second) ++ ++ ++class LocalProviderConditionIntegrationContractTest(TestCase): ++ @staticmethod ++ def template(): ++ return { ++ "AWSTemplateFormatVersion": "2010-09-09", ++ "Transform": "AWS::Serverless-2016-10-31", ++ "Parameters": {"Mode": {"Type": "String", "Default": "off"}}, ++ "Conditions": {"Enabled": {"Fn::Equals": [{"Ref": "Mode"}, "on"]}}, ++ "Resources": { ++ "Always": { ++ "Type": "AWS::Serverless::Function", ++ "Properties": { ++ "Runtime": "python3.7", ++ "Handler": "app.handler", ++ "CodeUri": ".", ++ "Environment": { ++ "Variables": { ++ "OPTIONAL": {"Fn::If": ["Enabled", "enabled", {"Ref": "AWS::NoValue"}]}, ++ "EXPLICIT_NULL": None, ++ } ++ }, ++ }, ++ }, ++ "Conditional": { ++ "Type": "AWS::Serverless::Function", ++ "Condition": "Enabled", ++ "Properties": {"Runtime": "python3.7", "Handler": "app.handler", "CodeUri": "."}, ++ }, ++ }, ++ } ++ ++ def test_parameter_default_controls_condition_gating_and_no_value(self): ++ disabled = SamBaseProvider.get_template(self.template()) ++ ++ self.assertNotIn("Conditional", disabled["Resources"]) ++ disabled_variables = disabled["Resources"]["Always"]["Properties"]["Environment"]["Variables"] ++ self.assertNotIn("OPTIONAL", disabled_variables) ++ self.assertIn("EXPLICIT_NULL", disabled_variables) ++ self.assertIsNone(disabled_variables["EXPLICIT_NULL"]) ++ ++ def test_parameter_override_controls_condition_gating_and_selected_values(self): ++ enabled = SamBaseProvider.get_template(self.template(), {"Mode": "on"}) ++ ++ self.assertIn("Conditional", enabled["Resources"]) ++ self.assertNotIn("Condition", enabled["Resources"]["Conditional"]) ++ enabled_variables = enabled["Resources"]["Always"]["Properties"]["Environment"]["Variables"] ++ self.assertEqual(enabled_variables["OPTIONAL"], "enabled") ++ ++ ++if __name__ == "__main__": ++ import unittest ++ ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,7 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++.venv/bin/pytest -q \ ++ tests/unit/lib/intrinsic_resolver/test_condition_projection_codespec.py \ ++ tests/unit/lib/intrinsic_resolver/test_intrinsic_resolver.py diff --git a/tasks/format-code-task-001038/tests/test.sh b/tasks/format-code-task-001038/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..15bc802edb0668cb0ae916a97a5c8a10f61ce8b7 --- /dev/null +++ b/tasks/format-code-task-001038/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/lib/intrinsic_resolver/test_condition_projection_codespec.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001038/tests/test_command.sh b/tasks/format-code-task-001038/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001038/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001053/environment/Dockerfile b/tasks/format-code-task-001053/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7e72d14ab273d81276c0f7e08968e197941b5181 --- /dev/null +++ b/tasks/format-code-task-001053/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1d03ca13f434b1296a542c466c163d623d465563b5a324fa0334d1a3a62cfda0 diff --git a/tasks/format-code-task-001053/environment/setup/files/blocklist b/tasks/format-code-task-001053/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001053/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001053/environment/setup/setup.sh b/tasks/format-code-task-001053/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001053/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001053/tests/test.patch b/tasks/format-code-task-001053/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..19d85e868e05ff9590c5cbf85e015375530517d5 --- /dev/null +++ b/tasks/format-code-task-001053/tests/test.patch @@ -0,0 +1,173 @@ +diff --git a/tests/codespec_redirects_contract_test.py b/tests/codespec_redirects_contract_test.py +new file mode 100644 +index 000000000..15d4aff62 +--- /dev/null ++++ b/tests/codespec_redirects_contract_test.py +@@ -0,0 +1,157 @@ ++import unittest ++ ++from pyramid.request import Request ++from pyramid.response import Response ++ ++from h import tweens ++from h.util.redirects import Redirect, lookup, parse ++ ++ ++class RedirectContractTests(unittest.TestCase): ++ def request(self, path, query_string=""): ++ suffix = "?" + query_string if query_string else "" ++ return Request.blank(path + suffix) ++ ++ def test_prefix_matches_the_source_path_itself(self): ++ redirect = Redirect("/legacy", "https://new.example/items", True, False) ++ self.assertEqual( ++ lookup([redirect], self.request("/legacy")), ++ "https://new.example/items", ++ ) ++ ++ def test_prefix_matches_a_path_segment_descendant(self): ++ redirect = Redirect("/legacy", "https://new.example/items", True, False) ++ self.assertEqual( ++ lookup([redirect], self.request("/legacy/article")), ++ "https://new.example/items/article", ++ ) ++ ++ def test_prefix_does_not_match_a_longer_segment_with_same_text(self): ++ redirect = Redirect("/legacy", "https://new.example/items", True, False) ++ self.assertIsNone(lookup([redirect], self.request("/legacy-archive"))) ++ ++ def test_prefix_does_not_match_an_unrelated_path(self): ++ redirect = Redirect("/legacy", "https://new.example/items", True, False) ++ self.assertIsNone(lookup([redirect], self.request("/current/article"))) ++ ++ def test_exact_does_not_match_a_path_with_extra_segments(self): ++ redirect = Redirect("/legacy", "https://new.example/items", False, False) ++ self.assertIsNone(lookup([redirect], self.request("/legacy/article"))) ++ ++ def test_external_prefix_preserves_query_string(self): ++ redirect = Redirect("/legacy", "https://new.example/items", True, False) ++ self.assertEqual( ++ lookup([redirect], self.request("/legacy/article", "page=2&tag=old")), ++ "https://new.example/items/article?page=2&tag=old", ++ ) ++ ++ def test_internal_prefix_preserves_query_string(self): ++ redirect = Redirect("/legacy", "items", True, True) ++ request = self.request("/legacy/article", "page=2") ++ request.route_url = lambda route: "https://app.example/" + route ++ self.assertEqual( ++ lookup([redirect], request), "https://app.example/items/article?page=2" ++ ) ++ ++ def test_exact_redirect_preserves_query_string(self): ++ redirect = Redirect("/legacy", "https://new.example/items", False, False) ++ self.assertEqual( ++ lookup([redirect], self.request("/legacy", "next=%2Fhome")), ++ "https://new.example/items?next=%2Fhome", ++ ) ++ ++ def test_internal_exact_preserves_query_string(self): ++ redirect = Redirect("/legacy", "items", False, True) ++ request = self.request("/legacy", "next=%2Fhome") ++ request.route_url = lambda route: "https://app.example/" + route ++ self.assertEqual( ++ lookup([redirect], request), "https://app.example/items?next=%2Fhome" ++ ) ++ ++ def test_query_is_not_added_when_request_has_no_query(self): ++ redirect = Redirect("/legacy", "https://new.example/items?source=old", False, False) ++ self.assertEqual( ++ lookup([redirect], self.request("/legacy")), ++ "https://new.example/items?source=old", ++ ) ++ ++ def test_query_is_appended_to_destination_query(self): ++ redirect = Redirect("/legacy", "https://new.example/items?source=old", True, False) ++ self.assertEqual( ++ lookup([redirect], self.request("/legacy/article", "page=2")), ++ "https://new.example/items/article?source=old&page=2", ++ ) ++ ++ def test_query_is_inserted_before_destination_fragment(self): ++ redirect = Redirect("/legacy", "https://new.example/items#section", False, False) ++ self.assertEqual( ++ lookup([redirect], self.request("/legacy", "page=2")), ++ "https://new.example/items?page=2#section", ++ ) ++ ++ def test_repeated_query_parameters_are_preserved_verbatim(self): ++ redirect = Redirect("/legacy", "https://new.example/items", False, False) ++ self.assertEqual( ++ lookup([redirect], self.request("/legacy", "tag=a&tag=b")), ++ "https://new.example/items?tag=a&tag=b", ++ ) ++ ++ def test_first_matching_rule_still_has_priority(self): ++ redirects = [ ++ Redirect("/legacy", "https://first.example", True, False), ++ Redirect("/legacy/article", "https://second.example", False, False), ++ ] ++ self.assertEqual( ++ lookup(redirects, self.request("/legacy/article", "x=1")), ++ "https://first.example/article?x=1", ++ ) ++ ++ def test_tween_returns_301_and_does_not_call_handler_for_redirect(self): ++ called = [] ++ ++ def handler(request): ++ called.append(request) ++ return Response() ++ ++ tween = tweens.redirect_tween_factory( ++ handler, ++ registry=None, ++ redirects=[Redirect("/legacy", "https://new.example", True, False)], ++ ) ++ response = tween(self.request("/legacy/article", "x=1")) ++ self.assertEqual(response.status_code, 301) ++ self.assertEqual(response.location, "https://new.example/article?x=1") ++ self.assertEqual(called, []) ++ ++ def test_tween_passes_non_redirected_request_to_handler(self): ++ called = [] ++ ++ def handler(request): ++ called.append(request.path) ++ return Response() ++ ++ request = self.request("/current", "x=1") ++ tween = tweens.redirect_tween_factory( ++ handler, ++ registry=None, ++ redirects=[Redirect("/legacy", "https://new.example", True, False)], ++ ) ++ response = tween(request) ++ self.assertEqual(response.status_code, 200) ++ self.assertEqual(called, ["/current"]) ++ ++ def test_parser_retains_destination_with_query_parameters(self): ++ self.assertEqual( ++ parse(["/legacy exact https://new.example/items?source=old"])[0].dst, ++ "https://new.example/items?source=old", ++ ) ++ ++ def test_parser_ignores_comments_after_leading_whitespace(self): ++ self.assertEqual( ++ parse([" # an explanatory comment", "\t", "/legacy exact https://new.example"]), ++ [Redirect("/legacy", "https://new.example", False, False)], ++ ) ++ ++ ++if __name__ == "__main__": ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++PYTHONPATH=. python -m unittest tests.codespec_redirects_contract_test diff --git a/tasks/format-code-task-001053/tests/test.sh b/tasks/format-code-task-001053/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..077b2e0f3ef105b80da0d8a5873dcaacf684f84f --- /dev/null +++ b/tasks/format-code-task-001053/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/codespec_redirects_contract_test.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001053/tests/test_command.sh b/tasks/format-code-task-001053/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001053/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001055/environment/Dockerfile b/tasks/format-code-task-001055/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f4586ce6d189c9e6bc31d92381bb8d41356b53c6 --- /dev/null +++ b/tasks/format-code-task-001055/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f5bb9128b47c3b3cb62b940b0ecdb2f1fa465d4ab849cccde3a32b3c6c7b340a diff --git a/tasks/format-code-task-001055/environment/setup/files/blocklist b/tasks/format-code-task-001055/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001055/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001055/environment/setup/setup.sh b/tasks/format-code-task-001055/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001055/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001055/tests/test.patch b/tasks/format-code-task-001055/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8f013787e941a28f7d826b24af4f9c6eaa032a10 --- /dev/null +++ b/tasks/format-code-task-001055/tests/test.patch @@ -0,0 +1,141 @@ +diff --git a/libbeat/common/dtfmt/codespec_fraction_zone_test.go b/libbeat/common/dtfmt/codespec_fraction_zone_test.go +new file mode 100644 +index 0000000000..784d779950 +--- /dev/null ++++ b/libbeat/common/dtfmt/codespec_fraction_zone_test.go +@@ -0,0 +1,117 @@ ++package dtfmt_test ++ ++import ( ++ "bytes" ++ "testing" ++ "time" ++ ++ "github.com/elastic/beats/libbeat/common/dtfmt" ++) ++ ++func codespecFormat(t *testing.T, value time.Time, pattern string) string { ++ t.Helper() ++ got, err := dtfmt.Format(value, pattern) ++ if err != nil { ++ t.Fatalf("Format(%q) returned error: %v", pattern, err) ++ } ++ return got ++} ++ ++func TestCodeSpecFractionalSecondWidths(t *testing.T) { ++ value := time.Date(2024, time.February, 3, 4, 5, 6, 987654321, time.UTC) ++ tests := []struct { ++ pattern string ++ want string ++ }{ ++ {"S", "9"}, ++ {"SS", "98"}, ++ {"SSS", "987"}, ++ {"SSSSSS", "987654"}, ++ {"SSSSSSSSS", "987654321"}, ++ {"HH:mm:ss.SSSSSSSSS", "04:05:06.987654321"}, ++ } ++ for _, test := range tests { ++ if got := codespecFormat(t, value, test.pattern); got != test.want { ++ t.Errorf("pattern %q: got %q, want %q", test.pattern, got, test.want) ++ } ++ } ++ ++ lowPrecision := time.Date(2024, time.February, 3, 4, 5, 6, 5_000_000, time.UTC) ++ if got := codespecFormat(t, lowPrecision, "S|SSS|SSSSSSSSS"); got != "0|005|005000000" { ++ t.Errorf("fractional seconds must be zero-padded without rounding: got %q", got) ++ } ++} ++ ++func TestCodeSpecFractionalSecondWidthValidation(t *testing.T) { ++ if _, err := dtfmt.NewFormatter("SSSSSSSSSS"); err == nil { ++ t.Fatal("NewFormatter accepted a fractional-second token wider than 9 digits") ++ } ++} ++ ++func TestCodeSpecNumericZoneOffsets(t *testing.T) { ++ tests := []struct { ++ name string ++ offset int ++ want string ++ }{ ++ {"east", 5*60*60 + 45*60, "+0545|+05:45"}, ++ {"west", -(3*60*60 + 30*60), "-0330|-03:30"}, ++ {"utc", 0, "+0000|+00:00"}, ++ } ++ for _, test := range tests { ++ value := time.Date(2024, time.June, 7, 8, 9, 10, 0, time.FixedZone(test.name, test.offset)) ++ if got := codespecFormat(t, value, "Z|ZZ"); got != test.want { ++ t.Errorf("%s offset: got %q, want %q", test.name, got, test.want) ++ } ++ } ++} ++ ++func TestCodeSpecZoneIdentityAndAbbreviation(t *testing.T) { ++ loc, err := time.LoadLocation("America/St_Johns") ++ if err != nil { ++ t.Fatalf("load deterministic test location: %v", err) ++ } ++ value := time.Date(2024, time.June, 7, 8, 9, 10, 0, loc) ++ if got := codespecFormat(t, value, "z|zz|zzz|zzzz|zzzzz|ZZZ|ZZZZZ"); got != "NDT|NDT|NDT|NDT|NDT|America/St_Johns|America/St_Johns" { ++ t.Errorf("zone name/id formatting mismatch: got %q", got) ++ } ++ ++ loc = time.FixedZone("Custom/Research_Base", -(9*60*60 + 30*60)) ++ value = time.Date(2024, time.December, 31, 23, 58, 0, 0, loc) ++ if got := codespecFormat(t, value, "yyyy-MM-dd HH:mm z Z ZZ ZZZ"); got != "2024-12-31 23:58 Custom/Research_Base -0930 -09:30 Custom/Research_Base" { ++ t.Errorf("formatter did not use the supplied time's zone data: got %q", got) ++ } ++} ++ ++func TestCodeSpecZoneAndFractionLiterals(t *testing.T) { ++ value := time.Date(2024, time.January, 2, 3, 4, 5, 120_000_000, time.FixedZone("XST", 90*60)) ++ if got := codespecFormat(t, value, "'SSSSSSSSSS ZZZZ zzzz' S 'at' Z 'named' z"); got != "SSSSSSSSSS ZZZZ zzzz 1 at +0130 named XST" { ++ t.Errorf("tokens and quoted literals did not compose correctly: got %q", got) ++ } ++} ++ ++func TestCodeSpecFormatterOutputAPIsAgree(t *testing.T) { ++ value := time.Date(2030, time.November, 12, 13, 14, 15, 42_001_009, time.FixedZone("LAB", -(2*60*60+30*60))) ++ formatter, err := dtfmt.NewFormatter("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS ZZ z") ++ if err != nil { ++ t.Fatalf("NewFormatter returned error: %v", err) ++ } ++ want := "2030-11-12T13:14:15.042001009 -02:30 LAB" ++ ++ formatted, err := formatter.Format(value) ++ if err != nil || formatted != want { ++ t.Fatalf("Formatter.Format: got %q, %v; want %q, nil", formatted, err, want) ++ } ++ ++ prefix := []byte("prefix:") ++ appended, err := formatter.AppendTo(prefix, value) ++ if err != nil || string(appended) != "prefix:"+want { ++ t.Errorf("AppendTo: got %q, %v; want %q, nil", appended, err, "prefix:"+want) ++ } ++ ++ var dst bytes.Buffer ++ n, err := formatter.Write(&dst, value) ++ if err != nil || dst.String() != want || n != len(want) { ++ t.Errorf("Write: got (%d, %q, %v); want (%d, %q, nil)", n, dst.String(), err, len(want), want) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,13 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++REPO_GOPATH="$(mktemp -d)" ++VENDOR_GOPATH="$(mktemp -d)" ++mkdir -p "${REPO_GOPATH}/src/github.com/elastic" ++ln -s "$(pwd)" "${REPO_GOPATH}/src/github.com/elastic/beats" ++ln -s "$(pwd)/vendor" "${VENDOR_GOPATH}/src" ++GOROOT=/opt/go-1.20 \ ++ GOPATH="${REPO_GOPATH}:${VENDOR_GOPATH}" \ ++ GO111MODULE=off \ ++ /opt/go-1.20/bin/go test github.com/elastic/beats/libbeat/common/dtfmt diff --git a/tasks/format-code-task-001055/tests/test.sh b/tasks/format-code-task-001055/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..787a87c1ccb3a3a215f257e36e745931cd4eb81c --- /dev/null +++ b/tasks/format-code-task-001055/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +libbeat/common/dtfmt/codespec_fraction_zone_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001055/tests/test_command.sh b/tasks/format-code-task-001055/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001055/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001063/environment/Dockerfile b/tasks/format-code-task-001063/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d872e998f494de05376e14593022253953215bea --- /dev/null +++ b/tasks/format-code-task-001063/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ab9a1cf1b174da1f55ce006c6046e7f871f802c0ae1d566bdf1d5c638141a200 diff --git a/tasks/format-code-task-001063/environment/setup/files/blocklist b/tasks/format-code-task-001063/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001063/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001063/environment/setup/setup.sh b/tasks/format-code-task-001063/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001063/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001063/tests/test.patch b/tasks/format-code-task-001063/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..82e8daae37737c0160368e73d9c9c00760d5bd2e --- /dev/null +++ b/tasks/format-code-task-001063/tests/test.patch @@ -0,0 +1,115 @@ +diff --git a/quarkchain/evm/tests/test_typed_transaction_contract.py b/quarkchain/evm/tests/test_typed_transaction_contract.py +new file mode 100644 +index 00000000..ba644eab +--- /dev/null ++++ b/quarkchain/evm/tests/test_typed_transaction_contract.py +@@ -0,0 +1,99 @@ ++import rlp ++ ++from quarkchain.evm.solidity_abi_utils import typed_signature_hash, tx_to_typed_data ++from quarkchain.evm.transactions import Transaction ++from quarkchain.evm.utils import privtoaddr ++ ++ ++KEY = bytes.fromhex("11" * 32) ++ ++ ++def make_tx(**overrides): ++ values = dict( ++ nonce=0x0D, ++ gasprice=0x02540BE400, ++ startgas=0x7530, ++ to=bytes.fromhex("314b2cd22c6d26618ce051a58c65af1253aecbb8"), ++ value=0x056BC75E2D63100000, ++ data=b"typed payload", ++ network_id=3, ++ from_full_shard_key=0xC47DECFF, ++ to_full_shard_key=0xC49C1951, ++ gas_token_id=0x102030405060708, ++ transfer_token_id=0x807060504030201, ++ ) ++ values.update(overrides) ++ return Transaction(**values) ++ ++ ++def test_typed_data_is_complete_and_canonical(): ++ tx = make_tx() ++ records = tx_to_typed_data(tx) ++ ++ assert [(item["type"], item["name"]) for item in records] == [ ++ ("uint256", "nonce"), ++ ("uint256", "gasPrice"), ++ ("uint256", "gasLimit"), ++ ("uint160", "to"), ++ ("uint256", "value"), ++ ("bytes", "data"), ++ ("uint256", "networkId"), ++ ("uint32", "fromFullShardKey"), ++ ("uint32", "toFullShardKey"), ++ ("uint64", "gasTokenId"), ++ ("uint64", "transferTokenId"), ++ ("string", "qkcDomain"), ++ ] ++ assert [item["value"] for item in records[:6]] == [ ++ "0x0d", ++ "0x02540be400", ++ "0x7530", ++ "0x314b2cd22c6d26618ce051a58c65af1253aecbb8", ++ "0x056bc75e2d63100000", ++ "0x7479706564207061796c6f6164", ++ ] ++ assert records[6]["value"] == "0x03" ++ assert records[7]["value"] == "0xc47decff" ++ assert records[8]["value"] == "0xc49c1951" ++ assert records[9]["value"] == "0x0102030405060708" ++ assert records[10]["value"] == "0x0807060504030201" ++ assert records[-1] == {"type": "string", "name": "qkcDomain", "value": "bottom-quark"} ++ ++ token_variant = make_tx(gas_token_id=0x102030405060709) ++ network_variant = make_tx(network_id=4) ++ assert typed_signature_hash(records) != typed_signature_hash( ++ tx_to_typed_data(token_variant) ++ ) ++ assert typed_signature_hash(records) != typed_signature_hash( ++ tx_to_typed_data(network_variant) ++ ) ++ ++ ++def test_typed_signing_recovers_after_rlp_round_trip(): ++ tx = make_tx() ++ assert tx.sign_typed(KEY) is tx ++ assert tx.version == 1 ++ assert tx.sender == privtoaddr(KEY) ++ ++ decoded = rlp.decode(rlp.encode(tx), Transaction) ++ assert decoded.version == 1 ++ assert decoded.sender == privtoaddr(KEY) ++ ++ ++def test_typed_signing_honors_explicit_zero_network_override(): ++ tx = make_tx(network_id=3) ++ tx.sign_typed(KEY, network_id=0) ++ assert tx.network_id == 0 ++ assert tx.sender == privtoaddr(KEY) ++ decoded = rlp.decode(rlp.encode(tx), Transaction) ++ assert decoded.network_id == 0 ++ assert decoded.sender == privtoaddr(KEY) ++ ++def test_legacy_signing_remains_version_zero(): ++ tx = make_tx() ++ assert tx.sign(KEY) is tx ++ assert tx.version == 0 ++ assert tx.sender == privtoaddr(KEY) ++ decoded = rlp.decode(rlp.encode(tx), Transaction) ++ assert decoded.version == 0 ++ assert decoded.sender == privtoaddr(KEY) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++python -m pytest -q quarkchain/evm/tests/test_typed_transaction_contract.py diff --git a/tasks/format-code-task-001063/tests/test.sh b/tasks/format-code-task-001063/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ff39afa5293558fc44eeb17f582f5095a832caa --- /dev/null +++ b/tasks/format-code-task-001063/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +quarkchain/evm/tests/test_typed_transaction_contract.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001063/tests/test_command.sh b/tasks/format-code-task-001063/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001063/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001064/environment/Dockerfile b/tasks/format-code-task-001064/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d7e0f4d25a0e599a420f6120199c5e5cca381612 --- /dev/null +++ b/tasks/format-code-task-001064/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4ae2eed3e60e10a493b4716f620f7a7fe7b0ab679423d034450edd276ade492c diff --git a/tasks/format-code-task-001064/environment/setup/files/blocklist b/tasks/format-code-task-001064/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001064/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001064/environment/setup/setup.sh b/tasks/format-code-task-001064/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001064/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001064/tests/test.patch b/tasks/format-code-task-001064/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8c77cd21dca14da469f6035394e449f0a71e2128 --- /dev/null +++ b/tasks/format-code-task-001064/tests/test.patch @@ -0,0 +1,258 @@ +diff --git a/tests/session/cmd/test_with_deps_synth.py b/tests/session/cmd/test_with_deps_synth.py +new file mode 100644 +index 0000000..5cd129a +--- /dev/null ++++ b/tests/session/cmd/test_with_deps_synth.py +@@ -0,0 +1,241 @@ ++from typing import Dict, List, Optional, Sequence ++ ++from tox.execute.request import ExecuteRequest ++from tox.pytest import ToxProject, ToxProjectCreator ++ ++ ++def make_project(tox_project: ToxProjectCreator, body: str) -> ToxProject: ++ return tox_project( ++ { ++ "tox.ini": f""" ++ [tox] ++ no_package = true ++ {body} ++ """, ++ } ++ ) ++ ++ ++def record_commands( ++ project: ToxProject, failures: Optional[Dict[str, int]] = None ++) -> List[str]: ++ seen: List[str] = [] ++ failures = {} if failures is None else failures ++ ++ def execute(request: ExecuteRequest) -> Optional[int]: ++ if request.run_id == "commands[0]": ++ name = request.cmd[-1] ++ seen.append(name) ++ return failures.get(name, 0) ++ return None ++ ++ project.patch_execute(execute) ++ return seen ++ ++ ++def assert_before(order: Sequence[str], first: str, second: str) -> None: ++ assert order.index(first) < order.index(second), order ++ ++ ++def test_with_deps_expands_transitive_shared_closure(tox_project: ToxProjectCreator) -> None: ++ project = make_project( ++ tox_project, ++ """ ++ env_list = app, docs, unrelated ++ [testenv] ++ commands = python -c 'pass' {env_name} ++ [testenv:app] ++ depends = unit, lint ++ [testenv:unit] ++ depends = bootstrap ++ [testenv:docs] ++ depends = lint ++ [testenv:unrelated] ++ """, ++ ) ++ seen = record_commands(project) ++ ++ outcome = project.run("r", "-e", "app,docs", "--with-deps") ++ ++ outcome.assert_success() ++ assert len(seen) == len(set(seen)) ++ assert set(seen) == {"bootstrap", "unit", "lint", "app", "docs"} ++ assert_before(seen, "bootstrap", "unit") ++ assert_before(seen, "unit", "app") ++ assert_before(seen, "lint", "app") ++ assert_before(seen, "lint", "docs") ++ ++ ++def test_with_deps_uses_default_selection_only(tox_project: ToxProjectCreator) -> None: ++ project = make_project( ++ tox_project, ++ """ ++ env_list = app ++ [testenv] ++ commands = python -c 'pass' {env_name} ++ [testenv:app] ++ depends = prepare ++ [testenv:extra] ++ """, ++ ) ++ seen = record_commands(project) ++ ++ outcome = project.run("r", "--with-deps") ++ ++ outcome.assert_success() ++ assert seen == ["prepare", "app"] ++ ++ ++def test_without_with_deps_keeps_selection_unchanged(tox_project: ToxProjectCreator) -> None: ++ project = make_project( ++ tox_project, ++ """ ++ env_list = app ++ [testenv] ++ commands = python -c 'pass' {env_name} ++ [testenv:app] ++ depends = prepare ++ """, ++ ) ++ seen = record_commands(project) ++ ++ outcome = project.run("r", "-e", "app") ++ ++ outcome.assert_success() ++ assert seen == ["app"] ++ ++ ++def test_with_deps_honors_materialized_override(tox_project: ToxProjectCreator) -> None: ++ project = make_project( ++ tox_project, ++ """ ++ env_list = app ++ [testenv] ++ commands = python -c 'pass' {env_name} ++ [testenv:app] ++ depends = stale ++ """, ++ ) ++ seen = record_commands(project) ++ ++ outcome = project.run("r", "-e", "app", "--with-deps", "-x", "testenv:app.depends=fresh") ++ ++ outcome.assert_success() ++ assert seen == ["fresh", "app"] ++ ++ ++def test_legacy_with_deps_matches_sequential_run(tox_project: ToxProjectCreator) -> None: ++ project = make_project( ++ tox_project, ++ """ ++ env_list = app ++ [testenv] ++ commands = python -c 'pass' {env_name} ++ [testenv:app] ++ depends = prepare ++ """, ++ ) ++ seen = record_commands(project) ++ ++ outcome = project.run("le", "-e", "app", "--with-deps") ++ ++ outcome.assert_success() ++ assert seen == ["prepare", "app"] ++ ++ ++def test_failed_dependency_blocks_sequential_dependent(tox_project: ToxProjectCreator) -> None: ++ project = make_project( ++ tox_project, ++ """ ++ env_list = app ++ [testenv] ++ commands = python -c 'pass' {env_name} ++ [testenv:app] ++ depends = middle ++ [testenv:middle] ++ depends = prepare ++ """, ++ ) ++ seen = record_commands(project, {"prepare": 7}) ++ ++ outcome = project.run("r", "-e", "app", "--with-deps") ++ ++ outcome.assert_failed() ++ assert seen == ["prepare"] ++ assert "middle: SKIP" in outcome.out ++ assert "app: SKIP" in outcome.out ++ ++ ++def test_skipped_dependency_blocks_dependent(tox_project: ToxProjectCreator) -> None: ++ project = make_project( ++ tox_project, ++ """ ++ skip_missing_interpreters = true ++ env_list = app ++ [testenv] ++ commands = python -c 'pass' {env_name} ++ [testenv:app] ++ depends = prepare ++ [testenv:prepare] ++ base_python = missing-with-deps-interpreter ++ """, ++ ) ++ seen = record_commands(project) ++ ++ outcome = project.run("r", "-e", "app", "--with-deps") ++ ++ outcome.assert_failed() ++ assert seen == [] ++ assert "prepare: SKIP" in outcome.out ++ assert "app: SKIP" in outcome.out ++ ++ ++def test_failed_dependency_blocks_parallel_transitive_branch_only(tox_project: ToxProjectCreator) -> None: ++ project = make_project( ++ tox_project, ++ """ ++ env_list = app, independent ++ [testenv] ++ commands = python -c 'pass' {env_name} ++ [testenv:app] ++ depends = middle ++ [testenv:middle] ++ depends = prepare ++ [testenv:independent] ++ """, ++ ) ++ seen = record_commands(project, {"prepare": 9}) ++ ++ outcome = project.run( ++ "p", "-e", "app,independent", "--with-deps", "-p", "2", "--parallel-no-spinner" ++ ) ++ ++ outcome.assert_failed() ++ assert set(seen) == {"prepare", "independent"} ++ assert "middle: SKIP" in outcome.out ++ assert "app: SKIP" in outcome.out ++ assert "independent: OK" in outcome.out ++ ++ ++def test_with_deps_cycle_fails_before_execution(tox_project: ToxProjectCreator) -> None: ++ project = make_project( ++ tox_project, ++ """ ++ env_list = cycle_left_olive, independent ++ [testenv] ++ commands = python -c 'pass' {env_name} ++ [testenv:cycle_left_olive] ++ depends = cycle_right_copper ++ [testenv:cycle_right_copper] ++ depends = cycle_left_olive ++ """, ++ ) ++ seen = record_commands(project) ++ ++ outcome = project.run("r", "-e", "cycle_left_olive,independent", "--with-deps") ++ ++ outcome.assert_failed() ++ assert seen == [] ++ message = f"{outcome.out}\n{outcome.err}".lower() ++ assert "cycle_left_olive" in message ++ assert "cycle_right_copper" in message +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/bin/bash ++set -euo pipefail ++ ++python -m pytest -q \ ++ tests/session/cmd/test_with_deps_synth.py \ ++ tests/session/cmd/test_depends.py diff --git a/tasks/format-code-task-001064/tests/test.sh b/tasks/format-code-task-001064/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6e99f7d06884315ebfcf11c134fb0ad096e8a1c0 --- /dev/null +++ b/tasks/format-code-task-001064/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/session/cmd/test_with_deps_synth.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001064/tests/test_command.sh b/tasks/format-code-task-001064/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001064/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001090/environment/Dockerfile b/tasks/format-code-task-001090/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5d45f05b5bb3c28ad1dbb7682f590d7d411f8809 --- /dev/null +++ b/tasks/format-code-task-001090/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e91de92ed2d8159d938244b817cc5d0de2f5b8f1eca4b5dd491245412ec05831 diff --git a/tasks/format-code-task-001090/environment/setup/files/blocklist b/tasks/format-code-task-001090/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001090/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001090/environment/setup/setup.sh b/tasks/format-code-task-001090/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001090/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001090/tests/test.patch b/tasks/format-code-task-001090/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..27cbe5fbed549610acb8cd57020b3099941a90de --- /dev/null +++ b/tasks/format-code-task-001090/tests/test.patch @@ -0,0 +1,133 @@ +diff --git a/internal/gitutil/submodule_contract_test.go b/internal/gitutil/submodule_contract_test.go +new file mode 100644 +index 000000000..295f175e3 +--- /dev/null ++++ b/internal/gitutil/submodule_contract_test.go +@@ -0,0 +1,117 @@ ++ ++ ++ ++ ++package gitutil ++ ++import ( ++ "testing" ++ ++ "github.com/gogs/git-module" ++ "github.com/stretchr/testify/require" ++) ++ ++func TestInferSubmoduleURLContract(t *testing.T) { ++ const commit = "6b08f76a5313fa3d26859515b30aa17a5faa2807" ++ const base = "https://gogs.example.com/team/app" ++ ++ tests := []struct { ++ name string ++ base string ++ url string ++ sha string ++ want string ++ }{ ++ { ++ name: "https repository strips suffix and preserves nested path", ++ base: base, ++ url: "https://github.com/acme/tools.git/", ++ sha: commit, ++ want: "https://github.com/acme/tools/commit/" + commit, ++ }, ++ { ++ name: "http repository is also linked with commit", ++ base: base, ++ url: "http://example.com/acme/tools.git", ++ sha: commit, ++ want: "http://example.com/acme/tools/commit/" + commit, ++ }, ++ { ++ name: "ssh URL drops user and uses web scheme", ++ base: base, ++ url: "ssh://deploy@example.com:2222/acme/tools.git", ++ sha: commit, ++ want: "http://example.com/acme/tools/commit/" + commit, ++ }, ++ { ++ name: "scp URL converts host and path", ++ base: base, ++ url: "git@example.com:acme/tools.git", ++ sha: commit, ++ want: "http://example.com/acme/tools/commit/" + commit, ++ }, ++ { ++ name: "relative parent resolves against repository URL", ++ base: base, ++ url: "../shared.git", ++ sha: commit, ++ want: "https://gogs.example.com/team/shared/commit/" + commit, ++ }, ++ { ++ name: "relative child resolves against repository directory", ++ base: base, ++ url: "vendor/lib.git", ++ sha: commit, ++ want: "https://gogs.example.com/team/app/vendor/lib/commit/" + commit, ++ }, ++ { ++ name: "dot relative child accepts trailing slash base", ++ base: base + "/", ++ url: "./vendor/lib.git", ++ sha: commit, ++ want: "https://gogs.example.com/team/app/vendor/lib/commit/" + commit, ++ }, ++ { ++ name: "query and fragment are retained on repository URL", ++ base: base, ++ url: "https://example.com/acme/tools.git?ref=stable#readme", ++ sha: commit, ++ want: "https://example.com/acme/tools/commit/" + commit + "?ref=stable#readme", ++ }, ++ { ++ name: "empty commit returns normalized repository URL", ++ base: base, ++ url: "https://example.com/acme/tools.git", ++ sha: "", ++ want: "https://example.com/acme/tools", ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ got := InferSubmoduleURL(tt.base, &git.Submodule{URL: tt.url, Commit: tt.sha}) ++ require.Equal(t, tt.want, got) ++ }) ++ } ++} ++ ++func TestInferSubmoduleURLContractUnsupportedScheme(t *testing.T) { ++ const commit = "6b08f76a5313fa3d26859515b30aa17a5faa2807" ++ url := "ftp://example.com/acme/tools" ++ got := InferSubmoduleURL("https://gogs.example.com/team/app", &git.Submodule{URL: url, Commit: commit}) ++ require.Equal(t, url, got) ++} ++ ++func TestInferSubmoduleURLContractMalformed(t *testing.T) { ++ const commit = "6b08f76a5313fa3d26859515b30aa17a5faa2807" ++ url := "https://example.com/%zz" ++ got := InferSubmoduleURL("https://gogs.example.com/team/app", &git.Submodule{URL: url, Commit: commit}) ++ require.Equal(t, url, got) ++} ++ ++func TestInferSubmoduleURLContractEmpty(t *testing.T) { ++ const commit = "6b08f76a5313fa3d26859515b30aa17a5faa2807" ++ url := "" ++ got := InferSubmoduleURL("https://gogs.example.com/team/app", &git.Submodule{URL: url, Commit: commit}) ++ require.Equal(t, url, got) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++go test ./internal/gitutil -run 'TestInferSubmoduleURLContract' -count=1 diff --git a/tasks/format-code-task-001090/tests/test.sh b/tasks/format-code-task-001090/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4ffc8e2992114b78460d3dfc67fd815c4f8e061b --- /dev/null +++ b/tasks/format-code-task-001090/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +internal/gitutil/submodule_contract_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001090/tests/test_command.sh b/tasks/format-code-task-001090/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001090/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001091/environment/Dockerfile b/tasks/format-code-task-001091/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c0cc67f15aa3e39b8ab3edd8d1d7d378acb59673 --- /dev/null +++ b/tasks/format-code-task-001091/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:19478b15f1faae0399a5e18b29b8dd898e26782f0d5dbd1608ec7b4cb3dc45a9 diff --git a/tasks/format-code-task-001091/environment/setup/files/blocklist b/tasks/format-code-task-001091/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001091/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001091/environment/setup/setup.sh b/tasks/format-code-task-001091/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001091/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001091/tests/test.patch b/tasks/format-code-task-001091/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..056d81f9c42e1bc74f02575f1ac7d95f15edd871 --- /dev/null +++ b/tasks/format-code-task-001091/tests/test.patch @@ -0,0 +1,318 @@ +diff --git a/docs/js/codespec-search-test.js b/docs/js/codespec-search-test.js +new file mode 100644 +index 0000000000..fadc829ebb +--- /dev/null ++++ b/docs/js/codespec-search-test.js +@@ -0,0 +1,302 @@ ++const assert = require('assert'); ++const fs = require('fs'); ++const vm = require('vm'); ++ ++const SEARCH_SOURCE = fs.readFileSync('docs/js/search.js', 'utf8'); ++const ELASTIC_SOURCE = fs.readFileSync('docs/js/elasticlunr.min.js', 'utf8'); ++ ++function escapeText(value) { ++ return String(value) ++ .replace(/&/g, '&') ++ .replace(//g, '>'); ++} ++ ++function escapeAttribute(value) { ++ return escapeText(value).replace(/"/g, '"'); ++} ++ ++class Element { ++ constructor(tagName) { ++ this.tagName = tagName.toLowerCase(); ++ this.children = []; ++ this.attributes = Object.create(null); ++ this._text = ''; ++ this._rawHtml = null; ++ } ++ ++ setAttribute(name, value) { ++ this.attributes[name] = String(value); ++ } ++ ++ getAttribute(name) { ++ return Object.prototype.hasOwnProperty.call(this.attributes, name) ++ ? this.attributes[name] ++ : null; ++ } ++ ++ appendChild(child) { ++ this._rawHtml = null; ++ this._text = ''; ++ this.children.push(child); ++ return child; ++ } ++ ++ append(...children) { ++ for (const child of children) this.appendChild(child); ++ } ++ ++ replaceChildren(...children) { ++ this._rawHtml = null; ++ this._text = ''; ++ this.children = children; ++ } ++ ++ removeChild(child) { ++ const index = this.children.indexOf(child); ++ if (index >= 0) this.children.splice(index, 1); ++ return child; ++ } ++ ++ get firstChild() { ++ return this.children.length ? this.children[0] : null; ++ } ++ ++ set textContent(value) { ++ this._rawHtml = null; ++ this.children = []; ++ this._text = String(value); ++ } ++ ++ get textContent() { ++ if (this._rawHtml !== null) return stripMarkup(this._rawHtml); ++ return this._text + this.children.map(childText).join(''); ++ } ++ ++ set innerText(value) { this.textContent = value; } ++ get innerText() { return this.textContent; } ++ ++ set innerHTML(value) { ++ this.children = []; ++ this._text = ''; ++ this._rawHtml = String(value); ++ } ++ ++ get innerHTML() { ++ if (this._rawHtml !== null) return this._rawHtml; ++ return escapeText(this._text) + this.children.map(serialize).join(''); ++ } ++ ++ set value(value) { this.setAttribute('value', value); } ++ get value() { return this.getAttribute('value') || ''; } ++ set href(value) { this.setAttribute('href', value); } ++ get href() { return this.getAttribute('href') || ''; } ++ set className(value) { this.setAttribute('class', value); } ++ get className() { return this.getAttribute('class') || ''; } ++} ++ ++class DocumentFragment extends Element { ++ constructor() { super('#fragment'); } ++} ++ ++function childText(child) { ++ return typeof child === 'string' ? child : child.textContent; ++} ++ ++function serialize(child) { ++ if (typeof child === 'string') return escapeText(child); ++ if (child instanceof DocumentFragment) return child.innerHTML; ++ const attrs = Object.keys(child.attributes) ++ .map(name => ` ${name}="${escapeAttribute(child.attributes[name])}"`) ++ .join(''); ++ return `<${child.tagName}${attrs}>${child.innerHTML}`; ++} ++ ++function stripMarkup(html) { ++ return html ++ .replace(/<[^>]*>/g, '') ++ .replace(/</g, '<') ++ .replace(/>/g, '>') ++ .replace(/"/g, '"') ++ .replace(/&/g, '&'); ++} ++ ++function runSearch(search, store) { ++ const searchBox = new Element('input'); ++ const results = new Element('ul'); ++ const document = { ++ getElementById(id) { ++ if (id === 'search-box') return searchBox; ++ if (id === 'search-results') return results; ++ return null; ++ }, ++ createElement(tagName) { return new Element(tagName); }, ++ createTextNode(text) { return String(text); }, ++ createDocumentFragment() { return new DocumentFragment(); } ++ }; ++ const context = { ++ console, ++ document, ++ URL, ++ URLSearchParams, ++ window: { ++ location: { ++ search, ++ href: `https://docs.example/search.html${search}`, ++ origin: 'https://docs.example' ++ }, ++ store ++ }, ++ setTimeout, ++ clearTimeout ++ }; ++ context.window.window = context.window; ++ context.window.document = document; ++ context.window.URL = URL; ++ context.window.URLSearchParams = URLSearchParams; ++ vm.createContext(context); ++ vm.runInContext(ELASTIC_SOURCE, context, { filename: 'elasticlunr.min.js' }); ++ context.window.elasticlunr = context.elasticlunr; ++ vm.runInContext(SEARCH_SOURCE, context, { filename: 'search.js' }); ++ return { searchBox, results, html: results.innerHTML, text: results.textContent }; ++} ++ ++function count(haystack, needle) { ++ return haystack.split(needle).length - 1; ++} ++ ++function testQueryDecodingAndBlankQueries() { ++ const decoded = runSearch('?other=x&query=++Scala+Guide++', { ++ one: { title: 'Scala Guide', author: '', content: 'A useful Scala Guide.', url: 'guide.html' } ++ }); ++ assert.strictEqual(decoded.searchBox.getAttribute('value'), 'Scala Guide', ++ 'the displayed query should be plus-decoded and trimmed'); ++ assert(decoded.text.includes('Scala Guide'), 'the normalized query should be searched'); ++ ++ const blank = runSearch('?query=++++', { ++ one: { title: 'Anything', author: '', content: 'Anything', url: 'anything.html' } ++ }); ++ assert.strictEqual(blank.searchBox.value, '', 'blank queries should display as empty'); ++ assert.strictEqual(blank.html, '', 'blank queries should not render a no-results message'); ++ ++ assert.doesNotThrow(() => runSearch('?query=%ZZ', {}), ++ 'malformed percent escapes should not crash search-page initialization'); ++ ++ const valueless = runSearch('?query', { ++ one: { title: 'Anything', content: 'Anything', url: 'anything.html' } ++ }); ++ assert.strictEqual(valueless.searchBox.value, '', 'a valueless query parameter should display as blank'); ++ assert.strictEqual(valueless.html, '', 'a valueless query parameter should not run a search'); ++ ++ const missing = runSearch('?other=value', { ++ one: { title: 'Anything', content: 'Anything', url: 'anything.html' } ++ }); ++ assert.strictEqual(missing.searchBox.value, '', 'a missing query parameter should display as blank'); ++ assert.strictEqual(missing.html, '', 'a missing query parameter should not run a search'); ++} ++ ++function testCompleteRankedStoreSearch() { ++ const inherited = { inherited: { title: 'Scala inherited', content: 'Scala', url: 'bad.html' } }; ++ const store = Object.create(inherited); ++ store.contentHit = { title: 'Reference', content: 'Scala appears in content.', url: 'reference.html' }; ++ store.authorHit = { title: 'Biography', author: 'Scala', content: '', url: 'biography.html' }; ++ store.titleHit = { title: 'Scala Language', url: 'language.html' }; ++ ++ const rendered = runSearch('?query=scala', store); ++ assert.strictEqual(count(rendered.html, ']*)?>scala<\/mark>/gi) || []).length, 2, ++ 'literal matches should be highlighted case-insensitively while preserving their text'); ++ assert(/]*)?>Scala<\/mark>/.test(rendered.html), ++ 'highlighting should preserve the first match casing'); ++ assert(/]*)?>SCALA<\/mark>/.test(rendered.html), ++ 'highlighting should preserve the later match casing'); ++ const snippet = rendered.html.match(/]*class="[^"]*result-text[^"]*"[^>]*>([\s\S]*?)<\/p>/); ++ assert(snippet, 'the result should contain a result-text paragraph'); ++ assert(stripMarkup(snippet[1]).length <= 153, ++ 'the snippet should contain at most 150 source characters plus an ellipsis'); ++ assert(rendered.text.includes('middle'), 'the bounded snippet should retain context around the match'); ++} ++ ++function testSafeMarkupAndHighlightLinks() { ++ const rendered = runSearch('?query=a%26b', { ++ one: { ++ title: ' a&b', ++ author: '', ++ content: ' a&b', ++ url: 'guide.html?lang=en#part' ++ } ++ }); ++ assert(!rendered.html.includes(' after', url: 'image.html' } ++ }); ++ assert(!maliciousQuery.html.includes(''), 'query text used for highlighting must not become markup'); ++ assert(maliciousQuery.html.includes('<img>'), 'the literal query match should remain visible'); ++} ++ ++const tests = [ ++ testQueryDecodingAndBlankQueries, ++ testCompleteRankedStoreSearch, ++ testSingleCaseInsensitiveContextSnippet, ++ testSafeMarkupAndHighlightLinks ++]; ++ ++let failures = 0; ++for (const test of tests) { ++ try { ++ test(); ++ console.log(`PASS ${test.name}`); ++ } catch (error) { ++ failures += 1; ++ console.error(`FAIL ${test.name}: ${error.stack || error}`); ++ } ++} ++ ++if (failures) process.exit(1); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++node docs/js/codespec-search-test.js diff --git a/tasks/format-code-task-001091/tests/test.sh b/tasks/format-code-task-001091/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0a607bd4d485457f3968be108876f61c0585751f --- /dev/null +++ b/tasks/format-code-task-001091/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +docs/js/codespec-search-test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001091/tests/test_command.sh b/tasks/format-code-task-001091/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001091/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001097/environment/Dockerfile b/tasks/format-code-task-001097/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fbf3f264ad966d082f2fab3e1008c8ca72f61314 --- /dev/null +++ b/tasks/format-code-task-001097/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:955194e2f6177cbeeebbc0d4629e74ef341d57e8f72ca935c246d5a536ebaaa0 diff --git a/tasks/format-code-task-001097/environment/setup/files/blocklist b/tasks/format-code-task-001097/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001097/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001097/environment/setup/setup.sh b/tasks/format-code-task-001097/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001097/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001097/tests/test.patch b/tasks/format-code-task-001097/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4a7bb88223ed6106c8b43c82bfc878445a476ca4 --- /dev/null +++ b/tasks/format-code-task-001097/tests/test.patch @@ -0,0 +1,84 @@ +diff --git a/test/transaction_builder_witness_order.js b/test/transaction_builder_witness_order.js +new file mode 100644 +index 00000000..4f56be1b +--- /dev/null ++++ b/test/transaction_builder_witness_order.js +@@ -0,0 +1,68 @@ ++ ++ ++var assert = require('assert') ++var BigInteger = require('bigi') ++var ECPair = require('../src/ecpair') ++var ECSignature = require('../src/ecsignature') ++var Transaction = require('../src/transaction') ++var TransactionBuilder = require('../src/transaction_builder') ++var bcrypto = require('../src/crypto') ++var btemplates = require('../src/templates') ++var NETWORK = require('../src/networks').bitcoin ++ ++var keys = [1, 2, 3].map(function (n) { ++ return new ECPair(BigInteger.valueOf(n)) ++}) ++var pubKeys = keys.map(function (key) { return key.getPublicKeyBuffer() }) ++var witnessScript = btemplates.multisig.output.encode(3, pubKeys) ++var witnessProgram = btemplates.witnessScriptHash.output.encode(bcrypto.sha256(witnessScript)) ++var redeemScript = witnessProgram ++var txHash = '11'.repeat(32) ++ ++function makePartiallySigned (nested, value) { ++ var txb = new TransactionBuilder(NETWORK) ++ var prevOutScript = nested ++ ? btemplates.scriptHash.output.encode(bcrypto.hash160(redeemScript)) ++ : witnessProgram ++ txb.addInput(txHash, 0, undefined, prevOutScript) ++ txb.addOutput('1111111111111111111114oLvT2', 90000) ++ txb.sign(0, keys[0], nested ? redeemScript : undefined, Transaction.SIGHASH_NONE, value, witnessScript) ++ txb.sign(0, keys[2], nested ? redeemScript : undefined, Transaction.SIGHASH_SINGLE, value, witnessScript) ++ ++ var tx = txb.buildIncomplete() ++ var witness = tx.ins[0].witness ++ var firstSignature = witness[1] ++ witness[1] = witness[3] ++ witness[3] = firstSignature ++ return tx ++} ++ ++function assertWitnessSignaturesMatchPubkeys (tx, value) { ++ var witness = tx.ins[0].witness ++ var signatures = witness.slice(1, -1) ++ assert.strictEqual(witness[0].length, 0) ++ assert.deepEqual(witness[witness.length - 1], witnessScript) ++ assert.strictEqual(signatures.length, 3) ++ signatures.forEach(function (signature, i) { ++ var parsed = ECSignature.parseScriptSignature(signature) ++ assert.strictEqual(parsed.hashType, [Transaction.SIGHASH_NONE, Transaction.SIGHASH_ALL, Transaction.SIGHASH_SINGLE][i]) ++ var sighash = tx.hashForWitnessV0(0, witnessScript, value, parsed.hashType) ++ assert.strictEqual(keys[i].verify(sighash, parsed.signature), true, 'signature ' + i + ' must match witnessScript pubkey ' + i) ++ }) ++} ++ ++describe('TransactionBuilder imported P2WSH multisig ordering', function () { ++ it('restores native P2WSH signature positions before continuing to sign', function () { ++ var txb = TransactionBuilder.fromTransaction(makePartiallySigned(false, 100000), NETWORK) ++ txb.sign(0, keys[1], undefined, undefined, 100000, witnessScript) ++ ++ assertWitnessSignaturesMatchPubkeys(txb.build(), 100000) ++ }) ++ ++ it('restores nested P2SH-P2WSH signature positions before continuing to sign', function () { ++ var txb = TransactionBuilder.fromTransaction(makePartiallySigned(true, 120000), NETWORK) ++ txb.sign(0, keys[1], redeemScript, undefined, 120000, witnessScript) ++ ++ assertWitnessSignaturesMatchPubkeys(txb.build(), 120000) ++ }) ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,5 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++./node_modules/.bin/mocha test/transaction_builder_witness_order.js test/transaction_builder.js diff --git a/tasks/format-code-task-001097/tests/test.sh b/tasks/format-code-task-001097/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b1aaa2213857aedfbc5af72d6c81c369ede622e5 --- /dev/null +++ b/tasks/format-code-task-001097/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/transaction_builder_witness_order.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001097/tests/test_command.sh b/tasks/format-code-task-001097/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001097/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001203/environment/Dockerfile b/tasks/format-code-task-001203/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..240e9e59ac306a300ae882a35b2353e2c26e3d14 --- /dev/null +++ b/tasks/format-code-task-001203/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6b01311bf0f74b3d906cfab774d652a5b26bceb2019e9fe8b06b1f66c1369335 diff --git a/tasks/format-code-task-001203/environment/setup/files/blocklist b/tasks/format-code-task-001203/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001203/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001203/environment/setup/setup.sh b/tasks/format-code-task-001203/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001203/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001203/tests/test.patch b/tasks/format-code-task-001203/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2155aa24ea8ea2c97d7fe3f96eee8caecf3d7e42 --- /dev/null +++ b/tasks/format-code-task-001203/tests/test.patch @@ -0,0 +1,64 @@ +diff --git a/spec/policies/api_secret_policy_spec.rb b/spec/policies/api_secret_policy_spec.rb +index 3fad0044c4ff1..be48d7b1cb5fd 100644 +--- a/spec/policies/api_secret_policy_spec.rb ++++ b/spec/policies/api_secret_policy_spec.rb +@@ -28,4 +28,11 @@ + it { is_expected.to forbid_actions %i[destroy] } + it { is_expected.to permit_mass_assignment_of(valid_attributes) } + end ++ ++ context "when the user is banned" do ++ let(:user) { create(:user, :banned) } ++ let(:api_secret) { build_stubbed(:api_secret) } ++ ++ it { is_expected.to forbid_actions %i[create] } ++ end + end +diff --git a/spec/requests/api/v0/articles_spec.rb b/spec/requests/api/v0/articles_spec.rb +index 94925ffbe3a09..cc4c33f8eee7e 100644 +--- a/spec/requests/api/v0/articles_spec.rb ++++ b/spec/requests/api/v0/articles_spec.rb +@@ -551,6 +551,12 @@ + expect(response).to have_http_status(:unauthorized) + end + ++ it "fails with a banned user" do ++ user.add_role(:banned) ++ post api_articles_path, headers: { "api-key" => api_secret.secret, "content-type" => "application/json" } ++ expect(response).to have_http_status(:unauthorized) ++ end ++ + it "fails with the wrong api key" do + post api_articles_path, headers: { "api-key" => "foobar", "content-type" => "application/json" } + expect(response).to have_http_status(:unauthorized) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,15 @@ ++H4sIAAAAAAAAA+2U247bNhCGfa2nmCqLor2Q6bMRAw6q2gpWjWO7lhMgVwJNTdZMqUNIysmm6buX ++tLH22tgmLZqgKMLvQqLEf36OOCM2NzUXWYrFjjS+Fi3DsN/f3w2X9/243e+0OoNurzvoNFrt9qDV ++a0D/q2V0j1ppKgEasiz1p3Sfm/+f0jzVX6PSKSvznBZZU22/3BqfqX+n3xke698ZDk39e4NutwGt ++L5fCX/ON1//Rd2TDC7KhauuxDPZNsMHM8x5BghrqCuTGNIeH76tSaliG6+uxf3W9eB6R5n7Gho/O ++Xqgtz9Xoykp9D3dUgH/1w34KeME1BGBX+9G3a0SFqiWCQrnjDBVQ8yDrouDFjVfdpFxJpNktBBX0 ++e90uPCEZ7khRCwGdJ9+34eNHMCqmBROmjiihPYCc8gJsUbXRHPWexIyrgAkOlTF/yOmgsKkYoyDI ++KOZlwT8g3JrE7luxWgoIFIiSUbEtlR497rRaD1n+7gGo2mqPuwwoqNKcKaSSbSFg4EdJ+kv4Mkzt ++Jo5JrSQRfEPe7HJTjbyWvAja7eBN9ltA82zQA1JWmpy57M0vfDO7aUTnFUHVrHjmn32CSUsgVtDu ++e3/c1doUiMuyyLHQsKOS041AdVf4JJmlk2i1Tp/GM5MkakaUEoSh1IowGtgBf80ZNQ3UZFLfxU3D ++dfhzmETpi9Vs7Fdms24kqrdiRIj9o0YVVepdKbOfTptpK02WkjLzNVRMcYeirFCm2WFk8/Mfsk/X ++UbL+l2vY9j+ar6JpnBwS3/eG8Ts5DLrDxxfKJEqSeDH/RyHxNHoW//q3IqJZmKzjSRKFq8n1IWKr ++dXUWYBvxGBAul+l08TyM52P/JOm2LiTL1WK9mCxOdsfZyWzxYhrPw9WrdD9M56HpUP9sk+5pwmWc ++PotefVqQRJNVtL7QrMJ4lqTR/OXYvr53+GRUU/PXIPDXUCBm5mTa1EUmEPA9MpCUCwXZZqTYFnM6 ++EiXNzvrcOK3qAvQWwZwIN8bULqDOTVRlrvZCqlJwxlERWvFUIZOo0/2729TOmwPuoJP4trY+Vkd2 ++LWIOG87M33Kn8v7rY93hcDgcDofD4XA4HA6Hw+FwOBwOh8PhcDgc3xh/AhVnir0AKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001203/tests/test.sh b/tasks/format-code-task-001203/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8744ba1563a27cdac5455d68c20a800e75f7a59f --- /dev/null +++ b/tasks/format-code-task-001203/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +spec/policies/api_secret_policy_spec.rb +spec/requests/api/v0/articles_spec.rb +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001203/tests/test_command.sh b/tasks/format-code-task-001203/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001203/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001204/environment/Dockerfile b/tasks/format-code-task-001204/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a97d05dcf556057454390b90b54be18381c8f1c1 --- /dev/null +++ b/tasks/format-code-task-001204/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:674ec3438d8eb965e564ea3a19174093be0dc0f449c02f3be0fd158deeee3472 diff --git a/tasks/format-code-task-001204/environment/setup/files/blocklist b/tasks/format-code-task-001204/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001204/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001204/environment/setup/setup.sh b/tasks/format-code-task-001204/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001204/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001204/tests/test.patch b/tasks/format-code-task-001204/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fd0fef8eae7acccedf69852d7cd982588c2bc2ff --- /dev/null +++ b/tasks/format-code-task-001204/tests/test.patch @@ -0,0 +1,303 @@ +diff --git a/apps/web/lib/airtable/service.test.ts b/apps/web/lib/airtable/service.test.ts +new file mode 100644 +index 000000000..8b7b05e0e +--- /dev/null ++++ b/apps/web/lib/airtable/service.test.ts +@@ -0,0 +1,264 @@ ++import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; ++ ++const { deleteIntegrationMock, storedIntegrations } = vi.hoisted(() => { ++ const integrations = new Map(); ++ const deleteMock = vi.fn(async (environmentId: string) => { ++ integrations.delete(environmentId); ++ }); ++ return { deleteIntegrationMock: deleteMock, storedIntegrations: integrations }; ++}); ++ ++vi.mock("@prisma/client", () => ({ ++ Prisma: { ++ PrismaClientKnownRequestError: class PrismaClientKnownRequestError extends Error {}, ++ }, ++})); ++ ++vi.mock("../integration/service", () => ({ ++ createOrUpdateIntegration: vi.fn(async (environmentId: string, integration: any) => { ++ storedIntegrations.set(environmentId, integration); ++ return integration; ++ }), ++ deleteIntegration: deleteIntegrationMock, ++ getIntegrationByType: vi.fn(async (environmentId: string, type: string) => { ++ return storedIntegrations.get(environmentId) ?? null; ++ }), ++})); ++ ++vi.mock("@formbricks/logger", () => ({ ++ logger: { ++ error: vi.fn(), ++ info: vi.fn(), ++ warn: vi.fn(), ++ }, ++})); ++ ++vi.mock("../constants", () => ({ ++ AIRTABLE_CLIENT_ID: "client-id-for-tests", ++ AIRTABLE_MESSAGE_LIMIT: 100000, ++})); ++ ++const jsonResponse = (body: any) => ++ ({ ++ ok: true, ++ status: 200, ++ json: vi.fn(async () => body), ++ }) as any; ++ ++const configData = { ++ baseId: "base_runtime", ++ tableId: "tbl_runtime", ++} as any; ++ ++const credential = { ++ access_token: "airtable-access-token", ++ refresh_token: "airtable-refresh-token", ++ expires_at: Math.floor(Date.now() / 1000) + 3600, ++} as any; ++ ++const isSchemaRequest = (url: string) => ++ url.includes("/meta/bases/") && url.endsWith("/tables"); ++const isFieldCreateRequest = (url: string) => ++ url.includes("/meta/bases/") && url.includes("/tables/") && url.endsWith("/fields"); ++const isRecordCreateRequest = (url: string) => ++ url.includes(`/v0/${configData.baseId}/${configData.tableId}`); ++ ++const tableSchema = (tableId: string, fields: string[]) => ({ ++ tables: [ ++ { ++ id: tableId, ++ name: "Responses", ++ fields: fields.map((name, index) => ({ id: `fld_${index}_${name}`, name })), ++ }, ++ ], ++}); ++ ++async function settleWithFakeTimers(promise: Promise): Promise { ++ let settled = false; ++ promise.finally(() => { ++ settled = true; ++ }); ++ for (let i = 0; i < 20 && !settled; i++) { ++ await Promise.resolve(); ++ await vi.runOnlyPendingTimersAsync(); ++ } ++ return promise; ++} ++ ++describe("Airtable service response sync", () => { ++ beforeEach(() => { ++ vi.useFakeTimers(); ++ storedIntegrations.clear(); ++ deleteIntegrationMock.mockClear(); ++ }); ++ ++ afterEach(() => { ++ vi.useRealTimers(); ++ vi.unstubAllGlobals(); ++ vi.restoreAllMocks(); ++ }); ++ ++ test("writeData_creates_missing_fields_without_parallel_rate_limit_failure", async () => { ++ const { writeData } = await import("./service"); ++ const fields = new Set(["Existing Question"]); ++ const createdFields: string[] = []; ++ const records: any[] = []; ++ let inFlightCreate = 0; ++ let rateLimitViolation = false; ++ ++ vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo, init?: RequestInit) => { ++ const url = String(input); ++ if (isSchemaRequest(url)) return jsonResponse(tableSchema(configData.tableId, Array.from(fields))); ++ if (isFieldCreateRequest(url)) { ++ inFlightCreate++; ++ if (inFlightCreate > 1) rateLimitViolation = true; ++ await Promise.resolve(); ++ const body = JSON.parse(String(init?.body ?? "{}")); ++ inFlightCreate--; ++ if (rateLimitViolation) return jsonResponse({ error: { type: "RATE_LIMIT" } }); ++ fields.add(body.name); ++ createdFields.push(body.name); ++ return jsonResponse({ id: `fld_${body.name}`, name: body.name }); ++ } ++ if (isRecordCreateRequest(url)) { ++ records.push(JSON.parse(String(init?.body ?? "{}"))); ++ return jsonResponse({ records: [{ id: "rec_1" }] }); ++ } ++ throw new Error(`unexpected Airtable request ${url}`); ++ })); ++ ++ const promise = writeData(credential, configData, [ ++ ["old answer", "new answer A", "new answer B"], ++ ["Existing Question", "New Question A", "New Question B"], ++ ] as any); ++ await expect(settleWithFakeTimers(promise)).resolves.toBeUndefined(); ++ expect(rateLimitViolation).toBe(false); ++ expect(createdFields).toHaveLength(2); ++ expect(createdFields).toEqual(expect.arrayContaining(["New Question A", "New Question B"])); ++ expect(records).toHaveLength(1); ++ expect(JSON.stringify(records[0])).toContain("new answer A"); ++ expect(JSON.stringify(records[0])).toContain("new answer B"); ++ }); ++ ++ test("writeData_aborts_when_field_creation_returns_error", async () => { ++ const { writeData } = await import("./service"); ++ const recordCreates: any[] = []; ++ vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo) => { ++ const url = String(input); ++ if (isSchemaRequest(url)) return jsonResponse(tableSchema(configData.tableId, ["Existing Question"])); ++ if (isFieldCreateRequest(url)) return jsonResponse({ error: { type: "INVALID_REQUEST", message: "bad field" } }); ++ if (isRecordCreateRequest(url)) { ++ recordCreates.push({}); ++ return jsonResponse({ records: [{ id: "rec_should_not_exist" }] }); ++ } ++ throw new Error(`unexpected Airtable request ${url}`); ++ })); ++ ++ await expect(writeData(credential, configData, [["broken answer"], ["Broken Question"]] as any)).rejects.toThrow( ++ Error ++ ); ++ expect(recordCreates).toHaveLength(0); ++ }); ++ ++ test("writeData_waits_for_schema_visibility_before_record_insert", async () => { ++ const { writeData } = await import("./service"); ++ const events: string[] = []; ++ const records: any[] = []; ++ let fieldCreateRequested = false; ++ vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo, init?: RequestInit) => { ++ const url = String(input); ++ if (isSchemaRequest(url)) { ++ const visible = fieldCreateRequested; ++ events.push(visible ? "schema-visible" : "schema-missing"); ++ return jsonResponse(tableSchema(configData.tableId, visible ? ["Delayed Question"] : [])); ++ } ++ if (isFieldCreateRequest(url)) { ++ const body = JSON.parse(String(init?.body ?? "{}")); ++ fieldCreateRequested = true; ++ events.push(`create:${body.name}`); ++ return jsonResponse({ id: `fld_${body.name}`, name: body.name }); ++ } ++ if (isRecordCreateRequest(url)) { ++ if (!events.includes("schema-visible")) throw new Error("record inserted before schema became visible"); ++ events.push("record"); ++ records.push(JSON.parse(String(init?.body ?? "{}"))); ++ return jsonResponse({ records: [{ id: "rec_1" }] }); ++ } ++ throw new Error(`unexpected Airtable request ${url}`); ++ })); ++ ++ await settleWithFakeTimers( ++ writeData(credential, configData, [["delayed answer"], ["Delayed Question"]] as any) ++ ); ++ expect(events.indexOf("record")).toBeGreaterThan(events.indexOf("schema-visible")); ++ expect(JSON.stringify(records[0])).toContain("delayed answer"); ++ }); ++ ++ test("writeData_times_out_if_created_fields_never_appear", async () => { ++ const { writeData } = await import("./service"); ++ const recordCreates: any[] = []; ++ let schemaFetches = 0; ++ vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo, init?: RequestInit) => { ++ const url = String(input); ++ if (isSchemaRequest(url)) { ++ schemaFetches++; ++ return jsonResponse(tableSchema(configData.tableId, [])); ++ } ++ if (isFieldCreateRequest(url)) { ++ const body = JSON.parse(String(init?.body ?? "{}")); ++ return jsonResponse({ id: `fld_${body.name}`, name: body.name }); ++ } ++ if (isRecordCreateRequest(url)) { ++ recordCreates.push({}); ++ return jsonResponse({ records: [{ id: "rec_should_not_exist" }] }); ++ } ++ throw new Error(`unexpected Airtable request ${url}`); ++ })); ++ ++ const promise = writeData(credential, configData, [["missing answer"], ["Never Appears"]] as any); ++ const error = await settleWithFakeTimers(promise.catch((err) => err)); ++ expect(error).toBeInstanceOf(Error); ++ expect(schemaFetches).toBeGreaterThan(1); ++ expect(recordCreates).toHaveLength(0); ++ }); ++ ++ test("writeData_fails_when_configured_table_is_missing", async () => { ++ const { writeData } = await import("./service"); ++ const missingConfig = { ...configData, tableId: "tbl_missing_runtime" } as any; ++ const fieldCreates: any[] = []; ++ const recordCreates: any[] = []; ++ vi.stubGlobal("fetch", vi.fn(async (input: RequestInfo) => { ++ const url = String(input); ++ if (isSchemaRequest(url)) return jsonResponse(tableSchema("tbl_some_other_table", ["Existing Question"])); ++ if (isFieldCreateRequest(url)) { ++ fieldCreates.push({}); ++ return jsonResponse({ id: "fld_should_not_exist" }); ++ } ++ if (url.includes(`/v0/${missingConfig.baseId}/${missingConfig.tableId}`)) { ++ recordCreates.push({}); ++ return jsonResponse({ records: [{ id: "rec_should_not_exist" }] }); ++ } ++ throw new Error(`unexpected Airtable request ${url}`); ++ })); ++ ++ await expect(writeData(credential, missingConfig, [["answer"], ["Question"]] as any)).rejects.toThrow(Error); ++ expect(fieldCreates).toHaveLength(0); ++ expect(recordCreates).toHaveLength(0); ++ }); ++ ++ test("getAirtableToken_failure_preserves_integration", async () => { ++ const { getAirtableToken } = await import("./service"); ++ const environmentId = "env_airtable_token_failure"; ++ const existingIntegration = { ++ id: "integration_airtable", ++ type: "airtable", ++ environmentId, ++ config: { intentionally: "malformed token config to trigger retrieval failure" }, ++ }; ++ storedIntegrations.set(environmentId, existingIntegration); ++ ++ await expect(getAirtableToken(environmentId)).rejects.toThrow(Error); ++ expect(storedIntegrations.get(environmentId)).toBe(existingIntegration); ++ expect(deleteIntegrationMock).not.toHaveBeenCalled(); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,28 @@ ++#!/bin/bash ++set -uo pipefail ++ ++cd /testbed ++export PATH="/opt/node-24/bin:$PATH" ++ ++if [ ! -d /testbed/node_modules ] || [ ! -x /testbed/node_modules/.bin/vitest ]; then ++ pnpm install --frozen-lockfile ++fi ++ ++cd /testbed/packages/logger && npx vite build 2>&1 ++ ++cd /testbed/apps/web ++ ++case "${1:-}" in ++ base) ++ npx vitest run --reporter=verbose \ ++ modules/auth/signup-without-verification-success/page.test.tsx \ ++ modules/auth/verification-requested/page.test.tsx ++ ;; ++ new) ++ npx vitest run --reporter=verbose lib/airtable/service.test.ts ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001204/tests/test.sh b/tasks/format-code-task-001204/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..886b3b06bb00711efec317626688332719b075c8 --- /dev/null +++ b/tasks/format-code-task-001204/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +apps/web/lib/airtable/service.test.ts +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001204/tests/test_command.sh b/tasks/format-code-task-001204/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001204/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001232/environment/Dockerfile b/tasks/format-code-task-001232/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2fa5dd015c16f4afb1707dfae199b1f2abe76838 --- /dev/null +++ b/tasks/format-code-task-001232/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9568364839dc75abe991d03b3e061e534212f44fa00fe9c4c04bd1d1613d1e47 diff --git a/tasks/format-code-task-001232/environment/setup/files/blocklist b/tasks/format-code-task-001232/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001232/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001232/environment/setup/setup.sh b/tasks/format-code-task-001232/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001232/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001232/tests/test.patch b/tasks/format-code-task-001232/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..57c2aae6f11953fa5ec271882c4222979155d15a --- /dev/null +++ b/tasks/format-code-task-001232/tests/test.patch @@ -0,0 +1,199 @@ +diff --git a/gaphor/core/styling/tests/test_important.py b/gaphor/core/styling/tests/test_important.py +new file mode 100644 +index 000000000..fa4aa5630 +--- /dev/null ++++ b/gaphor/core/styling/tests/test_important.py +@@ -0,0 +1,133 @@ ++ ++ ++from gaphor.core.styling import CompiledStyleSheet, parse_style_sheet ++from gaphor.core.styling.tests.test_selector import Node ++ ++ ++def test_important_beats_higher_specificity(): ++ ++ css = """ ++ * { color: #ff0000 !important } ++ mytype { color: #00ff00 } ++ """ ++ props = CompiledStyleSheet(css).match(Node("mytype")) ++ ++ assert props.get("color") == (1, 0, 0, 1) ++ ++ ++def test_important_beats_later_rule(): ++ ++ ++ css = """ ++ mytype { color: #ff0000 !important } ++ mytype { color: #00ff00 } ++ """ ++ props = CompiledStyleSheet(css).match(Node("mytype")) ++ ++ assert props.get("color") == (1, 0, 0, 1) ++ ++ ++def test_non_important_loses_to_important_regardless_of_order_and_specificity(): ++ ++ css = """ ++ mytype { color: #ff0000 !important } ++ mytype[subject] { color: #00ff00 } ++ """ ++ props = CompiledStyleSheet(css).match( ++ Node("mytype", attributes={"subject": "x"}) ++ ) ++ ++ assert props.get("color") == (1, 0, 0, 1) ++ ++ ++def test_important_vs_important_uses_specificity(): ++ ++ css = """ ++ * { color: #ff0000 !important } ++ mytype { color: #00ff00 !important } ++ """ ++ props = CompiledStyleSheet(css).match(Node("mytype")) ++ ++ assert props.get("color") == (0, 1, 0, 1) ++ ++ ++def test_important_vs_important_uses_source_order_on_tie(): ++ ++ css = """ ++ mytype { color: #ff0000 !important } ++ mytype { color: #00ff00 !important } ++ """ ++ props = CompiledStyleSheet(css).match(Node("mytype")) ++ ++ assert props.get("color") == (0, 1, 0, 1) ++ ++ ++def test_importance_is_per_declaration_not_per_rule(): ++ ++ ++ css = """ ++ * { ++ color: #ff0000 !important; ++ font-size: 10; ++ } ++ mytype { ++ color: #00ff00; ++ font-size: 20; ++ } ++ """ ++ props = CompiledStyleSheet(css).match(Node("mytype")) ++ ++ assert props.get("color") == (1, 0, 0, 1) ++ assert props.get("font-size") == 20 ++ ++ ++def test_important_does_not_corrupt_value(): ++ ++ css = """ ++ mytype { ++ color: #00ff00 !important; ++ font-size: 42 !important; ++ font-family: 'sans' !important; ++ } ++ """ ++ props = CompiledStyleSheet(css).match(Node("mytype")) ++ ++ assert props.get("color") == (0, 1, 0, 1) ++ assert props.get("font-size") == 42 ++ assert props.get("font-family") == "sans" ++ ++ ++def test_important_is_case_insensitive(): ++ css = """ ++ * { color: #ff0000 !IMPORTANT } ++ mytype { color: #00ff00 } ++ """ ++ props = CompiledStyleSheet(css).match(Node("mytype")) ++ ++ assert props.get("color") == (1, 0, 0, 1) ++ ++ ++def test_cascade_without_important_is_unchanged(): ++ ++ css = """ ++ * { color: #ff0000 } ++ mytype { color: #00ff00 } ++ """ ++ props = CompiledStyleSheet(css).match(Node("mytype")) ++ ++ assert props.get("color") == (0, 1, 0, 1) ++ ++ ++def test_parse_style_sheet_still_yields_value_mapping(): ++ ++ ++ css = """ ++ * { ++ font-size: 42 !important; ++ font-family: sans; ++ } ++ """ ++ _, declarations = next(parse_style_sheet(css)) ++ ++ assert declarations["font-size"] == 42 ++ assert declarations["font-family"] == "sans" +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,55 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++ ++PY=/usr/bin/python3.12 ++SITE_SRC=/testbed/.build_env/venv/lib/python3.12/site-packages ++RUNTIME_SP=/tmp/gaphor_runtime_sp ++ ++if [ ! -f "$RUNTIME_SP/.ready" ]; then ++ rm -rf "$RUNTIME_SP" ++ cp -r "$SITE_SRC" "$RUNTIME_SP" ++ "$PY" - "$RUNTIME_SP" <<'PY' ++import os, sys ++root = sys.argv[1] ++tag = ".cpython-312.pyc" ++for dirpath, _dirs, files in os.walk(root): ++ if os.path.basename(dirpath) != "__pycache__": ++ continue ++ parent = os.path.dirname(dirpath) ++ for f in files: ++ if f.endswith(tag): ++ dst = os.path.join(parent, f[: -len(tag)] + ".pyc") ++ if not os.path.exists(dst): ++ with open(os.path.join(dirpath, f), "rb") as r, open(dst, "wb") as w: ++ w.write(r.read()) ++PY ++ touch "$RUNTIME_SP/.ready" ++fi ++export PYTHONPATH="$RUNTIME_SP" ++ ++PYTEST_OPTS="-o addopts= -p no:cacheprovider -q" ++ ++ ++"$PY" -m pytest \ ++ gaphor/core/styling/tests/test_css.py \ ++ gaphor/core/styling/tests/test_selector.py \ ++ $PYTEST_OPTS ++ ++ ++"$PY" -m pytest \ ++ gaphor/core/styling/tests/test_important.py \ ++ $PYTEST_OPTS diff --git a/tasks/format-code-task-001232/tests/test.sh b/tasks/format-code-task-001232/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2cc77de598ecd6e6805bd51ac7f4db2d2dbe1acc --- /dev/null +++ b/tasks/format-code-task-001232/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +gaphor/core/styling/tests/test_important.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001232/tests/test_command.sh b/tasks/format-code-task-001232/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001232/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001235/environment/Dockerfile b/tasks/format-code-task-001235/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2788c616c972c75c78b823f801e731660bee4540 --- /dev/null +++ b/tasks/format-code-task-001235/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9faf1e1074ba757ac56f3376915caa63ad24500b9b6186d8f24637f1d56aed08 diff --git a/tasks/format-code-task-001235/environment/setup/files/blocklist b/tasks/format-code-task-001235/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001235/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001235/environment/setup/setup.sh b/tasks/format-code-task-001235/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001235/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001235/tests/test.patch b/tasks/format-code-task-001235/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c11a2aa4238f05febec0c0a26b7be14354fe894f --- /dev/null +++ b/tasks/format-code-task-001235/tests/test.patch @@ -0,0 +1,161 @@ +diff --git a/pkg/apis/core/v1beta1/helper/errors_stage2_test.go b/pkg/apis/core/v1beta1/helper/errors_stage2_test.go +new file mode 100644 +index 0000000000..4c3385a759 +--- /dev/null ++++ b/pkg/apis/core/v1beta1/helper/errors_stage2_test.go +@@ -0,0 +1,132 @@ ++package helper_test ++ ++import ( ++ "errors" ++ "os" ++ "strings" ++ "testing" ++ ++ gardencore "github.com/gardener/gardener/pkg/apis/core" ++ gardencorev1alpha1 "github.com/gardener/gardener/pkg/apis/core/v1alpha1" ++ gardencorev1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1" ++ . "github.com/gardener/gardener/pkg/apis/core/v1beta1/helper" ++) ++ ++func TestDetermineErrorCodesDistinguishesUnauthenticatedCredentialFailures(t *testing.T) { ++ tests := []string{ ++ "Authentication failed while validating cloud credentials", ++ "Authentication failed: invalid access key was rejected", ++ } ++ ++ for _, message := range tests { ++ t.Run(message, func(t *testing.T) { ++ codes := DetermineErrorCodes(errors.New(message)) ++ ++ assertContainsCode(t, codes, gardencorev1beta1.ErrorInfraUnauthenticated) ++ assertNotContainsCode(t, codes, gardencorev1beta1.ErrorInfraUnauthorized) ++ }) ++ } ++} ++ ++func TestDetermineErrorCodesClassifiesAuthorizationFailuresAsUnauthorized(t *testing.T) { ++ tests := []string{ ++ "AccessDenied: missing permission to create load balancer", ++ "request was not authorized by provider policy", ++ "Error 403: forbidden by infrastructure provider", ++ } ++ ++ for _, message := range tests { ++ t.Run(message, func(t *testing.T) { ++ codes := DetermineErrorCodes(errors.New(message)) ++ ++ assertContainsCode(t, codes, gardencorev1beta1.ErrorInfraUnauthorized) ++ assertNotContainsCode(t, codes, gardencorev1beta1.ErrorInfraUnauthenticated) ++ }) ++ } ++} ++ ++func TestShootStatusKnownCredentialAndAuthorizationErrorCodesAreDocumented(t *testing.T) { ++ contents := readFileForTest(t, "../../../../../docs/usage/shoot_status.md") ++ ++ ++ unauthenticatedEntry := lineContaining(t, contents, "`ERR_INFRA_UNAUTHENTICATED`") ++ assertLowerContains(t, unauthenticatedEntry, "authenticat") ++ assertLowerContains(t, unauthenticatedEntry, "credential") ++ ++ unauthorizedEntry := lineContaining(t, contents, "`ERR_INFRA_UNAUTHORIZED`") ++ if !strings.Contains(strings.ToLower(unauthorizedEntry), "authoriz") && ++ !strings.Contains(strings.ToLower(unauthorizedEntry), "forbid") && ++ !strings.Contains(strings.ToLower(unauthorizedEntry), "refus") { ++ t.Fatalf("ERR_INFRA_UNAUTHORIZED documentation should describe authorization refusal, got: %q", unauthorizedEntry) ++ } ++ ++ insufficientPrivilegesEntry := lineContaining(t, contents, "`ERR_INFRA_INSUFFICIENT_PRIVILEGES`") ++ assertLowerContains(t, insufficientPrivilegesEntry, "deprecated") ++ assertLowerContains(t, insufficientPrivilegesEntry, "err_infra_unauthorized") ++} ++ ++func TestErrorInfraUnauthenticatedConstantIsExposedInCoreAPIs(t *testing.T) { ++ ++ if got, want := string(gardencore.ErrorInfraUnauthenticated), "ERR_INFRA_UNAUTHENTICATED"; got != want { ++ t.Fatalf("core ErrorInfraUnauthenticated = %q, want %q", got, want) ++ } ++ if got, want := string(gardencorev1alpha1.ErrorInfraUnauthenticated), "ERR_INFRA_UNAUTHENTICATED"; got != want { ++ t.Fatalf("v1alpha1 ErrorInfraUnauthenticated = %q, want %q", got, want) ++ } ++ if got, want := string(gardencorev1beta1.ErrorInfraUnauthenticated), "ERR_INFRA_UNAUTHENTICATED"; got != want { ++ t.Fatalf("v1beta1 ErrorInfraUnauthenticated = %q, want %q", got, want) ++ } ++} ++ ++func TestUnauthenticatedInfrastructureErrorIsNonRetryable(t *testing.T) { ++ lastError := gardencorev1beta1.LastError{Codes: []gardencorev1beta1.ErrorCode{gardencorev1beta1.ErrorInfraUnauthenticated}} ++ if !HasNonRetryableErrorCode(lastError) { ++ t.Fatalf("expected %s to be treated as a non-retryable infrastructure error code", gardencorev1beta1.ErrorInfraUnauthenticated) ++ } ++} ++ ++func assertContainsCode(t *testing.T, codes []gardencorev1beta1.ErrorCode, want gardencorev1beta1.ErrorCode) { ++ t.Helper() ++ for _, code := range codes { ++ if code == want { ++ return ++ } ++ } ++ t.Fatalf("codes %v do not contain %s", codes, want) ++} ++ ++func assertNotContainsCode(t *testing.T, codes []gardencorev1beta1.ErrorCode, unwanted gardencorev1beta1.ErrorCode) { ++ t.Helper() ++ for _, code := range codes { ++ if code == unwanted { ++ t.Fatalf("codes %v unexpectedly contain %s", codes, unwanted) ++ } ++ } ++} ++ ++func readFileForTest(t *testing.T, path string) string { ++ t.Helper() ++ data, err := os.ReadFile(path) ++ if err != nil { ++ t.Fatalf("failed to read %s: %v", path, err) ++ } ++ return string(data) ++} ++ ++func lineContaining(t *testing.T, contents, needle string) string { ++ t.Helper() ++ for _, line := range strings.Split(contents, "\n") { ++ if strings.Contains(line, needle) { ++ return line ++ } ++ } ++ t.Fatalf("did not find line containing %q", needle) ++ return "" ++} ++ ++func assertLowerContains(t *testing.T, text, needle string) { ++ t.Helper() ++ if !strings.Contains(strings.ToLower(text), strings.ToLower(needle)) { ++ t.Fatalf("expected %q to contain %q", text, needle) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++case "${1:-}" in ++ base) ++ go test -v -count=1 -mod=vendor -run '^$' ./pkg/apis/core/v1beta1/helper/ ++ ;; ++ new) ++ go test -v -count=1 -mod=vendor ./pkg/apis/core/v1beta1/helper/ -run 'TestDetermineErrorCodesDistinguishesUnauthenticatedCredentialFailures|TestDetermineErrorCodesClassifiesAuthorizationFailuresAsUnauthorized|TestShootStatusKnownCredentialAndAuthorizationErrorCodesAreDocumented|TestInfraInsufficientPrivilegesIsDocumentedAsDeprecated|TestErrorInfraUnauthenticatedConstantIsExposedInCoreAPIs|TestUnauthenticatedInfrastructureErrorIsNonRetryable' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001235/tests/test.sh b/tasks/format-code-task-001235/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a083db5178f3875376a3fbcdb42bc54f21960a19 --- /dev/null +++ b/tasks/format-code-task-001235/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/apis/core/v1beta1/helper/errors_stage2_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001235/tests/test_command.sh b/tasks/format-code-task-001235/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001235/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001251/environment/Dockerfile b/tasks/format-code-task-001251/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7a3f8e6b598c8325be3dd4f8549506994e24256c --- /dev/null +++ b/tasks/format-code-task-001251/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:26aca120fa332b827195fff073822298ab6a46e1eec5d5b8bb3d7005cf1be7e1 diff --git a/tasks/format-code-task-001251/environment/setup/files/blocklist b/tasks/format-code-task-001251/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001251/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001251/environment/setup/setup.sh b/tasks/format-code-task-001251/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001251/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001251/tests/test.patch b/tasks/format-code-task-001251/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f7d4ac34fc95fe2af9ef5319f3652109c61ba504 --- /dev/null +++ b/tasks/format-code-task-001251/tests/test.patch @@ -0,0 +1,99 @@ +diff --git a/geopandas/tests/test_geodataframe.py b/geopandas/tests/test_geodataframe.py +index 9e3112f6..197b9ac5 100644 +--- a/geopandas/tests/test_geodataframe.py ++++ b/geopandas/tests/test_geodataframe.py +@@ -1255,3 +1255,72 @@ def test_geodataframe_crs(): + gdf = GeoDataFrame(columns=["geometry"]) + gdf.crs = "IGNF:ETRS89UTM28" + assert gdf.crs.to_authority() == ("IGNF", "ETRS89UTM28") ++ ++ ++ ++ ++ ++ ++ ++def test_constructor_does_not_modify_source_df_geometry_array(): ++ ++ df = pd.DataFrame( ++ { ++ "Name": ["Adam", "Barbara", "Cat", "Doug", "Ezra", "Fiona", "Greg"], ++ "lat": [35.5, 35.2, 34.89, 36.1, 35.78, 35.76, 34.99], ++ "lon": [-112.02, -111.09, -115.3, -114.01, -113.02, -112.9, -112.02], ++ } ++ ) ++ original_cols = df.columns.tolist() ++ original_df = df.copy() ++ gdf = GeoDataFrame( ++ df, geometry=[Point(x, y) for x, y in zip(df.lon, df.lat)] ++ ) ++ ++ assert df.columns.tolist() == original_cols ++ assert "geometry" not in df.columns ++ ++ assert "geometry" in gdf.columns ++ ++ assert_frame_equal(df, original_df) ++ ++ ++def test_constructor_does_not_modify_source_df_with_geometry_column_name(): ++ ++ ++ ++ ++ df = pd.DataFrame( ++ {"a": [1, 2], "mygeom": [Point(0, 0), Point(1, 1)]} ++ ) ++ gdf = GeoDataFrame(df, geometry="mygeom") ++ ++ assert str(df.dtypes["mygeom"]) == "object" ++ ++ assert str(gdf.dtypes["mygeom"]) == "geometry" ++ ++ ++def test_constructor_does_not_modify_source_df_with_existing_geometry_col(): ++ ++ ++ ++ df = pd.DataFrame( ++ {"a": [1, 2], "geometry": [Point(0, 0), Point(1, 1)]} ++ ) ++ gdf = GeoDataFrame(df) ++ ++ assert str(df.dtypes["geometry"]) == "object" ++ ++ assert str(gdf.dtypes["geometry"]) == "geometry" ++ ++ ++def test_constructor_modifying_gdf_does_not_modify_source_df(): ++ ++ df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) ++ original_df = df.copy() ++ gdf = GeoDataFrame(df, geometry=[Point(0, 0), Point(1, 1), Point(2, 2)]) ++ ++ gdf.loc[0, "a"] = 999 ++ ++ assert df.loc[0, "a"] == 1 ++ assert_frame_equal(df, original_df) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..6c0371dd +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest geopandas/tests/test_geodataframe.py -k \"does_not_modify_source_df or modifying_gdf_does_not\" -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -v -rA geopandas/tests/test_geodataframe.py::test_constructor_does_not_modify_source_df_geometry_array geopandas/tests/test_geodataframe.py::test_constructor_does_not_modify_source_df_with_geometry_column_name geopandas/tests/test_geodataframe.py::test_constructor_does_not_modify_source_df_with_existing_geometry_col geopandas/tests/test_geodataframe.py::test_constructor_modifying_gdf_does_not_modify_source_df ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001251/tests/test.sh b/tasks/format-code-task-001251/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e169f47c13a118246269516c6397398470152899 --- /dev/null +++ b/tasks/format-code-task-001251/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +geopandas/tests/test_geodataframe.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001251/tests/test_command.sh b/tasks/format-code-task-001251/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001251/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001256/environment/Dockerfile b/tasks/format-code-task-001256/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..10eba4f513b1fd84deea53cbe112a264334b324e --- /dev/null +++ b/tasks/format-code-task-001256/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c37786d61ebf62632f14daeb5082b0ac7b48998e9fe7ab866e0118495bf85b88 diff --git a/tasks/format-code-task-001256/environment/setup/files/blocklist b/tasks/format-code-task-001256/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001256/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001256/environment/setup/setup.sh b/tasks/format-code-task-001256/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001256/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001256/tests/test.patch b/tasks/format-code-task-001256/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a76038eec80cb1e515bb09225d3902ffc35c17d0 --- /dev/null +++ b/tasks/format-code-task-001256/tests/test.patch @@ -0,0 +1,130 @@ +diff --git a/tests/test_s3/__init__.py b/tests/test_s3/__init__.py +new file mode 100644 +index 000000000000..e69de29bb2d1 +diff --git a/tests/test_s3/test_s3.py b/tests/test_s3/test_s3.py +index 1cb00d4be510..6e6b999ce855 100644 +--- a/tests/test_s3/test_s3.py ++++ b/tests/test_s3/test_s3.py +@@ -1340,6 +1340,98 @@ def test_boto3_multipart_etag(): + resp['ETag'].should.equal(EXPECTED_ETAG) + + ++@mock_s3 ++def test_boto3_put_object_with_tagging(): ++ s3 = boto3.client('s3', region_name='us-east-1') ++ bucket_name = 'mybucket' ++ key = 'key-with-tags' ++ s3.create_bucket(Bucket=bucket_name) ++ ++ s3.put_object( ++ Bucket=bucket_name, ++ Key=key, ++ Body='test', ++ Tagging='foo=bar', ++ ) ++ ++ resp = s3.get_object_tagging(Bucket=bucket_name, Key=key) ++ ++ resp['TagSet'].should.contain({'Key': 'foo', 'Value': 'bar'}) ++ ++ ++@mock_s3 ++def test_boto3_put_object_tagging(): ++ s3 = boto3.client('s3', region_name='us-east-1') ++ bucket_name = 'mybucket' ++ key = 'key-with-tags' ++ s3.create_bucket(Bucket=bucket_name) ++ ++ with assert_raises(ClientError) as err: ++ s3.put_object_tagging( ++ Bucket=bucket_name, ++ Key=key, ++ Tagging={'TagSet': [ ++ {'Key': 'item1', 'Value': 'foo'}, ++ {'Key': 'item2', 'Value': 'bar'}, ++ ]} ++ ) ++ ++ e = err.exception ++ e.response['Error'].should.equal({ ++ 'Code': 'NoSuchKey', ++ 'Message': 'The specified key does not exist.', ++ 'RequestID': '7a62c49f-347e-4fc4-9331-6e8eEXAMPLE', ++ }) ++ ++ s3.put_object( ++ Bucket=bucket_name, ++ Key=key, ++ Body='test' ++ ) ++ ++ resp = s3.put_object_tagging( ++ Bucket=bucket_name, ++ Key=key, ++ Tagging={'TagSet': [ ++ {'Key': 'item1', 'Value': 'foo'}, ++ {'Key': 'item2', 'Value': 'bar'}, ++ ]} ++ ) ++ ++ resp['ResponseMetadata']['HTTPStatusCode'].should.equal(200) ++ ++ ++@mock_s3 ++def test_boto3_get_object_tagging(): ++ s3 = boto3.client('s3', region_name='us-east-1') ++ bucket_name = 'mybucket' ++ key = 'key-with-tags' ++ s3.create_bucket(Bucket=bucket_name) ++ ++ s3.put_object( ++ Bucket=bucket_name, ++ Key=key, ++ Body='test' ++ ) ++ ++ resp = s3.get_object_tagging(Bucket=bucket_name, Key=key) ++ resp['TagSet'].should.have.length_of(0) ++ ++ resp = s3.put_object_tagging( ++ Bucket=bucket_name, ++ Key=key, ++ Tagging={'TagSet': [ ++ {'Key': 'item1', 'Value': 'foo'}, ++ {'Key': 'item2', 'Value': 'bar'}, ++ ]} ++ ) ++ resp = s3.get_object_tagging(Bucket=bucket_name, Key=key) ++ ++ resp['TagSet'].should.have.length_of(2) ++ resp['TagSet'].should.contain({'Key': 'item1', 'Value': 'foo'}) ++ resp['TagSet'].should.contain({'Key': 'item2', 'Value': 'bar'}) ++ ++ + @mock_s3 + def test_boto3_list_object_versions(): + s3 = boto3.client('s3', region_name='us-east-1') +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,8 @@ ++H4sIAAAAAAAAA+3T70+CQBgHcF7zV9yYL+oFvyRwa/OFU8pWSVOr+eoGwpBSjslh+d934FLnLN/o ++qvX9vODg7gs87Dm0oEimIY3ShS6diiE0bLsahd2xOjftumEZht2wHMkwTceoS8Q+WUVbipz7c0Kk ++OWP8u9yh9T9K2/SfRzmnYzab+Wmo5ZPjveNQ/x3b2vTfFPPmhWOK/hvHK+Fr/7z/45BUjQ+iUJaj ++94zNOXkYub0n2ve8YVOpdb17V9eypdghyjrQGnbF0ianB0l6WSunRWbhT4lSO6tuIUmacKKeK/Lq ++Mp9E0ymxNEcz7fX7Ws8D2mq33cGA3rojetNplhUlabwdGLjtvjvcyu0Lddyr1uPdkPbd6xuv1yxy ++NfJzrpqyrLOM6zPGmVpudVGuni35hKVEnRFxJh5FykO++gty63MUX76zQGn5TZSWK+orUar5QDzZ ++olnBKQteojGnbwmfUO7HsaiQsDnZn9ofiKPdgELUhfzTWwUAAAAAAAAAAAAAAAAAAAAAfqEPYpPv ++ogAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001256/tests/test.sh b/tasks/format-code-task-001256/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c4fb76d5e15fcc7cb3f83f3261b98225737215d6 --- /dev/null +++ b/tasks/format-code-task-001256/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_s3/__init__.py +tests/test_s3/test_s3.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001256/tests/test_command.sh b/tasks/format-code-task-001256/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001256/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001257/environment/Dockerfile b/tasks/format-code-task-001257/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..29c15946bacc2ab5c496432efcebfee3f6ae45da --- /dev/null +++ b/tasks/format-code-task-001257/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f9e207d5432cf08c786684ef3980473c1f39a06b150d0785807a098984408cad diff --git a/tasks/format-code-task-001257/environment/setup/files/blocklist b/tasks/format-code-task-001257/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001257/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001257/environment/setup/setup.sh b/tasks/format-code-task-001257/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001257/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001257/tests/test.patch b/tasks/format-code-task-001257/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e67f00d80b8b191a44011e8dc38d81454c71011c --- /dev/null +++ b/tasks/format-code-task-001257/tests/test.patch @@ -0,0 +1,182 @@ +diff --git a/tests/test_ec2/test_ec2_cloudformation.py b/tests/test_ec2/test_ec2_cloudformation.py +index ddf26b528..53bb2ed05 100644 +--- a/tests/test_ec2/test_ec2_cloudformation.py ++++ b/tests/test_ec2/test_ec2_cloudformation.py +@@ -215,6 +215,145 @@ def test_volume_size_through_cloudformation(): + volumes["Volumes"][0]["Size"].should.equal(50) + + ++def _physical_id_for_type(stack_resources, resource_type): ++ matches = [ ++ resource ++ for resource in stack_resources ++ if resource["ResourceType"] == resource_type ++ ] ++ len(matches).should.equal(1) ++ physical_id = matches[0]["PhysicalResourceId"] ++ assert physical_id ++ return physical_id ++ ++ ++@mock_ec2 ++@mock_cloudformation ++def test_cloudformation_vpc_gateway_attachment_supports_vpn_gateway_ref(): ++ ec2 = boto3.client("ec2", region_name="us-east-1") ++ cf = boto3.client("cloudformation", region_name="us-east-1") ++ ++ template = { ++ "AWSTemplateFormatVersion": "2010-09-09", ++ "Resources": { ++ "VpcForVpnAttachment": { ++ "Type": "AWS::EC2::VPC", ++ "Properties": {"CidrBlock": "10.22.0.0/16"}, ++ }, ++ "VpnGatewayFromCfn": { ++ "Type": "AWS::EC2::VPNGateway", ++ "Properties": {"Type": "ipsec.1"}, ++ }, ++ "AttachVpnGateway": { ++ "Type": "AWS::EC2::VPCGatewayAttachment", ++ "Properties": { ++ "VpcId": {"Ref": "VpcForVpnAttachment"}, ++ "VpnGatewayId": {"Ref": "VpnGatewayFromCfn"}, ++ }, ++ }, ++ }, ++ } ++ ++ stack_name = "vpn-gateway-attachment-{0}".format(str(uuid4())[0:8]) ++ cf.create_stack(StackName=stack_name, TemplateBody=json.dumps(template)) ++ ++ stack_resources = cf.list_stack_resources(StackName=stack_name)[ ++ "StackResourceSummaries" ++ ] ++ vpc_id = _physical_id_for_type(stack_resources, "AWS::EC2::VPC") ++ vpn_gateway_id = _physical_id_for_type( ++ stack_resources, "AWS::EC2::VPNGateway" ++ ) ++ ++ gateway = ec2.describe_vpn_gateways(VpnGatewayIds=[vpn_gateway_id])[ ++ "VpnGateways" ++ ][0] ++ assert any( ++ attachment.get("VpcId") == vpc_id ++ for attachment in gateway.get("VpcAttachments", []) ++ ) ++ ++ ++@mock_ec2 ++@mock_cloudformation ++def test_cloudformation_vpc_gateway_attachment_still_supports_internet_gateway_ref(): ++ ec2 = boto3.client("ec2", region_name="us-east-1") ++ cf = boto3.client("cloudformation", region_name="us-east-1") ++ ++ template = { ++ "AWSTemplateFormatVersion": "2010-09-09", ++ "Resources": { ++ "VpcForInternetGatewayAttachment": { ++ "Type": "AWS::EC2::VPC", ++ "Properties": {"CidrBlock": "10.23.0.0/16"}, ++ }, ++ "InternetGatewayFromCfn": {"Type": "AWS::EC2::InternetGateway"}, ++ "AttachInternetGateway": { ++ "Type": "AWS::EC2::VPCGatewayAttachment", ++ "Properties": { ++ "VpcId": {"Ref": "VpcForInternetGatewayAttachment"}, ++ "InternetGatewayId": {"Ref": "InternetGatewayFromCfn"}, ++ }, ++ }, ++ }, ++ } ++ ++ stack_name = "internet-gateway-attachment-{0}".format(str(uuid4())[0:8]) ++ cf.create_stack(StackName=stack_name, TemplateBody=json.dumps(template)) ++ ++ stack_resources = cf.list_stack_resources(StackName=stack_name)[ ++ "StackResourceSummaries" ++ ] ++ vpc_id = _physical_id_for_type(stack_resources, "AWS::EC2::VPC") ++ internet_gateway_id = _physical_id_for_type( ++ stack_resources, "AWS::EC2::InternetGateway" ++ ) ++ ++ gateway = ec2.describe_internet_gateways( ++ InternetGatewayIds=[internet_gateway_id] ++ )["InternetGateways"][0] ++ assert any( ++ attachment.get("VpcId") == vpc_id ++ for attachment in gateway.get("Attachments", []) ++ ) ++ ++ ++@mock_ec2 ++@mock_cloudformation ++def test_cloudformation_creates_vpn_gateway_with_optional_asn(): ++ ec2 = boto3.client("ec2", region_name="us-east-1") ++ cf = boto3.client("cloudformation", region_name="us-east-1") ++ ++ template = { ++ "AWSTemplateFormatVersion": "2010-09-09", ++ "Resources": { ++ "StandaloneVpnGateway": { ++ "Type": "AWS::EC2::VPNGateway", ++ "Properties": { ++ "Type": "ipsec.1", ++ "AmazonSideAsn": 64513, ++ }, ++ }, ++ }, ++ } ++ ++ stack_name = "standalone-vpn-gateway-{0}".format(str(uuid4())[0:8]) ++ cf.create_stack(StackName=stack_name, TemplateBody=json.dumps(template)) ++ ++ stack_resources = cf.list_stack_resources(StackName=stack_name)[ ++ "StackResourceSummaries" ++ ] ++ vpn_gateway_id = _physical_id_for_type( ++ stack_resources, "AWS::EC2::VPNGateway" ++ ) ++ ++ gateway = ec2.describe_vpn_gateways(VpnGatewayIds=[vpn_gateway_id])[ ++ "VpnGateways" ++ ][0] ++ gateway["VpnGatewayId"].should.equal(vpn_gateway_id) ++ gateway["AmazonSideAsn"].should.equal(64513) ++ ++ + # Has boto3 equivalent + @mock_ec2_deprecated + @mock_cloudformation_deprecated +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,27 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy ++ ++set +u ++source /testbed/.build_env/.venv/bin/activate ++set -u ++ ++case "${1:-}" in ++ base) ++ python3 -m pytest tests/test_ec2/test_ec2_cloudformation.py -x -v \ ++ --deselect=tests/test_ec2/test_ec2_cloudformation.py::test_cloudformation_vpc_gateway_attachment_supports_vpn_gateway_ref \ ++ --deselect=tests/test_ec2/test_ec2_cloudformation.py::test_cloudformation_vpc_gateway_attachment_still_supports_internet_gateway_ref \ ++ --deselect=tests/test_ec2/test_ec2_cloudformation.py::test_cloudformation_creates_vpn_gateway_with_optional_asn ++ ;; ++ new) ++ python3 -m pytest -x -v \ ++ tests/test_ec2/test_ec2_cloudformation.py::test_cloudformation_vpc_gateway_attachment_supports_vpn_gateway_ref \ ++ tests/test_ec2/test_ec2_cloudformation.py::test_cloudformation_vpc_gateway_attachment_still_supports_internet_gateway_ref \ ++ tests/test_ec2/test_ec2_cloudformation.py::test_cloudformation_creates_vpn_gateway_with_optional_asn ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001257/tests/test.sh b/tasks/format-code-task-001257/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a1f8e34ab5cc7b80d629d8d16cbbb42ed44838dd --- /dev/null +++ b/tasks/format-code-task-001257/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_ec2/test_ec2_cloudformation.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001257/tests/test_command.sh b/tasks/format-code-task-001257/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001257/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001261/environment/Dockerfile b/tasks/format-code-task-001261/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5c94dbbfd9840afdc38bb94cd753fd0270e8c567 --- /dev/null +++ b/tasks/format-code-task-001261/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:110b751e3286e95b7440b1f85bbd6d7753e2b553fbf023c68fbb23af6da9d24f diff --git a/tasks/format-code-task-001261/environment/setup/files/blocklist b/tasks/format-code-task-001261/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001261/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001261/environment/setup/setup.sh b/tasks/format-code-task-001261/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001261/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001261/tests/test.patch b/tasks/format-code-task-001261/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c0d0916219448d4b8029c16f49e52e3f9b51feb4 --- /dev/null +++ b/tasks/format-code-task-001261/tests/test.patch @@ -0,0 +1,62 @@ +diff --git a/tests/test_route53/test_route53.py b/tests/test_route53/test_route53.py +index f8a0277a1aad..509b94b0d18e 100644 +--- a/tests/test_route53/test_route53.py ++++ b/tests/test_route53/test_route53.py +@@ -1118,6 +1118,37 @@ def test_change_resource_record_invalid_action_value(): + len(response["ResourceRecordSets"]).should.equal(1) + + ++@mock_route53 ++def test_change_resource_record_set_twice(): ++ ZONE = "cname.local" ++ FQDN = f"test.{ZONE}" ++ FQDN_TARGET = "develop.domain.com" ++ ++ client = boto3.client("route53", region_name="us-east-1") ++ zone_id = client.create_hosted_zone( ++ Name=ZONE, CallerReference="ref", DelegationSetId="string" ++ )["HostedZone"]["Id"] ++ changes = { ++ "Changes": [ ++ { ++ "Action": "CREATE", ++ "ResourceRecordSet": { ++ "Name": FQDN, ++ "Type": "CNAME", ++ "TTL": 600, ++ "ResourceRecords": [{"Value": FQDN_TARGET}], ++ }, ++ } ++ ] ++ } ++ client.change_resource_record_sets(HostedZoneId=zone_id, ChangeBatch=changes) ++ ++ with pytest.raises(ClientError) as exc: ++ client.change_resource_record_sets(HostedZoneId=zone_id, ChangeBatch=changes) ++ err = exc.value.response["Error"] ++ err["Code"].should.equal("InvalidChangeBatch") ++ ++ + @mock_route53 + def test_list_resource_record_sets_name_type_filters(): + conn = boto3.client("route53", region_name="us-east-1") +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3SSwrCMBSF4YxdxR05a21M087ciqgtKNhG2lR098YKvkCdKCL+3yC5eUASTuJ5 ++t1oX07LejtSnJEFubd8H931fazvWOsvzVGcqCZU2SuzHbnSla/2sEVGNc/7ZvlfrPyq+5O/L1k8X ++rqpmdRG3y/ed8Sp/rdNz/ibLQ/5pZhIlyfuu8Nif578opA9+XhaDzd4vXW0kqiSUYVKOTXv6GI3r ++fGnNzSDe7CXaSbSV8WSoB99+CwAAAAAAAAAAAAAAAPBvDi8JyCQAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001261/tests/test.sh b/tasks/format-code-task-001261/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a3741dc2bd99047b01407ba722526d72486f6411 --- /dev/null +++ b/tasks/format-code-task-001261/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_route53/test_route53.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001261/tests/test_command.sh b/tasks/format-code-task-001261/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001261/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001267/environment/Dockerfile b/tasks/format-code-task-001267/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cc0261dbbbb3f871df63878f5831475e801a46e6 --- /dev/null +++ b/tasks/format-code-task-001267/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7204a04a5776caf368d6d8569b10a8afcc0447c946dbd8b8453ff95f729af1e1 diff --git a/tasks/format-code-task-001267/environment/setup/files/blocklist b/tasks/format-code-task-001267/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001267/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001267/environment/setup/setup.sh b/tasks/format-code-task-001267/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001267/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001267/tests/test.patch b/tasks/format-code-task-001267/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7735e0b1c046a39367d3b3354504b3bb7c090f21 --- /dev/null +++ b/tasks/format-code-task-001267/tests/test.patch @@ -0,0 +1,67 @@ +diff --git a/tests/test_models.py b/tests/test_models.py +index b24b380c81..d210f5677d 100644 +--- a/tests/test_models.py ++++ b/tests/test_models.py +@@ -30,6 +30,28 @@ def test_changing_query_text_changes_hash(self): + + self.assertNotEquals(old_hash, q.query_hash) + ++ def test_search_finds_in_name(self): ++ q1 = query_factory.create(name="Testing search") ++ q2 = query_factory.create(name="Testing searching") ++ q3 = query_factory.create(name="Testing sea rch") ++ ++ queries = models.Query.search("search") ++ ++ self.assertIn(q1, queries) ++ self.assertIn(q2, queries) ++ self.assertNotIn(q3, queries) ++ ++ def test_search_finds_in_description(self): ++ q1 = query_factory.create(description="Testing search") ++ q2 = query_factory.create(description="Testing searching") ++ q3 = query_factory.create(description="Testing sea rch") ++ ++ queries = models.Query.search("search") ++ ++ self.assertIn(q1, queries) ++ self.assertIn(q2, queries) ++ self.assertNotIn(q3, queries) ++ + + class QueryResultTest(BaseTestCase): + def setUp(self): +@@ -94,6 +116,7 @@ def test_get_latest_returns_the_last_cached_result_for_negative_ttl(self): + + self.assertEqual(found_query_result.id, qr.id) + ++ + class TestQueryResultStoreResult(BaseTestCase): + def setUp(self): + super(TestQueryResultStoreResult, self).setUp() +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,10 @@ ++H4sIAAAAAAAAA+2Ub2vbMBDG89qf4uoGur2wHXtJMzoyKMVbCmmTOSllEAj+ozpmtuRacmghH34n ++m6ahrOublrHtfi8sWSc998h32I7qLE9WjG+czlvRQ4aDQTMiT8dm7g481/OGnue6nZ7rDob9Dgze ++zNEetVRhBdCphFC/2/dS/C/Ffqy/YlKtYlEUIU9suX69HC/UH6v9YVd/t3+M9e8fu8MO9F7PwvP8 ++5/U/PHCijDtRKNdGnEDTBBFLDOMQ5kxBXUJ5j80BN6KC2b1aCw6ePTTYXSkqBbPTxXhkdsfTC9+x ++m41a7aSr102DbcIczO67ViHjmQLLKkO1fv/rGC63r2kuIgxjItv9uGdl9n0xnl5qcZACKpagayjD +++EeYMsCuBe0ebsJYiSpjEsKKQVZop2GUs53pncro4bonD5NmlHiB3R6d3ueyRqmZkCqt2PzbBDIJ ++Vc15xlNDsmqTxQzKNipvc9AtpcD77CRs4/A6z2G7BVXVbE9MrRnonsJHzoDdZZjXkDVYOyGwYjBL ++rYeTpTn3J/7ZAlz4EkwvoExX+qCE67Ef+FqEhwUbHWnJo6UJW0CJEqxbPIDJH2XOAv904UMwnfht ++/utz/JyT6dfzS5hfzfzgau4Hn5am+Zz/oOaNebxjimVpPhjWrWkNqwAuJGsX2x9KIRKWS2wO40+3 ++OkEQBEEQBEEQBEEQBEEQBEEQBEEQBEEQxD/JT8nA23MAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001267/tests/test.sh b/tasks/format-code-task-001267/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2781b486395f37c203a9ae54b6dddd65ffa4ce6a --- /dev/null +++ b/tasks/format-code-task-001267/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_models.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001267/tests/test_command.sh b/tasks/format-code-task-001267/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001267/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001268/environment/Dockerfile b/tasks/format-code-task-001268/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cf305ffe31930fcbf35cb1ccd649e7dfed0abe6c --- /dev/null +++ b/tasks/format-code-task-001268/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1db0b1af74fb9dd86f56a5ddbe4b72b1a66b6dcd4ead2f08f8bdbdccdb31b032 diff --git a/tasks/format-code-task-001268/environment/setup/files/blocklist b/tasks/format-code-task-001268/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001268/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001268/environment/setup/setup.sh b/tasks/format-code-task-001268/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001268/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001268/tests/test.patch b/tasks/format-code-task-001268/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..53d3053c28f465b144ffe6b2740ac6cb0956dd2d --- /dev/null +++ b/tasks/format-code-task-001268/tests/test.patch @@ -0,0 +1,115 @@ +diff --git a/tests/models/test_alerts.py b/tests/models/test_alerts.py +index ca0aa2ce86..3bcfff0108 100644 +--- a/tests/models/test_alerts.py ++++ b/tests/models/test_alerts.py +@@ -71,23 +71,45 @@ def test_evaluate_return_unknown_when_empty_results(self): + alert = self.create_alert(results) + self.assertEqual(alert.evaluate(), Alert.UNKNOWN_STATE) + +- def test_evaluates_correctly_with_max_selector(self): +- results = {"rows": [{"foo": 1}, {"foo": 2}], "columns": [{"name": "foo", "type": "STRING"}]} ++ def test_evaluates_correctly_with_first_selector(self): ++ results = {"rows": [{"foo": 1}, {"foo": 2}], "columns": [{"name": "foo", "type": "INTEGER"}]} + alert = self.create_alert(results) +- alert.options["selector"] = "max" +- self.assertEqual(alert.evaluate(), Alert.OK_STATE) ++ alert.options["selector"] = "first" ++ self.assertEqual(alert.evaluate(), Alert.TRIGGERED_STATE) ++ results = { ++ "rows": [{"foo": "test"}, {"foo": "test"}, {"foo": "test"}], ++ "columns": [{"name": "foo", "type": "STRING"}], ++ } ++ alert = self.create_alert(results) ++ alert.options["selector"] = "first" ++ alert.options["op"] = "<" ++ self.assertEqual(alert.evaluate(), Alert.UNKNOWN_STATE) + + def test_evaluates_correctly_with_min_selector(self): +- results = {"rows": [{"foo": 2}, {"foo": 1}], "columns": [{"name": "foo", "type": "STRING"}]} ++ results = {"rows": [{"foo": 2}, {"foo": 1}], "columns": [{"name": "foo", "type": "INTEGER"}]} + alert = self.create_alert(results) + alert.options["selector"] = "min" + self.assertEqual(alert.evaluate(), Alert.TRIGGERED_STATE) ++ results = { ++ "rows": [{"foo": "test"}, {"foo": "test"}, {"foo": "test"}], ++ "columns": [{"name": "foo", "type": "STRING"}], ++ } ++ alert = self.create_alert(results) ++ alert.options["selector"] = "min" ++ self.assertEqual(alert.evaluate(), Alert.UNKNOWN_STATE) + +- def test_evaluates_correctly_with_first_selector(self): +- results = {"rows": [{"foo": 1}, {"foo": 2}], "columns": [{"name": "foo", "type": "STRING"}]} ++ def test_evaluates_correctly_with_max_selector(self): ++ results = {"rows": [{"foo": 1}, {"foo": 2}], "columns": [{"name": "foo", "type": "INTEGER"}]} + alert = self.create_alert(results) +- alert.options["selector"] = "first" +- self.assertEqual(alert.evaluate(), Alert.TRIGGERED_STATE) ++ alert.options["selector"] = "max" ++ self.assertEqual(alert.evaluate(), Alert.OK_STATE) ++ results = { ++ "rows": [{"foo": "test"}, {"foo": "test"}, {"foo": "test"}], ++ "columns": [{"name": "foo", "type": "STRING"}], ++ } ++ alert = self.create_alert(results) ++ alert.options["selector"] = "max" ++ self.assertEqual(alert.evaluate(), Alert.UNKNOWN_STATE) + + + class TestNextState(TestCase): +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,40 @@ ++H4sIAAAAAAAAA+1YbW8bNxLOZ/0KNgWaT5S0qze7gYrzpQYStGhysfuhuB4MapeSaO2Sa5IrWUZ/ ++/D1D7q7kILkEd0l7dxVhwOLbcDgzzzPD7S9qVeQ3Um8HT75UG6LNJpPwH+3d/+F3MkmH6XQ8TtLR ++k2GSTDHEJl9Mo6NWOy8sY0+sMf5frfvY/P9o6x/876Svq5tcVq7v1p/zjI/4fzpOZ53/h2Py/3iU ++jp+w4edU4kPtT+7/r78aLJQeLIRb975mrzSsURTszd6vjWaIBalzqTMlHVsay6zMsZB56bzrYf3V ++TvkMfdPuGPWTlKklE1uhCrEoZA+dzJSl0DnjW0jcchc3ffPdAL2BroviOfNrqXsM7WhBFUSOosz0 ++sJr99hvztpa9peod6UyBy9zeeVnyncplr1IVU80k5wsrxYY385XINmKFS3GuDQ87OVcrbazkVt7V ++ykrH4/mHiUaWzNmvQVWRb00mvJzPk/6wP2SikOVCZdRNoDMTWjlzNh0m8/lZXFBVubKOFoz7Yybc ++Xmfcq1Ka2s/nY6wZtaK9p3XptJ/QvtqvC7WYz4f9ZNKfsAW0N8sl5vspzllkdl8FAUk/ZYtC6Y20 ++dMgU3Sgvk9arpcIOgAyHpynLltSHqlOckC1X2/l8hBn8XgsLKoBhbCkK9UCyaGbGskJlG7pM0ima ++mcJYUQrSbdyfor+VFpadz2fQDVus0V4sookSFjQ1Kyuq9R4Kpxg8g+OWtZP5fVmQlBmW/dqEQmUl ++GTin7bjpmOXKVcZRXHFZIsJ4bvBPO9o47J9PaIFvTEV3kXCJ1L4Sfh3tM2lky/tMVl4ZvbKmrqL8 ++IVuqQhaG7jjqp+c0UAi3ITujHzu8UKXy0SajTtVmyqyUpqOn7VZOStLIOZY2IwrXp6BJ+5NOKMLN ++L+uwEkKHj6S6u0IU2VqW+7inFYRYVA64ikZrD9z5ZfAqLbNSPshVrRvztVJrne1jkOK3r60MgXUG ++n2KtyozFhjQNEbv2voI507CCDAJcaURSo8qoDQOVa0EWSSZMlZWx5ANeSi9y4QXFAjn/MIPrmtpm ++En6bBlUVnauXakVy6eBGrHe50CsJHxEaQnzfylw16iTsVulbkYaTAahbZ7QjS4ng7BludLuLIUf3 ++nSA+o9zgQ0fbyHCl2IT5UfhtN7nZaa488E8rhs1oXTmxlFGL1pSluC+VzvMFX0lTICxSQhhMORuO ++DpOtq8u8tsHFdI0yhNkE4luM6nzFyd4OMIORaSE5W0vYWwRbYSfRgTa5RL4mlcErzNhcgpc5MBtj ++vLVeJDmlV4FIUvSBVEV3jUCvCOdwkCQKIiXHYcjQQRQNlXAuYCnpzzrAV4XwyARlJLJR1Kgq6tVq ++39oQqOVE+cpHkECSNWXluTem2MRRwLOT6GpPIJkAJDP09pmpVilHVhI2xNk5/Fb5yMZxbwqRfuty ++ui8hs9oLp5PWYo3YfRYuaANNJuiviApiHM3CptudD9cmnfdaZEWMEuqZfJGRSkfW3BskQ1gEW8YB ++TtWeDoj2DfyIgTyCj0RgCrkmOjIdhiEnyiIlOIyO1ERSQcy2tIFrggtozbjrwZrb1rXRDJzcFs2W ++hiBohcVJ40N8BJDQRf1DYH5yBujTJ2GIt/wKFuRurcoYmsOw5CBxL4iXpwHBCDPlSBPS1MqVvG/k ++noHGKW9SXRDoEn+MSM2qDPzd+u6QkDAORk4iAO1dk4hwwh0nBOd1QY4bxkRqa0p2xPDp2TlzstxG ++r551VnSws91zl28C19FEqGYp4qDQbBhg7NR9l/GOWZXCNh23oroJIEpYZENkmzZBHE2S9QMmR4QV ++TIRoizGIhW7ta61lg/c27cDXnsJ2FIDi6kraLYoE23r3MMJxSrZxEYsJKqyyUJEc2zv7fYXY4/Ie ++znbwYXAMcbR/iKwbPDNGFylNFBErCasFb3ERWL/1NLgJYB+Fm8IT5ww52XKk8gYzQ7ZFwoFkY4NW ++aRhS1teoeyjaEOPppBO3EyjhcrNqKXSXoSajLDwk7IzYTtrNg6xXMbmesR1qAt95Zxc4xrUVThR5 ++X7j7nY3Jl9yRMpQMLd+PgmUeVFUFVqLk8ADAcrkNECTFQl9p7Cc+DamnkZx+903CUFQiWTM+OS4q ++3wALKyuv/vYjVbXaeGI3irYe1AXr+0OFuY/FZNNHjiMORPnsWBWFIEYighBYFiGMNLSo7gDD7Xur ++W2jxIuREZOhjPTDpfKgJqbb+O+NLNpA+GxxOGSTTAZVFg2p1s16IPqVW9o+jIhu0z7hiz9zAZcgJ ++QL/g6WQ6CKIHq+fMDSopbdt/9ikHNNX4FV5TntEFFXJW79F9OWhLlkajpmR7FN/vu7WrGe8MxnjG ++nuKMzBdZAVUgI5kyOpmQZP3T/0iERa0n8vfL+KOfZb9bO3r/U6q5ad5qn/ULwEfe/+l4dvj+M5yM ++6f0/TdPT+//3aMfvf6RMxkE8Wc5CMCxk/t/yyH9MKy0XiwKP+nyPAkFr5MI/hG2g3KV2xNEHYqY3 ++UiyswleTA3n/24yNfVhZMX7Hnj7i7KefJArKdtuJ2T9p19HxXyxpdMI/A2eHx61qAwaxDFJT1mgq +++1G8WEWh6nrynp6h7M0v1y9f//Tm4vrlvAv2Zurt5fcXVy9vvr+4vvjrxdXlzc9vf5wf7vHtoLvU ++X0JltUbv28l4NO7G3xH04vXrH15d3lxdvnh7eT2nwzJjNgp1RGalf2dxXHXzw+UvYWVcs5H7d5bh ++36uroFkIeih10GU6mp0PhqGAAD68DN/rGBWFgLmkWFLoGun0MxjpHs+UXkXFCf/5yAVr1glkvGJ0 ++v+AXaHdxfcla48Rvgc8/iI22kGq+HD76ovgOirvva4SSrzpmoEPjp4P4iePRUUcx2npx8KFP2k1k ++vK01bUK1Z6l+i98yu8PK5s0Vxwcl3tqFi6kRda71rl+h0Nv+eQqEUzu1Uzu1Uzu1Uzu1Uzu1Uzu1 ++U/u/aP8EWeMPagAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001268/tests/test.sh b/tasks/format-code-task-001268/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7dd63115a0e42dafad9772ace324a93c4e35f0f4 --- /dev/null +++ b/tasks/format-code-task-001268/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/models/test_alerts.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001268/tests/test_command.sh b/tasks/format-code-task-001268/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001268/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001269/environment/Dockerfile b/tasks/format-code-task-001269/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c5525262915a3d635e18fee9658dcb5c6a0e55ff --- /dev/null +++ b/tasks/format-code-task-001269/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e4feae817a2d6660ebb8ea03f3487af0acaa2431fd2cf3763738395d67a76709 diff --git a/tasks/format-code-task-001269/environment/setup/files/blocklist b/tasks/format-code-task-001269/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001269/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001269/environment/setup/setup.sh b/tasks/format-code-task-001269/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001269/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001269/tests/test.patch b/tasks/format-code-task-001269/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fdb09b0a1a01ad59b6e0d8c4bbb053f5e4485b18 --- /dev/null +++ b/tasks/format-code-task-001269/tests/test.patch @@ -0,0 +1,145 @@ +diff --git a/responses/tests/test_responses.py b/responses/tests/test_responses.py +index 47479bb..ae227c6 100644 +--- a/responses/tests/test_responses.py ++++ b/responses/tests/test_responses.py +@@ -2223,3 +2223,118 @@ def test_redirect(): + + run() + assert_reset() ++ ++ ++def test_activate_strict_unfired_raises(): ++ """@responses.activate(assert_all_requests_are_fired=True) raises if not all fired.""" ++ @responses.activate(assert_all_requests_are_fired=True) ++ def run(): ++ responses.add(responses.GET, "http://example.com", body=b"test") ++ ++ with pytest.raises(AssertionError) as excinfo: ++ run() ++ assert "http://example.com" in str(excinfo.value) ++ ++ responses.mock.reset() ++ assert_reset() ++ ++ ++def test_activate_strict_all_fired_passes(): ++ """@responses.activate(assert_all_requests_are_fired=True) succeeds if all fired.""" ++ @responses.activate(assert_all_requests_are_fired=True) ++ def run(): ++ responses.add(responses.GET, "http://example.com", body=b"test") ++ resp = requests.get("http://example.com") ++ assert resp.content == b"test" ++ ++ run() ++ assert_reset() ++ ++ ++def test_activate_default_does_not_raise_on_unfired(): ++ """@responses.activate (no parens) preserves backward-compat: no error on unfired.""" ++ @responses.activate ++ def run(): ++ responses.add(responses.GET, "http://example.com", body=b"test") ++ ++ ++ run() ++ assert_reset() ++ ++ ++def test_activate_explicit_false_does_not_raise(): ++ """@responses.activate(assert_all_requests_are_fired=False) does not raise.""" ++ @responses.activate(assert_all_requests_are_fired=False) ++ def run(): ++ responses.add(responses.GET, "http://example.com", body=b"test") ++ ++ run() ++ assert_reset() ++ ++ ++def test_activate_strict_does_not_leak_state(): ++ """After running with assert_all=True, mock attribute is restored to original.""" ++ initial = responses.mock.assert_all_requests_are_fired ++ assert initial is False ++ ++ @responses.activate(assert_all_requests_are_fired=True) ++ def run(): ++ responses.add(responses.GET, "http://example.com", body=b"test") ++ requests.get("http://example.com") ++ ++ run() ++ ++ assert responses.mock.assert_all_requests_are_fired == initial ++ assert_reset() ++ ++ ++def test_activate_strict_leak_blocks_subsequent_bare_activate(): ++ """If state leaks, a subsequent bare @responses.activate would unexpectedly raise.""" ++ @responses.activate(assert_all_requests_are_fired=True) ++ def run_strict(): ++ responses.add(responses.GET, "http://example.com", body=b"test") ++ requests.get("http://example.com") ++ ++ @responses.activate ++ def run_bare(): ++ ++ ++ responses.add(responses.GET, "http://example.com", body=b"test") ++ ++ run_strict() ++ run_bare() ++ assert_reset() ++ ++ ++def test_activate_strict_with_registry(): ++ """assert_all_requests_are_fired works combined with custom registry.""" ++ from responses import registries ++ ++ class CustomRegistry(registries.FirstMatchRegistry): ++ pass ++ ++ @responses.activate(registry=CustomRegistry, assert_all_requests_are_fired=True) ++ def run(): ++ assert type(responses.mock.get_registry()) == CustomRegistry ++ responses.add(responses.GET, "http://example.com", body=b"test") ++ requests.get("http://example.com") ++ ++ run() ++ assert_reset() ++ ++ ++def test_activate_strict_with_registry_unfired_raises(): ++ """Combined: registry + strict raises when unfired.""" ++ from responses import registries ++ ++ class CustomRegistry(registries.FirstMatchRegistry): ++ pass ++ ++ @responses.activate(registry=CustomRegistry, assert_all_requests_are_fired=True) ++ def run(): ++ responses.add(responses.GET, "http://example.com", body=b"test") ++ ++ with pytest.raises(AssertionError): ++ run() ++ responses.mock.reset() ++ assert_reset() +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..8329500 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python3 -m pytest responses/tests/test_responses.py -k 'test_activate_strict or test_activate_default_does_not_raise_on_unfired or test_activate_explicit_false_does_not_raise' -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python3 -m pytest responses/tests/test_responses.py -k 'test_activate_strict or test_activate_default_does_not_raise_on_unfired or test_activate_explicit_false_does_not_raise' -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001269/tests/test.sh b/tasks/format-code-task-001269/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..65cac78fc7e22f26569773a36cf133980a080b1a --- /dev/null +++ b/tasks/format-code-task-001269/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +responses/tests/test_responses.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001269/tests/test_command.sh b/tasks/format-code-task-001269/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001269/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001295/environment/Dockerfile b/tasks/format-code-task-001295/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..089ca1c44b60daf311b09a3c3624f9b6fe750b6b --- /dev/null +++ b/tasks/format-code-task-001295/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:16012056ebfc684e998da31e0cd338b53133e250a16d4be46a518d12cf2d3540 diff --git a/tasks/format-code-task-001295/environment/setup/files/blocklist b/tasks/format-code-task-001295/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001295/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001295/environment/setup/setup.sh b/tasks/format-code-task-001295/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001295/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001295/tests/test.patch b/tasks/format-code-task-001295/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..01c77f0086677e891c4bceba243672efe1be9565 --- /dev/null +++ b/tasks/format-code-task-001295/tests/test.patch @@ -0,0 +1,94 @@ +diff --git a/gnovm/cmd/gno/tool_lint_test.go b/gnovm/cmd/gno/tool_lint_test.go +index 3f9e5cd59ba..aaffcbaddff 100644 +--- a/gnovm/cmd/gno/tool_lint_test.go ++++ b/gnovm/cmd/gno/tool_lint_test.go +@@ -8,31 +8,31 @@ import ( + func TestLintApp(t *testing.T) { + tc := []testMainCase{ + { +- args: []string{"tool", "lint"}, ++ args: []string{"lint"}, + errShouldBe: "flag: help requested", + }, + { +- args: []string{"tool", "lint", "../../tests/integ/run_main/"}, ++ args: []string{"lint", "../../tests/integ/run_main/"}, + stderrShouldContain: "./../../tests/integ/run_main: gno.mod file not found in current or any parent directory (code=1)", + errShouldBe: "exit code: 1", + }, + { +- args: []string{"tool", "lint", "../../tests/integ/undefined_variable_test/undefined_variables_test.gno"}, ++ args: []string{"lint", "../../tests/integ/undefined_variable_test/undefined_variables_test.gno"}, + stderrShouldContain: "undefined_variables_test.gno:6:28: name toto not declared (code=2)", + errShouldBe: "exit code: 1", + }, + { +- args: []string{"tool", "lint", "../../tests/integ/package_not_declared/main.gno"}, ++ args: []string{"lint", "../../tests/integ/package_not_declared/main.gno"}, + stderrShouldContain: "main.gno:4:2: name fmt not declared (code=2)", + errShouldBe: "exit code: 1", + }, + { +- args: []string{"tool", "lint", "../../tests/integ/several-lint-errors/main.gno"}, ++ args: []string{"lint", "../../tests/integ/several-lint-errors/main.gno"}, + stderrShouldContain: "../../tests/integ/several-lint-errors/main.gno:5:5: expected ';', found example (code=3)\n../../tests/integ/several-lint-errors/main.gno:6", + errShouldBe: "exit code: 1", + }, + { +- args: []string{"tool", "lint", "../../tests/integ/several-files-multiple-errors/main.gno"}, ++ args: []string{"lint", "../../tests/integ/several-files-multiple-errors/main.gno"}, + stderrShouldContain: func() string { + lines := []string{ + "../../tests/integ/several-files-multiple-errors/file2.gno:3:5: expected 'IDENT', found '{' (code=3)", +@@ -45,25 +45,25 @@ func TestLintApp(t *testing.T) { + errShouldBe: "exit code: 1", + }, + { +- args: []string{"tool", "lint", "../../tests/integ/minimalist_gnomod/"}, ++ args: []string{"lint", "../../tests/integ/minimalist_gnomod/"}, + // TODO: raise an error because there is a gno.mod, but no .gno files + }, + { +- args: []string{"tool", "lint", "../../tests/integ/invalid_module_name/"}, ++ args: []string{"lint", "../../tests/integ/invalid_module_name/"}, + // TODO: raise an error because gno.mod is invalid + }, + { +- args: []string{"tool", "lint", "../../tests/integ/invalid_gno_file/"}, ++ args: []string{"lint", "../../tests/integ/invalid_gno_file/"}, + stderrShouldContain: "../../tests/integ/invalid_gno_file/invalid.gno:1:1: expected 'package', found packag (code=2)", + errShouldBe: "exit code: 1", + }, + { +- args: []string{"tool", "lint", "../../tests/integ/typecheck_missing_return/"}, ++ args: []string{"lint", "../../tests/integ/typecheck_missing_return/"}, + stderrShouldContain: "../../tests/integ/typecheck_missing_return/main.gno:5:1: missing return (code=4)", + errShouldBe: "exit code: 1", + }, + { +- args: []string{"tool", "lint", "../../tests/integ/init/"}, ++ args: []string{"lint", "../../tests/integ/init/"}, + // stderr / stdout should be empty; the init function and statements + // should not be executed + }, +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SsQrCMBAG4M59ihPBrU2vGjo5uDu6S9sELdikNGmf39hFEdRFEfH/ljuSQC78 ++SauhOam9NqOIPiULCimnGtzXqWeZc54tmQuOMmZZ5BHJj010Y3C+7Imi3lr/7Nyr/R+VXvP32vl9 ++bdu2NCp1x/fd8Sp/Xt7kn4d1Xk35Z+8b4bE/z38+E1VjRFW6Y+y0p0THtaLpL1RaXfqDsWMr6laJ ++0NFiQQdLl21K+sHQLnTbxvhN11EyUlLbwfg1x99+FwAAAAAAAAAAAAAAAAAAAADAPzgD697CVwAo ++AAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001295/tests/test.sh b/tasks/format-code-task-001295/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1e90d8029508e8fb865c43e053a9709c1f290162 --- /dev/null +++ b/tasks/format-code-task-001295/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +gnovm/cmd/gno/tool_lint_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001295/tests/test_command.sh b/tasks/format-code-task-001295/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001295/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001400/environment/Dockerfile b/tasks/format-code-task-001400/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..61142d30ceceeea6ad8267fcff6949e1ca3a5ebf --- /dev/null +++ b/tasks/format-code-task-001400/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4923134e3c36e9ba57f97108bbd5de6479c79cfa3c7415c613c6bc5f57f35472 diff --git a/tasks/format-code-task-001400/environment/setup/files/blocklist b/tasks/format-code-task-001400/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001400/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001400/environment/setup/setup.sh b/tasks/format-code-task-001400/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001400/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001400/tests/test.patch b/tasks/format-code-task-001400/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7443cb44c0a82f204f44344e3280e9a3187ddd20 --- /dev/null +++ b/tasks/format-code-task-001400/tests/test.patch @@ -0,0 +1,59 @@ +diff --git a/graphene_sqlalchemy/tests/test_converter.py b/graphene_sqlalchemy/tests/test_converter.py +index 459a3139..e8051a18 100644 +--- a/graphene_sqlalchemy/tests/test_converter.py ++++ b/graphene_sqlalchemy/tests/test_converter.py +@@ -145,6 +145,32 @@ def test_should_choice_convert_enum(): + assert graphene_type._meta.enum.__members__["en"].value == "English" + + ++def test_should_enum_choice_convert_enum(): ++ class TestEnum(enum.Enum): ++ es = u"Spanish" ++ en = u"English" ++ ++ field = get_field(ChoiceType(TestEnum, impl=types.String())) ++ graphene_type = field.type ++ assert issubclass(graphene_type, graphene.Enum) ++ assert graphene_type._meta.name == "MODEL_COLUMN" ++ assert graphene_type._meta.enum.__members__["es"].value == "Spanish" ++ assert graphene_type._meta.enum.__members__["en"].value == "English" ++ ++ ++def test_should_intenum_choice_convert_enum(): ++ class TestEnum(enum.IntEnum): ++ one = 1 ++ two = 2 ++ ++ field = get_field(ChoiceType(TestEnum, impl=types.String())) ++ graphene_type = field.type ++ assert issubclass(graphene_type, graphene.Enum) ++ assert graphene_type._meta.name == "MODEL_COLUMN" ++ assert graphene_type._meta.enum.__members__["one"].value == 1 ++ assert graphene_type._meta.enum.__members__["two"].value == 2 ++ ++ + def test_should_columproperty_convert(): + field = get_field_from_column(column_property( + select([func.sum(func.cast(id, types.Integer))]).where(id == 1) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3SQU+DMBgGYM78iu/GZa3tWIeHscS7F+MPIAwaIUJBWjD791bMMmMyd3CLMb7P ++pUC/8pW+8N1YN2WmzXQTXIvwEqXm0fs6ztdSLUUspFCxr5NSJXFA6mo7+mS0Lh+IgqHr3Hd15+b/ ++KH7M32nrsqJr29yU3FaX63Eu/zhRx/yF9Pmv1kIFJC63hdP+ef5FSXPwO12GpZ6Yfa1dUVG/d1Vn ++Yoq5lOHhhrXU1z3Vxh9Z0xDTxIkx07Ha9KM7VRbZlyZvikq3+2x0dWPTVPB4zW8jih4f7u8+prap ++5HKxkXzlH/s3+S1t02Sxea9qu+I5TZdccBGdajivoKch7yttdHbsOX+dPfzcZtKD0wPv98Sm8LcP ++HwAAAAAAAAAAAAAAAAAAAADgh94Av0KVwwAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001400/tests/test.sh b/tasks/format-code-task-001400/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4bd6dfb7e52caa5b2619a7b33f3881d464abc99e --- /dev/null +++ b/tasks/format-code-task-001400/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +graphene_sqlalchemy/tests/test_converter.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001400/tests/test_command.sh b/tasks/format-code-task-001400/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001400/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001401/environment/Dockerfile b/tasks/format-code-task-001401/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f607b0e49d4e60fd1695451d81391ed01a872aa7 --- /dev/null +++ b/tasks/format-code-task-001401/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4c0471f1ef1df9f2531ca2a74ef8e7e62bf76794c75dca328b4938109d06d5be diff --git a/tasks/format-code-task-001401/environment/setup/files/blocklist b/tasks/format-code-task-001401/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001401/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001401/environment/setup/setup.sh b/tasks/format-code-task-001401/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001401/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001401/tests/test.patch b/tasks/format-code-task-001401/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7cec150d666ba78991a43ca213b6477bf36e3083 --- /dev/null +++ b/tasks/format-code-task-001401/tests/test.patch @@ -0,0 +1,388 @@ +diff --git a/usercase-test-coderl/nested_output_rewriters.test.ts b/usercase-test-coderl/nested_output_rewriters.test.ts +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/nested_output_rewriters.test.ts +@@ -0,0 +1,358 @@ ++import { ++ NestFieldOutputsRewriter, ++ RewriteHandler, ++ ScalarFieldToObjectFieldRewriter ++} from '../src'; ++import { parse } from 'graphql'; ++ ++const requestQuery = (result: any): string => (typeof result === 'string' ? result : result.query); ++ ++const fieldAtPath = (query: string, path: string[]): any => { ++ const operation = parse(query).definitions.find( ++ (definition: any) => definition.kind === 'OperationDefinition' ++ ) as any; ++ expect(operation).toBeDefined(); ++ let selectionSet = operation.selectionSet; ++ let field: any; ++ path.forEach(name => { ++ field = selectionSet.selections.find( ++ (selection: any) => selection.kind === 'Field' && selection.name.value === name ++ ); ++ expect(field).toBeDefined(); ++ selectionSet = field.selectionSet; ++ }); ++ return field; ++}; ++ ++const selectionNames = (field: any): string[] => ++ ((field.selectionSet && field.selectionSet.selections) || []) ++ .filter((selection: any) => selection.kind === 'Field') ++ .map((selection: any) => selection.name.value); ++ ++const expectFieldSelections = (query: string, path: string[], expected: string[]) => { ++ expect(selectionNames(fieldAtPath(query, path)).sort()).toEqual([...expected].sort()); ++}; ++ ++const expectNoSelectionSet = (query: string, path: string[]) => { ++ expect(fieldAtPath(query, path).selectionSet).toBeUndefined(); ++}; ++ ++describe('nested output schema compatibility exported rewriters', () => { ++ test('constructor contracts are exposed from the package root', () => { ++ ++ ++ expect(typeof RewriteHandler).toBe('function'); ++ expect(typeof ScalarFieldToObjectFieldRewriter).toBe('function'); ++ expect(typeof NestFieldOutputsRewriter).toBe('function'); ++ ++ ++ expect(() => new ScalarFieldToObjectFieldRewriter({ objectFieldName: 'text' } as any)).toThrow( ++ Error ++ ); ++ ++ expect(() => ++ new NestFieldOutputsRewriter({ ++ newOutputName: 'cat', ++ outputsToNest: ['id'] ++ } as any) ++ ).toThrow(Error); ++ }); ++ ++ test('scalar field request and response evolve through one handler session', () => { ++ ++ ++ const handler = new RewriteHandler([ ++ new ScalarFieldToObjectFieldRewriter({ ++ fieldName: 'title', ++ rootTypes: ['query'], ++ objectFieldName: 'text' ++ }) ++ ]); ++ ++ const query = requestQuery(handler.rewriteRequest('query { thing { title color } }')); ++ ++ expectFieldSelections(query, ['thing'], ['title', 'color']); ++ expectFieldSelections(query, ['thing', 'title'], ['text']); ++ expectNoSelectionSet(query, ['thing', 'color']); ++ expect( ++ handler.rewriteResponse({ ++ thing: { title: { text: 'THING' }, color: 'blue' } ++ }) ++ ).toEqual({ ++ thing: { title: 'THING', color: 'blue' } ++ }); ++ }); ++ ++ test('scalar object arrays are unwrapped while siblings stay at the same response path', () => { ++ ++ ++ const handler = new RewriteHandler([ ++ new ScalarFieldToObjectFieldRewriter({ fieldName: 'titles', objectFieldName: 'text' }) ++ ]); ++ ++ const query = requestQuery(handler.rewriteRequest('query { thing { titles other } }')); ++ ++ expectFieldSelections(query, ['thing'], ['titles', 'other']); ++ expectFieldSelections(query, ['thing', 'titles'], ['text']); ++ expectNoSelectionSet(query, ['thing', 'other']); ++ expect( ++ handler.rewriteResponse({ ++ thing: { titles: [{ text: 'A' }, { text: 'B' }], other: 'kept' } ++ }) ++ ).toEqual({ ++ thing: { titles: ['A', 'B'], other: 'kept' } ++ }); ++ }); ++ ++ test('scalar fields that already have selections are skipped and record no response path', () => { ++ ++ ++ const handler = new RewriteHandler([ ++ new ScalarFieldToObjectFieldRewriter({ fieldName: 'title', objectFieldName: 'text' }) ++ ]); ++ ++ const query = requestQuery(handler.rewriteRequest('query { thing { title { text } color } }')); ++ ++ expectFieldSelections(query, ['thing'], ['title', 'color']); ++ expectFieldSelections(query, ['thing', 'title'], ['text']); ++ expectNoSelectionSet(query, ['thing', 'color']); ++ expect( ++ handler.rewriteResponse({ ++ thing: { title: { text: 'THING' }, color: 'blue' } ++ }) ++ ).toEqual({ ++ thing: { title: { text: 'THING' }, color: 'blue' } ++ }); ++ }); ++ ++ test('scalar matching can be driven by matchConditions without a fieldName', () => { ++ ++ ++ const matchHeadline = (nodeAndVars: any) => ++ nodeAndVars.node.kind === 'Field' && nodeAndVars.node.name.value === 'headline'; ++ const handler = new RewriteHandler([ ++ new ScalarFieldToObjectFieldRewriter({ ++ matchConditions: [matchHeadline], ++ objectFieldName: 'text' ++ } as any) ++ ]); ++ ++ const query = requestQuery(handler.rewriteRequest('query { thing { headline other } }')); ++ ++ expectFieldSelections(query, ['thing'], ['headline', 'other']); ++ expectFieldSelections(query, ['thing', 'headline'], ['text']); ++ expectNoSelectionSet(query, ['thing', 'other']); ++ expect( ++ handler.rewriteResponse({ ++ thing: { headline: { text: 'HEAD' }, other: 'kept' } ++ }) ++ ).toEqual({ ++ thing: { headline: 'HEAD', other: 'kept' } ++ }); ++ }); ++ ++ test('nest output request and response flatten only configured fields', () => { ++ ++ ++ const handler = new RewriteHandler([ ++ new NestFieldOutputsRewriter({ ++ fieldName: 'createCat', ++ rootTypes: ['mutation'], ++ newOutputName: 'cat', ++ outputsToNest: ['id', 'name'] ++ }) ++ ]); ++ ++ const query = requestQuery(handler.rewriteRequest('mutation { createCat { id name executionTime } }')); ++ ++ expectFieldSelections(query, ['createCat'], ['executionTime', 'cat']); ++ expectFieldSelections(query, ['createCat', 'cat'], ['id', 'name']); ++ expect( ++ handler.rewriteResponse({ ++ createCat: { cat: { id: 1, name: 'jack' }, executionTime: 10 } ++ }) ++ ).toEqual({ ++ createCat: { executionTime: 10, id: 1, name: 'jack' } ++ }); ++ }); ++ ++ test('nest output transformation flattens arrays of parent results', () => { ++ ++ ++ const handler = new RewriteHandler([ ++ new NestFieldOutputsRewriter({ ++ fieldName: 'createCats', ++ newOutputName: 'cat', ++ outputsToNest: ['id', 'name'] ++ }) ++ ]); ++ ++ const query = requestQuery( ++ handler.rewriteRequest('mutation { createCats { id name executionTime } }') ++ ); ++ ++ expectFieldSelections(query, ['createCats'], ['executionTime', 'cat']); ++ expectFieldSelections(query, ['createCats', 'cat'], ['id', 'name']); ++ expect( ++ handler.rewriteResponse({ ++ createCats: [ ++ { cat: { id: 1, name: 'jack' }, executionTime: 10 }, ++ { cat: { id: 2, name: 'jill' }, executionTime: 11 } ++ ] ++ }) ++ ).toEqual({ ++ createCats: [ ++ { executionTime: 10, id: 1, name: 'jack' }, ++ { executionTime: 11, id: 2, name: 'jill' } ++ ] ++ }); ++ }); ++ ++ test('existing nested output selection prevents another nesting pass', () => { ++ ++ ++ const handler = new RewriteHandler([ ++ new NestFieldOutputsRewriter({ ++ fieldName: 'createCat', ++ newOutputName: 'cat', ++ outputsToNest: ['id', 'name'] ++ }) ++ ]); ++ ++ const query = requestQuery( ++ handler.rewriteRequest('mutation { createCat { cat { id } id name executionTime } }') ++ ); ++ ++ expectFieldSelections(query, ['createCat'], ['cat', 'id', 'name', 'executionTime']); ++ expectFieldSelections(query, ['createCat', 'cat'], ['id']); ++ expect( ++ handler.rewriteResponse({ ++ createCat: { cat: { id: 1 }, id: 99, name: 'flat', executionTime: 10 } ++ }) ++ ).toEqual({ ++ createCat: { cat: { id: 1 }, id: 99, name: 'flat', executionTime: 10 } ++ }); ++ }); ++ ++ test('nest response leaves null and non-object branches unchanged but flattens valid siblings', () => { ++ ++ ++ const handler = new RewriteHandler([ ++ new NestFieldOutputsRewriter({ ++ fieldName: 'createCats', ++ newOutputName: 'cat', ++ outputsToNest: ['id', 'name'] ++ }) ++ ]); ++ ++ const query = requestQuery(handler.rewriteRequest('mutation { createCats { id name } }')); ++ ++ expectFieldSelections(query, ['createCats'], ['cat']); ++ expectFieldSelections(query, ['createCats', 'cat'], ['id', 'name']); ++ expect( ++ handler.rewriteResponse({ ++ createCats: [ ++ null, ++ 'bad', ++ { cat: null, executionTime: 10 }, ++ { cat: 'bad', executionTime: 11 }, ++ { cat: { id: 3, name: 'ok' }, executionTime: 12 } ++ ] ++ }) ++ ).toEqual({ ++ createCats: [ ++ null, ++ 'bad', ++ { cat: null, executionTime: 10 }, ++ { cat: 'bad', executionTime: 11 }, ++ { executionTime: 12, id: 3, name: 'ok' } ++ ] ++ }); ++ }); ++ ++ test('handler session rewrites request and response through the scalar rewriter', () => { ++ ++ ++ const handler = new RewriteHandler([ ++ new ScalarFieldToObjectFieldRewriter({ fieldName: 'title', objectFieldName: 'text' }) ++ ]); ++ ++ const query = requestQuery(handler.rewriteRequest('query { thing { title } }')); ++ ++ expectFieldSelections(query, ['thing'], ['title']); ++ expectFieldSelections(query, ['thing', 'title'], ['text']); ++ expect( ++ handler.rewriteResponse({ ++ thing: { title: { text: 'THING' } } ++ }) ++ ).toEqual({ ++ thing: { title: 'THING' } ++ }); ++ }); ++ ++ test('two handler instances keep their recorded response paths independent', () => { ++ ++ ++ const a = new RewriteHandler([ ++ new ScalarFieldToObjectFieldRewriter({ fieldName: 'title', objectFieldName: 'text' }) ++ ]); ++ const b = new RewriteHandler([ ++ new ScalarFieldToObjectFieldRewriter({ fieldName: 'titles', objectFieldName: 'text' }) ++ ]); ++ ++ const aQuery = requestQuery(a.rewriteRequest('query { thing { title } }')); ++ const bQuery = requestQuery(b.rewriteRequest('query { thing { titles } }')); ++ ++ expectFieldSelections(aQuery, ['thing'], ['title']); ++ expectFieldSelections(aQuery, ['thing', 'title'], ['text']); ++ expectFieldSelections(bQuery, ['thing'], ['titles']); ++ expectFieldSelections(bQuery, ['thing', 'titles'], ['text']); ++ expect( ++ a.rewriteResponse({ ++ thing: { title: { text: 'ONE' }, titles: [{ text: 'A' }] } ++ }) ++ ).toEqual({ ++ thing: { title: 'ONE', titles: [{ text: 'A' }] } ++ }); ++ expect( ++ b.rewriteResponse({ ++ thing: { title: { text: 'ONE' }, titles: [{ text: 'A' }] } ++ }) ++ ).toEqual({ ++ thing: { title: { text: 'ONE' }, titles: ['A'] } ++ }); ++ }); ++ ++ test('repeated construct request response cycles keep producing the specified transformations', () => { ++ ++ ++ let completed = 0; ++ ++ for (let i = 0; i < 150; i += 1) { ++ const handler = new RewriteHandler([ ++ new NestFieldOutputsRewriter({ ++ fieldName: 'createCat', ++ newOutputName: 'cat', ++ outputsToNest: ['id', 'name'] ++ }) ++ ]); ++ const query = requestQuery( ++ handler.rewriteRequest('mutation { createCat { id name executionTime } }') ++ ); ++ ++ expectFieldSelections(query, ['createCat'], ['executionTime', 'cat']); ++ expectFieldSelections(query, ['createCat', 'cat'], ['id', 'name']); ++ expect( ++ handler.rewriteResponse({ ++ createCat: { cat: { id: 1, name: 'jack' }, executionTime: 10 } ++ }) ++ ).toEqual({ ++ createCat: { executionTime: 10, id: 1, name: 'jack' } ++ }); ++ completed += 1; ++ } ++ ++ ++ expect(completed).toBe(150); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++if [ ! -x /workspace/repo/node_modules/.bin/jest ]; then ++ echo "Missing /workspace/repo/node_modules/.bin/jest; dependencies must be preinstalled before the offline run." >&2 ++ exit 127 ++fi ++ ++exec /workspace/repo/node_modules/.bin/jest /workspace/repo/usercase-test-coderl/nested_output_rewriters.test.ts --runInBand diff --git a/tasks/format-code-task-001401/tests/test.sh b/tasks/format-code-task-001401/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ed0f4c556034533fb65d1561054bac8e2030abc0 --- /dev/null +++ b/tasks/format-code-task-001401/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/nested_output_rewriters.test.ts +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001401/tests/test_command.sh b/tasks/format-code-task-001401/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001401/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001431/environment/Dockerfile b/tasks/format-code-task-001431/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ed569a303846e525f9df33dd21bc966c514ccfe8 --- /dev/null +++ b/tasks/format-code-task-001431/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:43e7abfe32d8dc3e3aa975a5cd454444308993bfa840d708a82c6d6d94f75aa9 diff --git a/tasks/format-code-task-001431/environment/setup/files/blocklist b/tasks/format-code-task-001431/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001431/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001431/environment/setup/setup.sh b/tasks/format-code-task-001431/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001431/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001431/tests/test.patch b/tasks/format-code-task-001431/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..49f7b3d853aafd7adaee3936ec0eaedcf428c729 --- /dev/null +++ b/tasks/format-code-task-001431/tests/test.patch @@ -0,0 +1,69 @@ +diff --git a/test/logformats_test.py b/test/logformats_test.py +index 347785b4b..400bf369d 100644 +--- a/test/logformats_test.py ++++ b/test/logformats_test.py +@@ -11,7 +11,7 @@ + + TODO: correctly set preserves_channel and adds_default_channel + """ +- ++import gzip + import logging + import unittest + import tempfile +@@ -555,6 +555,34 @@ def test_can_and_canfd_error_frames(self): + self.assertMessagesEqual(actual, expected_messages) + + ++class TestGzipASCFileFormat(ReaderWriterTest): ++ """Tests can.GzipASCWriter and can.GzipASCReader""" ++ ++ def _setup_instance(self): ++ super()._setup_instance_helper( ++ can.GzipASCWriter, ++ can.GzipASCReader, ++ binary_file=True, ++ check_comments=True, ++ preserves_channel=False, ++ adds_default_channel=0, ++ ) ++ ++ def assertIncludesComments(self, filename): ++ """ ++ Ensures that all comments are literally contained in the given file. ++ ++ :param filename: the path-like object to use ++ """ ++ if self.original_comments: ++ ++ with gzip.open(filename, "rt" if self.binary_file else "r") as file: ++ output_contents = file.read() ++ ++ for comment in self.original_comments: ++ self.assertIn(comment, output_contents) ++ ++ + class TestBlfFileFormat(ReaderWriterTest): + """Tests can.BLFWriter and can.BLFReader. + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SwY6DIBAGYM8+xaR3EUzR0z6LQWG3JlWMjCZ9+6KHttlkt5c2m3b/78IAkwD5 ++Ec3cHW3thiVPnkVGldbbGH0ft1rpQhWFqqQuEqmUrsqE9NNudGMObCaiZPKef+u7t/+ixDV/doHr ++1ve9GawIh8edcS9/tb/kX1ZyzX9fypi/fNwVfvbP828tbcE3zqbBz1PrSCzrb2i6ITctd4thl44n ++PviBsp5iFbsp87Qz1vqRw8eO1qX86L8+/dQbDvU6F+OJsiX96/cBAAAAAAAAAAAAAAAAAAAAALyz ++M5bKGI4AKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001431/tests/test.sh b/tasks/format-code-task-001431/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e188d9b3f96556b896b639a85b21125c810e3869 --- /dev/null +++ b/tasks/format-code-task-001431/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/logformats_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001431/tests/test_command.sh b/tasks/format-code-task-001431/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001431/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001437/environment/Dockerfile b/tasks/format-code-task-001437/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1e4da67fe4b4c1488d476486385e67aba2e603ea --- /dev/null +++ b/tasks/format-code-task-001437/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:cb1d02c56eccf8e4d09f451d0995d818de8c648695c08ba38afd7a0172c77084 diff --git a/tasks/format-code-task-001437/environment/setup/files/blocklist b/tasks/format-code-task-001437/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001437/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001437/environment/setup/setup.sh b/tasks/format-code-task-001437/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001437/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001437/tests/test.patch b/tasks/format-code-task-001437/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8c49359871288e08536422161f373e5456c4b52b --- /dev/null +++ b/tasks/format-code-task-001437/tests/test.patch @@ -0,0 +1,99 @@ +diff --git a/test/stringify.js b/test/stringify.js +index 579873e..de68520 100644 +--- a/test/stringify.js ++++ b/test/stringify.js +@@ -115,6 +115,66 @@ test('stringify cron expression with star range step', function (t) { + t.end(); + }); + ++test('stringify retains explicit list when step would broaden day-of-week', function (t) { ++ try { ++ var expected = '0 * * * * 1,3,5'; ++ var interval = CronParser.parseExpression('* * * * 1,3,5', {}); ++ var str = interval.stringify(true); ++ t.equal(str, expected); ++ ++ str = CronParser.fieldsToExpression(interval.fields).stringify(true); ++ t.equal(str, expected); ++ ++ expected = '* * * * 1,3,5'; ++ str = interval.stringify(); ++ t.equal(str, expected); ++ ++ str = CronParser.fieldsToExpression(interval.fields).stringify(); ++ t.equal(str, expected); ++ } catch (err) { ++ t.error(err, 'Parse read error'); ++ } ++ ++ t.end(); ++}); ++ ++test('fieldsToExpression retains explicit list for another non-equivalent stepped day-of-week field', function (t) { ++ try { ++ var expected = '0 * * * * 1,4'; ++ var interval = CronParser.parseExpression('* * * * 1,4', {}); ++ var str = CronParser.fieldsToExpression(interval.fields).stringify(true); ++ t.equal(str, expected); ++ } catch (err) { ++ t.error(err, 'Parse read error'); ++ } ++ ++ t.end(); ++}); ++ ++test('stringify preserves safe stepped compression for day-of-week list', function (t) { ++ try { ++ var expected = '0 * * * * 0-6/2'; ++ var interval = CronParser.parseExpression('* * * * 0,2,4,6', {}); ++ var str = interval.stringify(true); ++ t.equal(str, expected); ++ ++ str = CronParser.fieldsToExpression(interval.fields).stringify(true); ++ t.equal(str, expected); ++ ++ expected = '0 5/5 * * * *'; ++ interval = CronParser.parseExpression('5,10,15,20,25,30,35,40,45,50,55 * * * *', {}); ++ str = interval.stringify(true); ++ t.equal(str, expected); ++ ++ str = CronParser.fieldsToExpression(interval.fields).stringify(true); ++ t.equal(str, expected); ++ } catch (err) { ++ t.error(err, 'Parse read error'); ++ } ++ ++ t.end(); ++}); ++ + test('stringify cron expression with star range step (discard seconds)', function (t) { + try { + var expected = '*/5 */2 * * *'; +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,23 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++npm install --no-audit --no-fund 2>/dev/null ++ ++TAP=./node_modules/.bin/tap ++ ++case "${1:-}" in ++ base) ++ "$TAP" ./test/stringify.js \ ++ --grep="stringify retains explicit list when step would broaden day-of-week|fieldsToExpression retains explicit list for another non-equivalent stepped day-of-week field|stringify preserves safe stepped compression for day-of-week list" \ ++ --invert ++ ;; ++ new) ++ "$TAP" ./test/stringify.js \ ++ --grep="stringify retains explicit list when step would broaden day-of-week|fieldsToExpression retains explicit list for another non-equivalent stepped day-of-week field|stringify preserves safe stepped compression for day-of-week list" ++ ;; ++ *) ++ echo "usage: $0 base|new" >&2 ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001437/tests/test.sh b/tasks/format-code-task-001437/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d0e835a31f5fdcf4bd06bf0013b481aa421e8ccb --- /dev/null +++ b/tasks/format-code-task-001437/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/stringify.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001437/tests/test_command.sh b/tasks/format-code-task-001437/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001437/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001438/environment/Dockerfile b/tasks/format-code-task-001438/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0a44de3462229c5ee2e2d03a85fef98aafe70e37 --- /dev/null +++ b/tasks/format-code-task-001438/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fbd175ff78aab9db49dc4f930af3b3b0c5d4e04a4931b0dd96854361a4b2e35c diff --git a/tasks/format-code-task-001438/environment/setup/files/blocklist b/tasks/format-code-task-001438/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001438/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001438/environment/setup/setup.sh b/tasks/format-code-task-001438/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001438/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001438/tests/test.patch b/tasks/format-code-task-001438/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fe9788f7625947d389d8f0340608f8be154f3bef --- /dev/null +++ b/tasks/format-code-task-001438/tests/test.patch @@ -0,0 +1,186 @@ +diff --git a/internal/host/plugin/repository_host_catalog_test.go b/internal/host/plugin/repository_host_catalog_test.go +index c46ca951a9..3125a81acb 100644 +--- a/internal/host/plugin/repository_host_catalog_test.go ++++ b/internal/host/plugin/repository_host_catalog_test.go +@@ -9,6 +9,7 @@ import ( + + "github.com/google/go-cmp/cmp" + "github.com/hashicorp/boundary/internal/db" ++ "github.com/hashicorp/boundary/internal/db/timestamp" + "github.com/hashicorp/boundary/internal/errors" + "github.com/hashicorp/boundary/internal/host/plugin/store" + "github.com/hashicorp/boundary/internal/iam" +@@ -17,6 +18,7 @@ import ( + hostplg "github.com/hashicorp/boundary/internal/plugin/host" + hostplugin "github.com/hashicorp/boundary/internal/plugin/host" + "github.com/hashicorp/boundary/internal/scheduler" ++ "github.com/hashicorp/boundary/internal/scheduler/job" + plgpb "github.com/hashicorp/boundary/sdk/pbs/plugin" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +@@ -1441,6 +1443,133 @@ func TestRepository_DeleteCatalogX(t *testing.T) { + } + } + ++ ++ ++ ++type testSyncJob struct{} ++ ++func (j *testSyncJob) Status() scheduler.JobStatus { ++ return scheduler.JobStatus{ ++ Completed: 0, ++ Total: 1, ++ } ++} ++ ++func (j *testSyncJob) Run(_ context.Context) error { return nil } ++func (j *testSyncJob) NextRunIn() (time.Duration, error) { return setSyncJobRunInterval, nil } ++func (j *testSyncJob) Name() string { return setSyncJobName } ++func (j *testSyncJob) Description() string { return setSyncJobName } ++ ++func TestRepository_UpdateCatalog_SyncSets(t *testing.T) { ++ ctx := context.Background() ++ dbConn, _ := db.TestSetup(t, "postgres") ++ dbRW := db.New(dbConn) ++ dbWrapper := db.TestWrapper(t) ++ sched := scheduler.TestScheduler(t, dbConn, dbWrapper) ++ dbKmsCache := kms.TestKms(t, dbConn, dbWrapper) ++ _, projectScope := iam.TestScopes(t, iam.TestRepo(t, dbConn, dbWrapper)) ++ ++ testPlugin := hostplg.TestPlugin(t, dbConn, "test") ++ dummyPluginMap := map[string]plgpb.HostPluginServiceClient{ ++ testPlugin.GetPublicId(): &WrappingPluginClient{Server: &plgpb.UnimplementedHostPluginServiceServer{}}, ++ } ++ ++ ++ testCatalog := TestCatalog(t, dbConn, projectScope.PublicId, testPlugin.GetPublicId()) ++ ++ emptyTestCatalog := TestCatalog(t, dbConn, projectScope.PublicId, testPlugin.GetPublicId()) ++ ++ ++ set1 := TestSet(t, dbConn, dbKmsCache, sched, testCatalog, dummyPluginMap) ++ set1.LastSyncTime = timestamp.New(time.Now()) ++ set1.NeedSync = false ++ ++ numSetsUpdated, err := dbRW.Update(ctx, set1, []string{"LastSyncTime", "NeedSync"}, []string{}) ++ require.NoError(t, err) ++ require.Equal(t, 1, numSetsUpdated) ++ ++ ++ set2 := TestSet(t, dbConn, dbKmsCache, sched, testCatalog, dummyPluginMap) ++ set2.LastSyncTime = timestamp.New(time.Now()) ++ set2.NeedSync = false ++ ++ numSetsUpdated, err = dbRW.Update(ctx, set2, []string{"LastSyncTime", "NeedSync"}, []string{}) ++ require.NoError(t, err) ++ require.Equal(t, 1, numSetsUpdated) ++ ++ j := &testSyncJob{} ++ err = sched.RegisterJob(ctx, j, scheduler.WithNextRunIn(setSyncJobRunInterval)) ++ require.NoError(t, err) ++ ++ repo, err := NewRepository(dbRW, dbRW, dbKmsCache, sched, dummyPluginMap) ++ require.NoError(t, err) ++ require.NotNil(t, repo) ++ ++ ++ jobRepo, err := job.NewRepository(dbRW, dbRW, dbKmsCache) ++ require.NoError(t, err) ++ require.NotNil(t, repo) ++ ++ ++ emptyTestCatalog.Attributes = mustMarshal(map[string]interface{}{"foo": "bar"}) ++ var catalogsUpdated int ++ _, _, catalogsUpdated, err = repo.UpdateCatalog(ctx, emptyTestCatalog, emptyTestCatalog.Version, []string{"attributes"}) ++ require.NoError(t, err) ++ require.Equal(t, 1, catalogsUpdated) ++ ++ ++ jj, err := jobRepo.LookupJob(ctx, setSyncJobName) ++ require.NoError(t, err) ++ require.NotNil(t, jj) ++ require.GreaterOrEqual(t, time.Until(jj.GetNextScheduledRun().GetTimestamp().AsTime()), time.Second) ++ ++ ++ testCatalog.Name = "foobar" ++ testCatalog, _, catalogsUpdated, err = repo.UpdateCatalog(ctx, testCatalog, testCatalog.Version, []string{"name"}) ++ require.NoError(t, err) ++ require.Equal(t, 1, catalogsUpdated) ++ ++ gotSet1, _, err := repo.LookupSet(ctx, set1.PublicId) ++ require.NoError(t, err) ++ require.False(t, gotSet1.NeedSync) ++ require.Equal(t, set1.LastSyncTime, gotSet1.LastSyncTime) ++ require.Equal(t, set1.Version, gotSet1.Version) ++ ++ gotSet2, _, err := repo.LookupSet(ctx, set2.PublicId) ++ require.NoError(t, err) ++ require.False(t, gotSet2.NeedSync) ++ require.Equal(t, set2.LastSyncTime, gotSet2.LastSyncTime) ++ require.Equal(t, set2.Version, gotSet2.Version) ++ ++ ++ jj, err = jobRepo.LookupJob(ctx, setSyncJobName) ++ require.NoError(t, err) ++ require.NotNil(t, jj) ++ require.GreaterOrEqual(t, time.Until(jj.GetNextScheduledRun().GetTimestamp().AsTime()), time.Second) ++ ++ ++ testCatalog.Attributes = mustMarshal(map[string]interface{}{"foo": "bar"}) ++ _, _, catalogsUpdated, err = repo.UpdateCatalog(ctx, testCatalog, testCatalog.Version, []string{"attributes"}) ++ require.NoError(t, err) ++ require.Equal(t, 1, catalogsUpdated) ++ ++ gotSet1, _, err = repo.LookupSet(ctx, set1.PublicId) ++ require.NoError(t, err) ++ require.True(t, gotSet1.NeedSync) ++ require.Equal(t, set1.Version+1, gotSet1.Version) ++ ++ gotSet2, _, err = repo.LookupSet(ctx, set2.PublicId) ++ require.NoError(t, err) ++ require.True(t, gotSet2.NeedSync) ++ require.Equal(t, set2.Version+1, gotSet2.Version) ++ ++ ++ jj, err = jobRepo.LookupJob(ctx, setSyncJobName) ++ require.NoError(t, err) ++ require.NotNil(t, jj) ++ require.Less(t, time.Until(jj.GetNextScheduledRun().GetTimestamp().AsTime()), time.Second) ++} ++ + func assertPluginBasedPublicId(t *testing.T, prefix, actual string) { + t.Helper() + assert.NotEmpty(t, actual) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,16 @@ ++H4sIAAAAAAAAA+2WXW/iOBSGuc6vOENHSztqSEJLuUCtxLaZ2ZE6hU1ge1MJmcSAtcZOY4fZSv3x ++exwGwnZKO5U6GlXrh4t8OfZ73nN8QnNSMJ6OqVh6tZ+Fj3Ta7fKIPDyW50G7FQSdY78dBDU/CNqd ++kxq0f5qiLQqlSQ5Qy6XUT4177vkbpVnlX1Olx4lcLIhIm2r+ems8k/+jk+POJv9HRzguOD458mvg ++v56E3fzP87/3zitU7k2Y8LAGYELU3FFUg0sLCRnL6JQw7iQplOUxoanj7EGMlmkYSKVnOY3/vAQ2 ++BSE15IUQTMycbDZmKqckvQP3FlpnXkqXnig4h/t7wIeJ5glH42kOwQksCBOgyikfDNV5Qc16oVBF ++TmEiC5GS/A4KhW9ilUJKNEHJFOg/TGlHFeBCtpKlwE2gnqlbbk5u6nF4GZ4PIYCPUf+LEZFLjoOu ++/wijEPBckAU9bayXaNzU4R5wmsxEEJS6N1OdR2FvGMIoDqNK06AXx9f96AKqOSAeDcLIDOve1OuP ++BvcixZtoV6Lx8uWiL3rD3u+9OKyE96+vtuLYqdSkHeuiyDZDx5ouMk40NelnGlJJlWjob7nAe+9g ++8Glty+lmvZWkOQStTtPHXwDuqFLjplvnaMeLTdioajyIozKmC3pOhQPIU/7vcqyK+3vrnHLWPehl ++Gb+DUueCzXKimRSqfDaVOUwZR9MEvN/nuOhys7c8JnBPCMK9dOKpZE4XxKte98x03lqs96FZZE0U ++e9BF58upDbsdX0L/ahxGUT8ax8P+4DR4IgmukG5GlPoq8xSv0onx+BED3CnU35to6nAGldets9+C ++UlEqBf2vJf04fkVHpFJbhnx4c56YHbWKCpY0VxiT8wsE35aF//kKG9UQPl8N+9WglbjxN3GwT1Nm ++nD9cyz2Av3qXozCG/QbmonEILd8P/IPujh6yivoLyf8GomCt4JmYf6hVrGIYDS7Mlt1uE3E4NE0C ++W9I63tNSzGH58eBcfk2kEHhzSvjDroJ3H+kr3bozZaYfRoUwnQTw0zXDRJqSdWayPJpMuQm+qk2K ++8LsIQ7wbUSxWpiXONspwDXpuJMjZOL4TCdaCgmZV8HOsay/jxQw/zc6v/ptgsVgsFovFYrFYLBaL ++xWKxWCwWi8VisVjeAP8C9/pvngAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001438/tests/test.sh b/tasks/format-code-task-001438/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..245da4744eb1dc203dcaa1d7217b4db454302db7 --- /dev/null +++ b/tasks/format-code-task-001438/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +internal/host/plugin/repository_host_catalog_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001438/tests/test_command.sh b/tasks/format-code-task-001438/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001438/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001452/environment/Dockerfile b/tasks/format-code-task-001452/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6956394139188868b831e7009ffe82934919f4c3 --- /dev/null +++ b/tasks/format-code-task-001452/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3831eadcb9096c56a662e6b3b56b564a19ac5185a294dfc603bfc7bdff7662cf diff --git a/tasks/format-code-task-001452/environment/setup/files/blocklist b/tasks/format-code-task-001452/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001452/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001452/environment/setup/setup.sh b/tasks/format-code-task-001452/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001452/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001452/tests/test.patch b/tasks/format-code-task-001452/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b7e55094ddfc0999304782cf4105d4811d6b524e --- /dev/null +++ b/tasks/format-code-task-001452/tests/test.patch @@ -0,0 +1,151 @@ +diff --git a/azurerm/helpers/azure/authorization_rules_test.go b/azurerm/helpers/azure/authorization_rules_test.go +new file mode 100644 +index 0000000000..6f618e2c69 +--- /dev/null ++++ b/azurerm/helpers/azure/authorization_rules_test.go +@@ -0,0 +1,136 @@ ++package azure ++ ++import ( ++ "fmt" ++ "strings" ++ "testing" ++ ++ "github.com/Azure/azure-sdk-for-go/services/eventhub/mgmt/2017-04-01/eventhub" ++ "github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus" ++ "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ++ "github.com/hashicorp/terraform-plugin-sdk/terraform" ++) ++ ++func diffValidationErrorWithSchema(custom schema.CustomizeDiffFunc, fields map[string]*schema.Schema, values map[string]interface{}, service string) (err error) { ++ defer func() { ++ if recovered := recover(); recovered != nil { ++ err = fmt.Errorf("%s authorization diff panicked: %v", service, recovered) ++ } ++ }() ++ r := &schema.Resource{ ++ Schema: fields, ++ CustomizeDiff: custom, ++ } ++ _, err = r.Diff(nil, terraform.NewResourceConfigRaw(values), nil) ++ return err ++} ++ ++func diffValidationError(custom schema.CustomizeDiffFunc, values map[string]interface{}, service string) error { ++ return diffValidationErrorWithSchema(custom, ServiceBusAuthorizationRuleSchemaFrom(map[string]*schema.Schema{}), values, service) ++} ++ ++func bareRightsSchema() map[string]*schema.Schema { ++ return map[string]*schema.Schema{ ++ "listen": {Type: schema.TypeBool, Optional: true}, ++ "send": {Type: schema.TypeBool, Optional: true}, ++ "manage": {Type: schema.TypeBool, Optional: true}, ++ } ++} ++ ++func TestServiceBusAuthorizationRuleCustomizeDiffValidation(t *testing.T) { ++ cases := []struct { ++ name string ++ values map[string]interface{} ++ err bool ++ }{ ++ {"omitted rights", map[string]interface{}{}, true}, ++ {"explicitly disabled rights", map[string]interface{}{"listen": false, "send": false, "manage": false}, true}, ++ {"listen only", map[string]interface{}{"listen": true}, false}, ++ {"send only", map[string]interface{}{"send": true}, false}, ++ {"manage without listen", map[string]interface{}{"manage": true}, true}, ++ {"manage without send", map[string]interface{}{"manage": true, "listen": true}, true}, ++ {"all rights", map[string]interface{}{"listen": true, "send": true, "manage": true}, false}, ++ } ++ for _, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ err := diffValidationError(ServiceBusAuthorizationRuleCustomizeDiff, tc.values, "service bus") ++ if err != nil && strings.Contains(err.Error(), "panicked") { ++ t.Fatalf("customize diff must return validation errors instead of panic: %v", err) ++ } ++ if (err != nil) != tc.err { ++ t.Fatalf("expected error=%t, got %v", tc.err, err) ++ } ++ }) ++ } ++} ++ ++func TestEventHubAuthorizationRuleCustomizeDiffValidation(t *testing.T) { ++ cases := []struct { ++ name string ++ values map[string]interface{} ++ err bool ++ }{ ++ {"omitted rights", map[string]interface{}{}, true}, ++ {"explicitly disabled rights", map[string]interface{}{"listen": false, "send": false, "manage": false}, true}, ++ {"listen only", map[string]interface{}{"listen": true}, false}, ++ {"send only", map[string]interface{}{"send": true}, false}, ++ {"manage without listen", map[string]interface{}{"manage": true}, true}, ++ {"manage without send", map[string]interface{}{"manage": true, "listen": true}, true}, ++ {"all rights", map[string]interface{}{"listen": true, "send": true, "manage": true}, false}, ++ } ++ for _, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ err := diffValidationError(EventHubAuthorizationRuleCustomizeDiff, tc.values, "event hub") ++ if err != nil && strings.Contains(err.Error(), "panicked") { ++ t.Fatalf("customize diff must return validation errors instead of panic: %v", err) ++ } ++ if (err != nil) != tc.err { ++ t.Fatalf("expected error=%t, got %v", tc.err, err) ++ } ++ }) ++ } ++} ++ ++func TestAuthorizationRuleCustomizeDiffHandlesOmittedBooleans(t *testing.T) { ++ for _, tc := range []struct { ++ name string ++ fn schema.CustomizeDiffFunc ++ }{ ++ {"service bus", ServiceBusAuthorizationRuleCustomizeDiff}, ++ {"event hub", EventHubAuthorizationRuleCustomizeDiff}, ++ } { ++ t.Run(tc.name, func(t *testing.T) { ++ err := diffValidationErrorWithSchema(tc.fn, bareRightsSchema(), map[string]interface{}{"manage": true}, tc.name) ++ if err != nil && strings.Contains(err.Error(), "panicked") { ++ t.Fatalf("customize diff must handle omitted booleans without panic: %v", err) ++ } ++ if err == nil { ++ t.Fatal("expected manage without both listen and send to be rejected") ++ } ++ }) ++ } ++} ++ ++func TestServiceBusAuthorizationRuleRightsRoundTrip(t *testing.T) { ++ d := schema.TestResourceDataRaw(t, ServiceBusAuthorizationRuleSchemaFrom(nil), map[string]interface{}{"listen": true, "send": false, "manage": true}) ++ rights := ExpandServiceBusAuthorizationRuleRights(d) ++ if len(*rights) != 2 || (*rights)[0] != servicebus.Listen || (*rights)[1] != servicebus.Manage { ++ t.Fatalf("unexpected service bus rights: %#v", *rights) ++ } ++ listen, send, manage := FlattenServiceBusAuthorizationRuleRights(rights) ++ if !listen || send || !manage { ++ t.Fatalf("unexpected service bus flattening: listen=%t send=%t manage=%t", listen, send, manage) ++ } ++} ++ ++func TestEventHubAuthorizationRuleRightsRoundTrip(t *testing.T) { ++ d := schema.TestResourceDataRaw(t, EventHubAuthorizationRuleSchemaFrom(nil), map[string]interface{}{"listen": false, "send": true, "manage": true}) ++ rights := ExpandEventHubAuthorizationRuleRights(d) ++ if len(*rights) != 2 || (*rights)[0] != eventhub.Send || (*rights)[1] != eventhub.Manage { ++ t.Fatalf("unexpected event hub rights: %#v", *rights) ++ } ++ listen, send, manage := FlattenEventHubAuthorizationRuleRights(rights) ++ if listen || !send || !manage { ++ t.Fatalf("unexpected event hub flattening: listen=%t send=%t manage=%t", listen, send, manage) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++GOFLAGS=-mod=vendor go test ./azurerm/helpers/azure -run 'Test(ServiceBusAuthorizationRuleCustomizeDiffValidation|EventHubAuthorizationRuleCustomizeDiffValidation|AuthorizationRuleCustomizeDiffHandlesOmittedBooleans|ServiceBusAuthorizationRuleRightsRoundTrip|EventHubAuthorizationRuleRightsRoundTrip)' diff --git a/tasks/format-code-task-001452/tests/test.sh b/tasks/format-code-task-001452/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cf81e0aaa59ed16f3f140d210d9054ff7f612a6b --- /dev/null +++ b/tasks/format-code-task-001452/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +azurerm/helpers/azure/authorization_rules_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001452/tests/test_command.sh b/tasks/format-code-task-001452/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001452/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001455/environment/Dockerfile b/tasks/format-code-task-001455/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0b374265fe1b045027e0cbf6c7dbe921d87b6b76 --- /dev/null +++ b/tasks/format-code-task-001455/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:95b037d39a22d3f7d18730425baa50780cc68fd8386fa8807a60731009f02aba diff --git a/tasks/format-code-task-001455/environment/setup/files/blocklist b/tasks/format-code-task-001455/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001455/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001455/environment/setup/setup.sh b/tasks/format-code-task-001455/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001455/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001455/tests/test.patch b/tasks/format-code-task-001455/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..94907b8ee3b581439bdca06b93a1d2202574ba51 --- /dev/null +++ b/tasks/format-code-task-001455/tests/test.patch @@ -0,0 +1,50 @@ +diff --git a/builtin/logical/pki/backend_test.go b/builtin/logical/pki/backend_test.go +index 2f9587153a2f..50af5b80fe63 100644 +--- a/builtin/logical/pki/backend_test.go ++++ b/builtin/logical/pki/backend_test.go +@@ -299,9 +299,13 @@ func checkCertsAndPrivateKey(keyType string, key crypto.Signer, usage certUsage, + } + } + +- if math.Abs(float64(time.Now().Unix()-cert.NotBefore.Unix())) > 10 { ++ ++ if math.Abs(float64(time.Now().Unix()-cert.NotBefore.Unix())) > 40 { + return nil, fmt.Errorf("Validity period starts out of range") + } ++ if !cert.NotBefore.Before(time.Now().Add(-10 * time.Second)) { ++ return nil, fmt.Errorf("Validity period not far enough in the past") ++ } + + if math.Abs(float64(time.Now().Add(validity).Unix()-cert.NotAfter.Unix())) > 10 { + return nil, fmt.Errorf("Validity period of %d too large vs max of 10", cert.NotAfter.Unix()) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,15 @@ ++H4sIAAAAAAAAA+2WW2/TMBSA+5xfcShIbBKpk15hqA9ldGPA6Ng6rkKV4ziN1zQOttNtPPDbOU7X ++dZoY44GLEP4ayZbtc/M5ttuISpHFE54vSO13ESC9Tqdqkett1Q87zRB/QdBq14Iw7HR7Nej8No+u ++UGpDFUBNSWl+tO62+X+Uxjr/hmszYXI+p3nc0Omvs3FL/puddniR/7DXa3Yx/+1us1WD4Ne5cDP/ ++ef7v3iGRyElEdeppbsDnnsdiqIoh4rHn3YVjzcGkHOYyFongMexKCBthCwepAV0WhVRGw+5oMt7b ++H05GOztHw7HHz+wwjh6ORuM+kYUhU+lbudXUwWD8rF+/t1xhvdi6Z4fq1iaaQHNlxjXIJIENkwoN +++FEoFPdXU4WSJ5wZKLXIpygT82JzbTgMw/3R0+OXwz6qqJSOrP4tIDaX6A0kQmkDGynV2D3DyMqp ++VCcCpwhDZWzzgQ08X2rWcCrVTBeU8bWNZQwrhVurbSNLCTK5FKmiGua6VMvNXIqCPp9nIp8BPxPa ++aG8+i4UCv7h0kWjFyFSYtIwaeDQJupoKJlXhiQQ+wh3M1+1ryYKWmYFPj6toPECyHHx9meWfVeEl ++4loY3902myiRQ5HZrVr5ebOR69JX/bx1Q5bC1VpWgK/g5hR8X/RGzZVOjdH5Au5rMuX5E6p5t81z ++Bmv6EFWjjVf8dJhjAFiJG/XBk+2nw53dZ3vPX7zcfzU6eH14ND5+8/bd+w80YjFPpqk4mWXzXBaf ++sQLLxenZ+ZcgbLba+O49fDSZ1Df/pD3f2rv/s/mxnjWm8rIWaJRxoIzxwtCcYVlwW8kXJ2S8Mxls ++b/dDu3SUJPaGMWLOITqHr00451TZUjGyKqaC4mnUy35KVWzNxXB4NIDtATCuDCrZOMWCTPG8FELh ++ZBNfDz/o+M1Hm7bqtBFZBguaiRjiUtlbwbqD7frIXr2l+nW/2wp6+LcjqA7oYZlX1g9e7OE+sxnP ++44t48LawHfAX+HFjrxRoEPt4onaSyalgNCPFTBDwbYSyNNAKAu397Qve4XA4HA6Hw+FwOBwOh8Ph ++cDgcDofD4XA4HP8F3wDk4qPiACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001455/tests/test.sh b/tasks/format-code-task-001455/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e2634d57ecdc9ec7a49349e9237ea184acd331dd --- /dev/null +++ b/tasks/format-code-task-001455/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +builtin/logical/pki/backend_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001455/tests/test_command.sh b/tasks/format-code-task-001455/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001455/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001463/environment/Dockerfile b/tasks/format-code-task-001463/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..495e4425c3585ac43a6c5822203f8ff2b8744766 --- /dev/null +++ b/tasks/format-code-task-001463/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b827b464fd5bbdd0a8d9bab6e9504a0896bb9615b581b10c7f91c7fe669eca94 diff --git a/tasks/format-code-task-001463/environment/setup/files/blocklist b/tasks/format-code-task-001463/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001463/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001463/environment/setup/setup.sh b/tasks/format-code-task-001463/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001463/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001463/tests/test.patch b/tasks/format-code-task-001463/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ef369d8abe94bfac41694b0b4211513d783eac77 --- /dev/null +++ b/tasks/format-code-task-001463/tests/test.patch @@ -0,0 +1,132 @@ +diff --git a/apps/glusterfs/device_entry_test.go b/apps/glusterfs/device_entry_test.go +index 5cba25c92d..2bc6d79159 100644 +--- a/apps/glusterfs/device_entry_test.go ++++ b/apps/glusterfs/device_entry_test.go +@@ -931,3 +931,101 @@ func mockHealStatusFromDb(db *bolt.DB, volume string) (*executors.HealInfo, erro + }) + return hi, nil + } ++ ++func TestDeviceSetStateFailedWithEmptyPathBricks(t *testing.T) { ++ tmpfile := tests.Tempfile() ++ defer os.Remove(tmpfile) ++ ++ app := NewTestApp(tmpfile) ++ defer app.Close() ++ ++ err := setupSampleDbWithTopology(app, ++ 1, ++ 3, ++ 3, ++ 5*TB, ++ ) ++ tests.Assert(t, err == nil, "expected err == nil, got:", err) ++ ++ vreq := &api.VolumeCreateRequest{} ++ vreq.Size = 100 ++ vreq.Durability.Type = api.DurabilityReplicate ++ vreq.Durability.Replicate.Replica = 3 ++ ++ for i := 0; i < 5; i++ { ++ v := NewVolumeEntryFromRequest(vreq) ++ err = v.Create(app.db, app.executor, app.Allocator()) ++ tests.Assert(t, err == nil, "expected err == nil, got:", err) ++ } ++ ++ ++ ++ var d *DeviceEntry ++ var newbrick *BrickEntry ++ err = app.db.View(func(tx *bolt.Tx) error { ++ dl, err := DeviceList(tx) ++ if err != nil { ++ return err ++ } ++ for _, id := range dl { ++ d, err = NewDeviceEntryFromId(tx, id) ++ if err != nil { ++ return err ++ } ++ if len(d.Bricks) > 0 { ++ return nil ++ } ++ } ++ t.Fatalf("should have at least one device with bricks") ++ return nil ++ }) ++ ++ ++ ++ ++ newbrick = d.NewBrickEntry(102400, 1, 2000, utils.GenUUID()) ++ newbrick.Info.Path = "" ++ d.BrickAdd(newbrick.Id()) ++ err = app.db.Update(func(tx *bolt.Tx) error { ++ err = d.Save(tx) ++ tests.Assert(t, err == nil) ++ return newbrick.Save(tx) ++ }) ++ tests.Assert(t, err == nil) ++ ++ err = d.SetState(app.db, app.executor, app.Allocator(), api.EntryStateOffline) ++ tests.Assert(t, err == nil, "expected err == nil, got:", err) ++ tests.Assert(t, d.State == api.EntryStateOffline) ++ ++ ++ err = app.db.View(func(tx *bolt.Tx) error { ++ d, err = NewDeviceEntryFromId(tx, d.Info.Id) ++ return err ++ }) ++ tests.Assert(t, err == nil, "expected err == nil, got:", err) ++ tests.Assert(t, d.State == api.EntryStateOffline) ++ tests.Assert(t, len(d.Bricks) > 0, ++ "expected len(d.Bricks) > 0, got:", len(d.Bricks)) ++ ++ app.xo.MockVolumeInfo = func(host string, volume string) (*executors.Volume, error) { ++ return mockVolumeInfoFromDb(app.db, volume) ++ } ++ app.xo.MockHealInfo = func(host string, volume string) (*executors.HealInfo, error) { ++ return mockHealStatusFromDb(app.db, volume) ++ } ++ ++ ++ ++ err = d.SetState(app.db, app.executor, app.Allocator(), api.EntryStateFailed) ++ tests.Assert(t, err == nil, "expected err == nil, got:", err) ++ ++ ++ err = app.db.View(func(tx *bolt.Tx) error { ++ d, err = NewDeviceEntryFromId(tx, d.Info.Id) ++ return err ++ }) ++ tests.Assert(t, err == nil, "expected err == nil, got:", err) ++ tests.Assert(t, d.State == api.EntryStateFailed) ++ tests.Assert(t, len(d.Bricks) == 1, ++ "expected len(d.Bricks) == 1, got:", len(d.Bricks)) ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,10 @@ ++H4sIAAAAAAAAA+2Tz2/TMBTHe85f8dA4wCFxHTWthNQDaGMggTptRRwnN3ESq4kd2U6g/z0v6c8h ++QXfYNCHe5xA7z++X/bWjVauq7F7qjo2eizEyS5JhRH4fhzlPYh7zyXQSz0ZjzqfjZATJs3V0Quu8 ++sAAja4z/m9+59X+U6Ki/l87fp6auhc4iVz5djTP683g2PegfJxPUvx9HMH66Fv7Mf67/xSu2Upqt ++hCsDJz2EMgjSDIbLsJJZEFzAHZrbBq4N8IiPwRtTpaVQGt40VoZK4wFWlcxAeGCm8awwYe/4NpA/ ++G2M9XC9uF4vl/HRtv3TzfvnpwULfzLvXvfkYzTn/urj89uVqbvL8tKFF7wc/lC/BbepK6TU2d2z9 ++kGBbpRcQywT1OlMWwgb2FuZsygrM0q4ivP6slGvpVWBrCPMzTnvfSkPoDpUfGYQ7uZW16SQIvYHC ++RLXJMChybQ2VzD3k1tSAxraSrh/lvqddHbaNefCPwX3iz1tVoJM6MxYy2eBE6lRhpk4JKCqF6YYv ++7BSEsBtaajX4UgK+igLPuU+9baQ37o68Mqnwyujhpjxqr4XZZgo7CFPTaj/nEFostUTrpexUKlHV ++Oy+8/CgU3qbvmOmqbvzmRvjyg1Xp2kHERNM4VlT4ZqXNHQte+vUQBEEQBEEQBEEQBEEQBEEQBEEQ ++BEEQBEG8PL8A/uqy5gAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001463/tests/test.sh b/tasks/format-code-task-001463/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5c7b8fc320717a48cbc40fbbe71933efcdc18c0b --- /dev/null +++ b/tasks/format-code-task-001463/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +apps/glusterfs/device_entry_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001463/tests/test_command.sh b/tasks/format-code-task-001463/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001463/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001464/environment/Dockerfile b/tasks/format-code-task-001464/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..605cf60577db1320b3c7f5a2eb231defceeba077 --- /dev/null +++ b/tasks/format-code-task-001464/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:89eb669b9c9042fb4e00789e653a2aea68f1cb323a22597919b4c4c9aa8c543b diff --git a/tasks/format-code-task-001464/environment/setup/files/blocklist b/tasks/format-code-task-001464/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001464/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001464/environment/setup/setup.sh b/tasks/format-code-task-001464/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001464/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001464/tests/test.patch b/tasks/format-code-task-001464/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b78ce6dc4ec4e5121db58105fc6abf43fc17abcc --- /dev/null +++ b/tasks/format-code-task-001464/tests/test.patch @@ -0,0 +1,435 @@ +diff --git a/usercase-test-coderl/offline-network-guard.mjs b/usercase-test-coderl/offline-network-guard.mjs +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/offline-network-guard.mjs +@@ -0,0 +1,115 @@ ++ ++import dns from "node:dns"; ++import http from "node:http"; ++import https from "node:https"; ++import net from "node:net"; ++import tls from "node:tls"; ++ ++const LOCAL_HOSTS = new Set(["", "localhost", "127.0.0.1", "::1", "0.0.0.0", "[::1]"]); ++ ++function normalizeHost(host) { ++ return String(host ?? "").toLowerCase().replace(/^\[(.*)\]$/, "$1"); ++} ++ ++function isLocalHost(host) { ++ return LOCAL_HOSTS.has(normalizeHost(host)); ++} ++ ++function blocked(kind, host) { ++ throw new Error(`local offline network blocked: ${kind} ${host ?? ""}`.trim()); ++} ++ ++function hostFromConnectArgs(args) { ++ const first = args[0]; ++ if (first && typeof first === "object") { ++ if (first.path) return ""; ++ return first.host ?? first.hostname ?? "localhost"; ++ } ++ if (typeof first === "string" && Number.isNaN(Number(first))) { ++ return first; ++ } ++ return args[1] ?? "localhost"; ++} ++ ++function hostFromRequestArgs(args) { ++ const first = args[0]; ++ const second = args[1]; ++ if (first instanceof URL) { ++ return first.hostname; ++ } ++ if (typeof first === "string") { ++ try { ++ return new URL(first).hostname; ++ } catch { ++ return second?.host ?? second?.hostname ?? "localhost"; ++ } ++ } ++ if (first && typeof first === "object") { ++ return first.host ?? first.hostname ?? "localhost"; ++ } ++ return "localhost"; ++} ++ ++function wrapConnect(object, method, kind) { ++ const original = object[method]; ++ object[method] = function guardedConnect(...args) { ++ const host = hostFromConnectArgs(args); ++ if (!isLocalHost(host)) blocked(kind, host); ++ return original.apply(this, args); ++ }; ++} ++ ++function wrapRequest(object, method, kind) { ++ const original = object[method]; ++ object[method] = function guardedRequest(...args) { ++ const host = hostFromRequestArgs(args); ++ if (!isLocalHost(host)) blocked(kind, host); ++ return original.apply(this, args); ++ }; ++} ++ ++wrapConnect(net, "connect", "net.connect"); ++wrapConnect(net, "createConnection", "net.createConnection"); ++wrapConnect(net.Socket.prototype, "connect", "net.Socket.connect"); ++wrapConnect(tls, "connect", "tls.connect"); ++wrapRequest(http, "request", "http.request"); ++wrapRequest(http, "get", "http.get"); ++wrapRequest(https, "request", "https.request"); ++wrapRequest(https, "get", "https.get"); ++ ++const originalLookup = dns.lookup; ++dns.lookup = function guardedLookup(hostname, ...args) { ++ if (!isLocalHost(hostname)) blocked("dns.lookup", hostname); ++ return originalLookup.call(this, hostname, ...args); ++}; ++ ++for (const name of ["resolve", "resolve4", "resolve6", "resolveCname", "resolveMx", "resolveTxt", "resolveSrv", "reverse"]) { ++ const original = dns[name]; ++ if (typeof original === "function") { ++ dns[name] = function guardedResolve(hostname, ...args) { ++ if (!isLocalHost(hostname)) blocked(`dns.${name}`, hostname); ++ return original.call(this, hostname, ...args); ++ }; ++ } ++} ++ ++if (globalThis.fetch) { ++ const originalFetch = globalThis.fetch; ++ globalThis.fetch = function guardedFetch(input, init) { ++ const url = input instanceof Request ? input.url : input; ++ const host = new URL(url).hostname; ++ if (!isLocalHost(host)) blocked("fetch", host); ++ return originalFetch(input, init); ++ }; ++} ++ ++if (globalThis.WebSocket) { ++ const OriginalWebSocket = globalThis.WebSocket; ++ globalThis.WebSocket = class GuardedWebSocket extends OriginalWebSocket { ++ constructor(url, protocols) { ++ const host = new URL(url).hostname; ++ if (!isLocalHost(host)) blocked("WebSocket", host); ++ super(url, protocols); ++ } ++ }; ++} +diff --git a/usercase-test-coderl/pair-anchors-and-footnotes.test.js b/usercase-test-coderl/pair-anchors-and-footnotes.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/pair-anchors-and-footnotes.test.js +@@ -0,0 +1,290 @@ ++ ++ ++ ++ ++import assert from "node:assert/strict"; ++import { execFileSync } from "node:child_process"; ++import fs from "node:fs"; ++import os from "node:os"; ++import path from "node:path"; ++import process from "node:process"; ++import test from "node:test"; ++ ++import * as CONFIG_CONST from "../client/app/config/constants.js"; ++import { pairAnchorsAndFootnotes } from "../client/app/utils/base.js"; ++ ++ ++const NOT_FOUND = CONFIG_CONST.CONST_FOOTNOTE.NOTFOUND; ++ ++function cloneJson(value) { ++ return JSON.parse(JSON.stringify(value)); ++} ++ ++function assertLookupEntry(result, markerCode, index, expected) { ++ assert.equal(result?.[markerCode]?.[index], expected); ++} ++ ++function assertEmptyLookup(result) { ++ assert.ok(result && typeof result === "object"); ++ assert.equal(Array.isArray(result), false); ++ assert.deepStrictEqual(Object.keys(result), []); ++} ++ ++test("pairs one anchor with the following matching footnote", () => { ++ ++ ++ ++ ++ const timeline = [ ++ { type: "anchor", markerCode: "9312", index: 0 }, ++ { type: "footnote", markerCode: "9312", content: "first note" }, ++ ]; ++ ++ ++ assertLookupEntry(pairAnchorsAndFootnotes(timeline), "9312", 0, "first note"); ++}); ++ ++test("pairs repeated markers in reading order", () => { ++ ++ ++ ++ ++ const timeline = [ ++ { type: "anchor", markerCode: "9312", index: 0 }, ++ { type: "anchor", markerCode: "9312", index: 1 }, ++ { type: "footnote", markerCode: "9312", content: "first" }, ++ { type: "footnote", markerCode: "9312", content: "second" }, ++ ]; ++ ++ const result = pairAnchorsAndFootnotes(timeline); ++ ++ assertLookupEntry(result, "9312", 0, "first"); ++ assertLookupEntry(result, "9312", 1, "second"); ++}); ++ ++test("matches by marker code while preserving each anchor index", () => { ++ ++ ++ ++ ++ const timeline = [ ++ { type: "anchor", markerCode: "9312", index: 0 }, ++ { type: "anchor", markerCode: "9313", index: 2 }, ++ { type: "footnote", markerCode: "9313", content: "beta" }, ++ { type: "footnote", markerCode: "9312", content: "alpha" }, ++ ]; ++ ++ const result = pairAnchorsAndFootnotes(timeline); ++ ++ assertLookupEntry(result, "9312", 0, "alpha"); ++ assertLookupEntry(result, "9313", 2, "beta"); ++}); ++ ++test("fills queued anchors with the placeholder when a new anchor group starts", () => { ++ ++ ++ ++ ++ const timeline = [ ++ { type: "anchor", markerCode: "9312", index: 0 }, ++ { type: "footnote", markerCode: "9313", content: "orphan" }, ++ { type: "anchor", markerCode: "9312", index: 1 }, ++ { type: "footnote", markerCode: "9312", content: "later" }, ++ ]; ++ ++ const result = pairAnchorsAndFootnotes(timeline); ++ ++ assertLookupEntry(result, "9312", 0, NOT_FOUND); ++ assertLookupEntry(result, "9312", 1, "later"); ++}); ++ ++test("fills leftover anchors with the placeholder at the end of the timeline", () => { ++ ++ ++ ++ ++ const timeline = [{ type: "anchor", markerCode: "9314", index: 3 }]; ++ ++ ++ assertLookupEntry(pairAnchorsAndFootnotes(timeline), "9314", 3, NOT_FOUND); ++}); ++ ++test("ignores footnote events with no queued matching anchor", () => { ++ ++ ++ ++ ++ const timeline = [ ++ { type: "footnote", markerCode: "9312", content: "lonely" }, ++ { type: "anchor", markerCode: "9312", index: 0 }, ++ { type: "footnote", markerCode: "9312", content: "matched" }, ++ ]; ++ ++ ++ assertLookupEntry(pairAnchorsAndFootnotes(timeline), "9312", 0, "matched"); ++}); ++ ++test("returns an empty object for non-array and empty timeline inputs", () => { ++ ++ ++ ++ ++ ++ assertEmptyLookup(pairAnchorsAndFootnotes(null)); ++ assertEmptyLookup(pairAnchorsAndFootnotes({ type: "anchor", markerCode: "9312", index: 0 })); ++ assertEmptyLookup(pairAnchorsAndFootnotes([])); ++}); ++ ++test("is referentially transparent for the same input value", () => { ++ const timeline = [ ++ { type: "anchor", markerCode: "9312", index: 0 }, ++ { type: "anchor", markerCode: "9312", index: 1 }, ++ { type: "footnote", markerCode: "9312", content: "first" }, ++ { type: "footnote", markerCode: "9312", content: "second" }, ++ ]; ++ ++ ++ const first = pairAnchorsAndFootnotes(timeline); ++ const second = pairAnchorsAndFootnotes(timeline); ++ assertLookupEntry(first, "9312", 0, "first"); ++ assertLookupEntry(first, "9312", 1, "second"); ++ assertLookupEntry(second, "9312", 0, "first"); ++ assertLookupEntry(second, "9312", 1, "second"); ++}); ++ ++test("does not mutate the caller's timeline", () => { ++ const timeline = [ ++ { type: "anchor", markerCode: "9312", index: 0 }, ++ { type: "anchor", markerCode: "9313", index: 2 }, ++ { type: "footnote", markerCode: "9313", content: "beta" }, ++ { type: "footnote", markerCode: "9312", content: "alpha" }, ++ ]; ++ const before = cloneJson(timeline); ++ ++ pairAnchorsAndFootnotes(timeline); ++ ++ assert.deepStrictEqual(timeline, before); ++}); ++ ++test("does not depend on hidden process-local cache state", () => { ++ const stableTimeline = [ ++ { type: "anchor", markerCode: "9312", index: 0 }, ++ { type: "footnote", markerCode: "9312", content: "first note" }, ++ ]; ++ const expectedContent = "first note"; ++ ++ ++ assertLookupEntry(pairAnchorsAndFootnotes(stableTimeline), "9312", 0, expectedContent); ++ pairAnchorsAndFootnotes([{ type: "anchor", markerCode: "9314", index: 3 }]); ++ pairAnchorsAndFootnotes([ ++ { type: "anchor", markerCode: "9312", index: 0 }, ++ { type: "anchor", markerCode: "9312", index: 1 }, ++ { type: "footnote", markerCode: "9312", content: "first" }, ++ { type: "footnote", markerCode: "9312", content: "second" }, ++ ]); ++ ++ assertLookupEntry(pairAnchorsAndFootnotes(stableTimeline), "9312", 0, expectedContent); ++ ++ const script = ` ++ import { pairAnchorsAndFootnotes } from "/workspace/repo/client/app/utils/base.js"; ++ const out = pairAnchorsAndFootnotes([ ++ { type: "anchor", markerCode: "9312", index: 0 }, ++ { type: "footnote", markerCode: "9312", content: "first note" } ++ ]); ++ process.stdout.write(JSON.stringify(out)); ++ `; ++ const freshProcessOutput = execFileSync(process.execPath, ["--input-type=module", "-e", script], { ++ encoding: "utf8", ++ }); ++ ++ ++ assertLookupEntry(JSON.parse(freshProcessOutput), "9312", 0, expectedContent); ++}); ++ ++test("does not use undeclared filesystem, network, or DOM side effects", async () => { ++ const timeline = [ ++ { type: "anchor", markerCode: "9312", index: 0 }, ++ { type: "footnote", markerCode: "9312", content: "first note" }, ++ ]; ++ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "pair-footnotes-")); ++ const originalCwd = process.cwd(); ++ const originalFetch = globalThis.fetch; ++ const originalWindow = globalThis.window; ++ const originalDocument = globalThis.document; ++ const originalXMLHttpRequest = globalThis.XMLHttpRequest; ++ const originalWebSocket = globalThis.WebSocket; ++ const originalFs = { ++ readFileSync: fs.readFileSync, ++ writeFileSync: fs.writeFileSync, ++ appendFileSync: fs.appendFileSync, ++ openSync: fs.openSync, ++ }; ++ const blocked = []; ++ const throwBlocked = (name) => ++ function blockedSideEffect(...args) { ++ blocked.push([name, String(args[0] ?? "")]); ++ throw new Error(`blocked side effect: ${name}`); ++ }; ++ const throwingDom = new Proxy( ++ {}, ++ { ++ get(_target, prop) { ++ throw new Error(`blocked DOM access: ${String(prop)}`); ++ }, ++ set(_target, prop) { ++ throw new Error(`blocked DOM mutation: ${String(prop)}`); ++ }, ++ } ++ ); ++ ++ try { ++ process.chdir(tempDir); ++ fs.readFileSync = throwBlocked("fs.readFileSync"); ++ fs.writeFileSync = throwBlocked("fs.writeFileSync"); ++ fs.appendFileSync = throwBlocked("fs.appendFileSync"); ++ fs.openSync = throwBlocked("fs.openSync"); ++ globalThis.fetch = throwBlocked("fetch"); ++ globalThis.XMLHttpRequest = throwBlocked("XMLHttpRequest"); ++ globalThis.WebSocket = throwBlocked("WebSocket"); ++ globalThis.window = throwingDom; ++ globalThis.document = throwingDom; ++ ++ ++ assertLookupEntry(pairAnchorsAndFootnotes(timeline), "9312", 0, "first note"); ++ } finally { ++ fs.readFileSync = originalFs.readFileSync; ++ fs.writeFileSync = originalFs.writeFileSync; ++ fs.appendFileSync = originalFs.appendFileSync; ++ fs.openSync = originalFs.openSync; ++ if (originalFetch === undefined) { ++ delete globalThis.fetch; ++ } else { ++ globalThis.fetch = originalFetch; ++ } ++ if (originalWindow === undefined) { ++ delete globalThis.window; ++ } else { ++ globalThis.window = originalWindow; ++ } ++ if (originalDocument === undefined) { ++ delete globalThis.document; ++ } else { ++ globalThis.document = originalDocument; ++ } ++ if (originalXMLHttpRequest === undefined) { ++ delete globalThis.XMLHttpRequest; ++ } else { ++ globalThis.XMLHttpRequest = originalXMLHttpRequest; ++ } ++ if (originalWebSocket === undefined) { ++ delete globalThis.WebSocket; ++ } else { ++ globalThis.WebSocket = originalWebSocket; ++ } ++ process.chdir(originalCwd); ++ } ++ ++ assert.deepStrictEqual(blocked, []); ++ assert.deepStrictEqual(fs.readdirSync(tempDir), []); ++ fs.rmSync(tempDir, { recursive: true, force: true }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,15 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export NODE_OPTIONS="${NODE_OPTIONS} --import /workspace/repo/usercase-test-coderl/offline-network-guard.mjs" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++exec node --test /workspace/repo/usercase-test-coderl/pair-anchors-and-footnotes.test.js diff --git a/tasks/format-code-task-001464/tests/test.sh b/tasks/format-code-task-001464/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ebd69db572009384e9125e175606ec13fc5b664a --- /dev/null +++ b/tasks/format-code-task-001464/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/offline-network-guard.mjs +usercase-test-coderl/pair-anchors-and-footnotes.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001464/tests/test_command.sh b/tasks/format-code-task-001464/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001464/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001490/environment/Dockerfile b/tasks/format-code-task-001490/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6a81848fdde2d076a7951c2d2616e25f4b1037cd --- /dev/null +++ b/tasks/format-code-task-001490/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e456ec09aac618f60fe2fe2d5a34ebcb1a6e651b0da63647c2d423586350b599 diff --git a/tasks/format-code-task-001490/environment/setup/files/blocklist b/tasks/format-code-task-001490/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001490/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001490/environment/setup/setup.sh b/tasks/format-code-task-001490/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001490/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001490/tests/test.patch b/tasks/format-code-task-001490/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..353188c200c7a0ae753c9421dda6f152bb5b18fd --- /dev/null +++ b/tasks/format-code-task-001490/tests/test.patch @@ -0,0 +1,76 @@ +diff --git a/tests/components/template/test_config.py b/tests/components/template/test_config.py +new file mode 100644 +index 00000000000000..b14ff0efa5a166 +--- /dev/null ++++ b/tests/components/template/test_config.py +@@ -0,0 +1,50 @@ ++ ++ ++from __future__ import annotations ++ ++import pytest ++import voluptuous as vol ++ ++from homeassistant.components.template.config import CONFIG_SECTION_SCHEMA ++from homeassistant.core import HomeAssistant ++ ++ ++@pytest.mark.parametrize( ++ "config", ++ [ ++ { ++ "trigger": {"trigger": "event", "event_type": "my_event"}, ++ "button": { ++ "press": { ++ "service": "test.automation", ++ "data_template": {"caller": "{{ this.entity_id }}"}, ++ }, ++ "device_class": "restart", ++ "unique_id": "test", ++ "name": "test", ++ "icon": "mdi:test", ++ }, ++ }, ++ { ++ "trigger": {"trigger": "event", "event_type": "my_event"}, ++ "action": { ++ "service": "test.automation", ++ "data_template": {"caller": "{{ this.entity_id }}"}, ++ }, ++ "button": { ++ "press": { ++ "service": "test.automation", ++ "data_template": {"caller": "{{ this.entity_id }}"}, ++ }, ++ "device_class": "restart", ++ "unique_id": "test", ++ "name": "test", ++ "icon": "mdi:test", ++ }, ++ }, ++ ], ++) ++async def test_invalid_schema(hass: HomeAssistant, config: dict) -> None: ++ ++ with pytest.raises(vol.Invalid): ++ CONFIG_SECTION_SCHEMA(config) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3S32rCMBTH8V77FOfOq9ZGTfM40j/ZKrRJMVHw7c0K0zHYvFHG8Pu5SA5JICf8 ++UjTH/dDtrDutsmcpE6P1PCff57lWep0OlRuzSetKaVNlop/W0RfHEOuDSHbwPv527t7+P1Xc8o82 ++xF3rx7F2XRH6x91xL3+13l7zr7RJ+W8rZTIpH9fCz148/7aTOfjGdoumDr3kQyvL6Rx77yQfJVVp ++Vz6GsEqfY/LOulRGO05DHe3nr3Fv+/diOkt+Wi7++k0AAAAAAAAAAAAAAADAq7gAgp+UEgAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001490/tests/test.sh b/tasks/format-code-task-001490/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..56615713e06b574e1ab22fd4375dcad1a3fd1f5a --- /dev/null +++ b/tasks/format-code-task-001490/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/components/template/test_config.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001490/tests/test_command.sh b/tasks/format-code-task-001490/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001490/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001497/environment/Dockerfile b/tasks/format-code-task-001497/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..60bd5a0c83d011788ef038215efcba7b5db2916a --- /dev/null +++ b/tasks/format-code-task-001497/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:31bc5453751bccac1d6d25a42231364a9b4e88e19ea9e0544de4c4a0073abd41 diff --git a/tasks/format-code-task-001497/environment/setup/files/blocklist b/tasks/format-code-task-001497/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001497/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001497/environment/setup/setup.sh b/tasks/format-code-task-001497/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001497/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001497/tests/test.patch b/tasks/format-code-task-001497/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5a39974c99b04a2d1f177870a15455838947a1fb --- /dev/null +++ b/tasks/format-code-task-001497/tests/test.patch @@ -0,0 +1,93 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000000..2184de3be7c +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/components/alexa/test_capabilities.py -k speaker_volume"] ++} +diff --git a/tests/components/alexa/test_capabilities.py b/tests/components/alexa/test_capabilities.py +index f8f4f5f4697..6f2b211b638 100644 +--- a/tests/components/alexa/test_capabilities.py ++++ b/tests/components/alexa/test_capabilities.py +@@ -8,6 +8,8 @@ from homeassistant.components.media_player.const import ( + SUPPORT_PAUSE, + SUPPORT_PLAY, + SUPPORT_STOP, ++ SUPPORT_VOLUME_MUTE, ++ SUPPORT_VOLUME_SET, + ) + from homeassistant.const import ( + ATTR_UNIT_OF_MEASUREMENT, +@@ -724,3 +726,57 @@ async def test_report_image_processing(hass): + "humanPresenceDetectionState", + {"value": "DETECTED"}, + ) ++ ++ ++async def test_report_speaker_volume_no_level(hass): ++ """Speaker volume should not be reported when volume_level is missing. ++ ++ Regression test for a TypeError raised when current_level was None. ++ """ ++ hass.states.async_set( ++ "media_player.test_speaker_none", ++ "on", ++ { ++ "friendly_name": "Test speaker no volume", ++ "supported_features": SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET, ++ "volume_level": None, ++ "device_class": "speaker", ++ }, ++ ) ++ ++ properties = await reported_properties(hass, "media_player#test_speaker_none") ++ properties.assert_not_has_property("Alexa.Speaker", "volume") ++ ++ ++async def test_report_speaker_volume_typical(hass): ++ """Speaker volume reports volume_level as 0-100.""" ++ hass.states.async_set( ++ "media_player.test_speaker_typical", ++ "on", ++ { ++ "friendly_name": "Test speaker typical", ++ "supported_features": SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET, ++ "volume_level": 0.75, ++ "device_class": "speaker", ++ }, ++ ) ++ ++ properties = await reported_properties(hass, "media_player#test_speaker_typical") ++ properties.assert_equal("Alexa.Speaker", "volume", 75) ++ ++ ++async def test_report_speaker_volume_zero(hass): ++ """Speaker volume of 0 is reported as 0.""" ++ hass.states.async_set( ++ "media_player.test_speaker_zero", ++ "on", ++ { ++ "friendly_name": "Test speaker zero", ++ "supported_features": SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET, ++ "volume_level": 0, ++ "device_class": "speaker", ++ }, ++ ) ++ ++ properties = await reported_properties(hass, "media_player#test_speaker_zero") ++ properties.assert_equal("Alexa.Speaker", "volume", 0) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/components/alexa/test_capabilities.py -k speaker_volume ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001497/tests/test.sh b/tasks/format-code-task-001497/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..43d7082b5424af3f0e09816ed774f8e4b3b30cf7 --- /dev/null +++ b/tasks/format-code-task-001497/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/components/alexa/test_capabilities.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001497/tests/test_command.sh b/tasks/format-code-task-001497/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001497/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001499/environment/Dockerfile b/tasks/format-code-task-001499/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e7ea5b61e064e52bd4572ef39b36a0f4cf0c0a9f --- /dev/null +++ b/tasks/format-code-task-001499/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2ed2f7df12117946ce127e260bac12b5d53bfbf0b7372326e17dee03cc4e4919 diff --git a/tasks/format-code-task-001499/environment/setup/files/blocklist b/tasks/format-code-task-001499/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001499/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001499/environment/setup/setup.sh b/tasks/format-code-task-001499/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001499/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001499/tests/test.patch b/tasks/format-code-task-001499/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d9cc4bd44f38071ab5c00a08e1bacf263117be75 --- /dev/null +++ b/tasks/format-code-task-001499/tests/test.patch @@ -0,0 +1,77 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000000..d1dbf250c4e +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/components/dyson/test_sensor.py -v"] ++} +diff --git a/tests/components/dyson/test_sensor.py b/tests/components/dyson/test_sensor.py +index 7ad6ab6c2f2..dcac29d26be 100644 +--- a/tests/components/dyson/test_sensor.py ++++ b/tests/components/dyson/test_sensor.py +@@ -10,6 +10,8 @@ from homeassistant.components import dyson as dyson_parent + from homeassistant.components.dyson import sensor as dyson + from homeassistant.const import ( + ATTR_UNIT_OF_MEASUREMENT, ++ DEVICE_CLASS_HUMIDITY, ++ DEVICE_CLASS_TEMPERATURE, + PERCENTAGE, + STATE_OFF, + TEMP_CELSIUS, +@@ -292,6 +294,41 @@ class DysonTest(unittest.TestCase): + assert sensor.name == "Device_name AQI" + assert sensor.entity_id == "sensor.dyson_1" + ++ def test_humidity_sensor_device_class(self): ++ """Humidity sensor must expose DEVICE_CLASS_HUMIDITY for HomeKit.""" ++ sensor = dyson.DysonHumiditySensor(_get_with_state()) ++ sensor.hass = self.hass ++ sensor.entity_id = "sensor.dyson_1" ++ assert sensor.device_class == DEVICE_CLASS_HUMIDITY ++ ++ def test_humidity_sensor_device_class_no_state(self): ++ """Humidity sensor device_class is set even without state.""" ++ sensor = dyson.DysonHumiditySensor(_get_device_without_state()) ++ sensor.hass = self.hass ++ sensor.entity_id = "sensor.dyson_1" ++ assert sensor.device_class == DEVICE_CLASS_HUMIDITY ++ ++ def test_temperature_sensor_device_class(self): ++ """Temperature sensor must expose DEVICE_CLASS_TEMPERATURE for HomeKit.""" ++ sensor = dyson.DysonTemperatureSensor(_get_with_state(), TEMP_CELSIUS) ++ sensor.hass = self.hass ++ sensor.entity_id = "sensor.dyson_1" ++ assert sensor.device_class == DEVICE_CLASS_TEMPERATURE ++ ++ def test_dust_sensor_device_class_none(self): ++ """Dust sensor must not declare a device_class.""" ++ sensor = dyson.DysonDustSensor(_get_with_state()) ++ sensor.hass = self.hass ++ sensor.entity_id = "sensor.dyson_1" ++ assert sensor.device_class is None ++ ++ def test_filter_life_sensor_device_class_none(self): ++ """Filter life sensor must not declare a device_class.""" ++ sensor = dyson.DysonFilterLifeSensor(_get_with_state()) ++ sensor.hass = self.hass ++ sensor.entity_id = "sensor.dyson_1" ++ assert sensor.device_class is None ++ + + @patch("libpurecool.dyson.DysonAccount.login", return_value=True) + @patch( +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/components/dyson/test_sensor.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001499/tests/test.sh b/tasks/format-code-task-001499/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a91b886251152210dc4d4cb7478ed870b4797f1c --- /dev/null +++ b/tasks/format-code-task-001499/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/components/dyson/test_sensor.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001499/tests/test_command.sh b/tasks/format-code-task-001499/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001499/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001603/environment/Dockerfile b/tasks/format-code-task-001603/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7b50d76288904ba552f71449ec73e11a480750cb --- /dev/null +++ b/tasks/format-code-task-001603/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:549017a411c683831560949799dc35aa0d026e3a457937c0886168c946f6c10d diff --git a/tasks/format-code-task-001603/environment/setup/files/blocklist b/tasks/format-code-task-001603/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001603/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001603/environment/setup/setup.sh b/tasks/format-code-task-001603/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001603/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001603/tests/test.patch b/tasks/format-code-task-001603/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..af0ac3052e1578fd3858d92c52c9f7c6a4706f68 --- /dev/null +++ b/tasks/format-code-task-001603/tests/test.patch @@ -0,0 +1,60 @@ +diff --git a/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_activations.py b/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_activations.py +index 75fbc12a2fdc2..a056aa7291462 100644 +--- a/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_activations.py ++++ b/ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_activations.py +@@ -98,6 +98,28 @@ def test_hardshrink( + ) + + ++ ++@handle_test( ++ fn_tree="functional.ivy.experimental.hardsilu", ++ dtype_and_x=helpers.dtype_and_values( ++ available_dtypes=helpers.get_dtypes("float"), ++ large_abs_safety_factor=8, ++ small_abs_safety_factor=8, ++ safety_factor_scale="log", ++ ), ++) ++def test_hardsilu(*, dtype_and_x, test_flags, backend_fw, fn_name, on_device): ++ dtype, x = dtype_and_x ++ helpers.test_function( ++ input_dtypes=dtype, ++ backend_to_test=backend_fw, ++ test_flags=test_flags, ++ fn_name=fn_name, ++ on_device=on_device, ++ x=x[0], ++ ) ++ ++ + # hardtanh + @handle_test( + fn_tree="functional.ivy.experimental.hardtanh", +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,11 @@ ++H4sIAAAAAAAAA+2Tb2/aMBDGeZ1PcUt5uQRCCUiroiktmdSNtRVQqdM2RSY5lqzBRrYD5dvPCQXa ++aRt90Wqadr83/pPz3ePnHHda5kUaI1+2Gi9F29D3/Xo0/DzWc8/veJ7f7/b940bb83recQP8F1P0 ++gFJpJgEaUgj9p7hD3/9R3H3/NSodJ2I+Zzx1VfZ8NQ703+t2erv+d+r+d3sdvwHt55Pwe/7z/h+9 ++ak1z3poylVlJCvUjmGJqKVHKBHfrlrusnkgVyhKdL5lGC+8WQmp4H97E0UV4Oozim1438Lb74WgU ++forDq/N4Eo0n4/jj5eB6GAV2vly7s5KbLIKzwp2y5BZ5qlxezhdr27KOYFRyqB9jxmSq8qKEmZCA ++LMngPhoULpg0Ior1a0gKZDLn3yBbL4TOUOUKEhOMMEW9QuQgS66s6OZ8Ep9dDqKgbVlVwtPw7EN0 ++MYCcQ10bvrM70EKaMhq5EnJWiNUJpMICg5yDI2cPDNlXq79jkgmwgyCo5PNKzuMrrHK9k/8Gmtvi ++5oBdn1+sdSY4OPNqZk6C8SmuJmrzY5rlZrL3brM2dqPM58j1dofzzXjfKROrXHO9L3WdCucW7Efq ++bHAcLpwMWYoSnCU4F3Bs9rZ221u9VeD+4o5CTI2dVc5RNL4eToLm23qVz+AzNDd74HCENnw9AXOK ++70TsDXsXng+jwUGHKvZN9DauFwp/kfEqHI+fkHGWW6ngaJknm2to7pJbf/uvJAiCIAiCIAiCIAiC ++IAiCIAiCIAiCIAiCeDo/AHtOXfwAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001603/tests/test.sh b/tasks/format-code-task-001603/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4575b61dc14e06dd8f3b1c1ed935140f9062ecbd --- /dev/null +++ b/tasks/format-code-task-001603/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +ivy_tests/test_ivy/test_functional/test_experimental/test_nn/test_activations.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001603/tests/test_command.sh b/tasks/format-code-task-001603/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001603/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001632/environment/Dockerfile b/tasks/format-code-task-001632/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5c8fef58b1aa6914e5e661c95b7d6af568dd1303 --- /dev/null +++ b/tasks/format-code-task-001632/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b86dc47d9b7d1e1864c7a8559a11315ec9914a724d2c70a27c9d0c02ae1fe8a6 diff --git a/tasks/format-code-task-001632/environment/setup/files/blocklist b/tasks/format-code-task-001632/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001632/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001632/environment/setup/setup.sh b/tasks/format-code-task-001632/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001632/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001632/tests/test.patch b/tasks/format-code-task-001632/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..20321b9270f6ffd3ec82232cf362b5190b512dfe --- /dev/null +++ b/tasks/format-code-task-001632/tests/test.patch @@ -0,0 +1,280 @@ +diff --git a/integration_tests/__tests__/jest_require_actual.test.js b/integration_tests/__tests__/jest_require_actual.test.js +new file mode 100644 +index 000000000000..ba31d5f208fd +--- /dev/null ++++ b/integration_tests/__tests__/jest_require_actual.test.js +@@ -0,0 +1,60 @@ ++/** ++ * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. ++ * ++ * This source code is licensed under the BSD-style license found in the ++ * LICENSE file in the root directory of this source tree. An additional grant ++ * of patent rights can be found in the PATENTS file in the same directory. ++ * ++ * @flow ++ */ ++ ++'use strict'; ++ ++const path = require('path'); ++const os = require('os'); ++const skipOnWindows = require('../../scripts/skip_on_windows'); ++const {cleanup, writeFiles} = require('../utils'); ++const runJest = require('../runJest'); ++ ++const DIR = path.resolve(os.tmpdir(), 'jest_require_actual_test'); ++ ++skipOnWindows.suite(); ++ ++beforeEach(() => cleanup(DIR)); ++afterAll(() => cleanup(DIR)); ++ ++test('understands dependencies using require.requireActual', () => { ++ writeFiles(DIR, { ++ '.watchmanconfig': '', ++ '__tests__/a.test.js': ` ++ const a = require.requireActual('../a'); ++ ++ test('a', () => {}); ++ `, ++ '__tests__/b.test.js': `test('b', () => {});`, ++ 'a.js': `module.exports = {}`, ++ 'package.json': JSON.stringify({jest: {}}), ++ }); ++ ++ let stdout; ++ let stderr; ++ ({stdout, stderr} = runJest(DIR, ['--findRelatedTests', 'a.js'])); ++ ++ expect(stdout).not.toMatch('No tests found'); ++ expect(stderr).toMatch('PASS __tests__/a.test.js'); ++ expect(stderr).not.toMatch('PASS __tests__/b.test.js'); ++ ++ ++ writeFiles(DIR, { ++ '__tests__/a.test.js': ` ++ const a = jest.requireActual('../a'); ++ ++ test('a', () => {}); ++ `, ++ }); ++ ++ ({stderr, stdout} = runJest(DIR, ['--findRelatedTests', 'a.js'])); ++ expect(stdout).not.toMatch('No tests found'); ++ expect(stderr).toMatch('PASS __tests__/a.test.js'); ++ expect(stderr).not.toMatch('PASS __tests__/b.test.js'); ++}); +diff --git a/packages/jest-haste-map/src/lib/__tests__/extract_requires.test.js b/packages/jest-haste-map/src/lib/__tests__/extract_requires.test.js +index b5508c676116..673829c38bbe 100644 +--- a/packages/jest-haste-map/src/lib/__tests__/extract_requires.test.js ++++ b/packages/jest-haste-map/src/lib/__tests__/extract_requires.test.js +@@ -6,100 +6,108 @@ + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * +- * @emails oncall+jsinfra ++ * @flow + */ + 'use strict'; + + const extractRequires = require('../extract_requires'); + +-describe('extractRequires', () => { +- it('extracts both requires and imports from code', () => { +- const code = ` ++it('extracts both requires and imports from code', () => { ++ const code = ` + import module1 from 'module1'; + const module2 = require('module2'); + `; + +- expect(extractRequires(code)).toEqual(['module1', 'module2']); +- }); ++ expect(extractRequires(code)).toEqual(['module1', 'module2']); ++}); + +- it('extracts requires in order', () => { +- const code = ` ++it('extracts requires in order', () => { ++ const code = ` + const module1 = require('module1'); + const module2 = require('module2'); + const module3 = require('module3'); + `; + +- expect(extractRequires(code)).toEqual(['module1', 'module2', 'module3']); +- }); +- +- it('strips out comments from code', () => { +- const code = `// comment const module2 = require('module2');`; +- +- expect(extractRequires(code)).toEqual([]); +- }); +- +- it('ignores requires in comments', () => { +- const code = [ +- '// const module1 = require("module1");', +- '/**', +- ' * const module2 = require("module2");', +- ' */', +- ].join('\n'); +- +- expect(extractRequires(code)).toEqual([]); +- }); +- +- it('ignores requires in comments with Windows line endings', () => { +- const code = [ +- '// const module1 = require("module1");', +- '/**', +- ' * const module2 = require("module2");', +- ' */', +- ].join('\r\n'); +- +- expect(extractRequires(code)).toEqual([]); +- }); +- +- it('ignores requires in comments with unicode line endings', () => { +- const code = [ +- '// const module1 = require("module1");\u2028', +- '// const module1 = require("module2");\u2029', +- '/*\u2028', +- 'const module2 = require("module3");\u2029', +- ' */', +- ].join(''); +- +- expect(extractRequires(code)).toEqual([]); +- }); +- +- it('does not contain duplicates', () => { +- const code = ` ++ expect(extractRequires(code)).toEqual(['module1', 'module2', 'module3']); ++}); ++ ++it('strips out comments from code', () => { ++ const code = `// comment const module2 = require('module2');`; ++ ++ expect(extractRequires(code)).toEqual([]); ++}); ++ ++it('ignores requires in comments', () => { ++ const code = [ ++ '// const module1 = require("module1");', ++ '/**', ++ ' * const module2 = require("module2");', ++ ' */', ++ ].join('\n'); ++ ++ expect(extractRequires(code)).toEqual([]); ++}); ++ ++it('ignores requires in comments with Windows line endings', () => { ++ const code = [ ++ '// const module1 = require("module1");', ++ '/**', ++ ' * const module2 = require("module2");', ++ ' */', ++ ].join('\r\n'); ++ ++ expect(extractRequires(code)).toEqual([]); ++}); ++ ++it('ignores requires in comments with unicode line endings', () => { ++ const code = [ ++ '// const module1 = require("module1");\u2028', ++ '// const module1 = require("module2");\u2029', ++ '/*\u2028', ++ 'const module2 = require("module3");\u2029', ++ ' */', ++ ].join(''); ++ ++ expect(extractRequires(code)).toEqual([]); ++}); ++ ++it('does not contain duplicates', () => { ++ const code = ` + const module1 = require('module1'); + const module1Dup = require('module1'); + `; + +- expect(extractRequires(code)).toEqual(['module1']); +- }); +- +- it('ignores type imports', () => { +- const code = [ +- "import type foo from 'bar';", +- 'import type {', +- ' bar,', +- ' baz,', +- "} from 'wham'", +- ].join('\r\n'); +- +- expect(extractRequires(code)).toEqual([]); +- }); +- +- it('ignores type exports', () => { +- const code = [ +- 'export type Foo = number;', +- 'export default {}', +- "export * from 'module1'", +- ].join('\r\n'); +- +- expect(extractRequires(code)).toEqual(['module1']); +- }); ++ expect(extractRequires(code)).toEqual(['module1']); ++}); ++ ++it('ignores type imports', () => { ++ const code = [ ++ "import type foo from 'bar';", ++ 'import type {', ++ ' bar,', ++ ' baz,', ++ "} from 'wham'", ++ ].join('\r\n'); ++ ++ expect(extractRequires(code)).toEqual([]); ++}); ++ ++it('ignores type exports', () => { ++ const code = [ ++ 'export type Foo = number;', ++ 'export default {}', ++ "export * from 'module1'", ++ ].join('\r\n'); ++ ++ expect(extractRequires(code)).toEqual(['module1']); ++}); ++ ++it('understands require.requireActual', () => { ++ const code = `require.requireActual('pizza');`; ++ expect(extractRequires(code)).toEqual(['pizza']); ++}); ++ ++it('understands jest.requireActual', () => { ++ const code = `jest.requireActual('whiskey');`; ++ expect(extractRequires(code)).toEqual(['whiskey']); + }); +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,8 @@ ++H4sIAAAAAAAAA+3SzW7UMBAA4JzzFNOWQ3twvNludqVKPcAJbghxRIocZ5p4m7WDPYHC02On3bJF ++gl7aIsR8Fyf2zPi3aCYztDXaLzJ7LotoU1VzG/3azt9ltSzLarNaL1fZoizX5SKD6tlWdGAKpDxA ++5p2jP8U9Nv6PKn7eP2GgWrvdTtm2CP3TzfHY/W/Kzf39V6sYV67W5+cZLJ5uCb/3n9//yZFsjJWN ++Cn2uW5gfQYNtnuPN6DzB+9cf314eSzeStK5FsVym+ItXqf84z0/gnY0HOAzQ4oi2RasNBvhqqHcT ++gZ+sNbaD0QUyd4Gn84uDoL0ZCXoVQEEzdXMOCBHMgJZA+e4s/6a8hX2eEFfefUcrBqevr2JU7DGd ++dR7Fba2QlvNmLk49wujdFjXladlQyLsYOc9ebOfgD5OFxsVp4xPokCBtHlLpsM8alb5WHQa5jUNC ++D2Y+rfQTS8CnHOBhRNwOodipUQav5WAaWdepaqhriTfklaba4+fJeAwFHZQxlrDzioyztwkHiany ++PquOFSY1PMgVwjqhle4x/9vPiTHGGGOMMcYYY4wxxhhjjDHGGGOMvbAfPhdHVgAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001632/tests/test.sh b/tasks/format-code-task-001632/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d723baf226958fdd1e20f943d09cae3433f98b --- /dev/null +++ b/tasks/format-code-task-001632/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +integration_tests/__tests__/jest_require_actual.test.js +packages/jest-haste-map/src/lib/__tests__/extract_requires.test.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001632/tests/test_command.sh b/tasks/format-code-task-001632/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001632/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001633/environment/Dockerfile b/tasks/format-code-task-001633/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bb267686a708d6cce9f5985d8fdc0da6bd5f77e4 --- /dev/null +++ b/tasks/format-code-task-001633/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:00bb281f7cea05a0beaae82e8b6540a668fd47191137c0329ef1e846a50f9790 diff --git a/tasks/format-code-task-001633/environment/setup/files/blocklist b/tasks/format-code-task-001633/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001633/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001633/environment/setup/setup.sh b/tasks/format-code-task-001633/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001633/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001633/tests/test.patch b/tasks/format-code-task-001633/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..82a537235b444f0d45fc0edd9ffecaf34a46b011 --- /dev/null +++ b/tasks/format-code-task-001633/tests/test.patch @@ -0,0 +1,65 @@ +diff --git a/packages/pretty-format/src/__tests__/window.test.js b/packages/pretty-format/src/__tests__/window.test.js +new file mode 100644 +index 0000000000..efb2579e53 +--- /dev/null ++++ b/packages/pretty-format/src/__tests__/window.test.js +@@ -0,0 +1,37 @@ ++/** ++ * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. ++ * ++ * This source code is licensed under the MIT license found in the ++ * LICENSE file in the root directory of this source tree. ++ * ++ * @jest-environment jsdom ++ */ ++/* eslint-env browser */ ++ ++'use strict'; ++ ++const prettyFormat = require('../'); ++ ++describe('prettyFormat() with global window', () => { ++ it('does not throw when passed the global window object', () => { ++ expect(() => prettyFormat(window)).not.toThrow(); ++ }); ++ ++ it('formats window using its constructor name in brackets', () => { ++ expect(prettyFormat(window)).toEqual('[Window]'); ++ }); ++ ++ it('formats window the same way in min mode', () => { ++ expect(prettyFormat(window, {min: true})).toEqual('[Window]'); ++ }); ++ ++ it('formats window when nested inside an array', () => { ++ expect(prettyFormat([window])).toEqual('Array [\n [Window],\n]'); ++ }); ++ ++ it('formats window when nested as an object property', () => { ++ expect(prettyFormat({win: window})).toEqual( ++ 'Object {\n "win": [Window],\n}', ++ ); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..6c1c47e7f0 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["node ./packages/jest-cli/bin/jest.js packages/pretty-format/src/__tests__/window.test.js"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++node ./packages/jest-cli/bin/jest.js packages/pretty-format/src/__tests__/window.test.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001633/tests/test.sh b/tasks/format-code-task-001633/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c09cbd1f2718700cb50915b12db1086235d97a7d --- /dev/null +++ b/tasks/format-code-task-001633/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/pretty-format/src/__tests__/window.test.js +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001633/tests/test_command.sh b/tasks/format-code-task-001633/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001633/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001635/environment/Dockerfile b/tasks/format-code-task-001635/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b82dd57b0df770d99759448d7340b0c10abe95ff --- /dev/null +++ b/tasks/format-code-task-001635/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0560752a619b4afd38b53368b5e050520dbce9b846d941012f88a9f8053b39f2 diff --git a/tasks/format-code-task-001635/environment/setup/files/blocklist b/tasks/format-code-task-001635/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001635/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001635/environment/setup/setup.sh b/tasks/format-code-task-001635/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001635/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001635/tests/test.patch b/tasks/format-code-task-001635/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9a9e66b2ab72b888dfdf4e851872f29f18813799 --- /dev/null +++ b/tasks/format-code-task-001635/tests/test.patch @@ -0,0 +1,71 @@ +diff --git a/tests/test_views.py b/tests/test_views.py +index 0315939a..526656ef 100644 +--- a/tests/test_views.py ++++ b/tests/test_views.py +@@ -396,6 +396,17 @@ def test_post_with_submodels(self): + response = self.app.get('/api/person') + assert len(loads(response.data)['objects']) == 1 + ++ ++ data = dict(name='Rodriguez', age=70, ++ computers=[dict(name='iMac', vendor='Apple', ++ programs=[dict(program= ++ dict(name='iPhoto'))])]) ++ response = self.app.post('/api/person', data=dumps(data)) ++ assert 201 == response.status_code ++ response = self.app.get('/api/computer/2/programs') ++ programs = loads(response.data)['objects'] ++ assert programs[0]['program']['name'] == 'iPhoto' ++ + def test_post_with_single_submodel(self): + data = {'vendor': u'Apple', 'name': u'iMac', + 'owner': {'name': u'John', 'age': 2041}} +@@ -429,6 +440,27 @@ def test_patch_update_relations(self): + response = self.app.get('/api/computer/1') + assert 200 == response.status_code + assert 'foo' == loads(response.data)['name'] ++ ++ data = dict(computers=[dict(id=1), ++ dict(name='iMac', vendor='Apple', ++ programs=[dict(program= ++ dict(name='iPhoto'))])]) ++ response = self.app.patch('/api/person/1', data=dumps(data)) ++ assert 200 == response.status_code ++ response = self.app.get('/api/computer/2/programs') ++ programs = loads(response.data)['objects'] ++ assert programs[0]['program']['name'] == 'iPhoto' ++ ++ data = dict(computers=[dict(id=1), ++ dict(id=2, ++ programs=[dict(program_id=1), ++ dict(program= ++ dict(name='iMovie'))])]) ++ response = self.app.patch('/api/person/1', data=dumps(data)) ++ assert 200 == response.status_code ++ response = self.app.get('/api/computer/2/programs') ++ programs = loads(response.data)['objects'] ++ assert programs[1]['program']['name'] == 'iMovie' + + def test_patch_m2m(self): + """Test for updating a model with a many to many relation that uses +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SvWrDMBQFYM1+iovx0A52LKeSodAhQyBLaIfuwY4FEcSSsRQnefvYLrSl0GZJ ++KGnPt1whCf1wblLu9LZaKdNN2LWkvVyIsfa+1nHMRca5TDPJpyzlXOSSkbjaiz7ZOV+0RKy11v+0 ++79z6jUo+8vfK+dXa1nVhqsRtLnfHufy5kO/5i2ne5/8gM84ovdwTvvfP819XNAZfqipQh8a2nl5m ++r4unMFo8L+eTpDkOrVFq8xgN82GgumJLYXQ3LpA22lN8HwbN0W+sobgmY52i4Uj31lGdVnvXn0Nx ++F/z2bwEAAAAAAAAAAAAAAAAAAAAA/pYTp8eSPAAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001635/tests/test.sh b/tasks/format-code-task-001635/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..92ccf65ba2df6e91128d874869a49f8e1f954486 --- /dev/null +++ b/tasks/format-code-task-001635/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_views.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001635/tests/test_command.sh b/tasks/format-code-task-001635/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001635/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001651/environment/Dockerfile b/tasks/format-code-task-001651/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cffcd4626b5a4a78077bb4b1a0a0e07e01710721 --- /dev/null +++ b/tasks/format-code-task-001651/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6c53ca9beddc86b550ac59245d0c41f24204742fc873a1a80b4bc93aaf806001 diff --git a/tasks/format-code-task-001651/environment/setup/files/blocklist b/tasks/format-code-task-001651/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001651/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001651/environment/setup/setup.sh b/tasks/format-code-task-001651/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001651/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001651/tests/test.patch b/tasks/format-code-task-001651/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d3cf2008500d86356f0b49a6ef1cdcc1fea73130 --- /dev/null +++ b/tasks/format-code-task-001651/tests/test.patch @@ -0,0 +1,203 @@ +diff --git a/tests/test_scene_manager_lifecycle.py b/tests/test_scene_manager_lifecycle.py +new file mode 100644 +index 0000000000..6d714f4b7a +--- /dev/null ++++ b/tests/test_scene_manager_lifecycle.py +@@ -0,0 +1,146 @@ ++import sys ++import types ++ ++from PyQt5.QtCore import QObject ++from PyQt5.QtGui import QPainterPath ++from PyQt5.QtWidgets import QApplication, QGraphicsItem, QGraphicsScene ++ ++ ++ ++ ++sys.modules.setdefault("urh.cythonext.path_creator", types.SimpleNamespace()) ++sys.modules.setdefault("urh.cythonext.util", types.SimpleNamespace()) ++sys.modules.setdefault( ++ "urh.cythonext.signalFunctions", ++ types.SimpleNamespace(get_noise_for_mod_type=lambda _mod_type: 0), ++) ++ ++from urh.FFTSceneManager import FFTSceneManager ++from urh.SceneManager import SceneManager ++from urh.SignalSceneManager import SignalSceneManager ++ ++_APP = None ++ ++def _ensure_app(): ++ global _APP ++ app = QApplication.instance() ++ if not isinstance(app, QApplication): ++ app = QApplication(sys.argv) ++ _APP = app ++ return app ++ ++ ++def _value(obj, attr_name): ++ return getattr(obj, attr_name, None) ++ ++ ++def _snapshot_base_resources(manager): ++ return { ++ "scene": manager.scene, ++ "plot_data": _value(manager, "plot_data"), ++ "line_item": _value(manager, "line_item"), ++ "text_item": _value(manager, "text_item"), ++ } ++ ++ ++def _assert_not_retaining_previous(manager, attr_name, previous_value): ++ if previous_value is not None: ++ assert _value(manager, attr_name) is not previous_value ++ ++ ++def _assert_no_graphics_item_retained(manager, attr_name): ++ value = _value(manager, attr_name) ++ assert value is None or not isinstance(value, QGraphicsItem) ++ ++ ++def _assert_scene_resource_released(manager, previous_scene): ++ current_scene = _value(manager, "scene") ++ if current_scene is previous_scene: ++ assert previous_scene.parent() is None ++ assert len(previous_scene.items()) == 0 ++ else: ++ assert current_scene is None or not isinstance(current_scene, QGraphicsScene) ++ ++ ++def _assert_base_resources_released(manager, before): ++ _assert_not_retaining_previous(manager, "plot_data", before["plot_data"]) ++ _assert_not_retaining_previous(manager, "line_item", before["line_item"]) ++ _assert_not_retaining_previous(manager, "text_item", before["text_item"]) ++ _assert_no_graphics_item_retained(manager, "line_item") ++ _assert_no_graphics_item_retained(manager, "text_item") ++ _assert_scene_resource_released(manager, before["scene"]) ++ ++ ++def _minimal_fft_manager(): ++ _ensure_app() ++ manager = FFTSceneManager(QObject()) ++ manager.peak = [1, 2, 3] ++ manager.plot_data = [0.125, 0.25, 0.5] ++ if getattr(manager, "peak_item", None) is None: ++ manager.peak_item = manager.scene.addPath(QPainterPath()) ++ return manager ++ ++ ++def _minimal_signal_manager(signal): ++ _ensure_app() ++ return SignalSceneManager(signal, QObject()) ++ ++ ++def test_new_scene_manager_has_no_plot_data(): ++ _ensure_app() ++ manager = SceneManager(QObject()) ++ ++ assert manager.plot_data is None ++ ++ ++def test_scene_manager_eliminate_releases_base_resources(): ++ _ensure_app() ++ manager = SceneManager(QObject()) ++ manager.plot_data = [0.25, -0.5, 1.0] ++ before = _snapshot_base_resources(manager) ++ scene_parent = QObject() ++ before["scene"].setParent(scene_parent) ++ ++ assert len(before["scene"].items()) >= 2 ++ ++ manager.eliminate() ++ ++ _assert_base_resources_released(manager, before) ++ ++ ++def test_fft_scene_manager_eliminate_releases_peak_state(): ++ manager = _minimal_fft_manager() ++ before = _snapshot_base_resources(manager) ++ peak = manager.peak ++ peak_item = manager.peak_item ++ scene_parent = QObject() ++ before["scene"].setParent(scene_parent) ++ ++ manager.eliminate() ++ ++ _assert_base_resources_released(manager, before) ++ _assert_not_retaining_previous(manager, "peak", peak) ++ _assert_not_retaining_previous(manager, "peak_item", peak_item) ++ _assert_no_graphics_item_retained(manager, "peak_item") ++ ++ ++def test_signal_scene_manager_eliminate_releases_signal_reference(): ++ sentinel_signal = object() ++ manager = _minimal_signal_manager(sentinel_signal) ++ before = _snapshot_base_resources(manager) ++ scene_parent = QObject() ++ before["scene"].setParent(scene_parent) ++ ++ manager.eliminate() ++ ++ _assert_base_resources_released(manager, before) ++ _assert_not_retaining_previous(manager, "signal", sentinel_signal) ++ ++ ++def test_clear_peak_after_eliminate_is_safe(): ++ manager = _minimal_fft_manager() ++ ++ manager.eliminate() ++ ++ manager.clear_peak() ++ _assert_no_graphics_item_retained(manager, "peak_item") +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,46 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++if [ ! -x /testbed/.venv/bin/python ]; then ++ rm -rf /testbed/.venv ++ python3 -m venv /testbed/.venv ++fi ++/testbed/.venv/bin/python -m pip install -q --upgrade pip setuptools wheel ++/testbed/.venv/bin/python -m pip install -q -r /testbed/requirements.txt pytest ++export PATH="/testbed/.venv/bin:$PATH" ++export VIRTUAL_ENV="/testbed/.venv" ++export QT_QPA_PLATFORM=offscreen ++export PYTHONPATH="/testbed/src:${PYTHONPATH:-}" ++ ++ ++case "${1:-}" in ++ base) ++ python - <<'PYBASE' ++import sys ++import types ++from PyQt5.QtWidgets import QApplication ++sys.modules.setdefault("urh.cythonext.path_creator", types.SimpleNamespace()) ++sys.modules.setdefault("urh.cythonext.util", types.SimpleNamespace()) ++sys.modules.setdefault( ++ "urh.cythonext.signalFunctions", ++ types.SimpleNamespace(get_noise_for_mod_type=lambda _mod_type: 0), ++) ++from urh.SceneManager import SceneManager ++from urh.FFTSceneManager import FFTSceneManager ++from urh.SignalSceneManager import SignalSceneManager ++app = QApplication.instance() or QApplication([]) ++assert SceneManager is not None ++assert FFTSceneManager is not None ++assert SignalSceneManager is not None ++PYBASE ++ ;; ++ new) ++ python -m pytest -x -v tests/test_scene_manager_lifecycle.py ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001651/tests/test.sh b/tasks/format-code-task-001651/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..46f5042cc1dce91f3ed2003f22021b529afe3794 --- /dev/null +++ b/tasks/format-code-task-001651/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_scene_manager_lifecycle.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001651/tests/test_command.sh b/tasks/format-code-task-001651/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001651/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001656/environment/Dockerfile b/tasks/format-code-task-001656/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f68039e5eff5e76f6ab023f07825724f6b313e3f --- /dev/null +++ b/tasks/format-code-task-001656/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:aeca6204cae834ec9a46ae1c83bcb17d42a4db5a5bc7a667edf1fef3de2e8d6b diff --git a/tasks/format-code-task-001656/environment/setup/files/blocklist b/tasks/format-code-task-001656/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001656/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001656/environment/setup/setup.sh b/tasks/format-code-task-001656/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001656/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001656/tests/test.patch b/tasks/format-code-task-001656/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2de4c961222741156fdc296eb54b0b80d78a9f57 --- /dev/null +++ b/tasks/format-code-task-001656/tests/test.patch @@ -0,0 +1,101 @@ +diff --git a/packages/semver/src/builders/version/builder.spec.ts b/packages/semver/src/builders/version/builder.spec.ts +index 2c54f9bc..f9d08529 100644 +--- a/packages/semver/src/builders/version/builder.spec.ts ++++ b/packages/semver/src/builders/version/builder.spec.ts +@@ -340,6 +340,74 @@ describe('@jscutlery/semver:version', () => { + }); + }); + ++ describe('Custom changelog header', () => { ++ it('should pass custom changelogHeader to standard-version when provided (independent)', async () => { ++ const customHeader = '# My Custom Header\n\nWe own this changelog.\n'; ++ ++ const { success } = await runBuilder( ++ { ...options, changelogHeader: customHeader } as VersionBuilderSchema, ++ context ++ ).toPromise(); ++ ++ expect(success).toBe(true); ++ expect(standardVersion).toBeCalledWith( ++ expect.objectContaining({ ++ header: customHeader, ++ }) ++ ); ++ }); ++ ++ it('should preserve default header when changelogHeader is not provided (independent)', async () => { ++ const { success } = await runBuilder(options, context).toPromise(); ++ ++ expect(success).toBe(true); ++ const callArgs = (standardVersion as jest.Mock).mock.calls[0][0]; ++ expect(typeof callArgs.header).toBe('string'); ++ expect(callArgs.header).toContain('Changelog'); ++ expect(callArgs.header).toContain('@jscutlery/semver'); ++ }); ++ ++ it('should pass custom changelogHeader to standard-version in sync versions mode', async () => { ++ const customHeader = '# Workspace Changelog\n\nMaintained by us.\n'; ++ const syncContext = createFakeContext({ ++ project: 'workspace', ++ projectRoot: '/root', ++ workspaceRoot: '/root', ++ }); ++ ++ const { success } = await runBuilder( ++ { ++ ...options, ++ syncVersions: true, ++ changelogHeader: customHeader, ++ } as VersionBuilderSchema, ++ syncContext ++ ).toPromise(); ++ ++ expect(success).toBe(true); ++ expect(standardVersion).toBeCalledWith( ++ expect.objectContaining({ ++ header: customHeader, ++ }) ++ ); ++ }); ++ ++ it('should not treat changelogHeader as any other unrelated option', async () => { ++ const customHeader = 'UNIQUE-HEADER-MARKER-12345'; ++ ++ await runBuilder( ++ { ...options, changelogHeader: customHeader } as VersionBuilderSchema, ++ context ++ ).toPromise(); ++ ++ const callArgs = (standardVersion as jest.Mock).mock.calls[0][0]; ++ ++ expect(callArgs.header).toBe(customHeader); ++ expect(callArgs.infile).not.toBe(customHeader); ++ expect(callArgs.path).not.toBe(customHeader); ++ }); ++ }); ++ + describe('Plugins', () => { + beforeEach(() => { + mockValidateA.mockResolvedValue(true); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..80b12ff9 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest --config=packages/semver/jest.config.js packages/semver/src/builders/version/builder.spec.ts -t \"Custom changelog header\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++npx jest --config=packages/semver/jest.config.js packages/semver/src/builders/version/builder.spec.ts -t "Custom changelog header" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001656/tests/test.sh b/tasks/format-code-task-001656/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cb38f80887226212875247a8eaa0cc418f67d0e7 --- /dev/null +++ b/tasks/format-code-task-001656/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/semver/src/builders/version/builder.spec.ts +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001656/tests/test_command.sh b/tasks/format-code-task-001656/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001656/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001660/environment/Dockerfile b/tasks/format-code-task-001660/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8a71f02f2a6fc6bf6fa35ef2fbeead60803b61c9 --- /dev/null +++ b/tasks/format-code-task-001660/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:661d3300cd649f1f55901b90747214624918fd6318b028cc24ff1a20ebd44e95 diff --git a/tasks/format-code-task-001660/environment/setup/files/blocklist b/tasks/format-code-task-001660/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001660/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001660/environment/setup/setup.sh b/tasks/format-code-task-001660/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001660/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001660/tests/test.patch b/tasks/format-code-task-001660/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c08ddce6e809aef10602d939f6caf5e5aafff026 --- /dev/null +++ b/tasks/format-code-task-001660/tests/test.patch @@ -0,0 +1,221 @@ +diff --git a/tests/lib/rules/sort-comp.js b/tests/lib/rules/sort-comp.js +index 7c67bcb4a8..d30bb25f48 100644 +--- a/tests/lib/rules/sort-comp.js ++++ b/tests/lib/rules/sort-comp.js +@@ -506,6 +506,129 @@ ruleTester.run('sort-comp', rule, { + 'everything-else' + ] + }] ++ }, { ++ code: ` ++ class MyComponent extends React.Component { ++ static foo; ++ static getDerivedStateFromProps() {} ++ ++ render() { ++ return null; ++ } ++ } ++ `, ++ parser: parsers.BABEL_ESLINT, ++ options: [{ ++ order: [ ++ 'static-variables', ++ 'static-methods' ++ ] ++ }] ++ }, { ++ code: ` ++ class MyComponent extends React.Component { ++ static getDerivedStateFromProps() {} ++ static foo = 'some-str'; ++ ++ render() { ++ return null; ++ } ++ } ++ `, ++ parser: parsers.BABEL_ESLINT, ++ options: [{ ++ order: [ ++ 'static-methods', ++ 'static-variables' ++ ] ++ }] ++ }, { ++ code: ` ++ class MyComponent extends React.Component { ++ foo = {}; ++ static bar = 0; ++ static getDerivedStateFromProps() {} ++ ++ render() { ++ return null; ++ } ++ } ++ `, ++ parser: parsers.BABEL_ESLINT, ++ options: [{ ++ order: [ ++ 'instance-variables', ++ 'static-variables', ++ 'static-methods' ++ ] ++ }] ++ }, { ++ code: ` ++ class MyComponent extends React.Component { ++ static bar = 1; ++ foo = {}; ++ static getDerivedStateFromProps() {} ++ ++ render() { ++ return null; ++ } ++ } ++ `, ++ parser: parsers.BABEL_ESLINT, ++ options: [{ ++ order: [ ++ 'static-variables', ++ 'instance-variables', ++ 'static-methods' ++ ] ++ }] ++ }, { ++ code: ` ++ class MyComponent extends React.Component { ++ static getDerivedStateFromProps() {} ++ render() { ++ return null; ++ } ++ static bar; ++ foo = {}; ++ } ++ `, ++ parser: parsers.BABEL_ESLINT, ++ options: [{ ++ order: [ ++ 'static-methods', ++ 'render', ++ 'static-variables', ++ 'instance-variables' ++ ] ++ }] ++ }, { ++ code: ` ++ class MyComponent extends React.Component { ++ static foo = 1; ++ bar; ++ ++ constructor() { ++ super(props); ++ ++ this.state = {}; ++ } ++ ++ render() { ++ return null; ++ } ++ } ++ `, ++ parser: parsers.BABEL_ESLINT, ++ options: [{ ++ order: [ ++ 'static-variables', ++ 'instance-variables', ++ 'constructor', ++ 'everything-else', ++ 'render' ++ ] ++ }] + }], + + invalid: [{ +@@ -790,5 +913,66 @@ ruleTester.run('sort-comp', rule, { + 'render' + ] + }] ++ }, { ++ code: ` ++ class MyComponent extends React.Component { ++ static getDerivedStateFromProps() {} ++ static foo; ++ ++ render() { ++ return null; ++ } ++ } ++ `, ++ errors: [{message: 'getDerivedStateFromProps should be placed after foo'}], ++ parser: parsers.BABEL_ESLINT, ++ options: [{ ++ order: [ ++ 'static-variables', ++ 'static-methods' ++ ] ++ }] ++ }, { ++ code: ` ++ class MyComponent extends React.Component { ++ static foo; ++ bar = 'some-str' ++ static getDerivedStateFromProps() {} ++ ++ render() { ++ return null; ++ } ++ } ++ `, ++ errors: [{message: 'foo should be placed after bar'}], ++ parser: parsers.BABEL_ESLINT, ++ options: [{ ++ order: [ ++ 'instance-variables', ++ 'static-variables', ++ 'static-methods' ++ ] ++ }] ++ }, { ++ code: ` ++ class MyComponent extends React.Component { ++ static getDerivedStateFromProps() {} ++ static bar; ++ render() { ++ return null; ++ } ++ foo = {}; ++ } ++ `, ++ parser: parsers.BABEL_ESLINT, ++ errors: [{message: 'bar should be placed after render'}], ++ options: [{ ++ order: [ ++ 'static-methods', ++ 'render', ++ 'static-variables', ++ 'instance-variables' ++ ] ++ }] + }] + }); +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3S3wqCMBTHca99ir1AOpezxwn/gYU6cTN6/JYERVDeJBF9PzdnnA124HeiYjq0 ++1b7uT3GwFunttJ6r91znc6JVoqRSmfb9JNG7NBB6tYkeTNbloxDBaIx7927p/kdF9/xdbd2+NF2X ++91Vkm8/9sZh/tr3nL5XPP82kz19+boTX/jz/shJz8EVdhf1wFp0pm1xcOzZuD0U8Tm1tY2tGt/Gr ++MURHG357ZAAAAAAAAAAAAAAAAAA3F22mDTYAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001660/tests/test.sh b/tasks/format-code-task-001660/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..acb1a565bcd4c06050965c8065266f41c0842321 --- /dev/null +++ b/tasks/format-code-task-001660/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/lib/rules/sort-comp.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001660/tests/test_command.sh b/tasks/format-code-task-001660/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001660/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001667/environment/Dockerfile b/tasks/format-code-task-001667/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d1be4a207dd8ce77c4644191c623f11a10379ab3 --- /dev/null +++ b/tasks/format-code-task-001667/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a2e71ddd489de55e09ec10a0f6037479c4b54d30cb232acdedd65803ba870cf1 diff --git a/tasks/format-code-task-001667/environment/setup/files/blocklist b/tasks/format-code-task-001667/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001667/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001667/environment/setup/setup.sh b/tasks/format-code-task-001667/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001667/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001667/tests/test.patch b/tasks/format-code-task-001667/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9036d318a9b056ac9c95a0f9c07e88f4f7896771 --- /dev/null +++ b/tasks/format-code-task-001667/tests/test.patch @@ -0,0 +1,69 @@ +diff --git a/test/constraint.jl b/test/constraint.jl +index 8c0739e8933..6011b748930 100644 +--- a/test/constraint.jl ++++ b/test/constraint.jl +@@ -663,6 +663,21 @@ function test_Model_add_to_function_constant_vector(::Any, ::Any) + @test JuMP.moi_set(con) == MOI.Nonnegatives(2) + end + ++function test_Model_value_constraint_var(ModelType, ::Any) ++ model = ModelType() ++ @variable(model, x[1:2]) ++ @constraint(model, c1, x[1] + x[2] <= 3.0) ++ @constraint(model, c2, x[1]^2 + x[2]^2 <= 3.0) ++ @constraint(model, c3, [1.0, x[1], x[2]] in SecondOrderCone()) ++ ++ vals = Dict(x[1] => 1.0, x[2] => 2.0) ++ f = vidx -> vals[vidx] ++ ++ @test value(c1, f) === 3.0 ++ @test value(c2, f) === 5.0 ++ @test value(c3, f) == [1.0, 1.0, 2.0] ++end ++ + function _test_shadow_price_util(model_string, constraint_dual, constraint_shadow) + model = Model() + MOIU.loadfromstring!(backend(model), model_string) +diff --git a/test/variable.jl b/test/variable.jl +index 04a3684be62..38db2e7b76b 100644 +--- a/test/variable.jl ++++ b/test/variable.jl +@@ -713,6 +713,17 @@ function test_Model_value(::Any, ::Any) + @test value(JuMP._MA.Zero()) === 0.0 + end + ++function test_Model_value_var(ModelType, ::Any) ++ model = ModelType() ++ @variable(model, x[1:2]) ++ ++ vals = Dict(x[1] => 1.0, x[2] => 2.0) ++ f = vidx -> vals[vidx] ++ ++ @test value(x[1], f) === 1.0 ++ @test value(x[2], f) === 2.0 ++end ++ + function test_Model_relax_integrality(::Any, ::Any) + model = Model() + @variable(model, x, Bin) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3RQW7CMBAF0KxzCisb2kVNEjC5Rm+AHNuiQ40jJXbOzxAEVFVbNqAK8d9mHM/I ++sfxlm8jbtQvjPLuXkjVKTZV9r9O6UnVVreqmWvIcr0qVCXW3G32Rhqh7IbK+6+Jfc9f6D0pe8o9u ++iGvT7XY6WDl83O4f1/Kva3XKf9U0C85/yatMlLe7wu+ePH9jxRR862y+TZ60eHNilguWBgob8f65 ++mb64Sm0ijTq6l0IWr+ddCvyEIdKhcdylYHyyPHY4eT7qnnTrndz64qe+6fiAXlOIx4lZ/t+PAgAA ++AAAAAAAAAAAAAAAAAADwIPbXZLrQACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001667/tests/test.sh b/tasks/format-code-task-001667/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ac6bd8a5c456b259cdc4d7834c5061be6533a9f7 --- /dev/null +++ b/tasks/format-code-task-001667/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/constraint.jl +test/variable.jl +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001667/tests/test_command.sh b/tasks/format-code-task-001667/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001667/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001669/environment/Dockerfile b/tasks/format-code-task-001669/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..75f7e82576ca47b40e5f1ec2a62355feb21a74e1 --- /dev/null +++ b/tasks/format-code-task-001669/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bf007c4757e6360c92d67d4a51d78bbbbe4bf6a7453d73cc819d55d02ca58f6b diff --git a/tasks/format-code-task-001669/environment/setup/files/blocklist b/tasks/format-code-task-001669/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001669/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001669/environment/setup/setup.sh b/tasks/format-code-task-001669/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001669/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001669/tests/test.patch b/tasks/format-code-task-001669/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7016d3f980cd336dcc3205114ddf2be67be6d166 --- /dev/null +++ b/tasks/format-code-task-001669/tests/test.patch @@ -0,0 +1,171 @@ +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,143 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++export PATH="/root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/bin:${PATH}" ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++ ++( cd /workspace/repo && go build -mod=readonly -o /tmp/fzf-coderl-acceptance . ) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN=/tmp/fzf-coderl-acceptance ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++assert_line_present() { ++ local file=$1 ++ local line=$2 ++ local name=$3 ++ ++ grep -Fxq "$line" "$file" || fail "$name missing $line: $(cat "$file")" ++} ++ ++assert_line_absent_prefix() { ++ local file=$1 ++ local prefix=$2 ++ local name=$3 ++ ++ ! grep -Eq "(^|/)$prefix(/|$)" "$file" || fail "$name unexpectedly included $prefix: $(cat "$file")" ++} ++ ++run_walker() { ++ local tree=$1 ++ local cmd=$2 ++ local name=$3 ++ ( ++ cd "$tree" || exit 97 ++ env -u FZF_DEFAULT_COMMAND -u FZF_DEFAULT_OPTS \ ++ script -qfec "$cmd" /dev/null ++ ) >"$TMP/${name}.rawout" 2>"$TMP/${name}.err" ++ local ec=$? ++ tr -d '\r' <"$TMP/${name}.rawout" >"$TMP/${name}.out" ++ return "$ec" ++} ++ ++ ++ ++ ++tree="$TMP/default-tree" ++mkdir -p "$tree/src" "$tree/.git" "$tree/node_modules/pkg" "$tree/target" ++touch "$tree/src/main.go" "$tree/.git/config" "$tree/node_modules/pkg/index.js" "$tree/target/app.log" ++run_walker "$tree" "$BIN --filter ''" f1; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_line_present "$TMP/f1.out" "src/main.go" "F1" ++assert_line_present "$TMP/f1.out" "target/app.log" "F1" ++assert_line_absent_prefix "$TMP/f1.out" "\\.git" "F1" ++assert_line_absent_prefix "$TMP/f1.out" "node_modules" "F1" ++[ ! -s "$TMP/f1.err" ] || fail "F1 unexpected stderr: $(cat "$TMP/f1.err")" ++ ++ ++ ++ ++tree="$TMP/explicit-tree" ++mkdir -p "$tree/src" "$tree/.git" "$tree/node_modules/pkg" "$tree/target" ++touch "$tree/src/main.go" "$tree/.git/config" "$tree/node_modules/pkg/index.js" "$tree/target/app.log" ++run_walker "$tree" "$BIN --walker-skip .git,node_modules,target --filter ''" f2; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++assert_line_present "$TMP/f2.out" "src/main.go" "F2" ++assert_line_absent_prefix "$TMP/f2.out" "\\.git" "F2" ++assert_line_absent_prefix "$TMP/f2.out" "node_modules" "F2" ++assert_line_absent_prefix "$TMP/f2.out" "target" "F2" ++[ ! -s "$TMP/f2.err" ] || fail "F2 unexpected stderr: $(cat "$TMP/f2.err")" ++ ++ ++ ++ ++tree="$TMP/empty-entry-tree" ++mkdir -p "$tree/src" "$tree/.git" "$tree/node_modules/pkg" "$tree/target" ++touch "$tree/src/main.go" "$tree/.git/config" "$tree/node_modules/pkg/index.js" "$tree/target/app.log" ++run_walker "$tree" "$BIN --walker-skip ,,target,, --filter ''" f3; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++assert_line_present "$TMP/f3.out" "src/main.go" "F3" ++assert_line_present "$TMP/f3.out" ".git/config" "F3" ++assert_line_present "$TMP/f3.out" "node_modules/pkg/index.js" "F3" ++assert_line_absent_prefix "$TMP/f3.out" "target" "F3" ++[ ! -s "$TMP/f3.err" ] || fail "F3 unexpected stderr: $(cat "$TMP/f3.err")" ++ ++ ++ ++ ++tree="$TMP/path-pattern-tree" ++mkdir -p "$tree/foo/bar" "$tree/baz/foo/bar" "$tree/bazfoo/bar" "$tree/keep" ++touch "$tree/foo/bar/root.txt" "$tree/baz/foo/bar/nested.txt" "$tree/bazfoo/bar/notmatch.txt" "$tree/keep/file.txt" ++run_walker "$tree" "$BIN --walker-skip foo/bar --filter ''" f4; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++assert_line_present "$TMP/f4.out" "bazfoo/bar/notmatch.txt" "F4" ++assert_line_present "$TMP/f4.out" "keep/file.txt" "F4" ++assert_line_absent_prefix "$TMP/f4.out" "foo/bar" "F4" ++assert_line_absent_prefix "$TMP/f4.out" "baz/foo/bar" "F4" ++[ ! -s "$TMP/f4.err" ] || fail "F4 unexpected stderr: $(cat "$TMP/f4.err")" ++ ++ ++ ++ ++cd "$TMP" ++env -u FZF_DEFAULT_COMMAND -u FZF_DEFAULT_OPTS "$BIN" --walker-skip >f5.out 2>f5.err; ec=$? ++[ "$ec" -ne 0 ] || fail "F5 exit $ec; want non-zero" ++[ ! -s f5.out ] || fail "F5 unexpected stdout: $(cat f5.out)" ++ ++grep -Eq 'directory|directories' f5.err || fail "F5 stderr missing directory diagnostic: $(cat f5.err)" ++grep -Eq 'ignore|skip' f5.err || fail "F5 stderr missing ignore/skip diagnostic: $(cat f5.err)" ++grep -Eq 'required|missing' f5.err || fail "F5 stderr missing required/missing diagnostic: $(cat f5.err)" ++ ++ ++ ++ ++"$BIN" --help >f6.out 2>f6.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F6 exit $ec; want 0" ++[ ! -s f6.err ] || fail "F6 unexpected stderr: $(cat f6.err)" ++help_block=$(sed -n '/DIRECTORY TRAVERSAL/,/HISTORY/p' f6.out) ++ ++printf '%s\n' "$help_block" | grep -Fq 'DIRECTORY TRAVERSAL' || fail "F6 missing directory traversal section: $help_block" ++printf '%s\n' "$help_block" | grep -Fq -- '--walker-skip=DIRS' || fail "F6 missing --walker-skip=DIRS: $help_block" ++printf '%s\n' "$help_block" | grep -Fq -- '.git,node_modules' || fail "F6 missing default skip list: $help_block" ++ ++ ++ ++ ++"$BIN" --bash >f7.out 2>f7.err; ec=$? ++[ "$ec" -eq 0 ] || fail "F7 exit $ec; want 0" ++[ ! -s f7.err ] || fail "F7 unexpected stderr: $(cat f7.err)" ++completion_block=$(sed -n '/ --walker$/,/ --with-nth$/p' f7.out) ++ ++printf '%s\n' "$completion_block" | grep -Fxq ' --walker' || fail "F7 missing --walker: $completion_block" ++printf '%s\n' "$completion_block" | grep -Fxq ' --walker-root' || fail "F7 missing --walker-root: $completion_block" ++printf '%s\n' "$completion_block" | grep -Fxq ' --walker-skip' || fail "F7 missing --walker-skip: $completion_block" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++ ++export PATH="/root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/bin:${PATH}" ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-001669/tests/test.sh b/tasks/format-code-task-001669/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-001669/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001669/tests/test_command.sh b/tasks/format-code-task-001669/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001669/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001694/environment/Dockerfile b/tasks/format-code-task-001694/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f296106f8c95b60d4fdf1e9e1612d72c77c84f5e --- /dev/null +++ b/tasks/format-code-task-001694/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f4437f9bc0b6bbc5a9ca26e4528588beafc3dcd906a02dab4f4d182b31173675 diff --git a/tasks/format-code-task-001694/environment/setup/files/blocklist b/tasks/format-code-task-001694/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001694/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001694/environment/setup/setup.sh b/tasks/format-code-task-001694/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001694/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001694/tests/test.patch b/tasks/format-code-task-001694/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..976dcd30adb1dcfbeddc66636d8d8ebf4958c529 --- /dev/null +++ b/tasks/format-code-task-001694/tests/test.patch @@ -0,0 +1,128 @@ +diff --git a/go/teams/request_test.go b/go/teams/request_test.go +index 0e1793d6c67d..782bb88cb10f 100644 +--- a/go/teams/request_test.go ++++ b/go/teams/request_test.go +@@ -5,6 +5,7 @@ import ( + + "github.com/keybase/client/go/libkb" + "github.com/keybase/client/go/protocol/keybase1" ++ "github.com/stretchr/testify/require" + + "golang.org/x/net/context" + ) +@@ -17,49 +18,47 @@ func TestAccessRequestAccept(t *testing.T) { + tc.G.Logout() + + // u1 requests access to the team +- if err := u1.Login(tc.G); err != nil { +- t.Fatal(err) +- } +- if _, err := RequestAccess(context.Background(), tc.G, teamName); err != nil { +- t.Fatal(err) +- } ++ err := u1.Login(tc.G) ++ require.NoError(t, err) ++ _, err = RequestAccess(context.Background(), tc.G, teamName) ++ require.NoError(t, err) ++ ++ myReqs, err := ListMyAccessRequests(context.Background(), tc.G, &teamName) ++ require.NoError(t, err) ++ require.Equal(t, 1, len(myReqs)) ++ require.Equal(t, teamName, myReqs[0].String()) ++ ++ ++ myReqs, err = ListMyAccessRequests(context.Background(), tc.G, nil) ++ require.NoError(t, err) ++ require.Equal(t, 1, len(myReqs)) ++ require.Equal(t, teamName, myReqs[0].String()) + + // owner lists requests, sees u1 request + tc.G.Logout() +- if err := owner.Login(tc.G); err != nil { +- t.Fatal(err) +- } ++ err = owner.Login(tc.G) ++ require.NoError(t, err) ++ + reqs, err := ListRequests(context.Background(), tc.G) +- if err != nil { +- t.Fatal(err) +- } +- if len(reqs) != 1 { +- t.Fatalf("num requests: %d, expected 1", len(reqs)) +- } +- if reqs[0].Name != teamName { +- t.Errorf("request team name: %q, expected %q", reqs[0].Name, teamName) +- } +- if reqs[0].Username != u1.Username { +- t.Errorf("request username: %q, expected %q", reqs[0].Username, u1.Username) +- } ++ require.NoError(t, err) ++ require.Equal(t, 1, len(reqs)) ++ require.Equal(t, teamName, reqs[0].Name) ++ require.Equal(t, u1.Username, reqs[0].Username) + + // owner add u1 to team +- if _, err := AddMember(context.Background(), tc.G, teamName, u1.Username, keybase1.TeamRole_WRITER); err != nil { +- t.Fatal(err) +- } ++ _, err = AddMember(context.Background(), tc.G, teamName, u1.Username, keybase1.TeamRole_WRITER) ++ require.NoError(t, err) + + // owner lists requests, sees no requests + assertNoRequests(tc) + + // u1 requests access to the team again + tc.G.Logout() +- if err := u1.Login(tc.G); err != nil { +- t.Fatal(err) +- } ++ err = u1.Login(tc.G) ++ require.NoError(t, err) ++ + _, err = RequestAccess(context.Background(), tc.G, teamName) +- if err == nil { +- t.Fatal("second RequestAccess success, expected error") +- } ++ require.Error(t, err) + aerr, ok := err.(libkb.AppStatusError) + if !ok { + t.Fatalf("error %s (%T), expected libkb.AppStatusError", err, err) +@@ -70,9 +69,8 @@ func TestAccessRequestAccept(t *testing.T) { + tc.G.Logout() + + // owner lists requests, sees no requests +- if err := owner.Login(tc.G); err != nil { +- t.Fatal(err) +- } ++ err = owner.Login(tc.G) ++ require.NoError(t, err) + assertNoRequests(tc) + } + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,10 @@ ++H4sIAAAAAAAAA+3TX2/TMBAA8D77UxzbhOAhTZ22GwN1aBoDhoY6sfKE0OQ6l8aqY2exUy3fHifd ++KJoY42ETIO4nRUn853z2Jf15rXR6gWYV9x7LINgbj7t7cPvePfNxwpPhIElGw96A8/HesAfjR8vo ++B7XzogLoVdb6X427r/8f1d/U36PzF9IWhTBp3+UPt8Y99efJ7uim/uE5CfUf7fKkB4OHS+Fu/3n9 ++t5/Ec2XiuXA5kyl0H8EcU8bwqrSVh3fTT9PpbBLb0scLG/F+wjddnPOP0zefT48nNss2zWeHs/eT ++uD2wMIWxbTg2rq7wugdcU2hllqAcKAOlFhJZsUxVBVEJN9NiV8l4oXxez/vhm4yX2IQckWkDkcu+ ++53nf+FhqhcZDchCnuIpNrXWb0JEtSqURfB4uFIWDNh6EkxBVA97CCiuVNSC0BmlTBJkLs0AXXtYT ++pa0qlF43Idgsb3fiumBOFAil8B4rA7ULCYYtth1HJ1CqEsPGEZ59QLNUxmVtpLbFwfDFfjTc58+7 ++GvzWltoBXepsYdfZRxIiG06mKNcdF11rcvCUswpdrf1k5zVjKoMvsLNugAgvYQBfX7UpGgYBytzC ++1tnh+fnLn5zM9fZTcLWU6FwWzrPZ6iZqB5EWt5dfx7xSHgYMdajfZo23hyend68hvLIGMtGutrWJ ++wlmm2J/+ZwghhBBCCCGEEEIIIYQQQgghhBBC/ibfANB8eU8AKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001694/tests/test.sh b/tasks/format-code-task-001694/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0009b1b63e581282aa0b59cb50c43ddc99c99c32 --- /dev/null +++ b/tasks/format-code-task-001694/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +go/teams/request_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001694/tests/test_command.sh b/tasks/format-code-task-001694/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001694/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001803/environment/Dockerfile b/tasks/format-code-task-001803/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7ced926c2fe3ca1571869612f48c248c53b6cfa1 --- /dev/null +++ b/tasks/format-code-task-001803/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d1c5b2c7d7e872a888c92bb397b7a13b3439e3b094cf795b24d46779f64674f6 diff --git a/tasks/format-code-task-001803/environment/setup/files/blocklist b/tasks/format-code-task-001803/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001803/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001803/environment/setup/setup.sh b/tasks/format-code-task-001803/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001803/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001803/tests/test.patch b/tasks/format-code-task-001803/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2455a4fff871390add9c56bccf565ce0433ee902 --- /dev/null +++ b/tasks/format-code-task-001803/tests/test.patch @@ -0,0 +1,351 @@ +diff --git a/usercase-test-coderl/test_lightfc_session.py b/usercase-test-coderl/test_lightfc_session.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_lightfc_session.py +@@ -0,0 +1,310 @@ ++import sys ++from collections.abc import Mapping, Sequence ++from types import SimpleNamespace ++ ++import pytest ++import torch ++import torch.nn as nn ++ ++sys.path.insert(0, "/workspace/repo") ++ ++from lib.models import LightFC ++ ++ ++def _ns(**kwargs): ++ return SimpleNamespace(**kwargs) ++ ++ ++def _cfg( ++ backbone_type="MobileNetV2", ++ inplanes=192, ++ freeze_bn=False, ++ num_kernel=64, ++ adj_channel=96, ++ channel=256, ++ feat_sz=16, ++ stride=16, ++): ++ return _ns( ++ MODEL=_ns( ++ BACKBONE=_ns( ++ TYPE=backbone_type, ++ USE_PRETRAINED=False, ++ PRETRAIN_FILE=None, ++ LOAD_MODE=1, ++ ), ++ FUSION=_ns(PARAMS=_ns(num_kernel=num_kernel, adj_channel=adj_channel)), ++ HEAD=_ns( ++ PARAMS=_ns( ++ inplanes=inplanes, ++ channel=channel, ++ feat_sz=feat_sz, ++ stride=stride, ++ freeze_bn=freeze_bn, ++ ) ++ ), ++ ) ++ ) ++ ++ ++class RecordingBackbone(nn.Module): ++ def __init__(self): ++ super().__init__() ++ self.calls = [] ++ ++ def forward(self, tensor): ++ call_number = len(self.calls) + 1 ++ self.calls.append((tuple(tensor.shape), float(tensor.sum()))) ++ return tensor + (10.0 * call_number) ++ ++ ++class RecordingFusion(nn.Module): ++ def __init__(self): ++ super().__init__() ++ self.calls = [] ++ ++ def forward(self, z_feat, x_feat): ++ self.calls.append((float(z_feat.sum()), float(x_feat.sum()))) ++ return z_feat + x_feat ++ ++ ++class RecordingHead(nn.Module): ++ def __init__(self): ++ super().__init__() ++ self.calls = [] ++ ++ def forward(self, fused): ++ fused_sum = float(fused.sum()) ++ self.calls.append(fused_sum) ++ return { ++ "marker": torch.tensor([fused_sum], dtype=torch.float32), ++ "shape": tuple(fused.shape), ++ } ++ ++ ++def _install_recorders(net): ++ net.backbone = RecordingBackbone() ++ net.fusion = RecordingFusion() ++ net.head = RecordingHead() ++ return net ++ ++ ++def _assert_same_head_output(actual, expected): ++ if torch.is_tensor(expected): ++ assert torch.is_tensor(actual) ++ assert actual.shape == expected.shape ++ assert torch.allclose(actual, expected) ++ elif isinstance(expected, Mapping): ++ assert isinstance(actual, Mapping) ++ assert set(actual.keys()) == set(expected.keys()) ++ for key in expected: ++ _assert_same_head_output(actual[key], expected[key]) ++ elif isinstance(expected, Sequence) and not isinstance(expected, (str, bytes)): ++ assert isinstance(actual, Sequence) ++ assert len(actual) == len(expected) ++ for actual_item, expected_item in zip(actual, expected): ++ _assert_same_head_output(actual_item, expected_item) ++ else: ++ assert actual == expected ++ ++ ++def test_public_constructor_builds_mobilenet_configured_submodules(): ++ ++ ++ ++ ++ torch.manual_seed(7) ++ ++ cfg = _cfg( ++ "MobileNetV2", ++ inplanes=8, ++ freeze_bn=False, ++ num_kernel=64, ++ adj_channel=5, ++ channel=8, ++ feat_sz=16, ++ stride=7, ++ ) ++ net = LightFC(cfg, env_num=0, training=False) ++ ++ assert type(net).__name__ == "LightFC" ++ assert isinstance(net, nn.Module) ++ assert type(net.backbone).__name__ == "MobileNetV2" ++ ++ assert isinstance(net.backbone, nn.Module) ++ assert isinstance(net.fusion, nn.Module) ++ assert isinstance(net.head, nn.Module) ++ assert len({id(net.backbone), id(net.fusion), id(net.head)}) == 3 ++ ++ net.fusion.eval() ++ net.head.eval() ++ z_feat = torch.ones((1, 3, 8, 8), dtype=torch.float32) ++ x_feat = torch.ones((1, 3, 16, 16), dtype=torch.float32) ++ with torch.no_grad(): ++ fused = net.fusion(z_feat, x_feat) ++ head_out = net.head(fused) ++ ++ assert tuple(fused.shape) == ( ++ 1, ++ cfg.MODEL.FUSION.PARAMS.adj_channel + x_feat.shape[1], ++ x_feat.shape[2], ++ x_feat.shape[3], ++ ) ++ assert isinstance(head_out, Mapping) ++ assert all(torch.is_tensor(value) for value in head_out.values()) ++ ++ ++def test_public_constructor_builds_tinyvit_configured_submodules(): ++ ++ ++ ++ ++ torch.manual_seed(13) ++ ++ net = LightFC(_cfg("tiny_vit_5m_224", inplanes=256, freeze_bn=False), env_num=0, training=False) ++ ++ ++ assert "TinyViT" in type(net.backbone).__name__ ++ assert isinstance(net.backbone, nn.Module) ++ assert isinstance(net.fusion, nn.Module) ++ assert isinstance(net.head, nn.Module) ++ ++ ++def test_training_forward_extracts_template_and_search_then_returns_head_output(): ++ ++ ++ ++ ++ net = _install_recorders(LightFC(_cfg("MobileNetV2", inplanes=192), env_num=0, training=True)) ++ z = torch.full((1, 1, 2, 2), 1.0) ++ x = torch.full((1, 1, 2, 2), 2.0) ++ ++ out = net.forward(z, x) ++ ++ assert net.backbone.calls == [((1, 1, 2, 2), 4.0), ((1, 1, 2, 2), 8.0)] ++ assert net.fusion.calls == [(44.0, 88.0)] ++ assert net.head.calls == [132.0] ++ assert list(out.keys()) == ["marker", "shape"] ++ assert out["marker"].tolist() == [132.0] ++ assert out["shape"] == (1, 1, 2, 2) ++ ++ ++def test_tracking_forward_uses_cached_template_feature_and_forward_delegates_to_tracking(): ++ ++ ++ ++ ++ net = _install_recorders(LightFC(_cfg("MobileNetV2", inplanes=192), env_num=0, training=False)) ++ z = torch.full((1, 1, 2, 2), 1.0) ++ x = torch.full((1, 1, 2, 2), 2.0) ++ ++ z_feat = net.forward_backbone(z) ++ tracking_out = net.forward_tracking(z_feat, x) ++ forward_out = net.forward(z_feat, x) ++ ++ assert float(z_feat.sum()) == 44.0 ++ assert net.backbone.calls == [ ++ ((1, 1, 2, 2), 4.0), ++ ((1, 1, 2, 2), 8.0), ++ ((1, 1, 2, 2), 8.0), ++ ] ++ assert net.fusion.calls == [(44.0, 88.0), (44.0, 128.0)] ++ assert net.head.calls == [132.0, 172.0] ++ assert tracking_out["marker"].tolist() == [132.0] ++ assert forward_out["marker"].tolist() == [172.0] ++ assert tracking_out["shape"] == (1, 1, 2, 2) ++ assert forward_out["shape"] == (1, 1, 2, 2) ++ ++ ++def test_real_tracking_output_shapes_are_the_configured_head_output_shapes(): ++ ++ ++ ++ ++ torch.manual_seed(11) ++ net = LightFC(_cfg("MobileNetV2", inplanes=192), env_num=0, training=False) ++ net.backbone.eval() ++ net.fusion.eval() ++ net.head.eval() ++ z = torch.linspace(-1.0, 1.0, steps=1 * 3 * 128 * 128, dtype=torch.float32).reshape(1, 3, 128, 128) ++ x = torch.linspace(1.0, -1.0, steps=1 * 3 * 256 * 256, dtype=torch.float32).reshape(1, 3, 256, 256) ++ ++ with torch.no_grad(): ++ z_feat = net.forward_backbone(z) ++ out_tracking = net.forward_tracking(z_feat, x) ++ out_forward = net.forward(z_feat, x) ++ ++ expected_tracking = net.head(net.fusion(z_feat, net.backbone(x))) ++ ++ assert torch.is_tensor(z_feat) ++ assert z_feat.ndim == 4 ++ _assert_same_head_output(out_tracking, expected_tracking) ++ _assert_same_head_output(out_forward, expected_tracking) ++ ++ ++def test_forward_tracking_before_cached_feature_raises_specific_runtime_error(): ++ ++ ++ ++ ++ torch.manual_seed(19) ++ net = LightFC(_cfg("MobileNetV2", inplanes=192), env_num=0, training=False) ++ net.backbone.eval() ++ net.fusion.eval() ++ net.head.eval() ++ z = torch.zeros((1, 3, 128, 128), dtype=torch.float32) ++ x = torch.zeros((1, 3, 256, 256), dtype=torch.float32) ++ ++ ++ with pytest.raises(Exception): ++ net.forward_tracking(z, x) ++ ++ ++def test_two_instances_keep_submodule_lifecycle_state_independent(): ++ ++ ++ ++ ++ a = LightFC(_cfg("MobileNetV2", inplanes=192), env_num=0, training=False) ++ b = LightFC(_cfg("MobileNetV2", inplanes=192), env_num=0, training=False) ++ ++ before_b = (b.backbone.training, b.fusion.training, b.head.training) ++ a.backbone.train(not before_b[0]) ++ a.fusion.train(not before_b[1]) ++ a.head.train(not before_b[2]) ++ ++ ++ assert (b.backbone.training, b.fusion.training, b.head.training) == before_b ++ assert (a.backbone.training, a.fusion.training, a.head.training) == tuple(not state for state in before_b) ++ ++ ++def test_object_cleanup_after_use_is_idempotent_under_python_gc(): ++ ++ ++ ++ ++ net = LightFC(_cfg("MobileNetV2", inplanes=192), env_num=0, training=False) ++ children = dict(net.named_children()) ++ ++ ++ assert {"backbone", "fusion", "head"}.issubset(children) ++ assert children["backbone"] is net.backbone ++ assert children["fusion"] is net.fusion ++ assert children["head"] is net.head ++ ++ ++def test_repeated_construct_use_drop_cycles_keep_rss_bounded(): ++ ++ ++ ++ ++ nets = [LightFC(_cfg("MobileNetV2", inplanes=192), env_num=0, training=False) for _ in range(3)] ++ ++ ++ assert len({id(net.backbone) for net in nets}) == len(nets) ++ assert len({id(net.fusion) for net in nets}) == len(nets) ++ assert len({id(net.head) for net in nets}) == len(nets) ++ ++ before_others = [net.backbone.training for net in nets[1:]] ++ nets[0].backbone.train(not before_others[0]) ++ assert [net.backbone.training for net in nets[1:]] == before_others +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,31 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++export PYTHONPATH=/workspace/repo:${PYTHONPATH:-} ++export PIP_NO_INDEX=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export HF_HUB_OFFLINE=1 ++export TRANSFORMERS_OFFLINE=1 ++export WANDB_MODE=offline ++ ++python - <<'PY' ++import importlib.util ++import sys ++ ++missing = [name for name in ("pytest", "timm") if importlib.util.find_spec(name) is None] ++if missing: ++ raise SystemExit(f"Missing offline Python dependencies: {', '.join(missing)}") ++PY ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_lightfc_session.py -v diff --git a/tasks/format-code-task-001803/tests/test.sh b/tasks/format-code-task-001803/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f232ea491c0c2e9b965307b568bc6c827a33f363 --- /dev/null +++ b/tasks/format-code-task-001803/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_lightfc_session.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001803/tests/test_command.sh b/tasks/format-code-task-001803/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001803/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001804/environment/Dockerfile b/tasks/format-code-task-001804/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cd191b19cc2fbb4062a2c667e84f15c7f63ea17b --- /dev/null +++ b/tasks/format-code-task-001804/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:26ce265caa1f4c8a729b742c3caf0d4b176d7a4a0b6110db76fa2d55e62d3106 diff --git a/tasks/format-code-task-001804/environment/setup/files/blocklist b/tasks/format-code-task-001804/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001804/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001804/environment/setup/setup.sh b/tasks/format-code-task-001804/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001804/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001804/tests/test.patch b/tasks/format-code-task-001804/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7c9750d65f3e24e17c31f562b9e714bfae48d54f --- /dev/null +++ b/tasks/format-code-task-001804/tests/test.patch @@ -0,0 +1,133 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..2573f7e4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/unit/distribution/test_library_client_auto_init.py -v"] ++} +diff --git a/tests/unit/distribution/test_library_client_auto_init.py b/tests/unit/distribution/test_library_client_auto_init.py +new file mode 100644 +index 00000000..def7d0b0 +--- /dev/null ++++ b/tests/unit/distribution/test_library_client_auto_init.py +@@ -0,0 +1,105 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import pytest ++ ++import llama_stack.core.library_client as library_client_mod ++from llama_stack.core.library_client import ( ++ AsyncLlamaStackAsLibraryClient, ++ LlamaStackAsLibraryClient, ++) ++ ++ ++@pytest.fixture ++def mock_async_init(monkeypatch): ++ ++ ++ async def fake_init(self): ++ self.impls = {} ++ self.route_impls = {"__sentinel__": True} ++ return True ++ ++ ++ monkeypatch.setattr( ++ library_client_mod.AsyncLlamaStackAsLibraryClient, "initialize", fake_init, raising=False ++ ) ++ ++ ++ monkeypatch.setattr( ++ library_client_mod.AsyncLlamaStackAsLibraryClient, ++ "_do_initialize", ++ fake_init, ++ raising=False, ++ ) ++ return fake_init ++ ++ ++class TestSyncClientAutoInit: ++ ++ ++ def test_route_impls_set_after_construction(self, mock_async_init): ++ ++ ++ ++ ++ ++ client = LlamaStackAsLibraryClient("nvidia") ++ assert client.async_client.route_impls is not None ++ ++ assert client.async_client.route_impls.get("__sentinel__") is True ++ ++ def test_initialize_method_callable_after_construction(self, mock_async_init): ++ ++ client = LlamaStackAsLibraryClient("nvidia") ++ ++ client.initialize() ++ ++ def test_initialize_method_idempotent(self, mock_async_init): ++ ++ client = LlamaStackAsLibraryClient("nvidia") ++ client.initialize() ++ client.initialize() ++ ++ assert client.async_client.route_impls is not None ++ assert client.async_client.route_impls.get("__sentinel__") is True ++ ++ def test_construction_surfaces_init_failure_immediately(self): ++ ++ ++ ++ ++ ++ ++ with pytest.raises(Exception) as exc_info: ++ LlamaStackAsLibraryClient("nvidia") ++ ++ ++ assert "Client not initialized" not in str(exc_info.value) ++ ++ ++class TestAsyncClientUnchanged: ++ ++ ++ def test_async_client_construction_does_not_raise_for_bad_distro(self): ++ ++ ++ ++ ++ ++ ++ ++ ++ client = AsyncLlamaStackAsLibraryClient("nvidia") ++ assert client.route_impls is None +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/unit/distribution/test_library_client_auto_init.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001804/tests/test.sh b/tasks/format-code-task-001804/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..532758563d1d623e9bd38e96c312029b8c92ada9 --- /dev/null +++ b/tasks/format-code-task-001804/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/unit/distribution/test_library_client_auto_init.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001804/tests/test_command.sh b/tasks/format-code-task-001804/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001804/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001832/environment/Dockerfile b/tasks/format-code-task-001832/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7a66ef08948923169c90e795ec7325d6c9ac47d8 --- /dev/null +++ b/tasks/format-code-task-001832/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:595eed403c51ad41933d9ddd1f3a974480e387edde0222b7b5a657edcd80ba44 diff --git a/tasks/format-code-task-001832/environment/setup/files/blocklist b/tasks/format-code-task-001832/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001832/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001832/environment/setup/setup.sh b/tasks/format-code-task-001832/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001832/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001832/tests/test.patch b/tasks/format-code-task-001832/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c4238214bd315d31c997a36dfdc929ea1c96e5ed --- /dev/null +++ b/tasks/format-code-task-001832/tests/test.patch @@ -0,0 +1,299 @@ +diff --git a/usercase-test-coderl/test_rename_acceptance.py b/usercase-test-coderl/test_rename_acceptance.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_rename_acceptance.py +@@ -0,0 +1,273 @@ ++ ++ ++ ++ ++ ++ ++import builtins ++import json ++import pathlib ++import re ++import socket ++import subprocess ++import sys ++import textwrap ++ ++import pandas as pd ++import pytest ++from sqlalchemy import create_engine ++ ++from siuba import _, group_by, rename ++from siuba.sql import LazyTbl ++ ++ ++def _base_df(): ++ return pd.DataFrame({"a": [1], "b": [2], "c": [3]}) ++ ++ ++def _frame_literal(df): ++ return {"columns": list(df.columns), "records": df.to_dict("records")} ++ ++ ++def _group_names(grouped): ++ return [grouping.name for grouping in grouped.grouper.groupings] ++ ++ ++def _lazy_tbl(): ++ return LazyTbl(create_engine("sqlite:///:memory:"), "df", ["a", "b", "c"]) ++ ++ ++def _lazy_literal(tbl): ++ sel = tbl.last_select ++ return { ++ "columns": [getattr(col, "key", None) for col in sel.inner_columns], ++ "group_by": list(tbl.group_by), ++ "sql": str(sel), ++ } ++ ++ ++def _assert_sql_labeled(sql, source, label): ++ ++ label_pattern = rf'(?:["`\[])?{re.escape(label)}(?:["`\]])?' ++ assert re.search(rf"\bdf\.{re.escape(source)}\s+AS\s+{label_pattern}\b", sql, re.IGNORECASE), sql ++ ++ ++def test_pandas_rename_single_expression_target(): ++ ++ ++ ++ ++ actual = rename(_base_df(), A=_.a) ++ ++ assert _frame_literal(actual) == { ++ "columns": ["A", "b", "c"], ++ "records": [{"A": 1, "b": 2, "c": 3}], ++ } ++ ++ ++def test_pandas_rename_single_string_target(): ++ ++ ++ ++ ++ actual = rename(_base_df(), A="a") ++ ++ assert _frame_literal(actual) == { ++ "columns": ["A", "b", "c"], ++ "records": [{"A": 1, "b": 2, "c": 3}], ++ } ++ ++ ++def test_pandas_rename_multiple_expression_targets(): ++ ++ ++ ++ ++ actual = rename(_base_df(), A=_.a, C=_.c) ++ ++ assert _frame_literal(actual) == { ++ "columns": ["A", "b", "C"], ++ "records": [{"A": 1, "b": 2, "C": 3}], ++ } ++ ++ ++def test_pandas_rename_multiple_string_targets(): ++ ++ ++ ++ ++ actual = rename(_base_df(), A="a", C="c") ++ ++ assert _frame_literal(actual) == { ++ "columns": ["A", "b", "C"], ++ "records": [{"A": 1, "b": 2, "C": 3}], ++ } ++ ++ ++def test_grouped_pandas_rename_updates_group_key(): ++ ++ ++ ++ ++ actual = rename(group_by(_base_df(), _.a), z=_.a) ++ ++ assert _frame_literal(actual.obj) == { ++ "columns": ["z", "b", "c"], ++ "records": [{"z": 1, "b": 2, "c": 3}], ++ } ++ assert _group_names(actual) == ["z"] ++ ++ ++def test_sql_lazy_rename_single_expression_target(): ++ ++ ++ ++ ++ actual = rename(_lazy_tbl(), A=_.a) ++ ++ literal = _lazy_literal(actual) ++ ++ assert literal["columns"] == ["A", "b", "c"] ++ assert literal["group_by"] == [] ++ assert "FROM df" in literal["sql"] ++ _assert_sql_labeled(literal["sql"], "a", "A") ++ ++ ++def test_sql_lazy_rename_multiple_string_targets(): ++ ++ ++ ++ ++ actual = rename(_lazy_tbl(), A="a", C="c") ++ ++ literal = _lazy_literal(actual) ++ ++ assert literal["columns"] == ["A", "b", "C"] ++ assert literal["group_by"] == [] ++ assert "FROM df" in literal["sql"] ++ _assert_sql_labeled(literal["sql"], "a", "A") ++ _assert_sql_labeled(literal["sql"], "c", "C") ++ ++ ++def test_grouped_sql_lazy_rename_updates_group_key(): ++ ++ ++ ++ ++ actual = rename(group_by(_lazy_tbl(), _.a), z=_.a) ++ ++ literal = _lazy_literal(actual) ++ ++ assert literal["columns"] == ["z", "b", "c"] ++ assert literal["group_by"] == ["z"] ++ assert "FROM df" in literal["sql"] ++ _assert_sql_labeled(literal["sql"], "a", "z") ++ ++ ++def test_pandas_invalid_non_simple_target_raises_value_error(): ++ ++ ++ ++ ++ ++ with pytest.raises(ValueError): ++ rename(_base_df(), z=_.a + 1) ++ ++ ++def test_sql_invalid_non_simple_target_raises_key_error(): ++ ++ ++ ++ ++ ++ with pytest.raises(KeyError): ++ rename(_lazy_tbl(), z=_.a + 1) ++ ++ ++def test_rename_is_referentially_transparent_for_same_input(): ++ df = _base_df() ++ ++ assert _frame_literal(rename(df, A=_.a, C=_.c)) == _frame_literal(rename(df, A=_.a, C=_.c)) ++ ++ ++def test_rename_does_not_mutate_input_dataframe(): ++ df = _base_df() ++ before = df.copy(deep=True) ++ ++ rename(df, A=_.a, C=_.c) ++ ++ pd.testing.assert_frame_equal(df, before) ++ assert _frame_literal(df) == { ++ "columns": ["a", "b", "c"], ++ "records": [{"a": 1, "b": 2, "c": 3}], ++ } ++ ++ ++def test_rename_matches_fresh_process_result(): ++ in_process = _frame_literal(rename(_base_df(), A=_.a, C=_.c)) ++ script = textwrap.dedent( ++ """ ++ import json ++ import sys ++ sys.path.insert(0, "/workspace/repo") ++ import pandas as pd ++ from siuba import _, rename ++ ++ df = pd.DataFrame({"a": [1], "b": [2], "c": [3]}) ++ out = rename(df, A=_.a, C=_.c) ++ sys.stdout.write(json.dumps({ ++ "columns": list(out.columns), ++ "records": out.to_dict("records"), ++ }, sort_keys=True)) ++ """ ++ ) ++ ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ capture_output=True, ++ text=True, ++ ) ++ ++ assert in_process == json.loads(completed.stdout) ++ assert in_process == { ++ "columns": ["A", "b", "C"], ++ "records": [{"A": 1, "b": 2, "C": 3}], ++ } ++ ++ ++def test_rename_has_no_undeclared_filesystem_or_network_side_effects(tmp_path, monkeypatch): ++ monkeypatch.chdir(tmp_path) ++ ++ opened_paths = [] ++ real_open = builtins.open ++ real_path_open = pathlib.Path.open ++ ++ def recording_open(file, mode="r", *args, **kwargs): ++ opened_paths.append((str(file), mode)) ++ if any(flag in mode for flag in ("w", "a", "x", "+")): ++ raise AssertionError(f"unexpected file write via open({file!r}, {mode!r})") ++ return real_open(file, mode, *args, **kwargs) ++ ++ def recording_path_open(self, mode="r", *args, **kwargs): ++ return recording_open(self, mode, *args, **kwargs) ++ ++ def blocked_socket(*args, **kwargs): ++ raise AssertionError("unexpected network socket creation") ++ ++ monkeypatch.setattr(builtins, "open", recording_open) ++ monkeypatch.setattr(pathlib.Path, "open", recording_path_open) ++ monkeypatch.setattr(socket, "socket", blocked_socket) ++ monkeypatch.setattr(socket, "create_connection", blocked_socket) ++ ++ before = sorted(path.relative_to(tmp_path).as_posix() for path in tmp_path.rglob("*")) ++ actual = rename(_base_df(), A=_.a) ++ after = sorted(path.relative_to(tmp_path).as_posix() for path in tmp_path.rglob("*")) ++ ++ assert _frame_literal(actual) == { ++ "columns": ["A", "b", "c"], ++ "records": [{"A": 1, "b": 2, "c": 3}], ++ } ++ assert before == [] ++ assert after == [] ++ assert opened_paths == [] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_NO_INDEX=1 ++exec python -m pytest -o addopts= -p no:cacheprovider /workspace/repo/usercase-test-coderl/test_rename_acceptance.py -v diff --git a/tasks/format-code-task-001832/tests/test.sh b/tasks/format-code-task-001832/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2d5c39c5c6e4cf3e02fc13e065e640bb8002dd38 --- /dev/null +++ b/tasks/format-code-task-001832/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_rename_acceptance.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001832/tests/test_command.sh b/tasks/format-code-task-001832/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001832/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001835/environment/Dockerfile b/tasks/format-code-task-001835/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e8cb1ad1accce135b2a6fc8cae9eb5050c85ec98 --- /dev/null +++ b/tasks/format-code-task-001835/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9692434848184178bbea52b8996be2113ffb428d780f1a6e88f59d41486c8c7b diff --git a/tasks/format-code-task-001835/environment/setup/files/blocklist b/tasks/format-code-task-001835/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001835/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001835/environment/setup/setup.sh b/tasks/format-code-task-001835/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001835/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001835/tests/test.patch b/tasks/format-code-task-001835/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3d1dcfbab7847deeeb20218bf3a4c7a00b3c04a2 --- /dev/null +++ b/tasks/format-code-task-001835/tests/test.patch @@ -0,0 +1,136 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..533fc60 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_photos.py::PhotoAssetFilenameMissingTests --no-cov -v"] ++} +diff --git a/tests/test_photos.py b/tests/test_photos.py +index b496c02..3fd7bb1 100644 +--- a/tests/test_photos.py ++++ b/tests/test_photos.py +@@ -880,3 +880,109 @@ class PhotoAssetDeletionTests(unittest.TestCase): + # - isDeleted field = 1 + result = self.photo.delete() + assert result is not None ++ ++ ++class PhotoAssetFilenameMissingTests(unittest.TestCase): ++ """Regression tests for missing filenameEnc field (e.g. GoPro videos). ++ ++ The bug report shows that PhotoAsset.filename raised KeyError when the ++ master record did not contain a filenameEnc field, which crashed any ++ code accessing photo.filename or photo.versions. ++ """ ++ ++ def _build_master_record(self, with_filename_enc=True, with_res_original=True): ++ """Construct a synthetic master record for PhotoAsset.""" ++ fields = {} ++ if with_filename_enc: ++ ++ fields["filenameEnc"] = {"value": "SU1HXzEyMzQuSlBH", "type": "ENCRYPTED_BYTES"} ++ if with_res_original: ++ fields["resOriginalRes"] = { ++ "value": {"size": 12345, "downloadURL": "https://example.invalid/x"}, ++ "type": "ASSETID", ++ } ++ fields["resOriginalFileType"] = {"value": "public.jpeg", "type": "STRING"} ++ fields["resOriginalWidth"] = {"value": 100, "type": "INT64"} ++ fields["resOriginalHeight"] = {"value": 200, "type": "INT64"} ++ return { ++ "recordName": "TEST-RECORD-ID", ++ "recordType": "CPLMaster", ++ "fields": fields, ++ } ++ ++ def _build_asset_record(self): ++ return { ++ "recordName": "TEST-ASSET-ID", ++ "recordType": "CPLAsset", ++ "fields": { ++ "assetDate": {"value": 1629754179814, "type": "TIMESTAMP"}, ++ "addedDate": {"value": 1629754179814, "type": "TIMESTAMP"}, ++ }, ++ } ++ ++ def _make_photo(self, with_filename_enc=True, with_res_original=True): ++ from icloudpy.services.photos import PhotoAsset ++ ++ master = self._build_master_record( ++ with_filename_enc=with_filename_enc, ++ with_res_original=with_res_original, ++ ) ++ asset = self._build_asset_record() ++ return PhotoAsset(service=None, master_record=master, asset_record=asset) ++ ++ def test_filename_returns_none_when_filenameenc_missing(self): ++ """When filenameEnc field is absent, filename returns None instead of raising.""" ++ photo = self._make_photo(with_filename_enc=False) ++ ++ assert photo.filename is None ++ ++ def test_filename_access_does_not_raise_when_filenameenc_missing(self): ++ """Accessing filename on a record with missing filenameEnc must not raise.""" ++ photo = self._make_photo(with_filename_enc=False) ++ try: ++ _ = photo.filename ++ except Exception as exc: # noqa: BLE001 ++ self.fail( ++ f"photo.filename should not raise when filenameEnc missing, but raised {type(exc).__name__}: {exc}", ++ ) ++ ++ def test_filename_present_decodes_correctly(self): ++ """Preservation: when filenameEnc is present, filename decodes from base64.""" ++ photo = self._make_photo(with_filename_enc=True) ++ assert photo.filename == "IMG_1234.JPG" ++ ++ def test_versions_does_not_raise_when_filenameenc_missing(self): ++ """photo.versions must not raise when filenameEnc is missing — this is the ++ exact code path the bug report shows crashing in sync. ++ """ ++ photo = self._make_photo(with_filename_enc=False, with_res_original=True) ++ try: ++ versions = photo.versions ++ except Exception as exc: # noqa: BLE001 ++ self.fail( ++ f"photo.versions should not raise when filenameEnc missing, but raised {type(exc).__name__}: {exc}", ++ ) ++ assert isinstance(versions, dict) ++ ++ def test_versions_contains_entries_when_filenameenc_missing(self): ++ """When filenameEnc is missing, versions must still be a dict and must ++ not raise. Either of two shapes is acceptable per the implicit spec: ++ (a) populated entries with filename=None (reference's minimal fix), ++ (b) empty dict (treat photo without filename as having no versions). ++ Both prevent the original KeyError crash from the issue. ++ """ ++ photo = self._make_photo(with_filename_enc=False, with_res_original=True) ++ versions = photo.versions ++ assert isinstance(versions, dict) ++ ++ ++ if "original" in versions: ++ assert versions["original"]["filename"] is None ++ assert versions["original"]["size"] == 12345 ++ ++ def test_versions_with_filename_present_includes_filename(self): ++ """Preservation: when filenameEnc is present, versions include decoded filename.""" ++ photo = self._make_photo(with_filename_enc=True, with_res_original=True) ++ versions = photo.versions ++ assert "original" in versions ++ assert versions["original"]["filename"] == "IMG_1234.JPG" +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest tests/test_photos.py::PhotoAssetFilenameMissingTests --no-cov -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001835/tests/test.sh b/tasks/format-code-task-001835/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ac64299582f3ccd6d491225734ca7f6ecb9241ff --- /dev/null +++ b/tasks/format-code-task-001835/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/test_photos.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001835/tests/test_command.sh b/tasks/format-code-task-001835/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001835/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001858/environment/Dockerfile b/tasks/format-code-task-001858/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c42f9524856e515a1f0456b15c4e1425aa9aa4eb --- /dev/null +++ b/tasks/format-code-task-001858/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0c2f5748154d7bd828b4849190b4b4e5d6166a255efaec3684abcebbd711eb70 diff --git a/tasks/format-code-task-001858/environment/setup/files/blocklist b/tasks/format-code-task-001858/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001858/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001858/environment/setup/setup.sh b/tasks/format-code-task-001858/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001858/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001858/tests/test.patch b/tasks/format-code-task-001858/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..42dada634bee947b1cfd2bc59ad093e40ba3f289 --- /dev/null +++ b/tasks/format-code-task-001858/tests/test.patch @@ -0,0 +1,489 @@ +diff --git a/usercase-test-coderl/plane_stateful.test.js b/usercase-test-coderl/plane_stateful.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/plane_stateful.test.js +@@ -0,0 +1,454 @@ ++import assert from 'node:assert/strict' ++import { test } from 'node:test' ++ ++ ++ ++ ++ ++ ++const observedElements = new Set() ++const listeners = new Map() ++ ++class TestElement { ++ constructor(tagName = 'div') { ++ this.tagName = tagName.toUpperCase() ++ this.children = [] ++ this.parentNode = null ++ this.style = {} ++ this.attributes = {} ++ this.id = '' ++ this.className = '' ++ this.width = 300 ++ this.height = 150 ++ this._rect = { top: 20, left: 10, width: 200, height: 100 } ++ } ++ ++ setAttribute(name, value) { ++ this.attributes[name] = String(value) ++ if (name === 'id') this.id = String(value) ++ if (name === 'class') this.className = String(value) ++ } ++ ++ appendChild(child) { ++ child.parentNode = this ++ this.children.push(child) ++ return child ++ } ++ ++ removeChild(child) { ++ this.children = this.children.filter((entry) => entry !== child) ++ child.parentNode = null ++ return child ++ } ++ ++ getBoundingClientRect() { ++ const { top, left, width, height } = this._rect ++ return { top, left, width, height, right: left + width, bottom: top + height, x: left, y: top } ++ } ++ ++ isSameNode(other) { ++ return this === other ++ } ++ ++ querySelector(selector) { ++ return findIn(this, selector) ++ } ++ ++ querySelectorAll(selector) { ++ const found = [] ++ collectIn(this, selector, found) ++ return found ++ } ++} ++ ++class TestDocument { ++ constructor() { ++ this.body = new TestElement('body') ++ } ++ ++ createElement(tagName) { ++ return new TestElement(tagName) ++ } ++ ++ querySelector(selector) { ++ return this.body.querySelector(selector) ++ } ++ ++ querySelectorAll(selector) { ++ return this.body.querySelectorAll(selector) ++ } ++} ++ ++class TestResizeObserver { ++ observe(element) { ++ observedElements.add(element) ++ } ++ ++ unobserve(element) { ++ observedElements.delete(element) ++ } ++ ++ disconnect() { ++ observedElements.clear() ++ } ++} ++ ++function matches(element, selector) { ++ if (selector.startsWith('#')) return element.id === selector.slice(1) ++ if (selector.startsWith('.')) return String(element.className).split(/\s+/).includes(selector.slice(1)) ++ return element.tagName.toLowerCase() === selector.toLowerCase() ++} ++ ++function findIn(root, selector) { ++ if (matches(root, selector)) return root ++ ++ for (const child of root.children) { ++ const found = findIn(child, selector) ++ if (found) return found ++ } ++ ++ return null ++} ++ ++function collectIn(root, selector, found) { ++ if (matches(root, selector)) found.push(root) ++ for (const child of root.children) collectIn(child, selector, found) ++} ++ ++function installBrowserShim() { ++ observedElements.clear() ++ listeners.clear() ++ ++ globalThis.window = { ++ devicePixelRatio: 2, ++ pageXOffset: 0, ++ pageYOffset: 0, ++ location: { protocol: 'http:' }, ++ ResizeObserver: TestResizeObserver, ++ addEventListener(type) { ++ listeners.set(type, (listeners.get(type) ?? 0) + 1) ++ }, ++ removeEventListener(type) { ++ listeners.set(type, Math.max(0, (listeners.get(type) ?? 0) - 1)) ++ }, ++ } ++ ++ globalThis.document = new TestDocument() ++ globalThis.Element = TestElement ++ globalThis.HTMLElement = TestElement ++ globalThis.HTMLCanvasElement = TestElement ++ globalThis.HTMLImageElement = class HTMLImageElement extends TestElement {} ++ globalThis.HTMLVideoElement = class HTMLVideoElement extends TestElement {} ++ globalThis.HTMLIFrameElement = class HTMLIFrameElement extends TestElement {} ++ globalThis.HTMLCanvasElement = TestElement ++ globalThis.OffscreenCanvas = class OffscreenCanvas {} ++ globalThis.ResizeObserver = TestResizeObserver ++ globalThis.WebGLRenderingContext = { ++ BYTE: 5120, ++ UNSIGNED_BYTE: 5121, ++ SHORT: 5122, ++ UNSIGNED_SHORT: 5123, ++ INT: 5124, ++ UNSIGNED_INT: 5125, ++ FLOAT: 5126, ++ HALF_FLOAT: 5131, ++ ARRAY_BUFFER: 34962, ++ ELEMENT_ARRAY_BUFFER: 34963, ++ } ++ globalThis.navigator = { gpu: undefined } ++ globalThis.requestAnimationFrame = () => 1 ++ globalThis.cancelAnimationFrame = () => {} ++} ++ ++function appendElement(id, rect = { top: 20, left: 10, width: 200, height: 100 }) { ++ const element = document.createElement('div') ++ element.setAttribute('id', id) ++ element._rect = rect ++ document.body.appendChild(element) ++ return element ++} ++ ++function setupDOM() { ++ installBrowserShim() ++ ++ appendElement('canvas', { top: 0, left: 0, width: 800, height: 600 }) ++ appendElement('card', { top: 25, left: 40, width: 320, height: 180 }) ++ appendElement('other', { top: 70, left: 80, width: 120, height: 90 }) ++} ++ ++async function loadPublicAPI() { ++ return import('/workspace/repo/dist/esm/index.mjs') ++} ++ ++function createCurtains(GPUCurtains, container = '#canvas') { ++ return new GPUCurtains({ ++ container, ++ autoRender: false, ++ watchScroll: false, ++ pixelRatio: 1, ++ lights: false, ++ }) ++} ++ ++test('default Plane construction creates a DOM-backed quad with default geometry', async () => { ++ ++ ++ ++ ++ setupDOM() ++ const { GPUCurtains, Plane } = await loadPublicAPI() ++ ++ const gpuCurtains = createCurtains(GPUCurtains) ++ assert.equal(gpuCurtains.renderers.length, 1) ++ assert.equal(gpuCurtains.domMeshes.length, 0) ++ assert.equal(gpuCurtains.planes.length, 0) ++ ++ assert.ok((listeners.get('scroll') ?? 0) >= 0) ++ ++ const plane = new Plane(gpuCurtains, '#card') ++ ++ assert.equal(typeof Plane, 'function') ++ assert.equal(plane.type, 'Plane') ++ ++ assert.equal(gpuCurtains.domMeshes.includes(plane), true) ++ assert.equal(plane.domElement.element.id, 'card') ++ assert.equal(plane.options.label, 'Plane') ++ ++ assert.equal('autoloadSources' in plane, true) ++ assert.equal('watchScroll' in plane, true) ++ ++ assert.equal(Array.isArray(plane.domTextures), true) ++ assert.equal(gpuCurtains.renderer.domMeshes.length, 1) ++ assert.equal(gpuCurtains.domMeshes.length, 1) ++ assert.equal(gpuCurtains.planes.length, 1) ++ assert.equal(plane.geometry.type, 'PlaneGeometry') ++ assert.equal(plane.geometry.definition.width, 1) ++ assert.equal(plane.geometry.definition.height, 1) ++ assert.equal(plane.geometry.instancesCount, 1) ++ assert.equal(plane.geometry.options.vertexBuffers.length, 0) ++ ++ assert.equal(plane.geometry.definition.width * plane.geometry.definition.height, 1) ++ assert.equal(plane.boundingRect.width, 320) ++ assert.equal(plane.boundingRect.height, 180) ++ ++ ++ const rendererPlane = new Plane(gpuCurtains.renderer, '#other') ++ assert.equal(rendererPlane.type, 'Plane') ++ assert.equal(rendererPlane.domElement.element.id, 'other') ++ assert.equal(gpuCurtains.planes.includes(rendererPlane), true) ++}) ++ ++test('Plane parameters derive and cache matching geometry while preserving DOM mesh options', async () => { ++ ++ ++ ++ ++ setupDOM() ++ const { GPUCurtains, Plane } = await loadPublicAPI() ++ ++ const gpuCurtains = createCurtains(GPUCurtains) ++ const other = document.querySelector('#other') ++ const first = new Plane(gpuCurtains, other, { ++ label: 'Custom label', ++ widthSegments: 3, ++ heightSegments: 2, ++ instancesCount: 4, ++ autoloadSources: false, ++ watchScroll: false, ++ }) ++ ++ assert.equal(first.type, 'Plane') ++ assert.equal(first.domElement.element.id, 'other') ++ assert.equal(first.options.label, 'Custom label') ++ assert.equal(first.autoloadSources, false) ++ assert.equal(first.watchScroll, false) ++ assert.equal(gpuCurtains.planes.length, 1) ++ assert.equal(first.geometry.type, 'PlaneGeometry') ++ assert.equal(first.geometry.definition.width, 3) ++ assert.equal(first.geometry.definition.height, 2) ++ ++ assert.equal(first.geometry.definition.width * first.geometry.definition.height, 6) ++ assert.equal(first.geometry.options.vertexBuffers.length, 0) ++ assert.equal(first.geometry.instancesCount, 4) ++ ++ assert.equal(first.geometry.definition.width * first.geometry.definition.height, 6) ++ ++ const second = new Plane(gpuCurtains, '#card', { widthSegments: 3, heightSegments: 2, instancesCount: 7 }) ++ ++ assert.equal(second.geometry === first.geometry, true) ++ assert.equal(first.geometry.instancesCount, 7) ++ assert.equal(second.geometry.instancesCount, 7) ++ assert.equal(gpuCurtains.planes.length, 2) ++ ++ const customPlane = new Plane(gpuCurtains, '#card', { ++ widthSegments: 3, ++ heightSegments: 2, ++ instancesCount: 2, ++ vertexBuffers: [ ++ { ++ name: 'customInstances', ++ stepMode: 'instance', ++ attributes: [ ++ { ++ name: 'customPlaneId', ++ size: 1, ++ type: 'f32', ++ bufferFormat: 'float32', ++ array: new Float32Array([1, 2]), ++ }, ++ ], ++ }, ++ ], ++ }) ++ ++ assert.equal(customPlane.geometry.type, 'PlaneGeometry') ++ assert.equal(customPlane.geometry.definition.width, 3) ++ assert.equal(customPlane.geometry.definition.height, 2) ++ assert.equal(customPlane.geometry.instancesCount, 2) ++ ++ assert.notEqual(customPlane.geometry, first.geometry) ++ assert.ok(customPlane.geometry.getVertexBufferByName('customInstances')) ++ assert.equal(gpuCurtains.planes.length, 3) ++}) ++ ++test('explicit PlaneGeometry is used directly and invalid geometry falls back to derived PlaneGeometry', async () => { ++ ++ ++ ++ ++ setupDOM() ++ const { GPUCurtains, Plane, PlaneGeometry, BoxGeometry } = await loadPublicAPI() ++ ++ const gpuCurtains = createCurtains(GPUCurtains) ++ const explicitGeometry = new PlaneGeometry({ widthSegments: 5, heightSegments: 4, instancesCount: 6 }) ++ const explicitPlane = new Plane(gpuCurtains, '#other', { geometry: explicitGeometry, instancesCount: 9 }) ++ ++ assert.equal(explicitPlane.geometry === explicitGeometry, true) ++ assert.equal(explicitPlane.geometry.definition.width, 5) ++ assert.equal(explicitPlane.geometry.definition.height, 4) ++ assert.equal(explicitPlane.geometry.instancesCount, 6) ++ assert.equal(gpuCurtains.planes.length, 1) ++ ++ const invalidGeometry = new BoxGeometry() ++ const fallbackPlane = new Plane(gpuCurtains, '#other', { ++ geometry: invalidGeometry, ++ heightSegments: 3, ++ instancesCount: 2, ++ }) ++ ++ assert.equal(fallbackPlane.geometry === invalidGeometry, false) ++ assert.equal(fallbackPlane.geometry.type, 'PlaneGeometry') ++ assert.equal(fallbackPlane.geometry.definition.width, 1) ++ assert.equal(fallbackPlane.geometry.definition.height, 3) ++ assert.equal(fallbackPlane.geometry.instancesCount, 2) ++ assert.equal(gpuCurtains.planes.length, 2) ++}) ++ ++test('out-of-order Plane construction before renderer setup fails without pinning message text', async () => { ++ ++ ++ ++ ++ setupDOM() ++ const { GPUCurtains, Plane } = await loadPublicAPI() ++ ++ const unready = new GPUCurtains({ autoRender: false, watchScroll: false, pixelRatio: 1, lights: false }) ++ ++ ++ assert.throws(() => new Plane(unready, '#card'), Error) ++}) ++ ++test('selector lookup failure throws without pinning message text', async () => { ++ ++ ++ ++ ++ setupDOM() ++ const { GPUCurtains, Plane } = await loadPublicAPI() ++ ++ const gpuCurtains = createCurtains(GPUCurtains) ++ ++ ++ assert.throws(() => new Plane(gpuCurtains, '#missing'), Error) ++}) ++ ++test('Plane cleanup updates Plane and DOM mesh collections', async () => { ++ ++ ++ ++ ++ setupDOM() ++ const { GPUCurtains, Plane } = await loadPublicAPI() ++ ++ const gpuCurtains = createCurtains(GPUCurtains) ++ const firstPlane = new Plane(gpuCurtains, '#card') ++ const secondPlane = new Plane(gpuCurtains, '#other') ++ ++ assert.equal(gpuCurtains.planes.length, 2) ++ assert.doesNotThrow(() => firstPlane.remove()) ++ ++ assert.equal(gpuCurtains.planes.includes(firstPlane), false) ++ assert.equal(gpuCurtains.planes.length, 1) ++ assert.equal(gpuCurtains.domMeshes.length, 1) ++ assert.doesNotThrow(() => secondPlane.remove()) ++ ++ assert.equal(gpuCurtains.planes.includes(secondPlane), false) ++ assert.equal(gpuCurtains.planes.length, 0) ++ assert.equal(gpuCurtains.domMeshes.length, 0) ++}) ++ ++test('Plane collections are independent across GPUCurtains instances', async () => { ++ ++ ++ ++ ++ setupDOM() ++ const { GPUCurtains, Plane } = await loadPublicAPI() ++ ++ appendElement('a-canvas', { top: 0, left: 0, width: 400, height: 300 }) ++ appendElement('b-canvas', { top: 0, left: 0, width: 500, height: 350 }) ++ appendElement('a-el', { top: 10, left: 20, width: 100, height: 80 }) ++ appendElement('b-el', { top: 30, left: 40, width: 150, height: 90 }) ++ ++ const a = createCurtains(GPUCurtains, '#a-canvas') ++ const b = createCurtains(GPUCurtains, '#b-canvas') ++ ++ new Plane(a, '#a-el') ++ new Plane(a, '#card') ++ new Plane(b, '#b-el') ++ ++ assert.equal(a.planes.length, 2) ++ assert.equal(a.domMeshes.length, 2) ++ assert.equal(b.planes.length, 1) ++ assert.equal(b.domMeshes.length, 1) ++}) ++ ++test('Plane cleanup keeps resize-observer resource count bounded over repeated cycles', async () => { ++ ++ ++ ++ ++ setupDOM() ++ const { GPUCurtains, Plane } = await loadPublicAPI() ++ ++ const gpuCurtains = createCurtains(GPUCurtains) ++ const observedBaseline = observedElements.size ++ ++ assert.ok(observedBaseline >= 0) ++ ++ for (let index = 0; index < 150; index++) { ++ const id = `cycle-${index}` ++ appendElement(id, { top: index, left: index, width: 20, height: 10 }) ++ const plane = new Plane(gpuCurtains, `#${id}`) ++ ++ assert.equal(plane.type, 'Plane') ++ assert.equal(plane.geometry.definition.width, 1) ++ assert.equal(plane.geometry.definition.height, 1) ++ plane.remove() ++ } ++ ++ assert.equal(gpuCurtains.planes.length, 0) ++ assert.equal(gpuCurtains.domMeshes.length, 0) ++ ++ assert.ok(observedElements.size <= observedBaseline) ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,25 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++if [ ! -x node_modules/.bin/tsc ] || [ ! -x node_modules/.bin/rolldown ]; then ++ echo "Required node_modules binaries are missing; dependencies must be preinstalled before offline test execution." >&2 ++ exit 1 ++fi ++ ++rm -rf dist/types ++node_modules/.bin/tsc ++rm -rf dist/esm ++node_modules/.bin/rolldown -c >/dev/null ++exec node --test /workspace/repo/usercase-test-coderl/plane_stateful.test.js diff --git a/tasks/format-code-task-001858/tests/test.sh b/tasks/format-code-task-001858/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c4ee302bf6afc9a5944d1f7539acd01be63ab903 --- /dev/null +++ b/tasks/format-code-task-001858/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/plane_stateful.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001858/tests/test_command.sh b/tasks/format-code-task-001858/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001858/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001859/environment/setup/files/blocklist b/tasks/format-code-task-001859/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001859/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001860/environment/Dockerfile b/tasks/format-code-task-001860/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e698afe23c0746dada77f03cd00b1655eb18f8b7 --- /dev/null +++ b/tasks/format-code-task-001860/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:be7f6517566b176d947c574ea2ba1bff3df0b14de38a0f996a3eb6f742dda6e8 diff --git a/tasks/format-code-task-001860/environment/setup/files/blocklist b/tasks/format-code-task-001860/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001860/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001860/environment/setup/setup.sh b/tasks/format-code-task-001860/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001860/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001860/tests/test.patch b/tasks/format-code-task-001860/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fab37b0940b6d82286acd7d3d174e3f056491108 --- /dev/null +++ b/tasks/format-code-task-001860/tests/test.patch @@ -0,0 +1,158 @@ +diff --git a/tests/data/events/guest_access.json b/tests/data/events/guest_access.json +new file mode 100644 +index 00000000..5c41021e +--- /dev/null ++++ b/tests/data/events/guest_access.json +@@ -0,0 +1,13 @@ ++{ ++ "content": { ++ "guest_access": "can_join" ++ }, ++ "event_id": "$151957878229oehdx:localhost", ++ "origin_server_ts": 1519578782190, ++ "sender": "@example:localhost", ++ "state_key": "", ++ "type": "m.room.guest_access", ++ "unsigned": { ++ "age": 1392989711 ++ } ++} +diff --git a/tests/data/events/history_visibility.json b/tests/data/events/history_visibility.json +new file mode 100644 +index 00000000..fae3be3b +--- /dev/null ++++ b/tests/data/events/history_visibility.json +@@ -0,0 +1,13 @@ ++{ ++ "content": { ++ "history_visibility": "world_readable" ++ }, ++ "event_id": "$151957878235ricnD:localhost", ++ "origin_server_ts": 1519578782195, ++ "sender": "@example:localhost", ++ "state_key": "", ++ "type": "m.room.history_visibility", ++ "unsigned": { ++ "age": 1392989715 ++ } ++} +diff --git a/tests/data/events/join_rules.json b/tests/data/events/join_rules.json +new file mode 100644 +index 00000000..7c116ae6 +--- /dev/null ++++ b/tests/data/events/join_rules.json +@@ -0,0 +1,13 @@ ++{ ++ "content": { ++ "join_rule": "public" ++ }, ++ "event_id": "$151957878231iejdB:localhost", ++ "origin_server_ts": 1519578782192, ++ "sender": "@example:localhost", ++ "state_key": "", ++ "type": "m.room.join_rules", ++ "unsigned": { ++ "age": 1392989713 ++ } ++} +diff --git a/tests/event_test.py b/tests/event_test.py +index cd9559d9..2d128dd4 100644 +--- a/tests/event_test.py ++++ b/tests/event_test.py +@@ -10,6 +10,9 @@ + UnknownBadEvent, + RedactedEvent, + RoomCreateEvent, ++ RoomGuestAccessEvent, ++ RoomJoinRulesEvent, ++ RoomHistoryVisibilityEvent, + RoomTopicEvent, + RoomNameEvent, + RoomAliasEvent, +@@ -49,6 +52,24 @@ def test_create_event(self): + event = RoomCreateEvent.from_dict(parsed_dict) + assert isinstance(event, RoomCreateEvent) + ++ def test_guest_access_event(self): ++ parsed_dict = TestClass._load_response( ++ "tests/data/events/guest_access.json") ++ event = RoomGuestAccessEvent.from_dict(parsed_dict) ++ assert isinstance(event, RoomGuestAccessEvent) ++ ++ def test_join_rules_event(self): ++ parsed_dict = TestClass._load_response( ++ "tests/data/events/join_rules.json") ++ event = RoomJoinRulesEvent.from_dict(parsed_dict) ++ assert isinstance(event, RoomJoinRulesEvent) ++ ++ def test_history_visibility_event(self): ++ parsed_dict = TestClass._load_response( ++ "tests/data/events/history_visibility.json") ++ event = RoomHistoryVisibilityEvent.from_dict(parsed_dict) ++ assert isinstance(event, RoomHistoryVisibilityEvent) ++ + def test_topic_event(self): + parsed_dict = TestClass._load_response( + "tests/data/events/topic.json") +diff --git a/tests/room_test.py b/tests/room_test.py +index 1fbd449c..bb01cad9 100644 +--- a/tests/room_test.py ++++ b/tests/room_test.py +@@ -7,7 +7,10 @@ + InviteAliasEvent, + InviteMemberEvent, + RoomNameEvent, +- RoomCreateEvent ++ RoomCreateEvent, ++ RoomGuestAccessEvent, ++ RoomHistoryVisibilityEvent, ++ RoomJoinRulesEvent, + ) + + TEST_ROOM = "!test:example.org" +@@ -150,6 +153,23 @@ def test_create_event(self): + assert room.federate is False + assert room.room_version == "1" + ++ def test_guest_access_event(self): ++ room = self.test_room ++ assert room.guest_access == "forbidden" ++ room.handle_event(RoomGuestAccessEvent("event_id", BOB_ID, 0, "can_join")) ++ assert room.guest_access == "can_join" ++ ++ def test_history_visibility_event(self): ++ room = self.test_room ++ assert room.history_visibility == "shared" ++ room.handle_event(RoomHistoryVisibilityEvent("event_id", BOB_ID, 0, "invited")) ++ assert room.history_visibility == "invited" ++ ++ def test_join_rules_event(self): ++ room = self.test_room ++ assert room.join_rule == "invite" ++ room.handle_event(RoomJoinRulesEvent("event_id", BOB_ID, 0, "public")) ++ assert room.join_rule == "public" + + def test_name_event(self): + room = self.test_room +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3R0WrCMBQG4F7nKYI3bUVja43CYK+wFxij1CbTbDYpSXTz7ZfVibqxeaOMsf+D ++0uQk9Jzys/larUQp9WYUXUsWzDjv3sHnd7fO+TgbT4uc81mU5fk0m0WUX22iI2vnK0tpZI3xP907 ++d/5HsUP+Xjpf1qZpKi2YW16ux7n8J7w45D+ehPwn0zzkn11uhO/98/xrQbvg51KQduuXRhd0WNMe ++UU1rrKdPzmhirFooXa3KlamEo7ddlXUbIuQjbStfL6XYHSduQPv955fKLlx6Q2iw27DWtEksdW2E ++0ot4QO+Mlml3wUq/tpqe9jn5EDm0DP1PGpL9rGH+8Cf7nds6Eh4mX5VPdkesqZRO7uP3tRvJjdS+ ++7OrtNozzUQ5BN8fV4SZ+SFPSI78dFQAAAAAAAAAAAAAAAAAAAADAF2/PnpvMACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001860/tests/test.sh b/tasks/format-code-task-001860/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3f6df94bde40d3475dd4b7977769a5fc76a62b68 --- /dev/null +++ b/tasks/format-code-task-001860/tests/test.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/data/events/guest_access.json +tests/data/events/history_visibility.json +tests/data/events/join_rules.json +tests/event_test.py +tests/room_test.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001860/tests/test_command.sh b/tasks/format-code-task-001860/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001860/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001866/environment/Dockerfile b/tasks/format-code-task-001866/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0072c432232db660815bc2782dd5c5ea5be2c86f --- /dev/null +++ b/tasks/format-code-task-001866/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a85dd1ed11ee11e8906d5e7d264ae85d76bbaed2e845d9e9129275d55d068b6c diff --git a/tasks/format-code-task-001866/environment/setup/files/blocklist b/tasks/format-code-task-001866/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001866/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001866/environment/setup/setup.sh b/tasks/format-code-task-001866/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001866/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001866/tests/test.patch b/tasks/format-code-task-001866/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e7a08df95741b77d4a6247843b44859294c96fe3 --- /dev/null +++ b/tasks/format-code-task-001866/tests/test.patch @@ -0,0 +1,480 @@ +diff --git a/app/oauth_test.go b/app/oauth_test.go +index b525c180fb..1b7a70ccf5 100644 +--- a/app/oauth_test.go ++++ b/app/oauth_test.go +@@ -633,3 +633,190 @@ func TestDeactivatedUserOAuthApp(t *testing.T) { + require.Equal(t, http.StatusBadRequest, accErr.StatusCode) + assert.Equal(t, "api.oauth.get_access_token.expired_code.app_error", accErr.Id) + } ++ ++func newOAuthAppForDeauthorizeCleanupTest(t *testing.T, th *TestHelper, creatorID string) *model.OAuthApp { ++ t.Helper() ++ ++ oapp := &model.OAuthApp{ ++ Name: "oauth-deauth-" + model.NewRandomString(10), ++ CreatorId: creatorID, ++ Homepage: "https://example.com", ++ Description: "deauthorization cleanup test", ++ CallbackUrls: []string{"https://example.com/callback"}, ++ } ++ ++ oapp, err := th.App.CreateOAuthApp(oapp) ++ require.Nil(t, err) ++ require.NotEmpty(t, oapp.Id) ++ return oapp ++} ++ ++func authorizeOAuthAppAndReturnCodeForCleanupTest(t *testing.T, th *TestHelper, userID string, oapp *model.OAuthApp) string { ++ t.Helper() ++ ++ authRequest := &model.AuthorizeRequest{ ++ ResponseType: model.AuthCodeResponseType, ++ ClientId: oapp.Id, ++ RedirectURI: oapp.CallbackUrls[0], ++ Scope: "", ++ State: model.NewRandomString(8), ++ } ++ ++ redirectURL, err := th.App.AllowOAuthAppAccessToUser(userID, authRequest) ++ require.Nil(t, err) ++ ++ uri, parseErr := url.Parse(redirectURL) ++ require.NoError(t, parseErr) ++ ++ code := uri.Query().Get("code") ++ require.NotEmpty(t, code) ++ return code ++} ++ ++func exchangeOAuthCodeForCleanupTest(t *testing.T, th *TestHelper, oapp *model.OAuthApp, code string) (*model.AccessResponse, *model.AppError) { ++ t.Helper() ++ ++ return th.App.GetOAuthAccessTokenForCodeFlow(oapp.Id, model.AccessTokenGrantType, oapp.CallbackUrls[0], code, oapp.ClientSecret, "") ++} ++ ++func TestDeauthorizeOAuthApp(t *testing.T) { ++ th := Setup(t).InitBasic() ++ defer th.TearDown() ++ ++ th.App.UpdateConfig(func(cfg *model.Config) { ++ *cfg.ServiceSettings.EnableOAuthServiceProvider = true ++ }) ++ ++ oapp := newOAuthAppForDeauthorizeCleanupTest(t, th, th.BasicUser2.Id) ++ code := authorizeOAuthAppAndReturnCodeForCleanupTest(t, th, th.BasicUser.Id, oapp) ++ ++ dErr := th.App.DeauthorizeOAuthAppForUser(th.BasicUser.Id, oapp.Id) ++ require.Nil(t, dErr) ++ ++ resp, accErr := exchangeOAuthCodeForCleanupTest(t, th, oapp, code) ++ require.Nil(t, resp) ++ require.NotNil(t, accErr) ++} ++ ++func TestDeauthorizeOAuthAppInvalidatesExistingAuthorizationCode(t *testing.T) { ++ th := Setup(t).InitBasic() ++ defer th.TearDown() ++ ++ th.App.UpdateConfig(func(cfg *model.Config) { ++ *cfg.ServiceSettings.EnableOAuthServiceProvider = true ++ }) ++ ++ oapp := newOAuthAppForDeauthorizeCleanupTest(t, th, th.BasicUser2.Id) ++ code := authorizeOAuthAppAndReturnCodeForCleanupTest(t, th, th.BasicUser.Id, oapp) ++ ++ dErr := th.App.DeauthorizeOAuthAppForUser(th.BasicUser.Id, oapp.Id) ++ require.Nil(t, dErr) ++ ++ resp, accErr := exchangeOAuthCodeForCleanupTest(t, th, oapp, code) ++ require.Nil(t, resp) ++ require.NotNil(t, accErr) ++} ++ ++func TestDeauthorizeOAuthAppDoesNotAffectOtherUsersOrApps(t *testing.T) { ++ th := Setup(t).InitBasic() ++ defer th.TearDown() ++ ++ th.App.UpdateConfig(func(cfg *model.Config) { ++ *cfg.ServiceSettings.EnableOAuthServiceProvider = true ++ }) ++ ++ targetApp := newOAuthAppForDeauthorizeCleanupTest(t, th, th.BasicUser2.Id) ++ otherApp := newOAuthAppForDeauthorizeCleanupTest(t, th, th.BasicUser2.Id) ++ ++ targetCode := authorizeOAuthAppAndReturnCodeForCleanupTest(t, th, th.BasicUser.Id, targetApp) ++ otherAppCode := authorizeOAuthAppAndReturnCodeForCleanupTest(t, th, th.BasicUser.Id, otherApp) ++ otherUserCode := authorizeOAuthAppAndReturnCodeForCleanupTest(t, th, th.BasicUser2.Id, targetApp) ++ ++ dErr := th.App.DeauthorizeOAuthAppForUser(th.BasicUser.Id, targetApp.Id) ++ require.Nil(t, dErr) ++ ++ targetResp, targetErr := exchangeOAuthCodeForCleanupTest(t, th, targetApp, targetCode) ++ require.Nil(t, targetResp) ++ require.NotNil(t, targetErr) ++ ++ otherAppResp, otherAppErr := exchangeOAuthCodeForCleanupTest(t, th, otherApp, otherAppCode) ++ require.Nil(t, otherAppErr) ++ require.NotNil(t, otherAppResp) ++ otherAppSession, appSessionErr := th.App.GetSession(otherAppResp.AccessToken) ++ require.Nil(t, appSessionErr) ++ require.NotNil(t, otherAppSession) ++ ++ otherUserResp, otherUserErr := exchangeOAuthCodeForCleanupTest(t, th, targetApp, otherUserCode) ++ require.Nil(t, otherUserErr) ++ require.NotNil(t, otherUserResp) ++ otherUserSession, userSessionErr := th.App.GetSession(otherUserResp.AccessToken) ++ require.Nil(t, userSessionErr) ++ require.NotNil(t, otherUserSession) ++} ++ ++func TestDeauthorizeOAuthAppInvalidatesExistingTokenAndSession(t *testing.T) { ++ th := Setup(t).InitBasic() ++ defer th.TearDown() ++ ++ th.App.UpdateConfig(func(cfg *model.Config) { ++ *cfg.ServiceSettings.EnableOAuthServiceProvider = true ++ }) ++ ++ oapp := newOAuthAppForDeauthorizeCleanupTest(t, th, th.BasicUser2.Id) ++ code := authorizeOAuthAppAndReturnCodeForCleanupTest(t, th, th.BasicUser.Id, oapp) ++ ++ resp, accErr := exchangeOAuthCodeForCleanupTest(t, th, oapp, code) ++ require.Nil(t, accErr) ++ require.NotNil(t, resp) ++ _, sessionErr := th.App.GetSession(resp.AccessToken) ++ require.Nil(t, sessionErr) ++ ++ dErr := th.App.DeauthorizeOAuthAppForUser(th.BasicUser.Id, oapp.Id) ++ require.Nil(t, dErr) ++ ++ session, getSessionErr := th.App.GetSession(resp.AccessToken) ++ require.NotNil(t, getSessionErr) ++ require.Nil(t, session) ++ accessData, getAccessErr := th.App.Srv().Store.OAuth().GetAccessData(resp.AccessToken) ++ require.Error(t, getAccessErr) ++ require.Nil(t, accessData) ++} ++ ++func TestDeauthorizeOAuthAppFailsWhenAuthorizationArtifactInvalidationFails(t *testing.T) { ++ th := Setup(t).InitBasic() ++ defer th.TearDown() ++ ++ th.App.UpdateConfig(func(cfg *model.Config) { ++ *cfg.ServiceSettings.EnableOAuthServiceProvider = true ++ }) ++ ++ oapp := newOAuthAppForDeauthorizeCleanupTest(t, th, th.BasicUser2.Id) ++ _ = authorizeOAuthAppAndReturnCodeForCleanupTest(t, th, th.BasicUser.Id, oapp) ++ ++ sqlStore := mainHelper.GetSQLStore() ++ ++ _, err := sqlStore.GetMasterX().Exec(` ++ CREATE OR REPLACE FUNCTION fixture_fail_oauth_authdata_change() ++ RETURNS trigger AS $$ ++ BEGIN ++ RAISE EXCEPTION 'fixture oauth auth data invalidation failure'; ++ END; ++ $$ LANGUAGE plpgsql; ++ DROP TRIGGER IF EXISTS fixture_fail_oauth_authdata_change ON OAuthAuthData; ++ CREATE TRIGGER fixture_fail_oauth_authdata_change ++ BEFORE UPDATE OR DELETE ON OAuthAuthData ++ FOR EACH ROW EXECUTE FUNCTION fixture_fail_oauth_authdata_change(); ++ `) ++ require.NoError(t, err) ++ defer func() { ++ _, _ = sqlStore.GetMasterX().Exec(` ++ DROP TRIGGER IF EXISTS fixture_fail_oauth_authdata_change ON OAuthAuthData; ++ DROP FUNCTION IF EXISTS fixture_fail_oauth_authdata_change(); ++ `) ++ }() ++ ++ dErr := th.App.DeauthorizeOAuthAppForUser(th.BasicUser.Id, oapp.Id) ++ require.NotNil(t, dErr) ++ ++ require.Equal(t, "Unable to remove oauth data.", dErr.Message) ++} +diff --git a/store/sqlstore/oauth_cleanup_migration_test.go b/store/sqlstore/oauth_cleanup_migration_test.go +new file mode 100644 +index 0000000000..02ec3f2bce +--- /dev/null ++++ b/store/sqlstore/oauth_cleanup_migration_test.go +@@ -0,0 +1,244 @@ ++ ++ ++ ++package sqlstore ++ ++import ( ++ "fmt" ++ "path/filepath" ++ "strconv" ++ "strings" ++ "testing" ++ ++ "github.com/stretchr/testify/require" ++ ++ "github.com/mattermost/mattermost-server/v6/db" ++ "github.com/mattermost/mattermost-server/v6/model" ++ "github.com/mattermost/mattermost-server/v6/store" ++) ++ ++type oauthCleanupFixture struct { ++ UserID string ++ ClientID string ++ Token string ++} ++ ++func seedOAuthAccessDataForCleanupTest(t *testing.T, sqlStore *SqlStore, f oauthCleanupFixture) { ++ t.Helper() ++ ++ _, err := sqlStore.GetMasterX().Exec( ++ `INSERT INTO OAuthAccessData ++ (ClientId, UserId, Token, RefreshToken, RedirectUri, ExpiresAt, Scope) ++ VALUES ++ (?, ?, ?, ?, ?, ?, ?)`, ++ f.ClientID, ++ f.UserID, ++ f.Token, ++ model.NewId(), ++ "https://example.com/callback", ++ model.GetMillis()+3600000, ++ "", ++ ) ++ require.NoError(t, err) ++} ++ ++func seedSessionForCleanupTest(t *testing.T, sqlStore *SqlStore, userID string, token string) { ++ t.Helper() ++ ++ _, err := sqlStore.GetMasterX().Exec( ++ `INSERT INTO Sessions ++ (Id, Token, UserId, CreateAt, ExpiresAt, LastActivityAt, Roles, Props) ++ VALUES ++ (?, ?, ?, ?, ?, ?, ?, ?)`, ++ model.NewId(), ++ token, ++ userID, ++ model.GetMillis(), ++ model.GetMillis()+3600000, ++ model.GetMillis(), ++ "", ++ "{}", ++ ) ++ require.NoError(t, err) ++} ++ ++func seedAuthorizedOAuthAppForCleanupTest(t *testing.T, sqlStore *SqlStore, userID string, clientID string) { ++ t.Helper() ++ ++ _, err := sqlStore.GetMasterX().Exec( ++ `INSERT INTO Preferences ++ (UserId, Category, Name, Value) ++ VALUES ++ (?, ?, ?, ?)`, ++ userID, ++ model.PreferenceCategoryAuthorizedOAuthApp, ++ clientID, ++ "true", ++ ) ++ require.NoError(t, err) ++} ++ ++func resetOAuthCleanupMigrationArtifactsForCleanupTest(t *testing.T, sqlStore *SqlStore) { ++ t.Helper() ++ ++ sqlStore.RemoveTableIfExists("oauth_token_cleanup_backup") ++} ++ ++func latestMigrationForCleanupTest(t *testing.T, sqlStore *SqlStore) (int, string) { ++ t.Helper() ++ ++ assetsList, err := db.Assets().ReadDir(filepath.Join("migrations", sqlStore.DriverName())) ++ require.NoError(t, err) ++ ++ latestVersion := 0 ++ latestName := "" ++ for _, entry := range assetsList { ++ name := entry.Name() ++ if !strings.HasSuffix(name, ".up.sql") { ++ continue ++ } ++ versionString := strings.Split(name, "_")[0] ++ version, err := strconv.Atoi(versionString) ++ require.NoError(t, err) ++ if version > latestVersion { ++ latestVersion = version ++ latestName = name ++ } ++ } ++ ++ require.NotZero(t, latestVersion) ++ require.NotEmpty(t, latestName) ++ return latestVersion, latestName ++} ++ ++func rerunLatestMigrationForOAuthCleanupTest(t *testing.T, sqlStore *SqlStore) { ++ t.Helper() ++ ++ latestVersion, _ := latestMigrationForCleanupTest(t, sqlStore) ++ resetOAuthCleanupMigrationArtifactsForCleanupTest(t, sqlStore) ++ ++ _, err := sqlStore.GetMasterX().Exec("DELETE FROM db_migrations WHERE Version = ?", latestVersion) ++ require.NoError(t, err) ++ ++ require.NoError(t, sqlStore.migrate(migrationsDirectionUp)) ++} ++ ++func runLatestDownMigrationForOAuthCleanupTest(t *testing.T, sqlStore *SqlStore) { ++ t.Helper() ++ ++ _, latestUpName := latestMigrationForCleanupTest(t, sqlStore) ++ latestDownName := strings.TrimSuffix(latestUpName, ".up.sql") + ".down.sql" ++ downSQL, err := db.Assets().ReadFile(filepath.Join("migrations", sqlStore.DriverName(), latestDownName)) ++ require.NoError(t, err) ++ ++ if strings.TrimSpace(string(downSQL)) == "" { ++ return ++ } ++ ++ _, err = sqlStore.GetMasterX().Exec(string(downSQL)) ++ require.NoError(t, err) ++} ++ ++func countRowsForCleanupTest(t *testing.T, sqlStore *SqlStore, table string, column string, value string) int { ++ t.Helper() ++ ++ var count int ++ query := fmt.Sprintf("SELECT COUNT(*) FROM %s WHERE %s = ?", table, column) ++ err := sqlStore.GetReplicaX().Get(&count, query, value) ++ require.NoError(t, err) ++ return count ++} ++ ++func requireOAuthTokenAbsentForCleanupTest(t *testing.T, sqlStore *SqlStore, token string) { ++ t.Helper() ++ require.Equal(t, 0, countRowsForCleanupTest(t, sqlStore, "OAuthAccessData", "Token", token)) ++} ++ ++func requireSessionAbsentForCleanupTest(t *testing.T, sqlStore *SqlStore, token string) { ++ t.Helper() ++ require.Equal(t, 0, countRowsForCleanupTest(t, sqlStore, "Sessions", "Token", token)) ++} ++ ++func requireOAuthTokenPresentForCleanupTest(t *testing.T, sqlStore *SqlStore, token string) { ++ t.Helper() ++ require.Equal(t, 1, countRowsForCleanupTest(t, sqlStore, "OAuthAccessData", "Token", token)) ++} ++ ++func requireSessionPresentForCleanupTest(t *testing.T, sqlStore *SqlStore, token string) { ++ t.Helper() ++ require.Equal(t, 1, countRowsForCleanupTest(t, sqlStore, "Sessions", "Token", token)) ++} ++ ++func TestOAuthUpgradeCleanupRemovesStaleTokensAndSessions(t *testing.T) { ++ StoreTest(t, func(t *testing.T, ss store.Store) { ++ sqlStore := ss.(*SqlStore) ++ stale := oauthCleanupFixture{ ++ UserID: model.NewId(), ++ ClientID: model.NewId(), ++ Token: model.NewId(), ++ } ++ crossUserSameClient := oauthCleanupFixture{ ++ UserID: model.NewId(), ++ ClientID: stale.ClientID, ++ Token: model.NewId(), ++ } ++ authorizedOtherUser := model.NewId() ++ ++ seedOAuthAccessDataForCleanupTest(t, sqlStore, stale) ++ seedSessionForCleanupTest(t, sqlStore, stale.UserID, stale.Token) ++ ++ seedAuthorizedOAuthAppForCleanupTest(t, sqlStore, authorizedOtherUser, stale.ClientID) ++ seedOAuthAccessDataForCleanupTest(t, sqlStore, crossUserSameClient) ++ seedSessionForCleanupTest(t, sqlStore, crossUserSameClient.UserID, crossUserSameClient.Token) ++ ++ rerunLatestMigrationForOAuthCleanupTest(t, sqlStore) ++ ++ requireOAuthTokenAbsentForCleanupTest(t, sqlStore, stale.Token) ++ requireSessionAbsentForCleanupTest(t, sqlStore, stale.Token) ++ requireOAuthTokenAbsentForCleanupTest(t, sqlStore, crossUserSameClient.Token) ++ requireSessionAbsentForCleanupTest(t, sqlStore, crossUserSameClient.Token) ++ }) ++} ++ ++func TestOAuthUpgradeCleanupPreservesAuthorizedTokensAndSessions(t *testing.T) { ++ StoreTest(t, func(t *testing.T, ss store.Store) { ++ sqlStore := ss.(*SqlStore) ++ authorized := oauthCleanupFixture{ ++ UserID: model.NewId(), ++ ClientID: model.NewId(), ++ Token: model.NewId(), ++ } ++ ++ seedAuthorizedOAuthAppForCleanupTest(t, sqlStore, authorized.UserID, authorized.ClientID) ++ seedOAuthAccessDataForCleanupTest(t, sqlStore, authorized) ++ seedSessionForCleanupTest(t, sqlStore, authorized.UserID, authorized.Token) ++ ++ rerunLatestMigrationForOAuthCleanupTest(t, sqlStore) ++ ++ requireOAuthTokenPresentForCleanupTest(t, sqlStore, authorized.Token) ++ requireSessionPresentForCleanupTest(t, sqlStore, authorized.Token) ++ }) ++} ++ ++func TestOAuthCleanupMigrationDownDoesNotRestoreDeletedData(t *testing.T) { ++ StoreTest(t, func(t *testing.T, ss store.Store) { ++ sqlStore := ss.(*SqlStore) ++ stale := oauthCleanupFixture{ ++ UserID: model.NewId(), ++ ClientID: model.NewId(), ++ Token: model.NewId(), ++ } ++ ++ seedOAuthAccessDataForCleanupTest(t, sqlStore, stale) ++ seedSessionForCleanupTest(t, sqlStore, stale.UserID, stale.Token) ++ ++ rerunLatestMigrationForOAuthCleanupTest(t, sqlStore) ++ requireOAuthTokenAbsentForCleanupTest(t, sqlStore, stale.Token) ++ requireSessionAbsentForCleanupTest(t, sqlStore, stale.Token) ++ ++ runLatestDownMigrationForOAuthCleanupTest(t, sqlStore) ++ ++ requireOAuthTokenAbsentForCleanupTest(t, sqlStore, stale.Token) ++ requireSessionAbsentForCleanupTest(t, sqlStore, stale.Token) ++ }) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,30 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++ ++pg_ctlcluster 16 main start 2>/dev/null || true ++pg_isready -q || { echo "PostgreSQL not ready"; exit 1; } ++ ++su - postgres -c "psql -c \"SELECT 1 FROM pg_roles WHERE rolname='mmuser'\" | grep -q 1" 2>/dev/null || \ ++ su - postgres -c "psql -c \"CREATE USER mmuser WITH PASSWORD 'mostest' CREATEDB;\"" 2>/dev/null ++su - postgres -c "psql -c \"SELECT 1 FROM pg_database WHERE datname='mattermost_test'\" | grep -q 1" 2>/dev/null || \ ++ su - postgres -c "psql -c \"CREATE DATABASE mattermost_test OWNER mmuser;\"" 2>/dev/null ++ ++export MM_SQLSETTINGS_DRIVERNAME=postgres ++export IS_CI=true ++ ++ ++case "${1:-}" in ++ base) ++ go test -v -run '^TestDeactivatedUserOAuthApp$' -count=1 -timeout 300s ./app/ ++ ;; ++ new) ++ go test -v -run '^TestDeauthorizeOAuthApp$|^TestDeauthorizeOAuthApp(InvalidatesExistingAuthorizationCode|DoesNotAffectOtherUsersOrApps|InvalidatesExistingTokenAndSession|FailsWhenAuthorizationArtifactInvalidationFails)$' -count=1 -timeout 300s ./app/ ++ go test -v -run '^(TestOAuthUpgradeCleanup(RemovesStaleTokensAndSessions|PreservesAuthorizedTokensAndSessions)|TestOAuthCleanupMigrationDownDoesNotRestoreDeletedData)$' -count=1 -timeout 300s ./store/sqlstore/ ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001866/tests/test.sh b/tasks/format-code-task-001866/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..26fdd68f5b1e5c0bff8b4694aa31b0144576a6fc --- /dev/null +++ b/tasks/format-code-task-001866/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +app/oauth_test.go +store/sqlstore/oauth_cleanup_migration_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001866/tests/test_command.sh b/tasks/format-code-task-001866/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001866/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001869/environment/Dockerfile b/tasks/format-code-task-001869/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..69be48e3bfaa2e90e8fd4919cf426dda4764b22c --- /dev/null +++ b/tasks/format-code-task-001869/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f029615e597eb831168ecaaae667d89451efd4622f170fd86705ecc907d21cf2 diff --git a/tasks/format-code-task-001869/environment/setup/files/blocklist b/tasks/format-code-task-001869/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001869/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001869/environment/setup/setup.sh b/tasks/format-code-task-001869/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001869/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001869/tests/test.patch b/tasks/format-code-task-001869/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e32755a51bf996ddc8b5dca4be701e5626984b7d --- /dev/null +++ b/tasks/format-code-task-001869/tests/test.patch @@ -0,0 +1,90 @@ +diff --git a/test/enumerable.js b/test/enumerable.js +index 317cccf..160fe92 100644 +--- a/test/enumerable.js ++++ b/test/enumerable.js +@@ -481,4 +481,64 @@ describe('enumerable', function () { + }); + }); + ++ var iterationMethods = [ ++ 'map', ++ 'each', ++ 'forEach', ++ 'count', ++ 'any', ++ 'some', ++ 'none', ++ 'every', ++ 'find', ++ 'findLast', ++ 'reject', ++ 'unique', ++ 'filter', ++ 'select', ++ 'max', ++ 'min', ++ 'sum', ++ 'avg', ++ 'mean', ++ 'first', ++ 'last' ++ ]; ++ ++ var reduceMethods = ['reduce', 'reduceRight']; ++ ++ describe('3rd parameter to callback', function(){ ++ iterationMethods.forEach(function(method){ ++ it('passes array for ' + method, function(){ ++ var arr = array([1]); ++ arr[method](function(item, idx, arr_){ ++ assert(arr === arr_); ++ }); ++ }); ++ }); ++ ++ reduceMethods.forEach(function(method){ ++ it('passes array for ' + method, function(){ ++ var arr = array([1]); ++ arr[method](function(curr, item, idx, arr_){ ++ assert(arr === arr_); ++ }, 0); ++ }); ++ }); ++ }); ++ ++ describe('context to callback in iteration methods', function(){ ++ iterationMethods.forEach(function(method){ ++ it('passes context for ' + method, function(){ ++ var arr = array([1]); ++ var context = {} ++ arr[method](function(item, idx, arr_){ ++ assert(this === context); ++ }, context); ++ }); ++ }); ++ }); ++ ++ ++ + }); +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3RS27DIBQFUI+9CjYQMA44s27Fss2T4oqPxSfrL7VUNYrUZpKoanvP5CFA8ODy ++uazWjOQvonmWrjppvdfqtu5jqXvZHzvdyTovpR6GhumndXSlpDxFxpoYQv5u3731X4p/5p8p5XEJ ++zk3e8HR+3B338pdKfuSvTkrV/NUgjw3rHtfC1/55/othe/AzmdZvjq2+/oe1rH8Rhi7CF2tbLnww ++NLpgiqUk+Lx64cJyntjhEGkLMVNkaaOFvZ8kyBdHcZot8dfU/vQDAQAAAAAAAAAAAAAAAAAAAAD+ ++sDd3f0PrACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001869/tests/test.sh b/tasks/format-code-task-001869/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..344c7c865c0a8e2d336e54bde35b27296663fb6d --- /dev/null +++ b/tasks/format-code-task-001869/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/enumerable.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001869/tests/test_command.sh b/tasks/format-code-task-001869/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001869/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001893/environment/Dockerfile b/tasks/format-code-task-001893/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1e9dac00125bf7477a16dbc62e11327dcee3697d --- /dev/null +++ b/tasks/format-code-task-001893/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:09b2e0499d5bb9ba10090b34aa9ab4227894f95045e6fabf286435109395c713 diff --git a/tasks/format-code-task-001893/environment/setup/files/blocklist b/tasks/format-code-task-001893/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001893/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001893/environment/setup/setup.sh b/tasks/format-code-task-001893/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001893/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001893/tests/test.patch b/tasks/format-code-task-001893/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3773c1bbac1f59dc4744ad6ed24ba9b948c7f01b --- /dev/null +++ b/tasks/format-code-task-001893/tests/test.patch @@ -0,0 +1,251 @@ +diff --git a/baremetal/metal3machine_manager_test.go b/baremetal/metal3machine_manager_test.go +index dd7983b2..7f50e1b8 100644 +--- a/baremetal/metal3machine_manager_test.go ++++ b/baremetal/metal3machine_manager_test.go +@@ -33,5 +33,6 @@ import ( + v1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" ++ utiljson "k8s.io/apimachinery/pkg/util/json" + clientfake "k8s.io/client-go/kubernetes/fake" +@@ -638,10 +639,11 @@ var _ = Describe("Metal3Machine manager", func() { + }) + + type testCaseSetPauseAnnotation struct { +- M3Machine *capm3.Metal3Machine +- Host *bmh.BareMetalHost +- ExpectPresent bool +- ExpectError bool ++ M3Machine *capm3.Metal3Machine ++ Host *bmh.BareMetalHost ++ ExpectPausePresent bool ++ ExpectStatusPresent bool ++ ExpectError bool + } + + DescribeTable("Test Set BMH Pause Annotation", +@@ -666,13 +668,24 @@ var _ = Describe("Metal3Machine manager", func() { + &savedHost, + ) + Expect(err).NotTo(HaveOccurred()) +- if tc.ExpectPresent { +- Expect(savedHost.Annotations[bmh.PausedAnnotation]).NotTo(BeNil()) ++ _, pausePresent := savedHost.Annotations[bmh.PausedAnnotation] ++ if tc.ExpectPausePresent { ++ Expect(pausePresent).To(BeTrue()) ++ } else { ++ Expect(pausePresent).To(BeFalse()) ++ } ++ ++ statusAnnotation, statusPresent := savedHost.Annotations[bmh.StatusAnnotation] ++ if tc.ExpectStatusPresent { ++ Expect(statusPresent).To(BeTrue()) ++ var annotatedStatus bmh.BareMetalHostStatus ++ Expect(utiljson.Unmarshal([]byte(statusAnnotation), &annotatedStatus)).To(Succeed()) ++ Expect(annotatedStatus).To(Equal(tc.Host.Status)) + } else { +- Expect(savedHost.Annotations[bmh.PausedAnnotation]).To(BeNil()) ++ Expect(statusPresent).To(BeFalse()) + } + }, +- Entry("Set BMH Pause Annotation, with valid CAPM3 Paused annotations", testCaseSetPauseAnnotation{ ++ Entry("Set BMH Pause Annotation, with valid CAPM3 Paused annotations, already paused", testCaseSetPauseAnnotation{ + Host: &bmh.BareMetalHost{ + ObjectMeta: *bmhObjectMetaWithValidCAPM3PausedAnnotations(), + Spec: bmh.BareMetalHostSpec{ +@@ -686,10 +699,10 @@ var _ = Describe("Metal3Machine manager", func() { + }, + M3Machine: newMetal3Machine("mym3machine", nil, m3mSpec(), nil, + m3mObjectMetaWithValidAnnotations()), +- ExpectPresent: true, +- ExpectError: false, ++ ExpectPausePresent: true, ++ ExpectError: false, + }), +- Entry("Set BMH Pause Annotation, with valid Paused annotations, Empty Key", testCaseSetPauseAnnotation{ ++ Entry("Set BMH Pause Annotation, with valid Paused annotations, Empty Key, already paused", testCaseSetPauseAnnotation{ + Host: &bmh.BareMetalHost{ + ObjectMeta: *bmhObjectMetaWithValidEmptyPausedAnnotations(), + Spec: bmh.BareMetalHostSpec{ +@@ -703,8 +716,8 @@ var _ = Describe("Metal3Machine manager", func() { + }, + M3Machine: newMetal3Machine("mym3machine", nil, m3mSpec(), nil, + m3mObjectMetaWithValidAnnotations()), +- ExpectPresent: true, +- ExpectError: false, ++ ExpectPausePresent: true, ++ ExpectError: false, + }), + Entry("Set BMH Pause Annotation, with no Paused annotations", testCaseSetPauseAnnotation{ + Host: &bmh.BareMetalHost{ +@@ -717,14 +730,124 @@ var _ = Describe("Metal3Machine manager", func() { + APIVersion: capm3.GroupVersion.String(), + }, + }, ++ Status: bmh.BareMetalHostStatus{ ++ OperationalStatus: bmh.OperationalStatusOK, ++ Provisioning: bmh.ProvisionStatus{ ++ State: bmh.StateProvisioned, ++ }, ++ }, + }, + M3Machine: newMetal3Machine("mym3machine", nil, m3mSpec(), nil, + m3mObjectMetaWithValidAnnotations()), +- ExpectPresent: true, +- ExpectError: false, ++ ExpectPausePresent: true, ++ ExpectStatusPresent: true, ++ ExpectError: false, ++ }), ++ Entry("Set BMH Pause Annotation records a different non-empty status", testCaseSetPauseAnnotation{ ++ Host: &bmh.BareMetalHost{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "myhost", ++ Namespace: "myns", ++ OwnerReferences: []metav1.OwnerReference{}, ++ Annotations: map[string]string{ ++ "example.metal3.io/existing": "kept", ++ }, ++ }, ++ Spec: bmh.BareMetalHostSpec{ ++ ConsumerRef: &corev1.ObjectReference{ ++ Name: "mym3machine", ++ Namespace: "myns", ++ Kind: "M3Machine", ++ APIVersion: capm3.GroupVersion.String(), ++ }, ++ }, ++ Status: bmh.BareMetalHostStatus{ ++ OperationalStatus: bmh.OperationalStatusDiscovered, ++ Provisioning: bmh.ProvisionStatus{ ++ State: bmh.StateReady, ++ }, ++ PoweredOn: true, ++ }, ++ }, ++ M3Machine: newMetal3Machine("mym3machine", nil, m3mSpec(), nil, ++ m3mObjectMetaWithValidAnnotations()), ++ ExpectPausePresent: true, ++ ExpectStatusPresent: true, ++ ExpectError: false, ++ }), ++ Entry("Set BMH Pause Annotation records status when annotations are initially nil", testCaseSetPauseAnnotation{ ++ Host: &bmh.BareMetalHost{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "myhost", ++ Namespace: "myns", ++ OwnerReferences: []metav1.OwnerReference{}, ++ }, ++ Spec: bmh.BareMetalHostSpec{ ++ ConsumerRef: &corev1.ObjectReference{ ++ Name: "mym3machine", ++ Namespace: "myns", ++ Kind: "M3Machine", ++ APIVersion: capm3.GroupVersion.String(), ++ }, ++ }, ++ Status: bmh.BareMetalHostStatus{ ++ OperationalStatus: bmh.OperationalStatusOK, ++ Provisioning: bmh.ProvisionStatus{ ++ State: bmh.StateReady, ++ }, ++ PoweredOn: true, ++ }, ++ }, ++ M3Machine: newMetal3Machine("mym3machine", nil, m3mSpec(), nil, ++ m3mObjectMetaWithValidAnnotations()), ++ ExpectPausePresent: true, ++ ExpectStatusPresent: true, ++ ExpectError: false, + }), + ) + ++ It("reports an update error when pause preparation cannot read the host reference", func() { ++ m3Machine := newMetal3Machine("mym3machine", nil, m3mSpec(), nil, ++ &metav1.ObjectMeta{ ++ Name: "mym3machine", ++ Namespace: "myns", ++ Annotations: map[string]string{ ++ HostAnnotation: "too/many/parts", ++ }, ++ }) ++ c := fakeclient.NewFakeClientWithScheme(setupSchemeMm(), m3Machine) ++ machineMgr, err := NewMachineManager(c, nil, nil, nil, m3Machine, klogr.New()) ++ Expect(err).NotTo(HaveOccurred()) ++ ++ err = machineMgr.SetPauseAnnotation(context.TODO()) ++ ++ Expect(err).To(HaveOccurred()) ++ Expect(machineMgr.Metal3Machine.Status.FailureReason).NotTo(BeNil()) ++ Expect(*machineMgr.Metal3Machine.Status.FailureReason).To(Equal(capierrors.UpdateMachineError)) ++ Expect(*machineMgr.Metal3Machine.Status.FailureReason).NotTo(Equal(capierrors.CreateMachineError)) ++ }) ++ ++ It("reports an update error when pause preparation cannot read the host reference with another malformed key", func() { ++ m3Machine := newMetal3Machine("mym3machine", nil, m3mSpec(), nil, ++ &metav1.ObjectMeta{ ++ Name: "mym3machine", ++ Namespace: "myns", ++ Annotations: map[string]string{ ++ HostAnnotation: "bad/reference/value", ++ }, ++ }) ++ c := fakeclient.NewFakeClientWithScheme(setupSchemeMm(), m3Machine) ++ machineMgr, err := NewMachineManager(c, nil, nil, nil, m3Machine, klogr.New()) ++ Expect(err).NotTo(HaveOccurred()) ++ ++ err = machineMgr.SetPauseAnnotation(context.TODO()) ++ ++ Expect(err).To(HaveOccurred()) ++ Expect(machineMgr.Metal3Machine.Status.FailureReason).NotTo(BeNil()) ++ Expect(*machineMgr.Metal3Machine.Status.FailureReason).To(Equal(capierrors.UpdateMachineError)) ++ Expect(*machineMgr.Metal3Machine.Status.FailureReason).NotTo(Equal(capierrors.CreateMachineError)) ++ }) ++ + type testCaseRemovePauseAnnotation struct { + Cluster *capi.Cluster + M3Machine *capm3.Metal3Machine +@@ -3202,9 +3325,9 @@ var _ = Describe("Metal3Machine manager", func() { + ) + }) + +-//----------------- ++ + // Helper functions +-//----------------- ++ + func setupSchemeMm() *runtime.Scheme { + s := runtime.NewScheme() + if err := capm3.AddToScheme(s); err != nil { +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,26 @@ ++#!/bin/bash ++set -euo pipefail ++ ++cd /testbed ++ ++ ++if [ ! -f /usr/local/kubebuilder/bin/etcd ]; then ++ echo "ERROR: kubebuilder test assets not found at /usr/local/kubebuilder/bin/" ++ echo "Run: setup-envtest use 1.23.5 --bin-dir /usr/local/kubebuilder/bin" ++ exit 1 ++fi ++ ++NEW_SPECS='Test Set BMH Pause Annotation|reports an update error when pause preparation cannot read the host reference' ++ ++case "${1:-}" in ++ base) ++ go test ./baremetal/ -v -count=1 -timeout 300s -args -ginkgo.skip="$NEW_SPECS" ++ ;; ++ new) ++ go test ./baremetal/ -v -count=1 -timeout 300s -args -ginkgo.focus="$NEW_SPECS" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001893/tests/test.sh b/tasks/format-code-task-001893/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2417d78ea9563ae572ab01f6a639c89d09c03278 --- /dev/null +++ b/tasks/format-code-task-001893/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +baremetal/metal3machine_manager_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001893/tests/test_command.sh b/tasks/format-code-task-001893/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001893/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-001894/environment/Dockerfile b/tasks/format-code-task-001894/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..21080e614c9a1a171288fb298fe3974ef1202c75 --- /dev/null +++ b/tasks/format-code-task-001894/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2477e87acfd4b93992e4688fc43ba32b60d8c5f0f9178dcac13a92d0e7fc5959 diff --git a/tasks/format-code-task-001894/environment/setup/files/blocklist b/tasks/format-code-task-001894/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001894/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001894/environment/setup/setup.sh b/tasks/format-code-task-001894/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001894/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001894/tests/test.patch b/tasks/format-code-task-001894/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6cfb33ccef9a87fa7c64b5755a125f361877ab52 --- /dev/null +++ b/tasks/format-code-task-001894/tests/test.patch @@ -0,0 +1,208 @@ +diff --git a/controller/controller_test.go b/controller/controller_test.go +index 17abb163..42bb0805 100644 +--- a/controller/controller_test.go ++++ b/controller/controller_test.go +@@ -883,3 +883,181 @@ func TestControllerDualStackConfig(t *testing.T) { + t.Fatalf("SetConfig that deletes the config was accepted") + } + } ++ ++func TestControllerLoadBalancerIPsAnnotation(t *testing.T) { ++ cfg := &config.Config{ ++ Pools: map[string]*config.Pool{ ++ "pool-dual": { ++ Protocol: config.BGP, ++ AutoAssign: true, ++ CIDR: []*net.IPNet{ipnet("1.2.3.0/31"), ipnet("1000::/127")}, ++ }, ++ }, ++ } ++ ++ type tc struct { ++ name string ++ svc *v1.Service ++ wantIPs []string ++ wantErr bool ++ } ++ ++ tests := []tc{ ++ { ++ name: "annotation single ipv4", ++ svc: &v1.Service{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Annotations: map[string]string{ ++ "metallb.universe.tf/loadBalancerIPs": "1.2.3.1", ++ }, ++ }, ++ Spec: v1.ServiceSpec{ ++ Type: "LoadBalancer", ++ ClusterIPs: []string{"1.2.3.4"}, ++ }, ++ }, ++ wantIPs: []string{"1.2.3.1"}, ++ }, ++ { ++ name: "annotation single ipv6", ++ svc: &v1.Service{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Annotations: map[string]string{ ++ "metallb.universe.tf/loadBalancerIPs": "1000::", ++ }, ++ }, ++ Spec: v1.ServiceSpec{ ++ Type: "LoadBalancer", ++ ClusterIPs: []string{"3000::1"}, ++ }, ++ }, ++ wantIPs: []string{"1000::"}, ++ }, ++ { ++ name: "annotation dual-stack v4 v6", ++ svc: &v1.Service{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Annotations: map[string]string{ ++ "metallb.universe.tf/loadBalancerIPs": "1.2.3.1,1000::", ++ }, ++ }, ++ Spec: v1.ServiceSpec{ ++ Type: "LoadBalancer", ++ ClusterIPs: []string{"1.2.3.4", "3000::1"}, ++ }, ++ }, ++ wantIPs: []string{"1.2.3.1", "1000::"}, ++ }, ++ { ++ name: "annotation dual-stack with whitespace", ++ svc: &v1.Service{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Annotations: map[string]string{ ++ "metallb.universe.tf/loadBalancerIPs": "1.2.3.1, 1000::", ++ }, ++ }, ++ Spec: v1.ServiceSpec{ ++ Type: "LoadBalancer", ++ ClusterIPs: []string{"1.2.3.4", "3000::1"}, ++ }, ++ }, ++ wantIPs: []string{"1.2.3.1", "1000::"}, ++ }, ++ { ++ name: "annotation invalid IP", ++ svc: &v1.Service{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Annotations: map[string]string{ ++ "metallb.universe.tf/loadBalancerIPs": "not-an-ip", ++ }, ++ }, ++ Spec: v1.ServiceSpec{ ++ Type: "LoadBalancer", ++ ClusterIPs: []string{"1.2.3.4"}, ++ }, ++ }, ++ wantErr: true, ++ }, ++ { ++ name: "annotation IP family mismatch", ++ svc: &v1.Service{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Annotations: map[string]string{ ++ "metallb.universe.tf/loadBalancerIPs": "1.2.3.1", ++ }, ++ }, ++ Spec: v1.ServiceSpec{ ++ Type: "LoadBalancer", ++ ClusterIPs: []string{"3000::1"}, ++ }, ++ }, ++ wantErr: true, ++ }, ++ { ++ name: "spec.LoadBalancerIP preserved without annotation", ++ svc: &v1.Service{ ++ Spec: v1.ServiceSpec{ ++ Type: "LoadBalancer", ++ LoadBalancerIP: "1.2.3.1", ++ ClusterIPs: []string{"1.2.3.4"}, ++ }, ++ }, ++ wantIPs: []string{"1.2.3.1"}, ++ }, ++ { ++ name: "empty annotation falls back to auto-allocation", ++ svc: &v1.Service{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Annotations: map[string]string{ ++ "metallb.universe.tf/loadBalancerIPs": "", ++ }, ++ }, ++ Spec: v1.ServiceSpec{ ++ Type: "LoadBalancer", ++ ClusterIPs: []string{"1.2.3.4"}, ++ }, ++ }, ++ wantIPs: []string{"1.2.3.0"}, ++ }, ++ } ++ ++ l := log.NewNopLogger() ++ ++ for _, test := range tests { ++ t.Run(test.name, func(t *testing.T) { ++ k := &testK8S{t: t} ++ c := &controller{ ++ ips: allocator.New(), ++ client: k, ++ } ++ if c.SetConfig(l, cfg) == k8s.SyncStateError { ++ t.Fatalf("SetConfig failed") ++ } ++ c.MarkSynced(l) ++ ++ if c.SetBalancer(l, "test", test.svc, k8s.EpsOrSlices{}) == k8s.SyncStateError { ++ t.Fatalf("SetBalancer returned SyncStateError") ++ } ++ ++ if test.wantErr != k.loggedWarning { ++ t.Fatalf("loggedWarning got %v, want %v", k.loggedWarning, test.wantErr) ++ } ++ ++ if test.wantErr { ++ return ++ } ++ ++ got := k.gotService(test.svc) ++ if got == nil { ++ t.Fatalf("expected service to be mutated, but no mutation recorded") ++ } ++ var gotIPs []string ++ for _, ing := range got.Status.LoadBalancer.Ingress { ++ gotIPs = append(gotIPs, ing.IP) ++ } ++ if diff := cmp.Diff(test.wantIPs, gotIPs); diff != "" { ++ t.Errorf("status IPs mismatch (-want +got):\n%s", diff) ++ } ++ }) ++ } ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..f4728156 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./controller/ -run TestControllerLoadBalancerIPsAnnotation -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test ./controller/ -run TestControllerLoadBalancerIPsAnnotation -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001894/tests/test.sh b/tasks/format-code-task-001894/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9df9a46183086572280a79e1574e0da23227a664 --- /dev/null +++ b/tasks/format-code-task-001894/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +controller/controller_test.go +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001894/tests/test_command.sh b/tasks/format-code-task-001894/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001894/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002016/environment/Dockerfile b/tasks/format-code-task-002016/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6d79716685f3405d12a67c7d6906f8c2731c694b --- /dev/null +++ b/tasks/format-code-task-002016/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1ef94c7656e6c68c68bdd0fe11d15149051da048ad4f3f6fbf811e08b51cc673 diff --git a/tasks/format-code-task-002016/environment/setup/files/blocklist b/tasks/format-code-task-002016/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002016/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002016/environment/setup/setup.sh b/tasks/format-code-task-002016/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002016/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002016/tests/test.patch b/tasks/format-code-task-002016/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e03461214563620854efe8871811e8a2da45e7ef --- /dev/null +++ b/tasks/format-code-task-002016/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py b/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py +index fd7aa325..50c73b14 100644 +--- a/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py ++++ b/napari/_qt/layer_controls/_tests/test_qt_labels_layer.py +@@ -102,3 +102,9 @@ def test_preserve_labels_checkbox(make_labels_controls): + assert not layer.preserve_labels + qtctrl.preserveLabelsCheckBox.setChecked(True) + assert layer.preserve_labels ++ ++ ++def test_contour_spinbox_minimum_is_zero(make_labels_controls): ++ """The contour spinbox must not allow negative values to be selected.""" ++ layer, qtctrl = make_labels_controls() ++ assert qtctrl.contourSpinBox.minimum() == 0 +diff --git a/napari/layers/labels/_tests/test_labels.py b/napari/layers/labels/_tests/test_labels.py +index 5e2b5762..7938db97 100644 +--- a/napari/layers/labels/_tests/test_labels.py ++++ b/napari/layers/labels/_tests/test_labels.py +@@ -1585,3 +1585,44 @@ class TestLabels: + obj, + {"seed", "num_colors", "show_selected_label", "color"}, + ) ++ ++ ++def test_contour_negative_raises_value_error(): ++ """Setting contour to a negative value must raise ValueError. ++ ++ See https://github.com/napari/napari/issues/... -- values < 0 ++ used to behave like 0 (whole label filled in). ++ """ ++ layer = Labels(np.zeros((5, 5), dtype=np.int32)) ++ with pytest.raises(ValueError): ++ layer.contour = -1 ++ ++ ++def test_contour_negative_large_raises_value_error(): ++ """A large negative contour value still raises ValueError.""" ++ layer = Labels(np.zeros((5, 5), dtype=np.int32)) ++ with pytest.raises(ValueError): ++ layer.contour = -100 ++ ++ ++def test_contour_negative_preserves_previous_value(): ++ """A failed negative assignment must not clobber the previous contour value.""" ++ layer = Labels(np.zeros((5, 5), dtype=np.int32)) ++ layer.contour = 3 ++ with pytest.raises(ValueError): ++ layer.contour = -1 ++ assert layer.contour == 3 ++ ++ ++def test_contour_zero_allowed(): ++ """Setting contour to 0 is the documented default and must not raise.""" ++ layer = Labels(np.zeros((5, 5), dtype=np.int32)) ++ layer.contour = 0 ++ assert layer.contour == 0 ++ ++ ++def test_contour_positive_allowed(): ++ """Setting contour to a positive integer must not raise.""" ++ layer = Labels(np.zeros((5, 5), dtype=np.int32)) ++ layer.contour = 5 ++ assert layer.contour == 5 +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..f5279927 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,5 @@ ++{ ++ "test_commands": [ ++ "QT_QPA_PLATFORM=offscreen python -m pytest napari/layers/labels/_tests/test_labels.py::test_contour_negative_raises_value_error napari/layers/labels/_tests/test_labels.py::test_contour_negative_large_raises_value_error napari/layers/labels/_tests/test_labels.py::test_contour_negative_preserves_previous_value napari/layers/labels/_tests/test_labels.py::test_contour_zero_allowed napari/layers/labels/_tests/test_labels.py::test_contour_positive_allowed napari/_qt/layer_controls/_tests/test_qt_labels_layer.py::test_contour_spinbox_minimum_is_zero -v" ++ ] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++QT_QPA_PLATFORM=offscreen python -m pytest napari/layers/labels/_tests/test_labels.py::test_contour_negative_raises_value_error napari/layers/labels/_tests/test_labels.py::test_contour_negative_large_raises_value_error napari/layers/labels/_tests/test_labels.py::test_contour_negative_preserves_previous_value napari/layers/labels/_tests/test_labels.py::test_contour_zero_allowed napari/layers/labels/_tests/test_labels.py::test_contour_positive_allowed napari/_qt/layer_controls/_tests/test_qt_labels_layer.py::test_contour_spinbox_minimum_is_zero -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002016/tests/test.sh b/tasks/format-code-task-002016/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..daa3e49b5d1a17cff3077cd5ebb8d5d3709cbda8 --- /dev/null +++ b/tasks/format-code-task-002016/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +napari/_qt/layer_controls/_tests/test_qt_labels_layer.py +napari/layers/labels/_tests/test_labels.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002016/tests/test_command.sh b/tasks/format-code-task-002016/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002016/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002018/environment/Dockerfile b/tasks/format-code-task-002018/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..89a829ed624b753bb9e028571ce6c7ca36d6c5a7 --- /dev/null +++ b/tasks/format-code-task-002018/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2af043bdc3ba36570c959147ae84bfe33dc6b8dc98a076861a0f6e2b4032e8f2 diff --git a/tasks/format-code-task-002018/environment/setup/files/blocklist b/tasks/format-code-task-002018/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002018/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002018/environment/setup/setup.sh b/tasks/format-code-task-002018/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002018/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002018/tests/test.patch b/tasks/format-code-task-002018/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bf6a57fd456d5e5afb011204d5602e17712a521a --- /dev/null +++ b/tasks/format-code-task-002018/tests/test.patch @@ -0,0 +1,416 @@ +diff --git a/serverless/src/generateGibsTags/__tests__/getSupportedGibsLayers.test.js b/serverless/src/generateGibsTags/__tests__/getSupportedGibsLayers.test.js +index 487338d88..7cdac69a9 100644 +--- a/serverless/src/generateGibsTags/__tests__/getSupportedGibsLayers.test.js ++++ b/serverless/src/generateGibsTags/__tests__/getSupportedGibsLayers.test.js +@@ -3,13 +3,37 @@ import nock from 'nock' + import { gibsResponse, capabilitiesResponse } from './mocks' + import { getSupportedGibsLayers } from '../getSupportedGibsLayers' + +-beforeEach(() => { +- jest.clearAllMocks() ++const buildSupportedLayer = (id, conceptId) => ({ ++ id, ++ type: 'wmts', ++ format: 'image/png', ++ startDate: '2002-06-01T00:00:00Z', ++ projections: { ++ geographic: { ++ source: 'GIBS:geographic', ++ matrixSet: '2km' ++ } ++ }, ++ conceptIds: [ ++ { ++ value: conceptId ++ } ++ ], ++ title: id, ++ subtitle: 'Hidden test fixture', ++ group: 'overlays', ++ daynight: ['day'] ++}) + ++const mockWorldviewProducts = (layers) => { + nock(/worldview/) + .get(/wv\.json/) +- .reply(200, gibsResponse) ++ .reply(200, { ++ layers ++ }) ++} + ++const mockGibsCapabilities = () => { + nock(/gibs\.earthdata/) + .get(/epsg4326\/best\/wmts.cgi/) + .reply(200, capabilitiesResponse) +@@ -21,21 +45,100 @@ beforeEach(() => { + nock(/gibs\.earthdata/) + .get(/epsg3031\/best\/wmts.cgi/) + .reply(200, capabilitiesResponse) ++} ++ ++const buildSupportedLayers = (layerIds) => ( ++ layerIds.reduce((layers, layerId) => ({ ++ ...layers, ++ [layerId]: buildSupportedLayer(layerId, `C-${layerId}`) ++ }), {}) ++) ++ ++beforeEach(() => { ++ jest.clearAllMocks() ++ ++ nock.cleanAll() ++ mockGibsCapabilities() ++}) ++ ++afterEach(() => { ++ nock.cleanAll() + }) + + describe('getSupportedGibsLayers', () => { + test('correctly excludes layers with faulty projections', async () => { ++ mockWorldviewProducts(gibsResponse.layers) ++ + const response = await getSupportedGibsLayers() + + expect(Object.keys(response)).not.toContain('ExcludedProjection_Value') + expect(Object.keys(response)).not.toContain('MissingProjection_Value') + }) + +- test('with custom gibs layers merged', async () => { ++ test('returns_layers_from_the_current_upstream_response_only', async () => { ++ const firstUpstreamLayerIds = [ ++ 'Upstream_Surface_Temperature_Daily', ++ 'MOPITT_CO_Currently_Supported_By_Upstream' ++ ] ++ ++ mockWorldviewProducts(buildSupportedLayers(firstUpstreamLayerIds)) ++ ++ const firstResponse = await getSupportedGibsLayers() ++ const firstLayerKeys = Object.keys(firstResponse) ++ ++ expect(firstLayerKeys.sort()).toEqual(firstUpstreamLayerIds.sort()) ++ ++ const secondUpstreamLayerIds = [ ++ 'Upstream_Aerosol_Index_Monthly' ++ ] ++ ++ mockWorldviewProducts(buildSupportedLayers(secondUpstreamLayerIds)) ++ ++ const secondResponse = await getSupportedGibsLayers() ++ const secondLayerKeys = Object.keys(secondResponse) ++ ++ expect(secondLayerKeys.sort()).toEqual(secondUpstreamLayerIds.sort()) ++ }) ++ ++ test('returns_layers_from_larger_upstream_responses_without_static_overlay', async () => { ++ const upstreamLayerIds = [ ++ 'Upstream_Surface_Temperature_Daily', ++ 'Upstream_Aerosol_Index_Monthly', ++ 'Upstream_Sea_Ice_Daily', ++ 'Upstream_Cloud_Fraction_Monthly' ++ ] ++ ++ mockWorldviewProducts(buildSupportedLayers(upstreamLayerIds)) ++ + const response = await getSupportedGibsLayers() ++ const layerKeys = Object.keys(response) ++ ++ expect(layerKeys.sort()).toEqual(upstreamLayerIds.sort()) ++ }) ++ ++ test('returns_layers_from_upstream_response_outside_jest_environment', async () => { ++ const originalNodeEnv = process.env.NODE_ENV ++ const upstreamLayerIds = [ ++ 'Production_Surface_Temperature_Daily', ++ 'Production_Aerosol_Index_Monthly' ++ ] ++ ++ try { ++ jest.resetModules() ++ process.env.NODE_ENV = 'production' ++ nock.cleanAll() ++ mockGibsCapabilities() ++ mockWorldviewProducts(buildSupportedLayers(upstreamLayerIds)) ++ ++ const { getSupportedGibsLayers: productionGetSupportedGibsLayers } = require('../getSupportedGibsLayers') ++ const response = await productionGetSupportedGibsLayers() ++ const layerKeys = Object.keys(response) + +- expect(Object.keys(response)).toContain('AMSRE_Surface_Rain_Rate_Night') +- expect(Object.keys(response)).toContain('MOPITT_CO_Monthly_Total_Column_Day') +- expect(Object.keys(response).length).toEqual(51) ++ expect(layerKeys.sort()).toEqual(upstreamLayerIds.sort()) ++ } finally { ++ process.env.NODE_ENV = originalNodeEnv ++ jest.resetModules() ++ nock.cleanAll() ++ } + }) + }) +diff --git a/serverless/src/generateGibsTags/__tests__/handler.test.js b/serverless/src/generateGibsTags/__tests__/handler.test.js +index ac87f96e1..85fb63db5 100644 +--- a/serverless/src/generateGibsTags/__tests__/handler.test.js ++++ b/serverless/src/generateGibsTags/__tests__/handler.test.js +@@ -28,6 +28,37 @@ AWS.SQS = jest.fn() + sendMessage: sqsSendMessagePromise + })) + ++const parseSqsBodies = () => ( ++ sqsSendMessagePromise.mock.calls.map(([message]) => JSON.parse(message.MessageBody)) ++) ++ ++const addConceptIdsFromMessages = (messages) => ( ++ new Set(messages ++ .filter((message) => message.action === 'ADD') ++ .map((message) => message.tagData['concept-id'])) ++) ++ ++const removeKeepConceptIdsFromMessages = (messages) => { ++ const removeMessage = messages.find((message) => message.action === 'REMOVE') ++ const keepConditions = removeMessage.searchCriteria.condition.and ++ .find((condition) => condition.not) ++ .not ++ .or ++ ++ return new Set(keepConditions.map((condition) => condition.concept_id)) ++} ++ ++const expectSetToEqual = (actualSet, expectedValues) => { ++ expect([...actualSet].sort()).toEqual([...expectedValues].sort()) ++} ++ ++const supportedConceptIdsFromWorldview = (worldviewResponse) => ( ++ new Set(Object.values(worldviewResponse.layers) ++ .flatMap((layer) => ( ++ (layer.conceptIds || []).map(({ value }) => value) ++ ))) ++) ++ + beforeEach(() => { + jest.clearAllMocks() + +@@ -53,7 +84,7 @@ afterEach(() => { + }) + + describe('generateGibsTags', () => { +- test('correctly generates and queues tag data including custom products', async () => { ++ test('sends_tags_only_for_upstream_supported_concepts', async () => { + process.env.tagQueueUrl = 'http://example.com/tagQueue' + + nock(/worldview/) +@@ -62,172 +93,14 @@ describe('generateGibsTags', () => { + + await generateGibsTags({}, {}) + +- // 14 ADD calls for the unique concept ids and 1 DELETE call +- expect(sqsSendMessagePromise.mock.calls.length).toEqual(15) +- +- expect(sqsSendMessagePromise.mock.calls[0]).toEqual([{ +- QueueUrl: 'http://example.com/tagQueue', +- MessageBody: JSON.stringify({ +- tagName: 'edsc.extra.serverless.gibs', +- action: 'ADD', +- requireGranules: false, +- tagData: { +- 'concept-id': 'C1000000001-EDSC', +- data: [ +- { +- match: { +- time_start: '>=2002-06-01T00:00:00Z', +- time_end: '<=2011-10-04T00:00:00Z', +- day_night_flag: 'night' +- }, +- product: 'AMSRE_Surface_Rain_Rate_Night', +- group: 'overlays', +- title: 'Surface Rain Rate (Night)', +- source: 'Aqua / AMSR-E', +- format: 'png', +- updated_at: '1988-09-03T10:00:00.000Z', +- antarctic: false, +- antarctic_resolution: null, +- arctic: false, +- arctic_resolution: null, +- geographic: true, +- geographic_resolution: '2km' +- } +- ] +- } +- }) +- }]) +- +- expect(sqsSendMessagePromise.mock.calls[1]).toEqual([{ +- QueueUrl: 'http://example.com/tagQueue', +- MessageBody: JSON.stringify({ +- tagName: 'edsc.extra.serverless.gibs', +- action: 'ADD', +- requireGranules: false, +- tagData: { +- 'concept-id': 'C1000000002-EDSC', +- data: [ +- { +- match: { +- time_start: '>=2002-08-30T00:00:00Z', +- day_night_flag: 'day' +- }, +- product: 'AIRS_L2_Methane_400hPa_Volume_Mixing_Ratio_Day', +- group: 'overlays', +- title: 'Methane (L2, 400 hPa, Day)', +- source: 'Aqua / AIRS', +- format: 'png', +- updated_at: '1988-09-03T10:00:00.000Z', +- antarctic: false, +- antarctic_resolution: null, +- arctic: false, +- arctic_resolution: null, +- geographic: true, +- geographic_resolution: '2km' +- } +- ] +- } +- }) +- }]) +- +- expect(sqsSendMessagePromise.mock.calls[2]).toEqual([{ +- QueueUrl: 'http://example.com/tagQueue', +- MessageBody: JSON.stringify({ +- tagName: 'edsc.extra.serverless.gibs', +- action: 'ADD', +- requireGranules: false, +- tagData: { +- 'concept-id': 'C1000000003-EDSC', +- data: [ +- { +- match: { +- time_start: '>=2002-08-30T00:00:00Z', +- day_night_flag: 'day' +- }, +- product: 'AIRS_L2_Methane_400hPa_Volume_Mixing_Ratio_Day', +- group: 'overlays', +- title: 'Methane (L2, 400 hPa, Day)', +- source: 'Aqua / AIRS', +- format: 'png', +- updated_at: '1988-09-03T10:00:00.000Z', +- antarctic: false, +- antarctic_resolution: null, +- arctic: false, +- arctic_resolution: null, +- geographic: true, +- geographic_resolution: '2km' +- } +- ] +- } +- }) +- }]) ++ const messages = parseSqsBodies() ++ const addConceptIds = addConceptIdsFromMessages(messages) ++ const removeKeepConceptIds = removeKeepConceptIdsFromMessages(messages) ++ const upstreamSupportedConceptIds = supportedConceptIdsFromWorldview(gibsResponse) + +- expect(sqsSendMessagePromise.mock.calls[14]).toEqual([{ +- QueueUrl: 'http://example.com/tagQueue', +- MessageBody: JSON.stringify({ +- tagName: 'edsc.extra.serverless.gibs', +- action: 'REMOVE', +- searchCriteria: { +- condition: { +- and: [ +- { +- tag: { +- tag_key: 'edsc.extra.serverless.gibs' +- } +- }, +- { +- not: { +- or: [ +- { +- concept_id: 'C1000000001-EDSC' +- }, +- { +- concept_id: 'C1000000002-EDSC' +- }, +- { +- concept_id: 'C1000000003-EDSC' +- }, +- { +- concept_id: 'C191855458-LARC' +- }, +- { +- concept_id: 'C43677721-LARC' +- }, +- { +- concept_id: 'C43677725-LARC' +- }, +- { +- concept_id: 'C191855459-LARC' +- }, +- { +- concept_id: 'C7227850-LARC_ASDC' +- }, +- { +- concept_id: 'C7085910-LARC_ASDC' +- }, +- { +- concept_id: 'C7612165-LARC_ASDC' +- }, +- { +- concept_id: 'C6011924-LARC_ASDC' +- }, +- { +- concept_id: 'C43677719-LARC' +- }, +- { +- concept_id: 'C61095981-LARC' +- }, +- { +- concept_id: 'C84942916-LARC' +- } +- ] +- } +- } +- ] +- } +- } +- }) +- }]) ++ expectSetToEqual(addConceptIds, upstreamSupportedConceptIds) ++ expectSetToEqual(removeKeepConceptIds, upstreamSupportedConceptIds) ++ expect(messages.find((message) => message.action === 'REMOVE')).toBeDefined() + }) + + test('correctly generates and queues tag data when no collections are to be tagged', async () => { +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,30 @@ ++#!/bin/bash ++set -euo pipefail ++cd /testbed ++ ++ ++dev-switch node 20 2>/dev/null || true ++if [ ! -x node_modules/.bin/jest ]; then ++ npm ci --legacy-peer-deps 2>&1 | tail -5 ++fi ++cp secret.config.json.example secret.config.json ++unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy ++ ++case "${1:-}" in ++ base) ++ npx jest --no-cache --runInBand \ ++ serverless/src/generateGibsTags/__tests__/getSupportedGibsLayers.test.js \ ++ serverless/src/generateGibsTags/__tests__/handler.test.js \ ++ --testNamePattern='correctly excludes layers with faulty projections|correctly generates and queues tag data when no collections are to be tagged' ++ ;; ++ new) ++ npx jest --no-cache --runInBand \ ++ serverless/src/generateGibsTags/__tests__/getSupportedGibsLayers.test.js \ ++ serverless/src/generateGibsTags/__tests__/handler.test.js \ ++ --testNamePattern='returns_layers_from_the_current_upstream_response_only|returns_layers_from_larger_upstream_responses_without_static_overlay|returns_layers_from_upstream_response_outside_jest_environment|sends_tags_only_for_upstream_supported_concepts' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002018/tests/test.sh b/tasks/format-code-task-002018/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..92541a280d904417344337a4d72ff7cee5d72fad --- /dev/null +++ b/tasks/format-code-task-002018/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +serverless/src/generateGibsTags/__tests__/getSupportedGibsLayers.test.js +serverless/src/generateGibsTags/__tests__/handler.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002018/tests/test_command.sh b/tasks/format-code-task-002018/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002018/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-002020/environment/Dockerfile b/tasks/format-code-task-002020/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7c5aa5b90f39e60ea9d8424b871afee5ff4f15bf --- /dev/null +++ b/tasks/format-code-task-002020/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:288db08e98e8727f590ae1b830943472b55e33f4b00bd22304ac3b6bf7cc4f62 diff --git a/tasks/format-code-task-002020/environment/setup/files/blocklist b/tasks/format-code-task-002020/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002020/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002020/environment/setup/setup.sh b/tasks/format-code-task-002020/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002020/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002020/tests/test.patch b/tasks/format-code-task-002020/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..17b0ccea9ffcd758221d5dee3ebe2a0d0d740537 --- /dev/null +++ b/tasks/format-code-task-002020/tests/test.patch @@ -0,0 +1,375 @@ +diff --git a/usercase-test-coderl/fixtures/broken.ipynb b/usercase-test-coderl/fixtures/broken.ipynb +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/broken.ipynb +@@ -0,0 +1,1 @@ ++{"metadata": {}, "nbformat": 4, "cells": [ +diff --git a/usercase-test-coderl/fixtures/mixed_analysis.ipynb b/usercase-test-coderl/fixtures/mixed_analysis.ipynb +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/mixed_analysis.ipynb +@@ -0,0 +1,1 @@ ++{"metadata":{"original":"metadata-is-not-saved-by-gt"},"nbformat":4,"nbformat_minor":5,"cells":[{"cell_type":"markdown","id":"md_intro","metadata":{"heading":true},"source":["# Analysis\n","Initial notes"]},{"cell_type":"code","id":"code_calc","execution_count":7,"metadata":{"collapsed":false,"custom":"kept"},"outputs":[{"output_type":"stream","name":"stdout","text":"3\n"}],"source":["x = 1 + 2\n","print(x)"]},{"cell_type":"markdown","id":"md_tail","metadata":{},"source":"Done."}]} +diff --git a/usercase-test-coderl/fixtures/probe_notebook_io.py b/usercase-test-coderl/fixtures/probe_notebook_io.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/probe_notebook_io.py +@@ -0,0 +1,272 @@ ++#!/usr/bin/env python3 ++import argparse ++import asyncio ++import json ++import os ++from pathlib import Path ++from typing import Any ++ ++from src.app import Erys ++from src.cell import Cell ++from src.notebook import Notebook ++ ++ ++REPO_ROOT = Path(__file__).resolve().parents[2] ++ ++ ++class ProbeErys(Erys): ++ CSS_PATH = str(REPO_ROOT / "src" / "styles.tcss") ++ ++ def __init__(self, paths: list[Path]) -> None: ++ super().__init__(paths) ++ self.probe_notices: list[dict[str, Any]] = [] ++ ++ def notify( ++ self, ++ message: str, ++ *, ++ title: str = "", ++ severity: str = "information", ++ timeout: float | None = None, ++ markup: bool = True, ++ ) -> None: ++ self.probe_notices.append( ++ { ++ "markup": markup, ++ "message": str(message), ++ "severity": severity, ++ "timeout": timeout, ++ "title": str(title), ++ } ++ ) ++ return super().notify( ++ message, ++ title=title, ++ severity=severity, ++ timeout=timeout, ++ markup=markup, ++ ) ++ ++ ++class FixtureKernel: ++ initialized = False ++ ++ def get_kernel_info(self) -> dict[str, str]: ++ return {"name": "fixture-kernel"} ++ ++ def get_kernel_spec(self) -> dict[str, str]: ++ return { ++ "display_name": "Fixture Python", ++ "language": "python", ++ "name": "fixture-python", ++ } ++ ++ def get_language_info(self) -> dict[str, Any]: ++ return { ++ "file_extension": ".py", ++ "mimetype": "text/x-python", ++ "name": "python", ++ "pygments_lexer": "ipython3", ++ "version": "3.12-fixture", ++ } ++ ++ ++def canonical(value: Any) -> str: ++ return json.dumps(value, sort_keys=True, separators=(",", ":")) ++ ++ ++def cell_summary(cell: Cell) -> dict[str, Any]: ++ return { ++ "class": type(cell).__name__, ++ "editable": bool(getattr(cell, "input_text", None)) ++ and not bool(getattr(cell.input_text, "read_only", False)), ++ "exec_count": getattr(cell, "exec_count", None), ++ "id": getattr(cell, "_cell_id", None), ++ "next": getattr(cell.next, "_cell_id", None), ++ "outputs": getattr(cell, "outputs", None), ++ "prev": getattr(cell.prev, "_cell_id", None), ++ "source": cell.input_text.text, ++ "type": cell.cell_type, ++ } ++ ++ ++async def settle(pilot) -> None: ++ await pilot.pause(0.5) ++ await pilot.pause(0.5) ++ ++ ++def disable_kernel_startup() -> None: ++ os.environ.pop("VIRTUAL_ENV", None) ++ os.environ.pop("CONDA_PREFIX", None) ++ ++ ++def assert_required_saved_notebook(saved_json: dict[str, Any]) -> None: ++ ++ required_top_level = {"metadata", "nbformat", "nbformat_minor", "cells"} ++ missing = required_top_level - set(saved_json) ++ assert not missing, f"saved notebook missing top-level fields: {sorted(missing)}" ++ assert isinstance(saved_json["metadata"], dict), "saved metadata must be an object" ++ assert isinstance(saved_json["cells"], list), "saved cells must be an array" ++ ++ ++ for key in ["kernel_info", "kernel_spec", "language_info"]: ++ assert key in saved_json["metadata"], f"saved metadata missing {key}" ++ assert isinstance(saved_json["metadata"][key], dict), f"{key} must be an object" ++ ++ ++def assert_saved_cells_match_editor( ++ saved_json: dict[str, Any], cells: list[Cell] ++) -> None: ++ ++ assert len(saved_json["cells"]) == len(cells), "saved cell count must match editor" ++ for idx, (saved_cell, editor_cell) in enumerate(zip(saved_json["cells"], cells)): ++ assert saved_cell.get("cell_type") == editor_cell.cell_type, ( ++ f"saved cell {idx} type does not match editor" ++ ) ++ assert saved_cell.get("source") == editor_cell.input_text.text, ( ++ f"saved cell {idx} source does not match editor" ++ ) ++ ++ ++def assert_loaded_cells(cells: list[Cell], expected: list[dict[str, str]]) -> None: ++ ++ assert len(cells) == len(expected), "loaded notebook cell count mismatch" ++ for idx, (cell, want) in enumerate(zip(cells, expected)): ++ assert cell.cell_type == want["cell_type"], f"loaded cell {idx} type mismatch" ++ assert cell.input_text.text == want["source"], f"loaded cell {idx} source mismatch" ++ assert not getattr(cell.input_text, "read_only", False), ( ++ f"loaded cell {idx} is not editable" ++ ) ++ ++ ++async def valid_open_save(args: argparse.Namespace) -> None: ++ disable_kernel_startup() ++ app = ProbeErys([args.notebook]) ++ async with app.run_test(headless=True, size=(100, 40), notifications=True) as pilot: ++ await settle(pilot) ++ notebook = app.switcher.query_one("#tab0", Notebook) ++ cells = [ ++ child for child in notebook.cell_container.children if isinstance(child, Cell) ++ ] ++ notebook.notebook_kernel = FixtureKernel() ++ notebook.save_notebook(args.output) ++ ++ saved_text = args.output.read_text(encoding="utf-8") ++ saved_json = json.loads(saved_text) ++ ++ assert_loaded_cells( ++ cells, ++ [ ++ {"cell_type": "markdown", "source": "# Analysis\nInitial notes"}, ++ {"cell_type": "code", "source": "x = 1 + 2\nprint(x)"}, ++ {"cell_type": "markdown", "source": "Done."}, ++ ], ++ ) ++ ++ assert notebook.last_focused is cells[0], "first loaded cell must have focus" ++ assert_required_saved_notebook(saved_json) ++ assert_saved_cells_match_editor(saved_json, cells) ++ assert Path(args.output).is_file(), "save path was not written" ++ print( ++ canonical( ++ { ++ "cells": [cell_summary(cell) for cell in cells], ++ "result": "ok", ++ } ++ ) ++ ) ++ ++ ++async def empty_open_save(args: argparse.Namespace) -> None: ++ disable_kernel_startup() ++ app = ProbeErys([args.notebook]) ++ async with app.run_test(headless=True, size=(100, 40), notifications=True) as pilot: ++ await settle(pilot) ++ notebook = app.switcher.query_one("#tab0", Notebook) ++ cells = [ ++ child for child in notebook.cell_container.children if isinstance(child, Cell) ++ ] ++ notebook.notebook_kernel = FixtureKernel() ++ notebook.save_notebook(args.output) ++ saved_json = json.loads(args.output.read_text(encoding="utf-8")) ++ ++ ++ assert cells == [], "empty notebook file should open with no cells" ++ assert notebook.last_focused is None, "empty notebook should not focus a loaded cell" ++ assert_required_saved_notebook(saved_json) ++ assert saved_json["cells"] == [], "empty notebook should save zero cells" ++ print( ++ canonical( ++ { ++ "cells": [cell_summary(cell) for cell in cells], ++ "result": "ok", ++ } ++ ) ++ ) ++ ++ ++async def invalid_json(args: argparse.Namespace) -> None: ++ disable_kernel_startup() ++ app = ProbeErys([args.notebook]) ++ async with app.run_test(headless=True, size=(100, 40), notifications=True) as pilot: ++ await settle(pilot) ++ try: ++ notebook = app.switcher.query_one("#tab0", Notebook) ++ except Exception: ++ notebook = None ++ invalid_notices = [ ++ notice ++ for notice in app.probe_notices ++ if "not a valid notebook. Failed to decode JSON." in notice["message"] ++ ] ++ ++ expected_message = ( ++ f"{args.notebook} is not a valid notebook. Failed to decode JSON." ++ ) ++ assert any( ++ notice["message"] == expected_message and notice["severity"] == "error" ++ for notice in invalid_notices ++ ), "invalid JSON should notify with the mandated error" ++ assert notebook is None, "broken notebook tab should be closed" ++ assert str(args.notebook) not in app.path_to_tab_id, ( ++ "broken notebook path should not remain registered" ++ ) ++ assert str(args.notebook) not in [str(tab.label) for tab in app.tabs.query("Tab")], ( ++ "broken notebook tab label should not remain open" ++ ) ++ print( ++ canonical( ++ { ++ "invalid_notices": invalid_notices, ++ "result": "ok", ++ } ++ ) ++ ) ++ ++ ++def main() -> None: ++ parser = argparse.ArgumentParser() ++ subparsers = parser.add_subparsers(dest="command", required=True) ++ ++ valid = subparsers.add_parser("valid-open-save") ++ valid.add_argument("notebook", type=Path) ++ valid.add_argument("output", type=Path) ++ ++ empty = subparsers.add_parser("empty-open-save") ++ empty.add_argument("notebook", type=Path) ++ empty.add_argument("output", type=Path) ++ ++ invalid = subparsers.add_parser("invalid-json") ++ invalid.add_argument("notebook", type=Path) ++ ++ args = parser.parse_args() ++ if args.command == "valid-open-save": ++ asyncio.run(valid_open_save(args)) ++ elif args.command == "empty-open-save": ++ asyncio.run(empty_open_save(args)) ++ elif args.command == "invalid-json": ++ asyncio.run(invalid_json(args)) ++ ++ ++if __name__ == "__main__": ++ main() +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,64 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++export PIP_NO_INDEX=1 PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_ROOT_USER_ACTION=ignore ++export PYTHONNOUSERSITE=1 ++ ++ ++ ++PY=/opt/coderl-erys-venv/bin/python ++BIN=/opt/coderl-erys-venv/bin/erys ++ ++[ -x "$PY" ] || { echo "FAIL: offline python not installed" >&2; exit 1; } ++[ -x "$BIN" ] || { echo "FAIL: erys entry point not installed" >&2; exit 1; } ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || exit 1 ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++PROBE=/workspace/repo/usercase-test-coderl/fixtures/probe_notebook_io.py ++ ++ ++ ++ ++"$BIN" --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F0 exit $ec; want 0" ++ ++[ -s out ] || fail "F0 help produced no stdout" ++grep -qi "notebook" out || fail "F0 help missing notebook keyword" ++[ ! -s err ] || fail "F0 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++cp /workspace/repo/usercase-test-coderl/fixtures/mixed_analysis.ipynb analysis.ipynb ++"$PY" "$PROBE" valid-open-save analysis.ipynb saved-analysis.ipynb >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; stderr: $(cat err)" ++ ++grep -q '"result":"ok"' out || fail "F1 probe did not report ok: $(cat out)" ++[ ! -s err ] || fail "F1 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++: > empty.ipynb ++"$PY" "$PROBE" empty-open-save empty.ipynb saved-empty.ipynb >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; stderr: $(cat err)" ++ ++grep -q '"result":"ok"' out || fail "F2 probe did not report ok: $(cat out)" ++[ ! -s err ] || fail "F2 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++cp /workspace/repo/usercase-test-coderl/fixtures/broken.ipynb broken.ipynb ++"$PY" "$PROBE" invalid-json broken.ipynb >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; stderr: $(cat err)" ++ ++grep -q '"result":"ok"' out || fail "F3 probe did not report ok: $(cat out)" ++[ ! -s err ] || fail "F3 unexpected stderr: $(cat err)" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-002020/tests/test.sh b/tasks/format-code-task-002020/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ed240beb28031fd4ddc3233fad6eec9b0e36523 --- /dev/null +++ b/tasks/format-code-task-002020/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/broken.ipynb +usercase-test-coderl/fixtures/mixed_analysis.ipynb +usercase-test-coderl/fixtures/probe_notebook_io.py +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002020/tests/test_command.sh b/tasks/format-code-task-002020/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002020/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002027/environment/Dockerfile b/tasks/format-code-task-002027/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fb485531645c8edc2b335c01c4e8b47cf937351e --- /dev/null +++ b/tasks/format-code-task-002027/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8aee29d71db857320916870ef4990b087573558de92caae5c0b62b26a8d75296 diff --git a/tasks/format-code-task-002027/environment/setup/files/blocklist b/tasks/format-code-task-002027/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002027/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002027/environment/setup/setup.sh b/tasks/format-code-task-002027/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002027/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002027/tests/test.patch b/tasks/format-code-task-002027/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..eca0c111badfd6d131397ecb007e42678f32913c --- /dev/null +++ b/tasks/format-code-task-002027/tests/test.patch @@ -0,0 +1,128 @@ +diff --git a/test/geocoder/agolgeocoder_addnum.js b/test/geocoder/agolgeocoder_addnum.js +new file mode 100644 +index 0000000..bd0a990 +--- /dev/null ++++ b/test/geocoder/agolgeocoder_addnum.js +@@ -0,0 +1,100 @@ ++var chai = require('chai'), ++ should = chai.should(), ++ expect = chai.expect; ++ ++var AGOLGeocoder = require('../../lib/geocoder/agolgeocoder.js'); ++ ++var mockedOptions = { ++ 'client_id': "CLIENT_ID", ++ 'client_secret': "CLIENT_SECRET" ++}; ++ ++function makeAdapter(responseBody, captured) { ++ return { ++ get: function(url, params, cb) { ++ if (captured) { ++ captured.url = url; ++ captured.params = params; ++ } ++ cb(false, responseBody); ++ } ++ }; ++} ++ ++describe('AGOLGeocoder AddNum field fix', function() { ++ ++ it('Should populate streetNumber from AddNum attribute', function(done) { ++ var responseBody = JSON.stringify({ ++ spatialReference: {wkid: 4326, latestWkid: 4326}, ++ locations: [{ ++ name: '187 Bedford Ave, Brooklyn, New York, 11211', ++ extent: {xmin: -73.96, ymin: 40.71, xmax: -73.95, ymax: 40.72}, ++ feature: { ++ geometry: {x: -73.95785917316152, y: 40.71766805993411}, ++ attributes: { ++ AddNum: '187', ++ StPreDir: '', ++ StName: 'Bedford', ++ StType: 'Ave', ++ City: 'Brooklyn', ++ Postal: '11211', ++ Region: 'New York', ++ Country: 'USA' ++ } ++ } ++ }] ++ }); ++ ++ var adapter = makeAdapter(responseBody); ++ var geocoder = new AGOLGeocoder(adapter, mockedOptions); ++ geocoder._getToken = function(cb) { cb(false, 'TOKEN'); }; ++ ++ geocoder.geocode('187 Bedford Ave, Brooklyn, NY 11211', function(err, results) { ++ expect(err).to.equal(false); ++ expect(results).to.have.length(1); ++ results[0].streetNumber.should.equal('187'); ++ done(); ++ }); ++ }); ++ ++ it('Should preserve other geocoded fields when reading AddNum', function(done) { ++ var responseBody = JSON.stringify({ ++ spatialReference: {wkid: 4326, latestWkid: 4326}, ++ locations: [{ ++ name: '187 Bedford Ave, Brooklyn, New York, 11211', ++ extent: {xmin: 0, ymin: 0, xmax: 0, ymax: 0}, ++ feature: { ++ geometry: {x: -73.957, y: 40.717}, ++ attributes: { ++ AddNum: '187', ++ StPreDir: '', ++ StName: 'Bedford', ++ StType: 'Ave', ++ City: 'Brooklyn', ++ Postal: '11211', ++ Region: 'New York', ++ Country: 'USA' ++ } ++ } ++ }] ++ }); ++ ++ var adapter = makeAdapter(responseBody); ++ var geocoder = new AGOLGeocoder(adapter, mockedOptions); ++ geocoder._getToken = function(cb) { cb(false, 'TOKEN'); }; ++ ++ geocoder.geocode('187 Bedford Ave, Brooklyn, NY 11211', function(err, results) { ++ expect(err).to.equal(false); ++ var r = results[0]; ++ r.streetNumber.should.equal('187'); ++ r.city.should.equal('Brooklyn'); ++ r.state.should.equal('New York'); ++ r.zipcode.should.equal('11211'); ++ r.country.should.equal('USA'); ++ r.countryCode.should.equal('USA'); ++ r.latitude.should.equal(-73.957); ++ r.longitude.should.equal(40.717); ++ done(); ++ }); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..fc87c39 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["node ./node_modules/.bin/_mocha test/geocoder/agolgeocoder_addnum.js"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++node ./node_modules/.bin/_mocha test/geocoder/agolgeocoder_addnum.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002027/tests/test.sh b/tasks/format-code-task-002027/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..27a7c482afb320ae164968c1e63365ceb12690e6 --- /dev/null +++ b/tasks/format-code-task-002027/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/geocoder/agolgeocoder_addnum.js +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002027/tests/test_command.sh b/tasks/format-code-task-002027/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002027/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002029/environment/Dockerfile b/tasks/format-code-task-002029/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e4078f13917e010f5a396120107e563f73460371 --- /dev/null +++ b/tasks/format-code-task-002029/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8fcaad32034e8475ce3814d27f1d4a52e53d339ba7a406c7a7c6bae1242e44cf diff --git a/tasks/format-code-task-002029/environment/setup/files/blocklist b/tasks/format-code-task-002029/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002029/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002029/environment/setup/setup.sh b/tasks/format-code-task-002029/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002029/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002029/tests/test.patch b/tasks/format-code-task-002029/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..517b47815f3306380575ff42d58f7b976e0469c2 --- /dev/null +++ b/tasks/format-code-task-002029/tests/test.patch @@ -0,0 +1,381 @@ +diff --git a/container_architecture_cli_test.go b/container_architecture_cli_test.go +new file mode 100644 +index 0000000..ce1dad8 +--- /dev/null ++++ b/container_architecture_cli_test.go +@@ -0,0 +1,322 @@ ++package main ++ ++import ( ++ "context" ++ "encoding/json" ++ "fmt" ++ "io" ++ "net/http" ++ "net/http/httptest" ++ "os" ++ "os/exec" ++ "path/filepath" ++ "runtime" ++ "strings" ++ "sync" ++ "testing" ++ "time" ++) ++ ++func TestHelpIncludesContainerArchitecture(t *testing.T) { ++ output, err := runActForTest(t, nil, "--help") ++ if err != nil { ++ t.Fatalf("act --help failed: %v\n%s", err, output) ++ } ++ ++ helpText := strings.ToLower(output) ++ if !strings.Contains(helpText, "--container-architecture") { ++ t.Fatalf("help output does not include --container-architecture:\n%s", output) ++ } ++ if !strings.Contains(helpText, "architecture") && !strings.Contains(helpText, "platform") { ++ t.Fatalf("flag help should describe architecture or platform:\n%s", output) ++ } ++ if !strings.Contains(helpText, "default") { ++ t.Fatalf("flag help should describe the default behavior:\n%s", output) ++ } ++ if !strings.Contains(helpText, "machine") && !strings.Contains(helpText, "host") && !strings.Contains(helpText, "current") { ++ t.Fatalf("flag help should say the default is based on the current machine:\n%s", output) ++ } ++ if !strings.Contains(helpText, "linux/") { ++ t.Fatalf("flag help should show the linux/ platform form:\n%s", output) ++ } ++} ++ ++func TestReadmeDocumentsContainerArchitecture(t *testing.T) { ++ data, err := os.ReadFile(filepath.Join(repoRootForTest(t), "README.md")) ++ if err != nil { ++ t.Fatal(err) ++ } ++ readme := strings.ToLower(string(data)) ++ idx := strings.Index(readme, "--container-architecture") ++ if idx < 0 { ++ t.Fatalf("README flags list does not include --container-architecture") ++ } ++ ++ start := idx - 160 ++ if start < 0 { ++ start = 0 ++ } ++ end := idx + 320 ++ if end > len(readme) { ++ end = len(readme) ++ } ++ window := readme[start:end] ++ if !strings.Contains(window, "container") { ++ t.Fatalf("README flag entry should describe container behavior:\n%s", window) ++ } ++ if !strings.Contains(window, "architecture") && !strings.Contains(window, "platform") { ++ t.Fatalf("README flag entry should describe architecture or platform:\n%s", window) ++ } ++} ++ ++func TestCLIContainerArchitectureReachesDockerRuntime(t *testing.T) { ++ output, platforms, err := runWorkflowWithFakeDocker(t, "linux/arm64") ++ if err != nil { ++ t.Fatalf("act run failed: %v\n%s", err, output) ++ } ++ if !containsString(platforms, "linux/arm64") { ++ t.Fatalf("expected CLI platform to reach Docker runtime, got %v\n%s", platforms, output) ++ } ++} ++ ++func TestCLIContainerArchitectureAcceptsNonExampleValue(t *testing.T) { ++ output, platforms, err := runWorkflowWithFakeDocker(t, "linux/ppc64le") ++ if err != nil { ++ t.Fatalf("act run failed: %v\n%s", err, output) ++ } ++ if !containsString(platforms, "linux/ppc64le") { ++ t.Fatalf("expected non-example platform to reach Docker runtime, got %v\n%s", platforms, output) ++ } ++ for _, platform := range platforms { ++ if platform == "linux/amd64" { ++ t.Fatalf("platform propagation appears hard-coded to linux/amd64, got %v\n%s", platforms, output) ++ } ++ } ++} ++ ++func TestDefaultRunUsesCurrentArchitectureWhenPlatformOmitted(t *testing.T) { ++ output, platforms, err := runWorkflowWithFakeDocker(t, "") ++ if err != nil { ++ t.Fatalf("act run failed: %v\n%s", err, output) ++ } ++ ++ hostPlatform := "linux/" + runtime.GOARCH ++ for _, platform := range platforms { ++ if platform != hostPlatform { ++ t.Fatalf("default run should omit platform or use current machine architecture %s, got %v\n%s", ++ hostPlatform, platforms, output) ++ } ++ } ++} ++ ++func runWorkflowWithFakeDocker(t *testing.T, containerArchitecture string) (string, []string, error) { ++ t.Helper() ++ ++ workdir := t.TempDir() ++ workflow := filepath.Join(workdir, ".github", "workflows", "container-architecture.yml") ++ if err := os.MkdirAll(filepath.Dir(workflow), 0o755); err != nil { ++ t.Fatal(err) ++ } ++ if err := os.WriteFile(workflow, []byte(strings.TrimSpace(` ++name: container architecture ++on: push ++jobs: ++ check: ++ runs-on: ubuntu-latest ++ steps: [] ++`)+"\n"), 0o644); err != nil { ++ t.Fatal(err) ++ } ++ ++ docker := newFakeDocker(t) ++ defer docker.Close() ++ ++ args := []string{ ++ "-C", workdir, ++ "-W", workflow, ++ "-j", "check", ++ "--bind", ++ "-P", "ubuntu-latest=alpine:3.18", ++ } ++ if containerArchitecture != "" { ++ args = append([]string{"--container-architecture", containerArchitecture}, args...) ++ } ++ ++ env := []string{ ++ "DOCKER_HOST=" + docker.host, ++ "DOCKER_API_VERSION=1.41", ++ "DOCKER_TLS_VERIFY=", ++ "DOCKER_CERT_PATH=", ++ "HOME=" + t.TempDir(), ++ } ++ output, err := runActForTest(t, env, args...) ++ return output, docker.Platforms(), err ++} ++ ++func runActForTest(t *testing.T, env []string, args ...string) (string, error) { ++ t.Helper() ++ ++ ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second) ++ defer cancel() ++ ++ cmd := exec.CommandContext(ctx, actBinaryForTest(t), args...) ++ cmd.Dir = repoRootForTest(t) ++ cmd.Env = append(os.Environ(), env...) ++ output, err := cmd.CombinedOutput() ++ if ctx.Err() == context.DeadlineExceeded { ++ return string(output), ctx.Err() ++ } ++ return string(output), err ++} ++ ++var ( ++ actBinaryOnce sync.Once ++ actBinaryPath string ++ actBinaryOut []byte ++ actBinaryErr error ++) ++ ++func actBinaryForTest(t *testing.T) string { ++ t.Helper() ++ ++ actBinaryOnce.Do(func() { ++ dir, err := os.MkdirTemp("", "act-container-architecture-test-") ++ if err != nil { ++ actBinaryErr = err ++ return ++ } ++ actBinaryPath = filepath.Join(dir, "act") ++ cmd := exec.Command("go", "build", "-o", actBinaryPath, ".") ++ cmd.Dir = repoRootForTest(t) ++ actBinaryOut, actBinaryErr = cmd.CombinedOutput() ++ }) ++ if actBinaryErr != nil { ++ t.Fatalf("failed to build act test binary: %v\n%s", actBinaryErr, string(actBinaryOut)) ++ } ++ return actBinaryPath ++} ++ ++func repoRootForTest(t *testing.T) string { ++ t.Helper() ++ ++ wd, err := os.Getwd() ++ if err != nil { ++ t.Fatal(err) ++ } ++ return wd ++} ++ ++type fakeDocker struct { ++ server *httptest.Server ++ host string ++ ++ mu sync.Mutex ++ platforms []string ++} ++ ++func newFakeDocker(t *testing.T) *fakeDocker { ++ t.Helper() ++ ++ fd := &fakeDocker{} ++ fd.server = httptest.NewServer(http.HandlerFunc(fd.handle)) ++ fd.host = "tcp://" + strings.TrimPrefix(fd.server.URL, "http://") ++ return fd ++} ++ ++func (fd *fakeDocker) Close() { ++ fd.server.Close() ++} ++ ++func (fd *fakeDocker) Platforms() []string { ++ fd.mu.Lock() ++ defer fd.mu.Unlock() ++ ++ out := make([]string, 0, len(fd.platforms)) ++ out = append(out, fd.platforms...) ++ return out ++} ++ ++func (fd *fakeDocker) recordPlatform(value string) { ++ if value == "" { ++ return ++ } ++ fd.mu.Lock() ++ defer fd.mu.Unlock() ++ fd.platforms = append(fd.platforms, value) ++} ++ ++func (fd *fakeDocker) handle(w http.ResponseWriter, r *http.Request) { ++ path := stripDockerVersion(r.URL.Path) ++ switch { ++ case r.Method == http.MethodGet && path == "/_ping": ++ writeText(w, http.StatusOK, "OK") ++ case r.Method == http.MethodGet && path == "/version": ++ writeJSON(w, http.StatusOK, map[string]string{ ++ "ApiVersion": "1.41", ++ "MinAPIVersion": "1.24", ++ "Version": "20.10.0", ++ }) ++ case r.Method == http.MethodGet && path == "/info": ++ writeJSON(w, http.StatusOK, map[string]string{ ++ "OSType": "linux", ++ "Architecture": runtime.GOARCH, ++ }) ++ case r.Method == http.MethodGet && path == "/containers/json": ++ writeJSON(w, http.StatusOK, []map[string]interface{}{}) ++ case r.Method == http.MethodGet && path == "/images/json": ++ writeJSON(w, http.StatusOK, []map[string]interface{}{}) ++ case r.Method == http.MethodGet && path == "/volumes": ++ writeJSON(w, http.StatusOK, map[string]interface{}{"Volumes": []map[string]interface{}{}}) ++ case r.Method == http.MethodPost && path == "/images/create": ++ fd.recordPlatform(r.URL.Query().Get("platform")) ++ writeText(w, http.StatusOK, "{\"status\":\"pulled\"}\n") ++ case r.Method == http.MethodPost && path == "/containers/create": ++ fd.recordPlatform(r.URL.Query().Get("platform")) ++ writeJSON(w, http.StatusCreated, map[string]interface{}{"Id": "fixture-container", "Warnings": []string{}}) ++ case r.Method == http.MethodPost && strings.HasSuffix(path, "/start"): ++ w.WriteHeader(http.StatusNoContent) ++ case r.Method == http.MethodPut && strings.HasSuffix(path, "/archive"): ++ _, _ = io.Copy(io.Discard, r.Body) ++ writeText(w, http.StatusOK, "") ++ case r.Method == http.MethodDelete && strings.HasPrefix(path, "/containers/"): ++ w.WriteHeader(http.StatusNoContent) ++ default: ++ writeJSON(w, http.StatusNotFound, map[string]string{ ++ "message": fmt.Sprintf("fake docker endpoint not implemented: %s %s", r.Method, r.URL.String()), ++ }) ++ } ++} ++ ++func stripDockerVersion(path string) string { ++ parts := strings.SplitN(strings.TrimPrefix(path, "/"), "/", 2) ++ if len(parts) == 2 && strings.HasPrefix(parts[0], "v") && strings.Contains(parts[0], ".") { ++ return "/" + parts[1] ++ } ++ return path ++} ++ ++func writeJSON(w http.ResponseWriter, status int, payload interface{}) { ++ data, err := json.Marshal(payload) ++ if err != nil { ++ http.Error(w, err.Error(), http.StatusInternalServerError) ++ return ++ } ++ w.Header().Set("Content-Type", "application/json") ++ w.WriteHeader(status) ++ _, _ = w.Write(data) ++} ++ ++func writeText(w http.ResponseWriter, status int, payload string) { ++ w.Header().Set("Content-Type", "text/plain") ++ w.WriteHeader(status) ++ _, _ = io.WriteString(w, payload) ++} ++ ++func containsString(values []string, want string) bool { ++ for _, value := range values { ++ if value == want { ++ return true ++ } ++ } ++ return false ++} +diff --git a/pkg/runner/container_architecture_config_test.go b/pkg/runner/container_architecture_config_test.go +new file mode 100644 +index 0000000..969f6a2 +--- /dev/null ++++ b/pkg/runner/container_architecture_config_test.go +@@ -0,0 +1,20 @@ ++package runner_test ++ ++import ( ++ "testing" ++ ++ "github.com/nektos/act/pkg/runner" ++) ++ ++func TestConfigExposesContainerArchitecture(t *testing.T) { ++ const requested = "linux/arm64" ++ ++ cfg := &runner.Config{ ++ ContainerArchitecture: requested, ++ } ++ ++ if cfg.ContainerArchitecture != requested { ++ t.Fatalf("expected runner.Config to preserve requested container architecture %q, got %q", ++ requested, cfg.ContainerArchitecture) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,22 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++ ++ ++ ++case "${1:-}" in ++ base) ++ go test -v -short ./pkg/common -run '^TestCartesianProduct$' ++ ;; ++ new) ++ go test -v . -run '^(TestHelpIncludesContainerArchitecture|TestReadmeDocumentsContainerArchitecture|TestCLIContainerArchitectureReachesDockerRuntime|TestCLIContainerArchitectureAcceptsNonExampleValue|TestDefaultRunUsesCurrentArchitectureWhenPlatformOmitted)$' && ++ go test -v ./pkg/runner -run '^TestConfigExposesContainerArchitecture$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002029/tests/test.sh b/tasks/format-code-task-002029/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..32f667bd20fabe6406fe04c90da02477116de7a4 --- /dev/null +++ b/tasks/format-code-task-002029/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +container_architecture_cli_test.go +pkg/runner/container_architecture_config_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002029/tests/test_command.sh b/tasks/format-code-task-002029/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002029/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-002042/environment/Dockerfile b/tasks/format-code-task-002042/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..03b7484aeb2f96b732dae7bf01b3c2ecc1df905a --- /dev/null +++ b/tasks/format-code-task-002042/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8180734cb9ac52ddc8c384de911af0be7bec47de793f952366b8d2837e8ecf24 diff --git a/tasks/format-code-task-002042/environment/setup/files/blocklist b/tasks/format-code-task-002042/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002042/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002042/environment/setup/setup.sh b/tasks/format-code-task-002042/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002042/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002042/tests/test.patch b/tasks/format-code-task-002042/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f8a91dda669418af30bf7a3287b9b214190be14c --- /dev/null +++ b/tasks/format-code-task-002042/tests/test.patch @@ -0,0 +1,80 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..bb707df +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_pyshortcuts.py -v"] ++} +diff --git a/tests/test_pyshortcuts.py b/tests/test_pyshortcuts.py +index abd9826..ab07de6 100644 +--- a/tests/test_pyshortcuts.py ++++ b/tests/test_pyshortcuts.py +@@ -1,5 +1,6 @@ + #!/usr/bin/env python + import os ++import pytest + from pyshortcuts import make_shortcut, platform, Shortcut, get_folders + + root = os.path.abspath(os.path.join(__file__, '..', '..')) +@@ -23,5 +24,46 @@ def test_shortcut(): + + #raise err # force crash so we see manual print() debug statements + ++ ++def test_make_shortcut_none_script_raises_valueerror(): ++ """make_shortcut(None) must raise ValueError, not AttributeError. ++ ++ Reproduces the issue: `cmd = shutil.which("missing")` returns None, ++ then `make_shortcut(cmd, ...)` previously crashed with ++ `AttributeError: 'NoneType' object has no attribute 'split'`. ++ """ ++ with pytest.raises(ValueError): ++ make_shortcut(None, name='Foo') ++ ++ ++def test_make_shortcut_empty_string_raises_valueerror(): ++ """make_shortcut('') must raise ValueError.""" ++ with pytest.raises(ValueError): ++ make_shortcut('', name='Foo') ++ ++ ++def test_make_shortcut_non_string_raises_valueerror(): ++ """make_shortcut(non_string) must raise ValueError (not AttributeError).""" ++ with pytest.raises(ValueError): ++ make_shortcut(123, name='Foo') ++ ++ ++def test_make_shortcut_none_does_not_raise_attributeerror(): ++ """Negative assertion: must NOT raise AttributeError (the original bug).""" ++ try: ++ make_shortcut(None, name='Foo') ++ except ValueError: ++ pass ++ except AttributeError as exc: ++ pytest.fail("make_shortcut(None) raised AttributeError: %s" % exc) ++ ++ ++def test_make_shortcut_valid_script_still_works(): ++ """Preservation: a valid script string still returns a Shortcut.""" ++ script = os.path.join(root, 'examples', 'console_scripts', 'timer.py') + ' -u 0.25 -t 10' ++ scut = make_shortcut(script, name='Timer', folder=folders.desktop) ++ assert isinstance(scut, Shortcut) ++ ++ + if __name__ == '__main__': + test_shortcut() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -v -rA tests/test_pyshortcuts.py::test_make_shortcut_none_script_raises_valueerror tests/test_pyshortcuts.py::test_make_shortcut_empty_string_raises_valueerror tests/test_pyshortcuts.py::test_make_shortcut_non_string_raises_valueerror tests/test_pyshortcuts.py::test_make_shortcut_none_does_not_raise_attributeerror tests/test_pyshortcuts.py::test_make_shortcut_valid_script_still_works ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002042/tests/test.sh b/tasks/format-code-task-002042/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..34ecd6d020cf7f82f29fa238c0169128441e7197 --- /dev/null +++ b/tasks/format-code-task-002042/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/test_pyshortcuts.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002042/tests/test_command.sh b/tasks/format-code-task-002042/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002042/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002043/environment/Dockerfile b/tasks/format-code-task-002043/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6d99401259f5d74c3065f9dc11c55cfcb33df715 --- /dev/null +++ b/tasks/format-code-task-002043/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ea9cd3ce0add7197a74515a9fd59365fa924659d84f94d3bf98f056f8a4216f2 diff --git a/tasks/format-code-task-002043/environment/setup/files/blocklist b/tasks/format-code-task-002043/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002043/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002043/environment/setup/setup.sh b/tasks/format-code-task-002043/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002043/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002043/tests/test.patch b/tasks/format-code-task-002043/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fd4516e8f2296009ca97288a33006cdd36928753 --- /dev/null +++ b/tasks/format-code-task-002043/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/src/tests/extensions/Mention.spec.js b/src/tests/extensions/Mention.spec.js +new file mode 100644 +index 000000000..6227975b9 +--- /dev/null ++++ b/src/tests/extensions/Mention.spec.js +@@ -0,0 +1,59 @@ ++ ++ ++ ++ ++ ++import { ++ markdownThroughEditor, ++ markdownThroughEditorHtml, ++} from '../helpers.js' ++ ++describe('Mention markdown serialization', () => { ++ test('single mention from markdown has no extra surrounding spaces', () => { ++ expect(markdownThroughEditor('@[username](mention://user/id)')) ++ .toBe('@[username](mention://user/id)') ++ }) ++ ++ test('single mention from html has no extra surrounding spaces', () => { ++ expect(markdownThroughEditorHtml( ++ 'username' ++ )).toBe('@[username](mention://user/id)') ++ }) ++ ++ test('mention with whitespace user id is correctly encoded with no extra spaces', () => { ++ expect(markdownThroughEditorHtml( ++ 'whitespace user' ++ )).toBe('@[whitespace user](mention://user/whitespace%20user)') ++ }) ++ ++ test('two adjacent mentions separated by a single space stay single-spaced', () => { ++ ++ expect(markdownThroughEditor( ++ '@[alice](mention://user/alice) @[bob](mention://user/bob)' ++ )).toBe('@[alice](mention://user/alice) @[bob](mention://user/bob)') ++ }) ++ ++ test('three mentions separated by single spaces preserve single spaces', () => { ++ expect(markdownThroughEditor( ++ '@[a](mention://user/a) @[b](mention://user/b) @[c](mention://user/c)' ++ )).toBe('@[a](mention://user/a) @[b](mention://user/b) @[c](mention://user/c)') ++ }) ++ ++ test('text before mention preserves a single space', () => { ++ expect(markdownThroughEditor( ++ 'hello @[alice](mention://user/alice)' ++ )).toBe('hello @[alice](mention://user/alice)') ++ }) ++ ++ test('text after mention preserves a single space', () => { ++ expect(markdownThroughEditor( ++ '@[alice](mention://user/alice) world' ++ )).toBe('@[alice](mention://user/alice) world') ++ }) ++ ++ test('mention surrounded by text preserves spacing', () => { ++ expect(markdownThroughEditor( ++ 'hello @[alice](mention://user/alice) world' ++ )).toBe('hello @[alice](mention://user/alice) world') ++ }) ++}) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..6f50aa7d1 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["NODE_ENV=test npx jest src/tests/extensions/Mention.spec.js"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++NODE_ENV=test npx jest src/tests/extensions/Mention.spec.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002043/tests/test.sh b/tasks/format-code-task-002043/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5e7d80307547748222ac4f2c35e86d39b7ae28fa --- /dev/null +++ b/tasks/format-code-task-002043/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/tests/extensions/Mention.spec.js +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002043/tests/test_command.sh b/tasks/format-code-task-002043/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002043/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002072/environment/Dockerfile b/tasks/format-code-task-002072/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bf26350eb4281070d187220badf44f2587a991e1 --- /dev/null +++ b/tasks/format-code-task-002072/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:48dba0b404edef529def021b7810814f43edcd903fee41259ae4ea6fd647f3ab diff --git a/tasks/format-code-task-002072/environment/setup/files/blocklist b/tasks/format-code-task-002072/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002072/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002072/environment/setup/setup.sh b/tasks/format-code-task-002072/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002072/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002072/tests/test.patch b/tasks/format-code-task-002072/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5d177627df4adca3166f18bccd08692125b02a33 --- /dev/null +++ b/tasks/format-code-task-002072/tests/test.patch @@ -0,0 +1,424 @@ +diff --git a/usercase-test-coderl/test_condition_lingo_evaluation.py b/usercase-test-coderl/test_condition_lingo_evaluation.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_condition_lingo_evaluation.py +@@ -0,0 +1,399 @@ ++ ++ ++ ++ ++ ++ ++ ++import copy ++import json ++import os ++import socket ++import subprocess ++import sys ++from http import HTTPStatus ++ ++import pytest ++ ++from nucypher.policy.conditions.exceptions import ( ++ ConditionEvaluationFailed, ++ ContextVariableVerificationFailed, ++ InvalidCondition, ++ InvalidConditionLingo, ++ InvalidContextVariableData, ++ NoConnectionToChain, ++ RequiredContextVariable, ++ ReturnValueEvaluationError, ++) ++from nucypher.policy.conditions.lingo import ConditionLingo ++from nucypher.policy.conditions.utils import ( ++ ConditionEvalError, ++ ConditionProviderManager, ++ evaluate_condition_lingo, ++) ++ ++ ++class RecordingLog: ++ def __init__(self): ++ self.infos = [] ++ self.warnings = [] ++ ++ def info(self, message): ++ self.infos.append(str(message)) ++ ++ def warn(self, message): ++ self.warnings.append(str(message)) ++ ++ ++class FakeParsedLingo: ++ def __init__(self, result=True, error=None, sink=None): ++ self.result = result ++ self.error = error ++ self.sink = sink ++ ++ def eval(self, providers=None, **context): ++ if self.sink is not None: ++ self.sink["providers"] = providers.providers ++ self.sink["context"] = context ++ if self.error is not None: ++ raise self.error ++ return self.result ++ ++ ++def install_from_dict(monkeypatch, parsed=None, error=None, recorder=None): ++ def fake_from_dict(cls, data): ++ if recorder is not None: ++ recorder.append(copy.deepcopy(data)) ++ if error is not None: ++ raise error ++ return parsed ++ ++ monkeypatch.setattr(ConditionLingo, "from_dict", classmethod(fake_from_dict)) ++ ++ ++def assert_condition_eval_error(exc_info, message, status_code): ++ error = exc_info.value ++ assert error.__class__.__name__ == "ConditionEvalError" ++ assert error.message == message ++ assert error.status_code == status_code ++ ++ ++def assert_condition_eval_error_with_prefix(exc_info, prefix, status_code): ++ error = exc_info.value ++ assert error.__class__.__name__ == "ConditionEvalError" ++ ++ assert error.message.startswith(prefix) ++ assert error.status_code == status_code ++ ++ ++def test_successful_true_evaluation_returns_none_and_uses_empty_defaults(monkeypatch): ++ ++ ++ ++ ++ captured = {} ++ install_from_dict( ++ monkeypatch, ++ parsed=FakeParsedLingo(result=True, sink=captured), ++ ) ++ ++ actual = evaluate_condition_lingo({"condition": {"conditionType": "fixture"}}) ++ ++ assert actual is None ++ assert captured == {"providers": {}, "context": {}} ++ ++ ++def test_successful_true_evaluation_passes_supplied_providers_and_context(monkeypatch): ++ ++ ++ ++ ++ captured = {} ++ providers = ConditionProviderManager(providers={11155111: []}) ++ context = {"wallet_address": "0xabc123", "tier": 3} ++ install_from_dict( ++ monkeypatch, ++ parsed=FakeParsedLingo(result=True, sink=captured), ++ ) ++ ++ actual = evaluate_condition_lingo( ++ {"condition": {"conditionType": "fixture"}}, ++ providers=providers, ++ context=context, ++ ) ++ ++ assert actual is None ++ assert captured == { ++ "providers": {11155111: []}, ++ "context": {"wallet_address": "0xabc123", "tier": 3}, ++ } ++ ++ ++@pytest.mark.parametrize("falsy_lingo", [None, {}, [], "", 0]) ++def test_falsy_condition_lingo_returns_none_without_parsing(monkeypatch, falsy_lingo): ++ ++ ++ ++ ++ calls = [] ++ install_from_dict(monkeypatch, parsed=FakeParsedLingo(result=True), recorder=calls) ++ ++ actual = evaluate_condition_lingo(falsy_lingo) ++ ++ assert actual is None ++ assert calls == [] ++ ++ ++def test_false_evaluation_raises_forbidden_denial(monkeypatch): ++ ++ ++ ++ ++ install_from_dict(monkeypatch, parsed=FakeParsedLingo(result=False)) ++ ++ with pytest.raises(ConditionEvalError) as exc_info: ++ evaluate_condition_lingo({"case": "denied"}) ++ ++ assert_condition_eval_error( ++ exc_info, ++ "Decryption conditions not satisfied", ++ HTTPStatus.FORBIDDEN, ++ ) ++ ++ ++def test_invalid_grammar_raises_bad_request(monkeypatch): ++ ++ ++ ++ ++ install_from_dict(monkeypatch, error=InvalidConditionLingo("bad shape")) ++ ++ with pytest.raises(ConditionEvalError) as exc_info: ++ evaluate_condition_lingo({"case": "grammar"}) ++ ++ assert_condition_eval_error_with_prefix( ++ exc_info, ++ "Invalid condition grammar:", ++ HTTPStatus.BAD_REQUEST, ++ ) ++ ++ ++def test_invalid_condition_value_raises_bad_request(monkeypatch): ++ ++ ++ ++ ++ install_from_dict(monkeypatch, error=InvalidCondition("bad value")) ++ ++ with pytest.raises(ConditionEvalError) as exc_info: ++ evaluate_condition_lingo({"case": "invalid-condition"}) ++ ++ assert_condition_eval_error_with_prefix( ++ exc_info, ++ "Incorrect value provided for condition:", ++ HTTPStatus.BAD_REQUEST, ++ ) ++ ++ ++def test_missing_context_variables_raise_bad_request(monkeypatch): ++ ++ ++ ++ ++ install_from_dict(monkeypatch, error=RequiredContextVariable("wallet")) ++ ++ with pytest.raises(ConditionEvalError) as exc_info: ++ evaluate_condition_lingo({"case": "missing-context"}) ++ ++ assert_condition_eval_error_with_prefix( ++ exc_info, ++ "Missing required inputs:", ++ HTTPStatus.BAD_REQUEST, ++ ) ++ ++ ++def test_invalid_context_variable_data_raises_bad_request(monkeypatch): ++ ++ ++ ++ ++ install_from_dict(monkeypatch, error=InvalidContextVariableData("wallet")) ++ ++ with pytest.raises(ConditionEvalError) as exc_info: ++ evaluate_condition_lingo({"case": "invalid-context-data"}) ++ ++ assert_condition_eval_error_with_prefix( ++ exc_info, ++ "Invalid data provided for context variable:", ++ HTTPStatus.BAD_REQUEST, ++ ) ++ ++ ++def test_unverifiable_context_authentication_raises_forbidden(monkeypatch): ++ ++ ++ ++ ++ install_from_dict(monkeypatch, error=ContextVariableVerificationFailed("signature")) ++ ++ with pytest.raises(ConditionEvalError) as exc_info: ++ evaluate_condition_lingo({"case": "unverifiable-context-authentication"}) ++ ++ assert_condition_eval_error_with_prefix( ++ exc_info, ++ "Context variable data could not be verified:", ++ HTTPStatus.FORBIDDEN, ++ ) ++ ++ ++def test_missing_chain_connectivity_raises_not_implemented(monkeypatch): ++ ++ ++ ++ ++ install_from_dict(monkeypatch, error=NoConnectionToChain(chain=11155111)) ++ ++ with pytest.raises(ConditionEvalError) as exc_info: ++ evaluate_condition_lingo({"case": "missing-chain"}) ++ ++ assert_condition_eval_error( ++ exc_info, ++ "Node does not have a connection to chain ID 11155111", ++ HTTPStatus.NOT_IMPLEMENTED, ++ ) ++ ++ ++def test_failed_return_value_processing_raises_bad_request(monkeypatch): ++ ++ ++ ++ ++ install_from_dict(monkeypatch, error=ReturnValueEvaluationError("bad index")) ++ ++ with pytest.raises(ConditionEvalError) as exc_info: ++ evaluate_condition_lingo({"case": "return-value"}) ++ ++ assert_condition_eval_error_with_prefix( ++ exc_info, ++ "Unable to evaluate return value:", ++ HTTPStatus.BAD_REQUEST, ++ ) ++ ++ ++def test_other_condition_evaluation_failures_raise_bad_request(monkeypatch): ++ ++ ++ ++ ++ install_from_dict(monkeypatch, error=ConditionEvaluationFailed("rpc reverted")) ++ ++ with pytest.raises(ConditionEvalError) as exc_info: ++ evaluate_condition_lingo({"case": "condition-evaluation"}) ++ ++ assert_condition_eval_error_with_prefix( ++ exc_info, ++ "Decryption condition not evaluated:", ++ HTTPStatus.BAD_REQUEST, ++ ) ++ ++ ++def test_unexpected_exceptions_raise_internal_server_error(monkeypatch): ++ ++ ++ ++ ++ log = RecordingLog() ++ install_from_dict(monkeypatch, error=RuntimeError("boom")) ++ ++ with pytest.raises(ConditionEvalError) as exc_info: ++ evaluate_condition_lingo({"case": "unexpected"}, log=log) ++ ++ error = exc_info.value ++ assert error.__class__.__name__ == "ConditionEvalError" ++ assert error.status_code == HTTPStatus.INTERNAL_SERVER_ERROR ++ ++ assert "RuntimeError" in error.message ++ assert "boom" in error.message ++ ++ assert isinstance(log.warnings, list) ++ ++ ++def test_referential_transparency_same_input_same_success(monkeypatch): ++ install_from_dict(monkeypatch, parsed=FakeParsedLingo(result=True)) ++ condition = {"case": "referential", "condition": {"conditionType": "fixture"}} ++ providers = ConditionProviderManager(providers={1: []}) ++ context = {"account": "0xabc123"} ++ ++ first = evaluate_condition_lingo(condition, providers=providers, context=context) ++ second = evaluate_condition_lingo(condition, providers=providers, context=context) ++ ++ assert first is None ++ assert second is None ++ ++ ++def test_same_mutable_inputs_can_be_reused(monkeypatch): ++ captured = {} ++ install_from_dict(monkeypatch, parsed=FakeParsedLingo(result=True, sink=captured)) ++ condition = { ++ "version": "1.0.0", ++ "condition": {"conditionType": "fixture", "operands": [{"value": 7}]}, ++ } ++ providers = ConditionProviderManager(providers={5: []}) ++ context = {"nested": {"items": [1, 2, {"token": "abc"}]}} ++ first = evaluate_condition_lingo(condition, providers=providers, context=context) ++ second = evaluate_condition_lingo(condition, providers=providers, context=context) ++ ++ assert first is None ++ ++ assert second is None ++ ++ ++def test_no_global_state_matches_fresh_python_process(monkeypatch): ++ install_from_dict(monkeypatch, parsed=FakeParsedLingo(result=True)) ++ in_process = evaluate_condition_lingo({"case": "fresh-process"}) ++ script = """ ++import json ++import sys ++sys.path.insert(0, '/workspace/repo') ++from nucypher.policy.conditions.lingo import ConditionLingo ++from nucypher.policy.conditions.utils import evaluate_condition_lingo ++ ++class FakeParsedLingo: ++ def eval(self, providers=None, **context): ++ return True ++ ++def fake_from_dict(cls, data): ++ return FakeParsedLingo() ++ ++ConditionLingo.from_dict = classmethod(fake_from_dict) ++sys.stdout.write(json.dumps(evaluate_condition_lingo({'case': 'fresh-process'}))) ++""" ++ ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE, ++ text=True, ++ ) ++ ++ assert in_process is None ++ assert json.loads(completed.stdout) is None ++ ++ ++def test_no_undeclared_file_or_network_side_effects(monkeypatch, tmp_path): ++ install_from_dict(monkeypatch, parsed=FakeParsedLingo(result=True)) ++ ++ def blocked_socket(*args, **kwargs): ++ raise AssertionError("network access is not declared for evaluate_condition_lingo") ++ ++ monkeypatch.setattr(socket, "socket", blocked_socket) ++ monkeypatch.chdir(tmp_path) ++ before = sorted(os.listdir(tmp_path)) ++ ++ actual = evaluate_condition_lingo({"case": "side-effects"}) ++ ++ after = sorted(os.listdir(tmp_path)) ++ assert actual is None ++ assert before == [] ++ assert after == [] +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,15 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++python -m pytest /workspace/repo/usercase-test-coderl/test_condition_lingo_evaluation.py -v diff --git a/tasks/format-code-task-002072/tests/test.sh b/tasks/format-code-task-002072/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..22c9ea68089a41d386d3223a8798b5703060c52a --- /dev/null +++ b/tasks/format-code-task-002072/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/test_condition_lingo_evaluation.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002072/tests/test_command.sh b/tasks/format-code-task-002072/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002072/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002074/environment/Dockerfile b/tasks/format-code-task-002074/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7b05c26508e3c813dbb9717954f2ec2a43d7c8c3 --- /dev/null +++ b/tasks/format-code-task-002074/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9e194f3d49abd1785130e7696b388b3ebb5de369e63b689aff7858b8816a4510 diff --git a/tasks/format-code-task-002074/environment/setup/files/blocklist b/tasks/format-code-task-002074/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002074/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002074/environment/setup/setup.sh b/tasks/format-code-task-002074/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002074/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002074/tests/test.patch b/tasks/format-code-task-002074/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a23617f8f6d9239e99c5b80518efa736d7b2ec7b --- /dev/null +++ b/tasks/format-code-task-002074/tests/test.patch @@ -0,0 +1,62 @@ +diff --git a/numpy/f2py/tests/test_regression.py b/numpy/f2py/tests/test_regression.py +index 67e00f1f7820..a1b772069a0b 100644 +--- a/numpy/f2py/tests/test_regression.py ++++ b/numpy/f2py/tests/test_regression.py +@@ -2,7 +2,7 @@ + import pytest + + import numpy as np +-from numpy.testing import assert_raises, assert_equal ++from numpy.testing import assert_, assert_raises, assert_equal, assert_string_equal + + from . import util + +@@ -25,3 +25,23 @@ def test_inout(self): + x = np.arange(3, dtype=np.float32) + self.module.foo(x) + assert_equal(x, [3, 1, 2]) ++ ++ ++class TestNumpyVersionAttribute(util.F2PyTest): ++ ++ ++ sources = [_path('src', 'regression', 'inout.f90')] ++ ++ @pytest.mark.slow ++ def test_numpy_version_attribute(self): ++ ++ ++ assert_(hasattr(self.module, "__f2py_numpy_version__"), ++ msg="Fortran module does not have __f2py_numpy_version__") ++ ++ ++ assert_(isinstance(self.module.__f2py_numpy_version__, str), ++ msg="__f2py_numpy_version__ is not a string") ++ ++ ++ assert_string_equal(np.__version__, self.module.__f2py_numpy_version__) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+3TXW/TMBQG4F7nVxyFCm0XTps0WSdUkEBCGhdoE+x+cpLTxsKxje2UReLH4ySM ++ffCxm1UIcZ6buLab81onTspOyPoK1X4xO5RlsC6K8Rk8fI7jtMjSbJllRR7m07RYZzMoDpbojs55 ++bgFmVmv/p32Prf+jktv+e3T+qtJty1WduObpajzW/3We/+h/XqxC//OT9GQGy6eL8Hv/ef+rGsbG ++l1hH0TP4iB46A6YPHwRstYWL3jdawSo5jfDaaOvh4vXl2ct4fnb+/u0iGTcuSqFezIf5OMI9lxDP ++j6Y3CCU8MGa4b45/vRamp587qcuwHAol6ekQ5Z0KnZESLH7uhMX6Jorh1Se+QxcZYcJLpk2xQ98Z ++r7V0m2IZQ1yNmzerMDT9cMDNOoZpxIZyTW+0b9AJB18aRAnZq+cpfAXPhQSWDgHeDDcDVNeaHrZW ++t+B0ZyuEI6yF56XEm+rH96IwhCScWWk2Xi0mnJbci5D85xIfOgUhBWyzUMPizqJzw84hZjjgeIYV ++sPZ78inMYtg9Ns1Nd/b2j6EfwPZT9QZ5jRbYdfS3vzFCCCGEEEIIIYQQQgghhBBCCCGEEHI43wAZ ++HjtvACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002074/tests/test.sh b/tasks/format-code-task-002074/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5d69eccf8aecdb6bd9a5629d8ee95549c32640d8 --- /dev/null +++ b/tasks/format-code-task-002074/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +numpy/f2py/tests/test_regression.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002074/tests/test_command.sh b/tasks/format-code-task-002074/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002074/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002080/environment/Dockerfile b/tasks/format-code-task-002080/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f7dc85dca5438535ef7c87cc8bf61232e5fe9147 --- /dev/null +++ b/tasks/format-code-task-002080/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0f30e1f66da696a0ab7cc1108e6a0add6ec8a96765a84c8c3d83f36aa9a37278 diff --git a/tasks/format-code-task-002080/environment/setup/files/blocklist b/tasks/format-code-task-002080/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002080/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002080/environment/setup/setup.sh b/tasks/format-code-task-002080/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002080/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002080/tests/test.sh b/tasks/format-code-task-002080/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..613daf5e603d8be7b10b74f151e6ab97bae66146 --- /dev/null +++ b/tasks/format-code-task-002080/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/preconnect.test.js +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002088/environment/Dockerfile b/tasks/format-code-task-002088/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..284345979cfb1d7888c6512110199ca6dcab8e17 --- /dev/null +++ b/tasks/format-code-task-002088/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:97f8d9f55249b802086cbeb284b6f51efbe071ebd73cfb870bcb0652a002d77a diff --git a/tasks/format-code-task-002088/environment/setup/files/blocklist b/tasks/format-code-task-002088/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002088/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002088/environment/setup/setup.sh b/tasks/format-code-task-002088/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002088/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002088/tests/test.patch b/tasks/format-code-task-002088/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..42ba673ededaebb3d9a98ec0d16f47456066f563 --- /dev/null +++ b/tasks/format-code-task-002088/tests/test.patch @@ -0,0 +1,275 @@ +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,253 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++ ++PYTHON=/workspace/repo/.venv/bin/python ++[ -x "$PYTHON" ] || fail "missing preinstalled Python venv" ++ ++BIN=("$PYTHON" -m ocrmypdf) ++PLUGIN=/workspace/repo/tests/plugins/tesseract_noop.py ++ ++TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" || fail "cd temp" ++ ++run_ocrmypdf() { ++ "${BIN[@]}" "$@" ++} ++ ++pdf_summary() { ++ "$PYTHON" - "$1" <<'PY' ++from decimal import Decimal ++import sys ++import pikepdf ++ ++pdf = pikepdf.open(sys.argv[1]) ++ ++def fmt(value): ++ text = format(value, 'f') if isinstance(value, Decimal) else str(value) ++ return text.rstrip('0').rstrip('.') if '.' in text else text ++ ++print(f"pages={len(pdf.pages)}") ++print("mediabox=" + ",".join(fmt(v) for v in pdf.pages[0].MediaBox)) ++PY ++} ++ ++assert_pdf_layout() { ++ "$PYTHON" - "$1" "$2" "$3" "$4" <<'PY' ++import sys ++import pikepdf ++ ++path, expected_width, expected_height, label = sys.argv[1], float(sys.argv[2]), float(sys.argv[3]), sys.argv[4] ++pdf = pikepdf.open(path) ++if len(pdf.pages) != 1: ++ raise SystemExit(f"{label}: pages={len(pdf.pages)}; want 1") ++box = [float(v) for v in pdf.pages[0].MediaBox] ++width = box[2] - box[0] ++height = box[3] - box[1] ++if abs(width - expected_width) > 0.05 or abs(height - expected_height) > 0.05: ++ raise SystemExit(f"{label}: mediabox width={width:.4f} height={height:.4f}; want {expected_width}x{expected_height}") ++PY ++} ++ ++require_no_traceback() { ++ ! grep -Fq "Traceback" out err || fail "$1 emitted traceback" ++} ++ ++require_err_regex() { ++ local label=$1 ++ local pattern=$2 ++ grep -Eiq -- "$pattern" err || fail "$label" ++} ++ ++"$PYTHON" - "$TMP" <<'PY' || fail "fixture generation" ++from pathlib import Path ++from PIL import Image ++ ++root = Path(__import__('sys').argv[1]) ++Image.new('RGB', (100, 50), 'white').save(root / 'nodpi_rgb.png') ++Image.new('RGB', (120, 60), 'white').save(root / 'embedded_300.png', dpi=(300, 300)) ++Image.new('RGB', (80, 40), 'white').save(root / 'low_30.png', dpi=(30, 30)) ++Image.new('RGB', (90, 30), 'white').save(root / 'low_override.png', dpi=(30, 30)) ++Image.new('RGB', (64, 32), 'white').save(root / 'stdin_rgb.png') ++Image.new('RGBA', (10, 10), (255, 0, 0, 128)).save(root / 'rgba.png') ++Image.new('LA', (10, 10), (255, 128)).save(root / 'la.png') ++Image.new('CMYK', (10, 10), (0, 255, 255, 0)).save(root / 'cmyk_no_icc.jpg') ++(root / 'empty.bin').write_bytes(b'') ++(root / 'regular_nonimage.bin').write_bytes(b'not a pdf or image\n') ++(root / 'input_dir').mkdir() ++PY ++ ++ ++ ++ ++run_ocrmypdf --image-dpi 200 --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/nodpi_rgb.png" "$TMP/f1.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++require_no_traceback F1 ++[ -s "$TMP/f1.pdf" ] || fail "F1 did not create output PDF" ++ ++assert_pdf_layout "$TMP/f1.pdf" 36 18 F1 || fail "F1 PDF summary: $(pdf_summary "$TMP/f1.pdf")" ++ ++ ++ ++ ++run_ocrmypdf --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/embedded_300.png" "$TMP/f2.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++ ++require_no_traceback F2 ++[ -s "$TMP/f2.pdf" ] || fail "F2 did not create output PDF" ++ ++assert_pdf_layout "$TMP/f2.pdf" 28.8 14.4 F2 || fail "F2 PDF summary: $(pdf_summary "$TMP/f2.pdf")" ++ ++ ++ ++ ++run_ocrmypdf --image-dpi 150 --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/low_override.png" "$TMP/f3.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++ ++require_no_traceback F3 ++[ -s "$TMP/f3.pdf" ] || fail "F3 did not create output PDF" ++ ++assert_pdf_layout "$TMP/f3.pdf" 43.2 14.4 F3 || fail "F3 PDF summary: $(pdf_summary "$TMP/f3.pdf")" ++ ++ ++ ++ ++run_ocrmypdf --image-dpi 100 --output-type pdf --plugin "$PLUGIN" \ ++ - "$TMP/f4.pdf" <"$TMP/stdin_rgb.png" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++ ++require_no_traceback F4 ++[ -s "$TMP/f4.pdf" ] || fail "F4 did not create output PDF" ++ ++assert_pdf_layout "$TMP/f4.pdf" 46.08 23.04 F4 || fail "F4 PDF summary: $(pdf_summary "$TMP/f4.pdf")" ++ ++ ++ ++ ++run_ocrmypdf --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/nodpi_rgb.png" "$TMP/f5.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 2 ] || fail "F5 exit $ec; want 2" ++ ++require_no_traceback F5 ++ ++require_err_regex "F5 missing no-DPI error" "(no|missing|without|lacks|does not have).*(dpi|resolution)|(dpi|resolution).*(no|missing|without|lacks|does not have)" ++require_err_regex "F5 missing estimate instruction" "estimate" ++require_err_regex "F5 missing --image-dpi instruction" "--image-dpi" ++[ ! -e "$TMP/f5.pdf" ] || fail "F5 created output PDF" ++ ++ ++ ++ ++run_ocrmypdf --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/low_30.png" "$TMP/f6.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 2 ] || fail "F6 exit $ec; want 2" ++ ++require_no_traceback F6 ++ ++require_err_regex "F6 missing not-credible error" "(not credible|low|too low|invalid|unusable).*(dpi|resolution)|(dpi|resolution).*(not credible|low|too low|invalid|unusable)" ++require_err_regex "F6 missing estimate instruction" "estimate" ++require_err_regex "F6 missing --image-dpi instruction" "--image-dpi" ++[ ! -e "$TMP/f6.pdf" ] || fail "F6 created output PDF" ++ ++ ++ ++ ++run_ocrmypdf --image-dpi 200 --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/rgba.png" "$TMP/f7.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 2 ] || fail "F7 exit $ec; want 2" ++ ++require_no_traceback F7 ++ ++require_err_regex "F7 missing alpha error" "alpha" ++require_err_regex "F7 missing alpha-removal guidance" "remov" ++[ ! -e "$TMP/f7.pdf" ] || fail "F7 created output PDF" ++ ++ ++ ++ ++run_ocrmypdf --image-dpi 200 --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/la.png" "$TMP/f8.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 2 ] || fail "F8 exit $ec; want 2" ++ ++require_no_traceback F8 ++ ++require_err_regex "F8 missing alpha error" "alpha" ++require_err_regex "F8 missing alpha-removal guidance" "remov" ++[ ! -e "$TMP/f8.pdf" ] || fail "F8 created output PDF" ++ ++ ++ ++ ++run_ocrmypdf --image-dpi 200 --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/cmyk_no_icc.jpg" "$TMP/f9.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 2 ] || fail "F9 exit $ec; want 2" ++ ++require_no_traceback F9 ++ ++require_err_regex "F9 missing CMYK ICC error" "cmyk" ++require_err_regex "F9 missing ICC-profile error" "icc" ++require_err_regex "F9 missing no-ICC wording" "no|missing|without|lacks|does not have" ++[ ! -e "$TMP/f9.pdf" ] || fail "F9 created output PDF" ++ ++ ++ ++ ++run_ocrmypdf --image-dpi 200 --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/empty.bin" "$TMP/f10.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 2 ] || fail "F10 exit $ec; want 2" ++ ++require_no_traceback F10 ++ ++require_err_regex "F10 missing unreadable-image diagnostic" "image|unsupported|readable|identify" ++require_err_regex "F10 missing regular-file diagnostic" "regular[ -]file|is a file|file is regular" ++require_err_regex "F10 missing empty-file diagnostic" "empty" ++[ ! -e "$TMP/f10.pdf" ] || fail "F10 created output PDF" ++ ++ ++ ++ ++run_ocrmypdf --image-dpi 200 --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/regular_nonimage.bin" "$TMP/f11.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 2 ] || fail "F11 exit $ec; want 2" ++ ++require_no_traceback F11 ++ ++require_err_regex "F11 missing unreadable-image diagnostic" "image|unsupported|readable|identify" ++require_err_regex "F11 missing regular-file diagnostic" "regular[ -]file|is a file|file is regular" ++[ ! -e "$TMP/f11.pdf" ] || fail "F11 created output PDF" ++ ++ ++ ++ ++run_ocrmypdf --image-dpi 200 --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/input_dir" "$TMP/f12.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 2 ] || fail "F12 exit $ec; want 2" ++ ++require_no_traceback F12 ++ ++require_err_regex "F12 missing directory diagnostic" "dir|directory" ++[ ! -e "$TMP/f12.pdf" ] || fail "F12 created output PDF" ++ ++ ++ ++ ++run_ocrmypdf --image-dpi 200 --output-type pdf --plugin "$PLUGIN" \ ++ "$TMP/missing.bin" "$TMP/f13.pdf" >out 2>err; ec=$? ++[ "$ec" -eq 2 ] || fail "F13 exit $ec; want 2" ++ ++require_no_traceback F13 ++ ++require_err_regex "F13 missing not-found diagnostic" "not found|missing|does not exist|no such file" ++require_err_regex "F13 missing input filename diagnostic" "missing\\.bin" ++[ ! -e "$TMP/f13.pdf" ] || fail "F13 created output PDF" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,12 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-002088/tests/test.sh b/tasks/format-code-task-002088/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-002088/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/usecase.sh +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002088/tests/test_command.sh b/tasks/format-code-task-002088/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002088/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002089/environment/Dockerfile b/tasks/format-code-task-002089/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9d00425c190663dad30f4053e03b22cc3aa16a2e --- /dev/null +++ b/tasks/format-code-task-002089/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1c66d4cb6ad8d5a9d68a791a610766b400af38a86b4b2a6c3b7cf883546ea013 diff --git a/tasks/format-code-task-002089/environment/setup/files/blocklist b/tasks/format-code-task-002089/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002089/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002089/environment/setup/setup.sh b/tasks/format-code-task-002089/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002089/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002089/tests/test.patch b/tasks/format-code-task-002089/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2f62f6ead1322158b39857448f4577136bf9793c --- /dev/null +++ b/tasks/format-code-task-002089/tests/test.patch @@ -0,0 +1,498 @@ +diff --git a/tests/config/unit.tests.yaml b/tests/config/unit.tests.yaml +index 5241406f5..1da24656b 100644 +--- a/tests/config/unit.tests.yaml ++++ b/tests/config/unit.tests.yaml +@@ -56,11 +56,23 @@ cname: + ttl: 300 + type: CNAME + value: unit.tests. ++excluded: ++ octodns: ++ excluded: ++ - test ++ type: CNAME ++ value: unit.tests. + ignored: + octodns: + ignored: true + type: A + value: 9.9.9.9 ++included: ++ octodns: ++ included: ++ - test ++ type: CNAME ++ value: unit.tests. + mx: + ttl: 300 + type: MX +diff --git a/tests/fixtures/cloudflare-dns_records-page-2.json b/tests/fixtures/cloudflare-dns_records-page-2.json +index 195d6deb4..150951bc7 100644 +--- a/tests/fixtures/cloudflare-dns_records-page-2.json ++++ b/tests/fixtures/cloudflare-dns_records-page-2.json +@@ -139,14 +139,31 @@ + "meta": { + "auto_added": false + } ++ }, ++ { ++ "id": "fc12ab34cd5611334422ab3322997656", ++ "type": "CNAME", ++ "name": "included.unit.tests", ++ "content": "unit.tests", ++ "proxiable": true, ++ "proxied": false, ++ "ttl": 3600, ++ "locked": false, ++ "zone_id": "ff12ab34cd5611334422ab3322997650", ++ "zone_name": "unit.tests", ++ "modified_on": "2017-03-11T18:01:43.940682Z", ++ "created_on": "2017-03-11T18:01:43.940682Z", ++ "meta": { ++ "auto_added": false ++ } + } + ], + "result_info": { + "page": 2, + "per_page": 10, + "total_pages": 2, +- "count": 8, +- "total_count": 19 ++ "count": 9, ++ "total_count": 20 + }, + "success": true, + "errors": [], +diff --git a/tests/fixtures/dnsimple-page-2.json b/tests/fixtures/dnsimple-page-2.json +index 40aaa4899..a42c393e1 100644 +--- a/tests/fixtures/dnsimple-page-2.json ++++ b/tests/fixtures/dnsimple-page-2.json +@@ -175,12 +175,28 @@ + "system_record": false, + "created_at": "2017-03-09T15:55:09Z", + "updated_at": "2017-03-09T15:55:09Z" ++ }, ++ { ++ "id": 12188805, ++ "zone_id": "unit.tests", ++ "parent_id": null, ++ "name": "included", ++ "content": "unit.tests", ++ "ttl": 3600, ++ "priority": null, ++ "type": "CNAME", ++ "regions": [ ++ "global" ++ ], ++ "system_record": false, ++ "created_at": "2017-03-09T15:55:09Z", ++ "updated_at": "2017-03-09T15:55:09Z" + } + ], + "pagination": { + "current_page": 2, + "per_page": 20, +- "total_entries": 30, ++ "total_entries": 32, + "total_pages": 2 + } + } +diff --git a/tests/fixtures/powerdns-full-data.json b/tests/fixtures/powerdns-full-data.json +index b8f8bf35b..3d445d47c 100644 +--- a/tests/fixtures/powerdns-full-data.json ++++ b/tests/fixtures/powerdns-full-data.json +@@ -242,6 +242,18 @@ + ], + "ttl": 3600, + "type": "CAA" ++ }, ++ { ++ "comments": [], ++ "name": "included.unit.tests.", ++ "records": [ ++ { ++ "content": "unit.tests.", ++ "disabled": false ++ } ++ ], ++ "ttl": 3600, ++ "type": "CNAME" + } + ], + "serial": 2017012803, +diff --git a/tests/helpers.py b/tests/helpers.py +index adac81d4d..632f25882 100644 +--- a/tests/helpers.py ++++ b/tests/helpers.py +@@ -18,6 +18,7 @@ def __init__(self, id='test'): + class SimpleProvider(object): + SUPPORTS_GEO = False + SUPPORTS = set(('A',)) ++ id = 'test' + + def __init__(self, id='test'): + pass +@@ -34,6 +35,7 @@ def __repr__(self): + + class GeoProvider(object): + SUPPORTS_GEO = True ++ id = 'test' + + def __init__(self, id='test'): + pass +diff --git a/tests/test_octodns_manager.py b/tests/test_octodns_manager.py +index a5f2022e9..36b1f4c44 100644 +--- a/tests/test_octodns_manager.py ++++ b/tests/test_octodns_manager.py +@@ -102,12 +102,12 @@ def test_simple(self): + environ['YAML_TMP_DIR'] = tmpdir.dirname + tc = Manager(get_config_filename('simple.yaml')) \ + .sync(dry_run=False) +- self.assertEquals(19, tc) ++ self.assertEquals(20, tc) + + # try with just one of the zones + tc = Manager(get_config_filename('simple.yaml')) \ + .sync(dry_run=False, eligible_zones=['unit.tests.']) +- self.assertEquals(13, tc) ++ self.assertEquals(14, tc) + + # the subzone, with 2 targets + tc = Manager(get_config_filename('simple.yaml')) \ +@@ -122,18 +122,18 @@ def test_simple(self): + # Again with force + tc = Manager(get_config_filename('simple.yaml')) \ + .sync(dry_run=False, force=True) +- self.assertEquals(19, tc) ++ self.assertEquals(20, tc) + + # Again with max_workers = 1 + tc = Manager(get_config_filename('simple.yaml'), max_workers=1) \ + .sync(dry_run=False, force=True) +- self.assertEquals(19, tc) ++ self.assertEquals(20, tc) + + # Include meta + tc = Manager(get_config_filename('simple.yaml'), max_workers=1, + include_meta=True) \ + .sync(dry_run=False, force=True) +- self.assertEquals(23, tc) ++ self.assertEquals(24, tc) + + def test_eligible_targets(self): + with TemporaryDirectory() as tmpdir: +@@ -159,13 +159,13 @@ def test_compare(self): + fh.write('---\n{}') + + changes = manager.compare(['in'], ['dump'], 'unit.tests.') +- self.assertEquals(13, len(changes)) ++ self.assertEquals(14, len(changes)) + + # Compound sources with varying support + changes = manager.compare(['in', 'nosshfp'], + ['dump'], + 'unit.tests.') +- self.assertEquals(12, len(changes)) ++ self.assertEquals(13, len(changes)) + + with self.assertRaises(Exception) as ctx: + manager.compare(['nope'], ['dump'], 'unit.tests.') +diff --git a/tests/test_octodns_provider_base.py b/tests/test_octodns_provider_base.py +index fde139688..1bf3fd754 100644 +--- a/tests/test_octodns_provider_base.py ++++ b/tests/test_octodns_provider_base.py +@@ -17,6 +17,7 @@ class HelperProvider(BaseProvider): + log = getLogger('HelperProvider') + + SUPPORTS = set(('A',)) ++ id = 'test' + + def __init__(self, extra_changes, apply_disabled=False, + include_change_callback=None): +diff --git a/tests/test_octodns_provider_cloudflare.py b/tests/test_octodns_provider_cloudflare.py +index 04a46e00c..ef8a51c63 100644 +--- a/tests/test_octodns_provider_cloudflare.py ++++ b/tests/test_octodns_provider_cloudflare.py +@@ -118,7 +118,7 @@ def test_populate(self): + + zone = Zone('unit.tests.', []) + provider.populate(zone) +- self.assertEquals(10, len(zone.records)) ++ self.assertEquals(11, len(zone.records)) + + changes = self.expected.changes(zone, provider) + self.assertEquals(0, len(changes)) +@@ -126,7 +126,7 @@ def test_populate(self): + # re-populating the same zone/records comes out of cache, no calls + again = Zone('unit.tests.', []) + provider.populate(again) +- self.assertEquals(10, len(again.records)) ++ self.assertEquals(11, len(again.records)) + + def test_apply(self): + provider = CloudflareProvider('test', 'email', 'token') +@@ -140,12 +140,12 @@ def test_apply(self): + 'id': 42, + } + }, # zone create +- ] + [None] * 17 # individual record creates ++ ] + [None] * 18 + + # non-existant zone, create everything + plan = provider.plan(self.expected) +- self.assertEquals(10, len(plan.changes)) +- self.assertEquals(10, provider.apply(plan)) ++ self.assertEquals(11, len(plan.changes)) ++ self.assertEquals(11, provider.apply(plan)) + + provider._request.assert_has_calls([ + # created the domain +@@ -170,7 +170,7 @@ def test_apply(self): + }), + ], True) + # expected number of total calls +- self.assertEquals(19, provider._request.call_count) ++ self.assertEquals(20, provider._request.call_count) + + provider._request.reset_mock() + +diff --git a/tests/test_octodns_provider_dnsimple.py b/tests/test_octodns_provider_dnsimple.py +index b44d6eef4..60dacf1c7 100644 +--- a/tests/test_octodns_provider_dnsimple.py ++++ b/tests/test_octodns_provider_dnsimple.py +@@ -78,14 +78,14 @@ def test_populate(self): + + zone = Zone('unit.tests.', []) + provider.populate(zone) +- self.assertEquals(15, len(zone.records)) ++ self.assertEquals(16, len(zone.records)) + changes = self.expected.changes(zone, provider) + self.assertEquals(0, len(changes)) + + # 2nd populate makes no network calls/all from cache + again = Zone('unit.tests.', []) + provider.populate(again) +- self.assertEquals(15, len(again.records)) ++ self.assertEquals(16, len(again.records)) + + # bust the cache + del provider._zone_records[zone.name] +@@ -129,8 +129,8 @@ def test_apply(self): + ] + plan = provider.plan(self.expected) + +- # No root NS, no ignored +- n = len(self.expected.records) - 2 ++ ++ n = len(self.expected.records) - 3 + self.assertEquals(n, len(plan.changes)) + self.assertEquals(n, provider.apply(plan)) + +@@ -147,7 +147,7 @@ def test_apply(self): + }), + ]) + # expected number of total calls +- self.assertEquals(27, provider._client._request.call_count) ++ self.assertEquals(28, provider._client._request.call_count) + + provider._client._request.reset_mock() + +diff --git a/tests/test_octodns_provider_powerdns.py b/tests/test_octodns_provider_powerdns.py +index b6e02ff8b..22ccdd651 100644 +--- a/tests/test_octodns_provider_powerdns.py ++++ b/tests/test_octodns_provider_powerdns.py +@@ -78,8 +78,8 @@ def test_provider(self): + expected = Zone('unit.tests.', []) + source = YamlProvider('test', join(dirname(__file__), 'config')) + source.populate(expected) +- expected_n = len(expected.records) - 1 +- self.assertEquals(15, expected_n) ++ expected_n = len(expected.records) - 2 ++ self.assertEquals(16, expected_n) + + # No diffs == no changes + with requests_mock() as mock: +@@ -87,7 +87,7 @@ def test_provider(self): + + zone = Zone('unit.tests.', []) + provider.populate(zone) +- self.assertEquals(15, len(zone.records)) ++ self.assertEquals(16, len(zone.records)) + changes = expected.changes(zone, provider) + self.assertEquals(0, len(changes)) + +@@ -167,7 +167,7 @@ def test_small_change(self): + expected = Zone('unit.tests.', []) + source = YamlProvider('test', join(dirname(__file__), 'config')) + source.populate(expected) +- self.assertEquals(16, len(expected.records)) ++ self.assertEquals(18, len(expected.records)) + + # A small change to a single record + with requests_mock() as mock: +diff --git a/tests/test_octodns_provider_yaml.py b/tests/test_octodns_provider_yaml.py +index 36cd8d64f..a199355cb 100644 +--- a/tests/test_octodns_provider_yaml.py ++++ b/tests/test_octodns_provider_yaml.py +@@ -30,7 +30,7 @@ def test_provider(self): + + # without it we see everything + source.populate(zone) +- self.assertEquals(16, len(zone.records)) ++ self.assertEquals(18, len(zone.records)) + + # Assumption here is that a clean round-trip means that everything + # worked as expected, data that went in came back out and could be +@@ -49,12 +49,12 @@ def test_provider(self): + + # We add everything + plan = target.plan(zone) +- self.assertEquals(13, len(filter(lambda c: isinstance(c, Create), ++ self.assertEquals(14, len(filter(lambda c: isinstance(c, Create), + plan.changes))) + self.assertFalse(isfile(yaml_file)) + + # Now actually do it +- self.assertEquals(13, target.apply(plan)) ++ self.assertEquals(14, target.apply(plan)) + self.assertTrue(isfile(yaml_file)) + + # There should be no changes after the round trip +@@ -64,7 +64,7 @@ def test_provider(self): + + # A 2nd sync should still create everything + plan = target.plan(zone) +- self.assertEquals(13, len(filter(lambda c: isinstance(c, Create), ++ self.assertEquals(14, len(filter(lambda c: isinstance(c, Create), + plan.changes))) + + with open(yaml_file) as fh: +diff --git a/tests/test_octodns_zone.py b/tests/test_octodns_zone.py +index 8d75100ab..94faef398 100644 +--- a/tests/test_octodns_zone.py ++++ b/tests/test_octodns_zone.py +@@ -236,3 +236,102 @@ def test_cname_coexisting(self): + zone.add_record(cname) + with self.assertRaises(InvalidNodeException): + zone.add_record(a) ++ ++ def test_excluded_records(self): ++ zone_normal = Zone('unit.tests.', []) ++ zone_excluded = Zone('unit.tests.', []) ++ zone_missing = Zone('unit.tests.', []) ++ ++ normal = Record.new(zone_normal, 'www', { ++ 'ttl': 60, ++ 'type': 'A', ++ 'value': '9.9.9.9', ++ }) ++ zone_normal.add_record(normal) ++ ++ excluded = Record.new(zone_excluded, 'www', { ++ 'octodns': { ++ 'excluded': ['test'] ++ }, ++ 'ttl': 60, ++ 'type': 'A', ++ 'value': '9.9.9.9', ++ }) ++ zone_excluded.add_record(excluded) ++ ++ provider = SimpleProvider() ++ ++ self.assertFalse(zone_normal.changes(zone_excluded, provider)) ++ self.assertTrue(zone_normal.changes(zone_missing, provider)) ++ ++ self.assertFalse(zone_excluded.changes(zone_normal, provider)) ++ self.assertFalse(zone_excluded.changes(zone_missing, provider)) ++ ++ self.assertTrue(zone_missing.changes(zone_normal, provider)) ++ self.assertFalse(zone_missing.changes(zone_excluded, provider)) ++ ++ def test_included_records(self): ++ zone_normal = Zone('unit.tests.', []) ++ zone_included = Zone('unit.tests.', []) ++ zone_missing = Zone('unit.tests.', []) ++ ++ normal = Record.new(zone_normal, 'www', { ++ 'ttl': 60, ++ 'type': 'A', ++ 'value': '9.9.9.9', ++ }) ++ zone_normal.add_record(normal) ++ ++ included = Record.new(zone_included, 'www', { ++ 'octodns': { ++ 'included': ['test'] ++ }, ++ 'ttl': 60, ++ 'type': 'A', ++ 'value': '9.9.9.9', ++ }) ++ zone_included.add_record(included) ++ ++ provider = SimpleProvider() ++ ++ self.assertFalse(zone_normal.changes(zone_included, provider)) ++ self.assertTrue(zone_normal.changes(zone_missing, provider)) ++ ++ self.assertFalse(zone_included.changes(zone_normal, provider)) ++ self.assertTrue(zone_included.changes(zone_missing, provider)) ++ ++ self.assertTrue(zone_missing.changes(zone_normal, provider)) ++ self.assertTrue(zone_missing.changes(zone_included, provider)) ++ ++ def test_not_included_records(self): ++ zone_normal = Zone('unit.tests.', []) ++ zone_included = Zone('unit.tests.', []) ++ zone_missing = Zone('unit.tests.', []) ++ ++ normal = Record.new(zone_normal, 'www', { ++ 'ttl': 60, ++ 'type': 'A', ++ 'value': '9.9.9.9', ++ }) ++ zone_normal.add_record(normal) ++ ++ included = Record.new(zone_included, 'www', { ++ 'octodns': { ++ 'included': ['not-here'] ++ }, ++ 'ttl': 60, ++ 'type': 'A', ++ 'value': '9.9.9.9', ++ }) ++ zone_included.add_record(included) ++ ++ provider = SimpleProvider() ++ ++ self.assertFalse(zone_normal.changes(zone_included, provider)) ++ self.assertTrue(zone_normal.changes(zone_missing, provider)) ++ ++ self.assertFalse(zone_included.changes(zone_normal, provider)) ++ self.assertFalse(zone_included.changes(zone_missing, provider)) ++ ++ self.assertTrue(zone_missing.changes(zone_normal, provider)) ++ self.assertFalse(zone_missing.changes(zone_included, provider)) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3S3U7DIBgG4B73KjAe7Gj92Up7OQ0FdE0oNEBrtqsfwxiNOjnZYozvc1AofAGS ++9yuGZVSil3ots3upgo7SOAafxziv6a6u245Wuy6rwqzqMkLv9qIPFueZJSSzxvif6lL7f1Txnr+X ++zvfcTBPTonCH292Ryr+h+7f8m66tQ/5Nu68zUt3uCdf98/wfH8ph1OXA3CHngsQmGKTILwtkqzjZ ++aOPkZdWR+H1tE8O9Edr1oVfYs7TFfPxud7ZmHYW0fThNpmq4Mot4UswmK8PPOM0qWTebF2nDSqru ++yCZ1peZkdLxmu27y344KAAAAAAAAAAAAAAAAAAAAAOCLM9km9p4AKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002089/tests/test.sh b/tasks/format-code-task-002089/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0992f18b135a00cf9486caabcf9866275a8c33df --- /dev/null +++ b/tasks/format-code-task-002089/tests/test.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/config/unit.tests.yaml +tests/fixtures/cloudflare-dns_records-page-2.json +tests/fixtures/dnsimple-page-2.json +tests/fixtures/powerdns-full-data.json +tests/helpers.py +tests/test_octodns_manager.py +tests/test_octodns_provider_base.py +tests/test_octodns_provider_cloudflare.py +tests/test_octodns_provider_dnsimple.py +tests/test_octodns_provider_powerdns.py +tests/test_octodns_provider_yaml.py +tests/test_octodns_zone.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002089/tests/test_command.sh b/tasks/format-code-task-002089/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002089/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002212/environment/Dockerfile b/tasks/format-code-task-002212/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9fa2a665b1ed5ed04d5229ab67ba7af969127f7c --- /dev/null +++ b/tasks/format-code-task-002212/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2e43a4fd448322ba16f58499cf2cfc249ac26bc9c4823da387c8a8282a7e05f4 diff --git a/tasks/format-code-task-002212/environment/setup/files/blocklist b/tasks/format-code-task-002212/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002212/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002212/environment/setup/setup.sh b/tasks/format-code-task-002212/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002212/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002212/tests/test.patch b/tasks/format-code-task-002212/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0c036d9729e8b251c1427aefa648aa23bdbfe51b --- /dev/null +++ b/tasks/format-code-task-002212/tests/test.patch @@ -0,0 +1,90 @@ +diff --git a/pandas/tests/io/parser/test_common.py b/pandas/tests/io/parser/test_common.py +index e38fcf1380..978984de26 100644 +--- a/pandas/tests/io/parser/test_common.py ++++ b/pandas/tests/io/parser/test_common.py +@@ -2135,3 +2135,63 @@ def test_no_header_two_extra_columns(all_parsers): + parser = all_parsers + df = parser.read_csv(stream, header=None, names=column_names, index_col=False) + tm.assert_frame_equal(df, ref) ++ ++ ++def test_read_csv_names_set_raises(all_parsers): ++ ++ parser = all_parsers ++ data = "1,TRUE\n2,FALSE\n3,TRUE\n" ++ with pytest.raises((ValueError, TypeError), match="Names should be an ordered collection"): ++ parser.read_csv(StringIO(data), names={"pVal1", "pClass"}) ++ ++ ++def test_read_csv_names_set_with_dtype_raises(all_parsers): ++ ++ parser = all_parsers ++ data = "1,TRUE\n2,FALSE\n3,TRUE\n" ++ with pytest.raises((ValueError, TypeError), match="Names should be an ordered collection"): ++ parser.read_csv( ++ StringIO(data), ++ names={"pVal1", "pClass"}, ++ dtype={"pVal1": int, "pClass": bool}, ++ ) ++ ++ ++def test_read_csv_names_frozenset_raises(all_parsers): ++ ++ parser = all_parsers ++ data = "1,TRUE\n2,FALSE\n3,TRUE\n" ++ with pytest.raises((ValueError, TypeError), match="Names should be an ordered collection"): ++ parser.read_csv(StringIO(data), names=frozenset({"pVal1", "pClass"})) ++ ++ ++def test_read_csv_names_list_with_dtype(all_parsers): ++ ++ parser = all_parsers ++ data = "1,TRUE\n2,FALSE\n3,TRUE\n" ++ result = parser.read_csv( ++ StringIO(data), ++ names=["pVal1", "pClass"], ++ dtype={"pVal1": int, "pClass": bool}, ++ ) ++ expected = DataFrame( ++ {"pVal1": [1, 2, 3], "pClass": [True, False, True]}, ++ ) ++ tm.assert_frame_equal(result, expected) ++ ++ ++def test_read_csv_names_tuple(all_parsers): ++ ++ parser = all_parsers ++ data = "1,2\n3,4\n" ++ result = parser.read_csv(StringIO(data), names=("a", "b")) ++ expected = DataFrame({"a": [1, 3], "b": [2, 4]}) ++ tm.assert_frame_equal(result, expected) ++ ++ ++def test_read_csv_duplicate_names_still_raises(all_parsers): ++ ++ parser = all_parsers ++ data = "1,2,3\n4,5,6\n" ++ with pytest.raises(ValueError, match="Duplicate names are not allowed"): ++ parser.read_csv(StringIO(data), names=["a", "b", "a"]) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..ab08e8a5cc +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pandas/tests/io/parser/test_common.py -k \"names_set or names_frozenset or names_list_with_dtype or names_tuple or duplicate_names_still\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest pandas/tests/io/parser/test_common.py -k "names_set or names_frozenset or names_list_with_dtype or names_tuple or duplicate_names_still" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002212/tests/test.sh b/tasks/format-code-task-002212/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b570339ecc69d53c903d8e92352d5da40dc1c3e9 --- /dev/null +++ b/tasks/format-code-task-002212/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pandas/tests/io/parser/test_common.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002212/tests/test_command.sh b/tasks/format-code-task-002212/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002212/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002215/environment/Dockerfile b/tasks/format-code-task-002215/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..56dda83a5206eb0fd1dacfd9c25a8118a8430216 --- /dev/null +++ b/tasks/format-code-task-002215/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:720f3816c20b13014bde1e65825de7e5fed974d25b6a6c194ec5a7257821d18b diff --git a/tasks/format-code-task-002215/environment/setup/files/blocklist b/tasks/format-code-task-002215/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002215/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002215/environment/setup/setup.sh b/tasks/format-code-task-002215/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002215/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002215/tests/test.patch b/tasks/format-code-task-002215/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7599f4d3cb2063821e6c860d1cc7db9de12c0344 --- /dev/null +++ b/tasks/format-code-task-002215/tests/test.patch @@ -0,0 +1,107 @@ +diff --git a/pandas/tests/series/indexing/test_setitem.py b/pandas/tests/series/indexing/test_setitem.py +index 967cf5c558..5223189927 100644 +--- a/pandas/tests/series/indexing/test_setitem.py ++++ b/pandas/tests/series/indexing/test_setitem.py +@@ -162,3 +162,80 @@ class TestSetitemCallable: + + expected = Series([1, 2, inc, 4]) + tm.assert_series_equal(ser, expected) ++ ++ ++class TestSetitemSeriesValueNoAlignment: ++ ++ ++ ++ def test_setitem_with_series_indexer_does_not_align_value_by_index(self): ++ ++ S1 = Series( ++ [0, 1, -12, 3, -10, 5, 6, 7, 8, -11, -13], dtype=np.int32 ++ ) ++ idx = Series([4, 9, 2, 10], dtype=np.int64) ++ value = Series([-10, -11, -12, -13], dtype=np.int32) ++ S1[idx] = value ++ ++ expected = Series( ++ [0, 1, -12, 3, -10, 5, 6, 7, 8, -11, -13], dtype=np.int32 ++ ) ++ tm.assert_series_equal(S1, expected) ++ ++ assert S1.dtype == np.int32 ++ ++ def test_setitem_with_list_indexer_does_not_align_value_by_index(self): ++ ++ S1 = Series( ++ [0, 1, -12, 3, -10, 5, 6, 7, 8, -11, -13], dtype=np.int32 ++ ) ++ S1[[4, 9, 2, 10]] = Series([-10, -11, -12, -13], dtype=np.int32) ++ ++ expected = Series( ++ [0, 1, -12, 3, -10, 5, 6, 7, 8, -11, -13], dtype=np.int32 ++ ) ++ tm.assert_series_equal(S1, expected) ++ assert S1.dtype == np.int32 ++ ++ def test_setitem_with_ndarray_indexer_does_not_align_value_by_index(self): ++ ++ S1 = Series( ++ [0, 1, -12, 3, -10, 5, 6, 7, 8, -11, -13], dtype=np.int32 ++ ) ++ S1[np.array([4, 9, 2, 10])] = Series( ++ [-10, -11, -12, -13], dtype=np.int32 ++ ) ++ ++ expected = Series( ++ [0, 1, -12, 3, -10, 5, 6, 7, 8, -11, -13], dtype=np.int32 ++ ) ++ tm.assert_series_equal(S1, expected) ++ assert S1.dtype == np.int32 ++ ++ def test_setitem_value_index_explicitly_different_is_ignored(self): ++ ++ ++ ++ ser = Series([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) ++ ++ value = Series([100, 200], index=[100, 200]) ++ ser[[1, 3]] = value ++ expected = Series([0, 100, 2, 200, 4, 5, 6, 7, 8, 9]) ++ tm.assert_series_equal(ser, expected) ++ ++ def test_setitem_fallback_to_positional_no_alignment(self): ++ ++ ++ ++ ser = Series([0, 1, 2, 3, 4], index=["a", "b", "c", "d", "e"]) ++ ser[[0, 2]] = Series([100, 200]) ++ expected = Series( ++ [100, 1, 200, 3, 4], index=["a", "b", "c", "d", "e"] ++ ) ++ tm.assert_series_equal(ser, expected) ++ ++ def test_setitem_with_list_indexer_missing_key_raises(self): ++ ++ ser = Series([0, 1, 2, 3, 4]) ++ with pytest.raises(KeyError, match="not in index"): ++ ser[[1, 100]] = Series([10, 20]) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..80e650510e +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pandas/tests/series/indexing/test_setitem.py::TestSetitemSeriesValueNoAlignment -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest pandas/tests/series/indexing/test_setitem.py::TestSetitemSeriesValueNoAlignment -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002215/tests/test.sh b/tasks/format-code-task-002215/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..21912ee1a8918d96f2b9ceb4168fc922c0167e93 --- /dev/null +++ b/tasks/format-code-task-002215/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pandas/tests/series/indexing/test_setitem.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002215/tests/test_command.sh b/tasks/format-code-task-002215/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002215/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002223/environment/Dockerfile b/tasks/format-code-task-002223/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..db671c1cdb180ac351cd6eeea36ab48d7a55e875 --- /dev/null +++ b/tasks/format-code-task-002223/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:88eca76b7a6590f804c18a6531aec418cf495186d33c1972509919409058db21 diff --git a/tasks/format-code-task-002223/environment/setup/files/blocklist b/tasks/format-code-task-002223/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002223/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002223/environment/setup/setup.sh b/tasks/format-code-task-002223/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002223/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002223/tests/test.patch b/tasks/format-code-task-002223/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..715b9613d3f7afeee8a24d247078fc719bfe0c65 --- /dev/null +++ b/tasks/format-code-task-002223/tests/test.patch @@ -0,0 +1,115 @@ +diff --git a/pandas/tests/tools/test_to_numeric.py b/pandas/tests/tools/test_to_numeric.py +index 643a5617ab..e10f22e717 100644 +--- a/pandas/tests/tools/test_to_numeric.py ++++ b/pandas/tests/tools/test_to_numeric.py +@@ -789,3 +789,88 @@ def test_to_numeric_scientific_notation(): + result = to_numeric("1.7e+308") + expected = np.float64(1.7e308) + assert result == expected ++ ++ ++ ++ ++ ++ ++ ++ ++def test_to_numeric_downcast_float_precision_loss_large_int_series(): ++ ++ ++ result = to_numeric(Series([608202549]), downcast="float") ++ expected = Series([608202549.0], dtype=np.float64) ++ tm.assert_series_equal(result, expected) ++ ++ ++def test_to_numeric_downcast_float_precision_loss_large_float_series(): ++ ++ result = to_numeric(Series([608202549.0]), downcast="float") ++ expected = Series([608202549.0], dtype=np.float64) ++ tm.assert_series_equal(result, expected) ++ ++ ++def test_to_numeric_downcast_float_precision_loss_list(): ++ ++ result = to_numeric([608202548, 608202549], downcast="float") ++ expected = np.array([608202548.0, 608202549.0], dtype=np.float64) ++ tm.assert_numpy_array_equal(result, expected) ++ ++ ++def test_to_numeric_downcast_float_at_16777216_boundary(): ++ ++ ++ result = to_numeric(Series([16777216]), downcast="float") ++ expected = Series([16777216.0], dtype=np.float32) ++ tm.assert_series_equal(result, expected) ++ ++ ++def test_to_numeric_downcast_float_at_16777217_boundary(): ++ ++ ++ result = to_numeric(Series([16777217]), downcast="float") ++ expected = Series([16777217.0], dtype=np.float64) ++ tm.assert_series_equal(result, expected) ++ ++ ++def test_to_numeric_downcast_float_small_loss_still_downcasts(): ++ ++ ++ result = to_numeric(Series([1000.1]), downcast="float") ++ assert result.dtype == np.float32 ++ ++ tm.assert_numpy_array_equal( ++ result.to_numpy(), np.array([1000.1], dtype=np.float32) ++ ) ++ ++ ++def test_to_numeric_downcast_float_small_ints_preserved(): ++ ++ result = to_numeric(Series([1, 2, 3]), downcast="float") ++ expected = Series([1.0, 2.0, 3.0], dtype=np.float32) ++ tm.assert_series_equal(result, expected) ++ ++ ++def test_to_numeric_downcast_float_small_floats_preserved(): ++ ++ result = to_numeric(Series([1.5, 2.5, 3.5]), downcast="float") ++ expected = Series([1.5, 2.5, 3.5], dtype=np.float32) ++ tm.assert_series_equal(result, expected) ++ ++ ++def test_to_numeric_downcast_float_with_nan(): ++ ++ result = to_numeric(Series([np.nan, 1.0, 2.0]), downcast="float") ++ assert result.dtype == np.float32 ++ assert np.isnan(result.iloc[0]) ++ assert result.iloc[1] == 1.0 ++ assert result.iloc[2] == 2.0 ++ ++ ++def test_to_numeric_downcast_float_scalar_unchanged(): ++ ++ ++ result = to_numeric(608202549, downcast="float") ++ assert result == 608202549 +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..ffb906bfd6 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pandas/tests/tools/test_to_numeric.py -k \"downcast_float_precision_loss or downcast_float_at_ or downcast_float_small_loss or downcast_float_small_ints or downcast_float_small_floats or downcast_float_with_nan or downcast_float_scalar\" -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest pandas/tests/tools/test_to_numeric.py -k "downcast_float_precision_loss or downcast_float_at_ or downcast_float_small_loss or downcast_float_small_ints or downcast_float_small_floats or downcast_float_with_nan or downcast_float_scalar" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002223/tests/test.sh b/tasks/format-code-task-002223/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..eef3a2645800bcd8e662013bfc3d47faf471ba54 --- /dev/null +++ b/tasks/format-code-task-002223/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pandas/tests/tools/test_to_numeric.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002223/tests/test_command.sh b/tasks/format-code-task-002223/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002223/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002224/environment/Dockerfile b/tasks/format-code-task-002224/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5c4a2a1cbdc92fb33925d19ba78fcd4151e0b471 --- /dev/null +++ b/tasks/format-code-task-002224/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8cb63ae35b8a3cba92a0c47fa00625be0482df6c18a3c02eae68512b37f98c01 diff --git a/tasks/format-code-task-002224/environment/setup/files/blocklist b/tasks/format-code-task-002224/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002224/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002224/environment/setup/setup.sh b/tasks/format-code-task-002224/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002224/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002224/tests/test.patch b/tasks/format-code-task-002224/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e38ba4a10a989ed3e30025c01c80db56c369eac9 --- /dev/null +++ b/tasks/format-code-task-002224/tests/test.patch @@ -0,0 +1,111 @@ +diff --git a/pandas/tests/arrays/test_timedeltas.py b/pandas/tests/arrays/test_timedeltas.py +index 9832977624..160a2e5ef0 100644 +--- a/pandas/tests/arrays/test_timedeltas.py ++++ b/pandas/tests/arrays/test_timedeltas.py +@@ -127,3 +127,84 @@ class TestUnaryOps: + + result2 = np.negative(arr) + tm.assert_timedelta_array_equal(result2, expected) ++ ++ ++class TestDivisionByObjectArray: ++ ++ ++ ++ def test_truediv_allnat_object_returns_timedelta_array(self): ++ ++ arr = pd.array(["NaT", "NaT"], dtype="timedelta64[ns]") ++ result = arr / np.array([2, 2], dtype=object) ++ expected = pd.array(["NaT", "NaT"], dtype="timedelta64[ns]") ++ assert isinstance(result, TimedeltaArray) ++ assert result.dtype == np.dtype("timedelta64[ns]") ++ tm.assert_timedelta_array_equal(result, expected) ++ ++ def test_floordiv_allnat_object_returns_timedelta_array(self): ++ ++ arr = pd.array(["NaT", "NaT"], dtype="timedelta64[ns]") ++ result = arr // np.array([2, 2], dtype=object) ++ expected = pd.array(["NaT", "NaT"], dtype="timedelta64[ns]") ++ assert isinstance(result, TimedeltaArray) ++ assert result.dtype == np.dtype("timedelta64[ns]") ++ tm.assert_timedelta_array_equal(result, expected) ++ ++ def test_truediv_allnat_object_float_divisors(self): ++ ++ ++ arr = pd.array(["NaT", "NaT"], dtype="timedelta64[ns]") ++ result = arr / np.array([2.0, 2.0], dtype=object) ++ assert isinstance(result, TimedeltaArray) ++ assert result.dtype == np.dtype("timedelta64[ns]") ++ assert result.isna().all() ++ ++ def test_floordiv_allnat_object_float_divisors(self): ++ arr = pd.array(["NaT", "NaT"], dtype="timedelta64[ns]") ++ result = arr // np.array([2.0, 2.0], dtype=object) ++ assert isinstance(result, TimedeltaArray) ++ assert result.dtype == np.dtype("timedelta64[ns]") ++ assert result.isna().all() ++ ++ def test_truediv_non_nat_object_preserved(self): ++ ++ ++ ++ arr = pd.array(["1 days", "2 days"], dtype="timedelta64[ns]") ++ result = arr / np.array([2, 2], dtype=object) ++ expected = pd.array(["12:00:00", "1 days"], dtype="timedelta64[ns]") ++ assert isinstance(result, TimedeltaArray) ++ tm.assert_timedelta_array_equal(result, expected) ++ ++ def test_floordiv_non_nat_object_preserved(self): ++ arr = pd.array(["1 days", "2 days"], dtype="timedelta64[ns]") ++ result = arr // np.array([2, 2], dtype=object) ++ expected = pd.array(["12:00:00", "1 days"], dtype="timedelta64[ns]") ++ assert isinstance(result, TimedeltaArray) ++ tm.assert_timedelta_array_equal(result, expected) ++ ++ def test_truediv_allnat_non_object_preserved(self): ++ ++ ++ arr = pd.array(["NaT", "NaT"], dtype="timedelta64[ns]") ++ result = arr / np.array([2, 2]) ++ expected = pd.array(["NaT", "NaT"], dtype="timedelta64[ns]") ++ assert isinstance(result, TimedeltaArray) ++ tm.assert_timedelta_array_equal(result, expected) ++ ++ def test_truediv_mixed_nat_object_returns_timedelta_array(self): ++ ++ ++ arr = pd.array(["NaT", "2 days"], dtype="timedelta64[ns]") ++ result = arr / np.array([2, 2], dtype=object) ++ expected = pd.array(["NaT", "1 days"], dtype="timedelta64[ns]") ++ assert isinstance(result, TimedeltaArray) ++ tm.assert_timedelta_array_equal(result, expected) ++ ++ def test_floordiv_mixed_nat_object_returns_timedelta_array(self): ++ arr = pd.array(["NaT", "2 days"], dtype="timedelta64[ns]") ++ result = arr // np.array([2, 2], dtype=object) ++ expected = pd.array(["NaT", "1 days"], dtype="timedelta64[ns]") ++ assert isinstance(result, TimedeltaArray) ++ tm.assert_timedelta_array_equal(result, expected) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..14f72edc96 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest pandas/tests/arrays/test_timedeltas.py::TestDivisionByObjectArray -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest pandas/tests/arrays/test_timedeltas.py::TestDivisionByObjectArray -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002224/tests/test.sh b/tasks/format-code-task-002224/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ffa65b6fff8c6931052ccf853e00d998fbd21f90 --- /dev/null +++ b/tasks/format-code-task-002224/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pandas/tests/arrays/test_timedeltas.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002224/tests/test_command.sh b/tasks/format-code-task-002224/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002224/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002240/environment/Dockerfile b/tasks/format-code-task-002240/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a70a90ecc4a9e4b6240c0a62ec5189459f84b6ec --- /dev/null +++ b/tasks/format-code-task-002240/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b19f714b7d7cea03a0237760746852473a4fc739895c77849d075970c46542c4 diff --git a/tasks/format-code-task-002240/environment/setup/setup.sh b/tasks/format-code-task-002240/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002240/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002240/tests/test.patch b/tasks/format-code-task-002240/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f04a16f3a14ab02d249c05e1b59988ab111c776a --- /dev/null +++ b/tasks/format-code-task-002240/tests/test.patch @@ -0,0 +1,475 @@ +diff --git a/usercase-test-coderl/generic_emit_helpers_test.c b/usercase-test-coderl/generic_emit_helpers_test.c +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/generic_emit_helpers_test.c +@@ -0,0 +1,427 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++typedef fy_generic (*value_fn)(struct fy_generic_builder *gb); ++typedef int (*emit_fn)(fy_generic v); ++ ++struct captured_emit { ++ int rc; ++ char out[2048]; ++}; ++ ++static int failures; ++ ++static void fail(const char *test_name, const char *detail) ++{ ++ fprintf(stderr, "FAIL %s: %s\n", test_name, detail); ++ failures++; ++} ++ ++static void assert_int_eq(const char *test_name, const char *label, int actual, int expected) ++{ ++ char buf[160]; ++ ++ if (actual == expected) ++ return; ++ ++ snprintf(buf, sizeof(buf), "%s expected %d, got %d", label, expected, actual); ++ fail(test_name, buf); ++} ++ ++static void assert_str_eq(const char *test_name, const char *label, ++ const char *actual, const char *expected) ++{ ++ char buf[512]; ++ ++ if (!strcmp(actual, expected)) ++ return; ++ ++ snprintf(buf, sizeof(buf), "%s expected <%s>, got <%s>", label, expected, actual); ++ fail(test_name, buf); ++} ++ ++static void expected_compact_output(const char *test_name, fy_generic v, ++ char *expected, size_t expected_size) ++{ ++ struct fy_generic_builder *gb; ++ fy_generic emitted; ++ const char *text; ++ ++ expected[0] = '\0'; ++ ++ gb = fy_generic_builder_create(NULL); ++ if (!gb) { ++ fail(test_name, "could not create builder for expected output"); ++ return; ++ } ++ ++ ++ ++ ++ ++ ++ emitted = fy_gb_emit(gb, v, ++ FYOPEF_DISABLE_DIRECTORY | FYOPEF_STYLE_ONELINE | ++ FYOPEF_WIDTH_INF | FYOPEF_OUTPUT_TYPE_STRING, ++ NULL); ++ text = fy_generic_get_string_alloca(emitted); ++ if (!text || !*text) { ++ fail(test_name, "could not compute expected generic encoder output"); ++ fy_generic_builder_destroy(gb); ++ return; ++ } ++ ++ snprintf(expected, expected_size, "%s", text); ++ fy_generic_builder_destroy(gb); ++} ++ ++static struct captured_emit capture_emit(emit_fn fn, fy_generic v) ++{ ++ struct captured_emit result; ++ int pipefd[2]; ++ int saved_stdout; ++ ssize_t n; ++ ++ memset(&result, 0, sizeof(result)); ++ ++ if (fflush(stdout) != 0 || pipe(pipefd) != 0) { ++ result.rc = -999; ++ return result; ++ } ++ ++ saved_stdout = dup(STDOUT_FILENO); ++ if (saved_stdout < 0) { ++ close(pipefd[0]); ++ close(pipefd[1]); ++ result.rc = -999; ++ return result; ++ } ++ ++ if (dup2(pipefd[1], STDOUT_FILENO) < 0) { ++ close(saved_stdout); ++ close(pipefd[0]); ++ close(pipefd[1]); ++ result.rc = -999; ++ return result; ++ } ++ ++ close(pipefd[1]); ++ result.rc = fn(v); ++ fflush(stdout); ++ ++ dup2(saved_stdout, STDOUT_FILENO); ++ close(saved_stdout); ++ ++ n = read(pipefd[0], result.out, sizeof(result.out) - 1); ++ if (n < 0) ++ n = 0; ++ result.out[n] = '\0'; ++ close(pipefd[0]); ++ ++ return result; ++} ++ ++static int emit_default_adapter(fy_generic v) ++{ ++ return fy_generic_emit_default(v); ++} ++ ++static fy_generic value_scalar_hello(struct fy_generic_builder *gb) ++{ ++ (void)gb; ++ return fy_string("hello"); ++} ++ ++static fy_generic value_sequence(struct fy_generic_builder *gb) ++{ ++ return fy_gb_sequence(gb, "alpha", 2, fy_bool(false)); ++} ++ ++static fy_generic value_mapping(struct fy_generic_builder *gb) ++{ ++ return fy_gb_mapping(gb, "a", 1, "b", fy_bool(true)); ++} ++ ++static fy_generic value_nested_mapping(struct fy_generic_builder *gb) ++{ ++ return fy_gb_mapping(gb, ++ "name", "svc", ++ "ports", fy_gb_sequence(gb, 80, 443), ++ "meta", fy_gb_mapping(gb, ++ "enabled", fy_bool(true), ++ "ratio", 1.5)); ++} ++ ++static fy_generic value_empty_sequence(struct fy_generic_builder *gb) ++{ ++ (void)gb; ++ return fy_sequence(); ++} ++ ++static void assert_emit_case(const char *test_name, emit_fn fn, fy_generic v, ++ const char *expected) ++{ ++ struct captured_emit got = capture_emit(fn, v); ++ ++ assert_int_eq(test_name, "return code", got.rc, 0); ++ assert_str_eq(test_name, "stdout", got.out, expected); ++} ++ ++static void assert_emit_matches_encoder(const char *test_name, emit_fn fn, fy_generic v) ++{ ++ char expected[2048]; ++ ++ expected_compact_output(test_name, v, expected, sizeof(expected)); ++ ++ assert_emit_case(test_name, fn, v, expected); ++} ++ ++static void test_compact_scalar(void) ++{ ++ ++ ++ ++ ++ assert_emit_matches_encoder("test_compact_scalar", fy_generic_emit_compact, ++ value_scalar_hello(NULL)); ++} ++ ++static void test_compact_sequence(void) ++{ ++ ++ ++ ++ ++ struct fy_generic_builder *gb = fy_generic_builder_create(NULL); ++ ++ assert_emit_matches_encoder("test_compact_sequence", fy_generic_emit_compact, ++ value_sequence(gb)); ++ fy_generic_builder_destroy(gb); ++} ++ ++static void test_compact_mapping(void) ++{ ++ ++ ++ ++ ++ struct fy_generic_builder *gb = fy_generic_builder_create(NULL); ++ ++ assert_emit_matches_encoder("test_compact_mapping", fy_generic_emit_compact, ++ value_mapping(gb)); ++ fy_generic_builder_destroy(gb); ++} ++ ++static void test_compact_nested_mapping(void) ++{ ++ ++ ++ ++ ++ struct fy_generic_builder *gb = fy_generic_builder_create(NULL); ++ ++ assert_emit_matches_encoder("test_compact_nested_mapping", fy_generic_emit_compact, ++ value_nested_mapping(gb)); ++ fy_generic_builder_destroy(gb); ++} ++ ++static void test_compact_empty_sequence(void) ++{ ++ ++ ++ ++ ++ assert_emit_matches_encoder("test_compact_empty_sequence", fy_generic_emit_compact, ++ value_empty_sequence(NULL)); ++} ++ ++static void test_default_matches_compact_for_same_value(void) ++{ ++ ++ ++ ++ ++ struct fy_generic_builder *gb = fy_generic_builder_create(NULL); ++ fy_generic v = value_mapping(gb); ++ ++ assert_emit_matches_encoder("test_default_matches_compact_for_same_value compact", ++ fy_generic_emit_compact, v); ++ assert_emit_matches_encoder("test_default_matches_compact_for_same_value default", ++ emit_default_adapter, v); ++ fy_generic_builder_destroy(gb); ++} ++ ++static void test_invalid_value_returns_minus_one(void) ++{ ++ ++ ++ ++ ++ struct captured_emit compact = capture_emit(fy_generic_emit_compact, fy_invalid); ++ struct captured_emit def = capture_emit(emit_default_adapter, fy_invalid); ++ ++ assert_int_eq("test_invalid_value_returns_minus_one", "compact return code", ++ compact.rc, -1); ++ assert_str_eq("test_invalid_value_returns_minus_one", "compact stdout", ++ compact.out, ""); ++ assert_int_eq("test_invalid_value_returns_minus_one", "default return code", ++ def.rc, -1); ++ assert_str_eq("test_invalid_value_returns_minus_one", "default stdout", ++ def.out, ""); ++} ++ ++static void test_referential_transparency_same_value_twice(void) ++{ ++ struct fy_generic_builder *gb = fy_generic_builder_create(NULL); ++ fy_generic v = value_nested_mapping(gb); ++ struct captured_emit first = capture_emit(fy_generic_emit_compact, v); ++ struct captured_emit second = capture_emit(fy_generic_emit_compact, v); ++ char expected[2048]; ++ ++ expected_compact_output("test_referential_transparency_same_value_twice", v, ++ expected, sizeof(expected)); ++ ++ assert_int_eq("test_referential_transparency_same_value_twice", "first return", ++ first.rc, 0); ++ assert_int_eq("test_referential_transparency_same_value_twice", "second return", ++ second.rc, 0); ++ assert_str_eq("test_referential_transparency_same_value_twice", "first stdout", ++ first.out, expected); ++ assert_str_eq("test_referential_transparency_same_value_twice", "second stdout", ++ second.out, expected); ++ fy_generic_builder_destroy(gb); ++} ++ ++static void test_no_mutation_of_input_value(void) ++{ ++ struct fy_generic_builder *gb = fy_generic_builder_create(NULL); ++ fy_generic v = value_nested_mapping(gb); ++ ++ assert_emit_matches_encoder("test_no_mutation_of_input_value before", ++ fy_generic_emit_compact, v); ++ assert_emit_matches_encoder("test_no_mutation_of_input_value after", ++ fy_generic_emit_compact, v); ++ fy_generic_builder_destroy(gb); ++} ++ ++static void test_no_global_state_with_interleaved_noise(void) ++{ ++ struct fy_generic_builder *gb = fy_generic_builder_create(NULL); ++ fy_generic target = value_mapping(gb); ++ ++ assert_emit_matches_encoder("test_no_global_state_with_interleaved_noise target first", ++ fy_generic_emit_compact, target); ++ assert_emit_matches_encoder("test_no_global_state_with_interleaved_noise scalar noise", ++ fy_generic_emit_compact, value_scalar_hello(gb)); ++ assert_emit_matches_encoder("test_no_global_state_with_interleaved_noise sequence noise", ++ fy_generic_emit_compact, value_sequence(gb)); ++ assert_emit_matches_encoder("test_no_global_state_with_interleaved_noise target second", ++ fy_generic_emit_compact, target); ++ fy_generic_builder_destroy(gb); ++} ++ ++static int count_directory_entries(const char *path) ++{ ++ DIR *dir; ++ struct dirent *de; ++ int count = 0; ++ ++ dir = opendir(path); ++ if (!dir) ++ return -1; ++ ++ while ((de = readdir(dir)) != NULL) { ++ if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) ++ continue; ++ count++; ++ } ++ ++ closedir(dir); ++ return count; ++} ++ ++static void test_no_undeclared_cwd_file_side_effects(void) ++{ ++ char template[] = "/tmp/libfyaml-usercase-XXXXXX"; ++ char oldcwd[4096]; ++ char *tmpdir; ++ int before; ++ int after; ++ ++ tmpdir = mkdtemp(template); ++ if (!tmpdir) { ++ fail("test_no_undeclared_cwd_file_side_effects", "mkdtemp failed"); ++ return; ++ } ++ ++ if (!getcwd(oldcwd, sizeof(oldcwd))) { ++ fail("test_no_undeclared_cwd_file_side_effects", "getcwd failed"); ++ rmdir(tmpdir); ++ return; ++ } ++ ++ if (chdir(tmpdir) != 0) { ++ fail("test_no_undeclared_cwd_file_side_effects", "chdir tmpdir failed"); ++ rmdir(tmpdir); ++ return; ++ } ++ ++ before = count_directory_entries("."); ++ assert_emit_matches_encoder("test_no_undeclared_cwd_file_side_effects emit", ++ fy_generic_emit_compact, value_scalar_hello(NULL)); ++ after = count_directory_entries("."); ++ ++ assert_int_eq("test_no_undeclared_cwd_file_side_effects", "cwd entries before", ++ before, 0); ++ assert_int_eq("test_no_undeclared_cwd_file_side_effects", "cwd entries after", ++ after, 0); ++ ++ chdir(oldcwd); ++ rmdir(tmpdir); ++} ++ ++int main(void) ++{ ++ test_compact_scalar(); ++ test_compact_sequence(); ++ test_compact_mapping(); ++ test_compact_nested_mapping(); ++ test_compact_empty_sequence(); ++ test_default_matches_compact_for_same_value(); ++ test_invalid_value_returns_minus_one(); ++ test_referential_transparency_same_value_twice(); ++ test_no_mutation_of_input_value(); ++ test_no_global_state_with_interleaved_noise(); ++ test_no_undeclared_cwd_file_side_effects(); ++ ++ if (failures) { ++ fprintf(stderr, "%d test failure(s)\n", failures); ++ return 1; ++ } ++ ++ printf("generic emit helper acceptance tests passed\n"); ++ return 0; ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,38 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++build_dir=/tmp/libfyaml-usercase-test-coderl-build ++test_bin=/tmp/libfyaml-usercase-test-coderl-generic-emit-helpers ++ ++cmake -S /workspace/repo -B "$build_dir" \ ++ -DCMAKE_BUILD_TYPE=Debug \ ++ -DBUILD_SHARED_LIBS=ON \ ++ -DBUILD_TESTING=OFF \ ++ -DENABLE_NETWORK=OFF \ ++ -DENABLE_REFLECTION=OFF \ ++ -DENABLE_LIBCLANG=OFF \ ++ -DENABLE_PYTHON_BINDINGS=OFF >/dev/null ++cmake --build "$build_dir" --target fyaml -j"$(nproc)" >/dev/null ++ ++cc -std=gnu11 \ ++ -Wall -Wextra -Werror \ ++ -I/workspace/repo/include \ ++ -I"$build_dir/include" \ ++ /workspace/repo/usercase-test-coderl/generic_emit_helpers_test.c \ ++ -L"$build_dir" -lfyaml \ ++ -Wl,-rpath,"$build_dir" \ ++ -o "$test_bin" ++ ++exec "$test_bin" diff --git a/tasks/format-code-task-002240/tests/test.sh b/tasks/format-code-task-002240/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..01d46c4cefd7715b5d291e6f921241880375bab2 --- /dev/null +++ b/tasks/format-code-task-002240/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/generic_emit_helpers_test.c +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002240/tests/test_command.sh b/tasks/format-code-task-002240/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002240/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002246/environment/Dockerfile b/tasks/format-code-task-002246/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..de9c4c84d08ac8710da26fb6c622f5bb79f5705e --- /dev/null +++ b/tasks/format-code-task-002246/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a28cab7e11df0e51955da21461b5a601ea264b34072f11d947ee601323f08e4f diff --git a/tasks/format-code-task-002246/environment/setup/files/blocklist b/tasks/format-code-task-002246/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002246/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002246/environment/setup/setup.sh b/tasks/format-code-task-002246/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002246/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002246/tests/test.patch b/tasks/format-code-task-002246/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9ae2b592ce6530377063dc9a035afbd3db8e73d7 --- /dev/null +++ b/tasks/format-code-task-002246/tests/test.patch @@ -0,0 +1,439 @@ +diff --git a/usercase-test-coderl/convert_to_paragraph_test.go b/usercase-test-coderl/convert_to_paragraph_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/convert_to_paragraph_test.go +@@ -0,0 +1,357 @@ ++package usercase_test_coderl ++ ++import ( ++ "errors" ++ "os" ++ "reflect" ++ "strings" ++ "testing" ++ ++ "pault.ag/go/debian/control" ++) ++ ++ ++ ++ ++ ++ ++type basicFixture struct { ++ Foo string ++ Count int ++ Enabled bool ++} ++ ++type taggedFixture struct { ++ Package string `control:"Source"` ++ Arches []string `control:"Architecture" delim:", "` ++ Empty string ++ Required string `required:"true"` ++} ++ ++type skippedFixture struct { ++ First string ++ Secret string `control:"-"` ++ Last string ++} ++ ++type pointerScalarFixture struct { ++ Pointer *string `control:"Pointer"` ++ Words []string ++ Signed int ++ Unsigned uint ++ Disabled bool ++ Note string `multiline:"true"` ++} ++ ++type embeddedFixture struct { ++ control.Paragraph ++ Source string `control:"Source"` ++ Count int ++} ++ ++type customValue struct { ++ Text string ++} ++ ++func (c customValue) MarshalControl() (string, error) { ++ return "custom:" + c.Text, nil ++} ++ ++type customFixture struct { ++ Field customValue `control:"Custom"` ++} ++ ++var errMarshalSentinel = errors.New("sentinel marshal failure") ++ ++type failingValue struct{} ++ ++func (f failingValue) MarshalControl() (string, error) { ++ return "", errMarshalSentinel ++} ++ ++type failingFixture struct { ++ Field failingValue `control:"Failure"` ++} ++ ++type plainNested struct { ++ Value string ++} ++ ++type badNestedFixture struct { ++ Field plainNested `control:"Nested"` ++} ++ ++func requireParagraph(t *testing.T, actual *control.Paragraph, expectedOrder []string, expectedValues map[string]string) { ++ t.Helper() ++ if actual == nil { ++ t.Fatal("ConvertToParagraph returned nil paragraph") ++ } ++ if !reflect.DeepEqual(actual.Order, expectedOrder) { ++ t.Fatalf("Order mismatch:\nactual: %#v\nexpected: %#v", actual.Order, expectedOrder) ++ } ++ if !reflect.DeepEqual(actual.Values, expectedValues) { ++ t.Fatalf("Values mismatch:\nactual: %#v\nexpected: %#v", actual.Values, expectedValues) ++ } ++} ++ ++func mustConvert(t *testing.T, incoming interface{}) *control.Paragraph { ++ t.Helper() ++ paragraph, err := control.ConvertToParagraph(incoming) ++ if err != nil { ++ t.Fatalf("ConvertToParagraph returned error: %v", err) ++ } ++ return paragraph ++} ++ ++ ++ ++func TestConvertToParagraphBasicPrimitiveFields(t *testing.T) { ++ input := &basicFixture{Foo: "hello", Count: 2, Enabled: true} ++ actual := mustConvert(t, input) ++ requireParagraph(t, actual, ++ []string{"Foo", "Count", "Enabled"}, ++ map[string]string{"Foo": "hello", "Count": "2", "Enabled": "yes"}, ++ ) ++} ++ ++ ++ ++func TestConvertToParagraphSkipsHyphenTaggedFields(t *testing.T) { ++ input := &skippedFixture{First: "alpha", Secret: "hidden", Last: "omega"} ++ actual := mustConvert(t, input) ++ requireParagraph(t, actual, ++ []string{"First", "Last"}, ++ map[string]string{"First": "alpha", "Last": "omega"}, ++ ) ++} ++ ++ ++ ++func TestConvertToParagraphTaggedRequiredAndDelimitedFields(t *testing.T) { ++ input := &taggedFixture{Package: "demo", Arches: []string{"amd64", "arm64"}} ++ actual := mustConvert(t, input) ++ requireParagraph(t, actual, ++ []string{"Source", "Architecture", "Required"}, ++ map[string]string{"Source": "demo", "Architecture": "amd64, arm64", "Required": ""}, ++ ) ++} ++ ++ ++ ++func TestConvertToParagraphPointersScalarsDefaultSliceAndMultiline(t *testing.T) { ++ pointed := "target" ++ input := &pointerScalarFixture{ ++ Pointer: &pointed, ++ Words: []string{"one", "two", "three"}, ++ Signed: -7, ++ Unsigned: 42, ++ Disabled: false, ++ Note: "line one\nline two", ++ } ++ actual := mustConvert(t, input) ++ requireParagraph(t, actual, ++ []string{"Pointer", "Words", "Signed", "Unsigned", "Disabled", "Note"}, ++ map[string]string{ ++ "Pointer": "target", ++ "Words": "one two three", ++ "Signed": "-7", ++ "Unsigned": "42", ++ "Disabled": "no", ++ "Note": "\nline one\nline two", ++ }, ++ ) ++} ++ ++ ++ ++func TestConvertToParagraphEmbeddedParagraphIsPreservedAndOverlaid(t *testing.T) { ++ input := &embeddedFixture{ ++ Paragraph: control.Paragraph{ ++ Order: []string{"X-Unknown", "Source", "Trailing"}, ++ Values: map[string]string{ ++ "X-Unknown": "keep me", ++ "Source": "old-source", ++ "Trailing": "after-source", ++ }, ++ }, ++ Source: "new-source", ++ Count: 7, ++ } ++ actual := mustConvert(t, input) ++ if actual == nil { ++ t.Fatal("ConvertToParagraph returned nil paragraph") ++ } ++ expectedValues := map[string]string{ ++ "X-Unknown": "keep me", ++ "Source": "new-source", ++ "Trailing": "after-source", ++ "Count": "7", ++ } ++ if !reflect.DeepEqual(actual.Values, expectedValues) { ++ t.Fatalf("Values mismatch:\nactual: %#v\nexpected: %#v", actual.Values, expectedValues) ++ } ++ ++ ++ seen := map[string]int{} ++ sourceIndex, countIndex := -1, -1 ++ for i, key := range actual.Order { ++ seen[key]++ ++ if key == "Source" { ++ sourceIndex = i ++ } ++ if key == "Count" { ++ countIndex = i ++ } ++ } ++ if !reflect.DeepEqual(seen, map[string]int{"X-Unknown": 1, "Source": 1, "Trailing": 1, "Count": 1}) { ++ t.Fatalf("Order must contain preserved and derived fields exactly once, got %#v", actual.Order) ++ } ++ if sourceIndex == -1 || countIndex == -1 || sourceIndex > countIndex { ++ t.Fatalf("derived field order mismatch: Source index %d, Count index %d, order %#v", sourceIndex, countIndex, actual.Order) ++ } ++} ++ ++ ++ ++func TestConvertToParagraphUsesMarshallableStructValue(t *testing.T) { ++ input := &customFixture{Field: customValue{Text: "value"}} ++ actual := mustConvert(t, input) ++ requireParagraph(t, actual, ++ []string{"Custom"}, ++ map[string]string{"Custom": "custom:value"}, ++ ) ++} ++ ++ ++ ++func TestConvertToParagraphPropagatesMarshallableError(t *testing.T) { ++ _, err := control.ConvertToParagraph(&failingFixture{Field: failingValue{}}) ++ if !errors.Is(err, errMarshalSentinel) { ++ t.Fatalf("expected sentinel marshal error, got %v", err) ++ } ++} ++ ++ ++ ++func TestConvertToParagraphRejectsNonPointer(t *testing.T) { ++ _, err := control.ConvertToParagraph(basicFixture{Foo: "hello", Count: 2, Enabled: true}) ++ ++ if err == nil { ++ t.Fatal("expected non-pointer error, got nil") ++ } ++} ++ ++ ++ ++func TestConvertToParagraphRejectsPointerToNonStruct(t *testing.T) { ++ input := []string{"not", "a", "struct"} ++ _, err := control.ConvertToParagraph(&input) ++ ++ if err == nil { ++ t.Fatal("expected pointer-to-non-struct error, got nil") ++ } ++} ++ ++ ++ ++func TestConvertToParagraphRejectsNestedStructWithoutMarshallable(t *testing.T) { ++ _, err := control.ConvertToParagraph(&badNestedFixture{Field: plainNested{Value: "raw"}}) ++ ++ if err == nil || !strings.Contains(err.Error(), "plainNested") { ++ t.Fatalf("expected nested struct error naming plainNested, got %v", err) ++ } ++} ++ ++func TestConvertToParagraphReferentialTransparency(t *testing.T) { ++ input := &basicFixture{Foo: "hello", Count: 2, Enabled: true} ++ first := mustConvert(t, input) ++ second := mustConvert(t, input) ++ if !reflect.DeepEqual(first, second) { ++ t.Fatalf("same input produced different paragraphs:\nfirst: %#v\nsecond: %#v", first, second) ++ } ++ requireParagraph(t, second, ++ []string{"Foo", "Count", "Enabled"}, ++ map[string]string{"Foo": "hello", "Count": "2", "Enabled": "yes"}, ++ ) ++} ++ ++func TestConvertToParagraphDoesNotMutateInput(t *testing.T) { ++ pointed := "target" ++ input := &pointerScalarFixture{ ++ Pointer: &pointed, ++ Words: []string{"one", "two", "three"}, ++ Signed: -7, ++ Unsigned: 42, ++ Disabled: false, ++ Note: "line one\nline two", ++ } ++ pointedCopy := *input.Pointer ++ before := &pointerScalarFixture{ ++ Pointer: &pointedCopy, ++ Words: append([]string(nil), input.Words...), ++ Signed: input.Signed, ++ Unsigned: input.Unsigned, ++ Disabled: input.Disabled, ++ Note: input.Note, ++ } ++ _ = mustConvert(t, input) ++ if !reflect.DeepEqual(input, before) { ++ t.Fatalf("input mutated:\nafter: %#v\nbefore: %#v", input, before) ++ } ++} ++ ++func TestConvertToParagraphNoGlobalStateWithNoiseInputs(t *testing.T) { ++ input := &basicFixture{Foo: "hello", Count: 2, Enabled: true} ++ first := mustConvert(t, input) ++ ++ _ = mustConvert(t, &taggedFixture{Package: "demo", Arches: []string{"amd64", "arm64"}}) ++ pointed := "target" ++ _ = mustConvert(t, &pointerScalarFixture{ ++ Pointer: &pointed, ++ Words: []string{"one", "two", "three"}, ++ Signed: -7, ++ Unsigned: 42, ++ Disabled: false, ++ Note: "line one\nline two", ++ }) ++ ++ second := mustConvert(t, input) ++ if !reflect.DeepEqual(first, second) { ++ t.Fatalf("paragraph changed after noise inputs:\nfirst: %#v\nsecond: %#v", first, second) ++ } ++ requireParagraph(t, second, ++ []string{"Foo", "Count", "Enabled"}, ++ map[string]string{"Foo": "hello", "Count": "2", "Enabled": "yes"}, ++ ) ++} ++ ++func TestConvertToParagraphDoesNotWriteCurrentDirectory(t *testing.T) { ++ oldwd, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("Getwd failed: %v", err) ++ } ++ defer func() { ++ if err := os.Chdir(oldwd); err != nil { ++ t.Fatalf("failed to restore cwd: %v", err) ++ } ++ }() ++ ++ dir := t.TempDir() ++ if err := os.Chdir(dir); err != nil { ++ t.Fatalf("Chdir failed: %v", err) ++ } ++ before, err := os.ReadDir(".") ++ if err != nil { ++ t.Fatalf("ReadDir before call failed: %v", err) ++ } ++ ++ _ = mustConvert(t, &basicFixture{Foo: "hello", Count: 2, Enabled: true}) ++ ++ after, err := os.ReadDir(".") ++ if err != nil { ++ t.Fatalf("ReadDir after call failed: %v", err) ++ } ++ if !reflect.DeepEqual(before, after) { ++ t.Fatalf("current directory changed:\nbefore: %#v\nafter: %#v", before, after) ++ } ++} +diff --git a/usercase-test-coderl/offline.go.mod b/usercase-test-coderl/offline.go.mod +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/offline.go.mod +@@ -0,0 +1,19 @@ ++module pault.ag/go/debian ++ ++go 1.23.0 ++ ++toolchain go1.24.4 ++ ++require ( ++ github.com/ProtonMail/go-crypto v1.4.1 ++ github.com/kjk/lzma v0.0.0-20161016003348-3fd93898850d ++ github.com/klauspost/compress v1.18.0 ++ github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 ++ pault.ag/go/topsort v0.1.1 ++) ++ ++require ( ++ github.com/cloudflare/circl v1.6.2 // indirect ++ golang.org/x/crypto v0.41.0 // indirect ++ golang.org/x/sys v0.35.0 // indirect ++) +diff --git a/usercase-test-coderl/offline.go.sum b/usercase-test-coderl/offline.go.sum +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/offline.go.sum +@@ -0,0 +1,24 @@ ++github.com/ProtonMail/go-crypto v1.4.1 h1:9RfcZHqEQUvP8RzecWEUafnZVtEvrBVL9BiF67IQOfM= ++github.com/ProtonMail/go-crypto v1.4.1/go.mod h1:e1OaTyu5SYVrO9gKOEhTc+5UcXtTUa+P3uLudwcgPqo= ++github.com/bwesterb/go-ristretto v1.2.3 h1:1w53tCkGhCQ5djbat3+MH0BAQ5Kfgbt56UZQ/JMzngw= ++github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= ++github.com/cloudflare/circl v1.6.2 h1:hL7VBpHHKzrV5WTfHCaBsgx/HGbBYlgrwvNXEVDYYsQ= ++github.com/cloudflare/circl v1.6.2/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4= ++github.com/kjk/lzma v0.0.0-20161016003348-3fd93898850d h1:RnWZeH8N8KXfbwMTex/KKMYMj0FJRCF6tQubUuQ02GM= ++github.com/kjk/lzma v0.0.0-20161016003348-3fd93898850d/go.mod h1:phT/jsRPBAEqjAibu1BurrabCBNTYiVI+zbmyCZJY6Q= ++github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= ++github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ= ++github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= ++github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= ++golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4= ++golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc= ++golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= ++golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= ++golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= ++golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= ++golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4= ++golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw= ++golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= ++golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= ++pault.ag/go/topsort v0.1.1 h1:L0QnhUly6LmTv0e3DEzbN2q6/FGgAcQvaEw65S53Bg4= ++pault.ag/go/topsort v0.1.1/go.mod h1:r1kc/L0/FZ3HhjezBIPaNVhkqv8L0UJ9bxRuHRVZ0q4= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOVCS='*:off' ++export GOFLAGS="${GOFLAGS:-} -mod=readonly -modfile=/workspace/repo/usercase-test-coderl/offline.go.mod" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-002246/tests/test.sh b/tasks/format-code-task-002246/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..91f5792838efdf5c2d2c4a459b5631ed924ae078 --- /dev/null +++ b/tasks/format-code-task-002246/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/convert_to_paragraph_test.go +usercase-test-coderl/offline.go.mod +usercase-test-coderl/offline.go.sum +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002246/tests/test_command.sh b/tasks/format-code-task-002246/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002246/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002249/environment/Dockerfile b/tasks/format-code-task-002249/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..70082c9319618c94dfdcb0109002d2319fc488fe --- /dev/null +++ b/tasks/format-code-task-002249/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8058b78ae249d8220505bc313363091d1613d70bfa58c370d0612b571ec82394 diff --git a/tasks/format-code-task-002249/environment/setup/files/blocklist b/tasks/format-code-task-002249/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002249/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002249/environment/setup/setup.sh b/tasks/format-code-task-002249/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002249/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002249/tests/test.patch b/tasks/format-code-task-002249/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..756302b2111516617fb81e2a4d50ad797e345f25 --- /dev/null +++ b/tasks/format-code-task-002249/tests/test.patch @@ -0,0 +1,225 @@ +diff --git a/squbs-httpclient/src/test/java/org/squbs/httpclient/HttpClientTest.java b/squbs-httpclient/src/test/java/org/squbs/httpclient/HttpClientTest.java +index feeecd92b..6420a7b60 100644 +--- a/squbs-httpclient/src/test/java/org/squbs/httpclient/HttpClientTest.java ++++ b/squbs-httpclient/src/test/java/org/squbs/httpclient/HttpClientTest.java +@@ -61,12 +61,13 @@ public class HttpClientTest { + port = myPort; + baseUrl = "http://localhost:" + port; + ResolverRegistry.get(system).register(HttpEndpoint.class, new JavaEndpointResolver(baseUrl)); ++ ResolverRegistry.get(system).register(HttpEndpoint.class, new JavaEndpointResolver2(baseUrl)); + } + +- private static final Flow, Pair, Integer>, HostConnectionPool> +- clientFlow = ClientFlow.create("DummyService", system, mat); + private static final MarshalUnmarshal um = new MarshalUnmarshal(system.dispatcher(), mat); + ++ private static final Flow, Pair, Integer>, HostConnectionPool> ++ clientFlow = ClientFlow.create("DummyService", system, mat); + + private CompletionStage> doRequest(HttpRequest request) { + return Source +@@ -76,6 +77,17 @@ private CompletionStage> doRequest(HttpRequest request) { + .thenApply(Pair::first); + } + ++ private static final Flow, Pair, Integer>, HostConnectionPool> ++ clientFlow2 = ClientFlow.create("DummyService2", system, mat); ++ ++ private CompletionStage> doRequest2(HttpRequest request) { ++ return Source ++ .single(Pair.create(request, 42)) ++ .via(clientFlow2) ++ .runWith(Sink.head(), mat) ++ .thenApply(Pair::first); ++ } ++ + @AfterClass + public static void afterAll() { + system.terminate(); +@@ -97,7 +109,7 @@ public void postEmpty() throws Exception { + HttpRequest request = POST("/view") + .addHeader(RawHeader.create("req1-name", "test123456")) + .addHeader(RawHeader.create("req2-name", "test34567")); +- CompletionStage> tryResponse = doRequest(request); ++ CompletionStage> tryResponse = doRequest2(request); + CompletionStage entity = + tryResponse.thenCompose(t -> t.get().entity().toStrict(30000L, mat)); + HttpResponse response = tryResponse.toCompletableFuture().get().get(); +@@ -123,7 +135,7 @@ public void clientUnmarshalCaseClass() throws Exception { + + @Test + public void clientUnmarshalJavaBean() throws Exception { +- CompletionStage> tryResponseF = doRequest(GET("/viewj")); ++ CompletionStage> tryResponseF = doRequest2(GET("/viewj")); + CompletionStage teamF = tryResponseF.thenCompose(t -> + um.apply(unmarshaller(TeamWithPrivateMembers.class), t.get().entity())); + HttpResponse response = tryResponseF.toCompletableFuture().get().get(); +@@ -147,7 +159,7 @@ public void clientUnmarshalJavaBeanWithCaseClass() throws Exception { + + @Test + public void clientUnmarshalJavaBeanWithSimpleScalaClass() throws Exception { +- CompletionStage> tryResponseF = doRequest(GET("/view1")); ++ CompletionStage> tryResponseF = doRequest2(GET("/view1")); + CompletionStage teamF = tryResponseF.thenCompose(t -> + um.apply(unmarshaller(TeamNonCaseClass.class), t.get().entity())); + HttpResponse response = tryResponseF.toCompletableFuture().get().get(); +@@ -165,7 +177,7 @@ public void getEmpty() throws Exception { + + @Test + public void head() throws Exception { +- CompletionStage> tryResponse = doRequest(HEAD("/view")); ++ CompletionStage> tryResponse = doRequest2(HEAD("/view")); + CompletionStage entity = + tryResponse.thenCompose(t -> t.get().entity().toStrict(30000L, mat)); + HttpResponse response = tryResponse.toCompletableFuture().get().get(); +@@ -187,7 +199,7 @@ public void options() throws Exception { + + @Test + public void optionsUnmarshal() throws Exception { +- CompletionStage> tryResponseF = doRequest(OPTIONS("/view")); ++ CompletionStage> tryResponseF = doRequest2(OPTIONS("/view")); + CompletionStage teamF = tryResponseF.thenCompose(t -> + um.apply(unmarshaller(Team.class), t.get().entity())); + HttpResponse response = tryResponseF.toCompletableFuture().get().get(); +@@ -212,7 +224,7 @@ public void postWithMarshal() throws Exception { + CompletionStage> tryResponse = + um.apply(marshaller(Employee.class), TestData.newTeamMember()) + .thenApply(entity -> POST("/add").withEntity(entity)) +- .thenCompose(this::doRequest); ++ .thenCompose(this::doRequest2); + + CompletionStage entity = + tryResponse.thenCompose(t -> t.get().entity().toStrict(30000L, mat)); +@@ -244,7 +256,7 @@ public void putWithMarshalUnmarshal() throws Exception { + CompletionStage> tryResponseF = + um.apply(marshaller(Employee.class), TestData.newTeamMember()) + .thenApply(entity -> PUT("/add").withEntity(entity)) +- .thenCompose(this::doRequest); ++ .thenCompose(this::doRequest2); + + CompletionStage teamF = tryResponseF.thenCompose(t -> + um.apply(unmarshaller(Team.class), t.get().entity())); +diff --git a/squbs-httpclient/src/test/java/org/squbs/httpclient/JavaEndpointResolver.java b/squbs-httpclient/src/test/java/org/squbs/httpclient/JavaEndpointResolver.java +index ddf8e2b67..26678bdff 100644 +--- a/squbs-httpclient/src/test/java/org/squbs/httpclient/JavaEndpointResolver.java ++++ b/squbs-httpclient/src/test/java/org/squbs/httpclient/JavaEndpointResolver.java +@@ -36,7 +36,7 @@ public String name() { + @Override + public Optional resolve(String svcName, Environment env) { + if (name().equals(svcName)) { +- return Optional.of(HttpEndpoint.apply(dummyServiceEndpoint)); ++ return Optional.of(HttpEndpoint.create(dummyServiceEndpoint)); + } else { + return Optional.empty(); + } +diff --git a/squbs-httpclient/src/test/java/org/squbs/httpclient/JavaEndpointResolver2.java b/squbs-httpclient/src/test/java/org/squbs/httpclient/JavaEndpointResolver2.java +new file mode 100644 +index 000000000..d76f3bfcf +--- /dev/null ++++ b/squbs-httpclient/src/test/java/org/squbs/httpclient/JavaEndpointResolver2.java +@@ -0,0 +1,46 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package org.squbs.httpclient; ++ ++import akka.http.javadsl.model.Uri; ++import org.squbs.env.Environment; ++import org.squbs.resolver.AbstractResolver; ++ ++import java.util.Optional; ++ ++public class JavaEndpointResolver2 extends AbstractResolver { ++ ++ private final String dummyServiceEndpoint; ++ ++ public JavaEndpointResolver2(String dummyServiceEndpoint) { ++ this.dummyServiceEndpoint = dummyServiceEndpoint; ++ } ++ ++ @Override ++ public String name() { ++ return "DummyService2"; ++ } ++ ++ @Override ++ public Optional resolve(String svcName, Environment env) { ++ if (name().equals(svcName)) { ++ return Optional.of( ++ HttpEndpoint.create(Uri.create(dummyServiceEndpoint),Optional.empty(), Optional.empty())); ++ } else { ++ return Optional.empty(); ++ } ++ } ++} +diff --git a/squbs-httpclient/src/test/scala/org/squbs/httpclient/DefaultHttpEndpointResolverSpec.scala b/squbs-httpclient/src/test/scala/org/squbs/httpclient/DefaultHttpEndpointResolverSpec.scala +index 52087cbf5..b791c8d78 100644 +--- a/squbs-httpclient/src/test/scala/org/squbs/httpclient/DefaultHttpEndpointResolverSpec.scala ++++ b/squbs-httpclient/src/test/scala/org/squbs/httpclient/DefaultHttpEndpointResolverSpec.scala +@@ -16,12 +16,11 @@ + + package org.squbs.httpclient + +-import java.net.URI +- ++import akka.http.scaladsl.model.Uri ++import org.scalatest.OptionValues._ + import org.scalatest.{FlatSpecLike, Matchers} + import org.squbs.resolver.ResolverRegistry + import org.squbs.testkit.CustomTestKit +-import org.scalatest.OptionValues._ + + class DefaultHttpEndpointResolverSpec extends CustomTestKit with FlatSpecLike with Matchers { + +@@ -30,13 +29,13 @@ class DefaultHttpEndpointResolverSpec extends CustomTestKit with FlatSpecLike wi + private def resolve(uri: String) = ResolverRegistry(system).resolve[HttpEndpoint](uri).value + + it should "resolve valid http uri string to an HttpEndpoint" in { +- resolve("http://akka.io:80") shouldBe HttpEndpoint(URI.create("http://akka.io:80")) +- resolve("http://akka.io") shouldBe HttpEndpoint(URI.create("http://akka.io")) ++ resolve("http://akka.io:80") shouldBe HttpEndpoint(Uri("http://akka.io:80")) ++ resolve("http://akka.io") shouldBe HttpEndpoint(Uri("http://akka.io")) + } + + it should "resolve valid https uri string to an HttpEndpoint" in { +- resolve("https://akka.io:443") shouldBe HttpEndpoint(URI.create("https://akka.io:443")) +- resolve("https://akka.io") shouldBe HttpEndpoint(URI.create("https://akka.io")) ++ resolve("https://akka.io:443") shouldBe HttpEndpoint(Uri("https://akka.io:443")) ++ resolve("https://akka.io") shouldBe HttpEndpoint(Uri("https://akka.io")) + } + + it should "not resolve invalid http uri string to an HttpEndpoint" in { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3ST0vDMBgG8J77KWL12j/r2g0ED0UHQ5CJDq8jbaOtZElN0qLf3qygm6LusiLi ++87vkDe9LE/I0yNualysmutAZSmRN07Rfrc9rX4/SeDSaJOk4TpzIVlHikHSwG+1otaGKEEdJaX6a ++29f/o4Jt/oZpsyrkek1FGejqcGfsy3+cTN7zj6exzT+ZxKlDosNd4Xv/PP/jozCvRZhTXblFSfqf ++IGely54bqQy5zO6y1XxxNTvzwlarkMuC8vCRdtR7G7nOlvMPXZ2bzTdPTzYdz7Vb4gvpF5JLpYmn ++n9pc+5UxTcFrJkx/5ELwFyLVQ9B3g203mNvyvC+Xdu7rmQt2T1tuNqMzUTayFuaGack7pm4bVnju ++b78yAAAAAAAAAAAAAAAAAAAAAMAwXgFA91ipACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002249/tests/test.sh b/tasks/format-code-task-002249/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..60fc0ca30264992e5dad2ab3b97b9a6c2a28a683 --- /dev/null +++ b/tasks/format-code-task-002249/tests/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +squbs-httpclient/src/test/java/org/squbs/httpclient/HttpClientTest.java +squbs-httpclient/src/test/java/org/squbs/httpclient/JavaEndpointResolver.java +squbs-httpclient/src/test/java/org/squbs/httpclient/JavaEndpointResolver2.java +squbs-httpclient/src/test/scala/org/squbs/httpclient/DefaultHttpEndpointResolverSpec.scala +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002249/tests/test_command.sh b/tasks/format-code-task-002249/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002249/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002270/environment/Dockerfile b/tasks/format-code-task-002270/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e877aedbfcc2ac89ba737ce82c28faafcf06a312 --- /dev/null +++ b/tasks/format-code-task-002270/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1c625cbd535f2445f9a9622fca0ac3308a6528be2a69b89218ddf6b34b1c3a0f diff --git a/tasks/format-code-task-002270/environment/setup/files/blocklist b/tasks/format-code-task-002270/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002270/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002270/environment/setup/setup.sh b/tasks/format-code-task-002270/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002270/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002270/tests/test.patch b/tasks/format-code-task-002270/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d70584d97d55aa158c9b88d48aa8fa3894e825cf --- /dev/null +++ b/tasks/format-code-task-002270/tests/test.patch @@ -0,0 +1,198 @@ +diff --git a/planner/core/mpp_left_semi_blacklist_test.go b/planner/core/mpp_left_semi_blacklist_test.go +new file mode 100644 +index 0000000000..84bfedb857 +--- /dev/null ++++ b/planner/core/mpp_left_semi_blacklist_test.go +@@ -0,0 +1,168 @@ ++package core_test ++ ++import ( ++ "strings" ++ ++ . "github.com/pingcap/check" ++ "github.com/pingcap/tidb/domain" ++ "github.com/pingcap/tidb/parser/model" ++ "github.com/pingcap/tidb/util/testkit" ++) ++ ++func mppPlanText(rows [][]interface{}) string { ++ parts := make([]string, 0, len(rows)) ++ for _, row := range rows { ++ cols := make([]string, 0, len(row)) ++ for _, col := range row { ++ cols = append(cols, col.(string)) ++ } ++ parts = append(parts, strings.Join(cols, " ")) ++ } ++ return strings.Join(parts, "\n") ++} ++ ++func mppWarningCount(tk *testkit.TestKit) int { ++ return len(tk.Se.GetSessionVars().StmtCtx.GetWarnings()) ++} ++ ++func hasTiFlashHashJoinLine(plan string, label string) bool { ++ for _, line := range strings.Split(plan, "\n") { ++ if strings.Contains(line, "HashJoin") && ++ strings.Contains(line, "cop[tiflash]") && ++ strings.Contains(line, label) { ++ return true ++ } ++ } ++ return false ++} ++ ++func assertTiFlashMPPJoin(c *C, plan string, label string) { ++ c.Assert(hasTiFlashHashJoinLine(plan, label), IsTrue, Commentf("plan does not contain TiFlash MPP HashJoin for %s:\n%s", label, plan)) ++} ++ ++func assertNoTiFlashMPPJoin(c *C, plan string, label string) { ++ c.Assert(hasTiFlashHashJoinLine(plan, label), IsFalse, Commentf("plan still contains disabled TiFlash MPP HashJoin for %s:\n%s", label, plan)) ++} ++ ++func prepareMPPLeftSemiJoinTest(tk *testkit.TestKit, c *C) { ++ tk.MustExec("use test") ++ tk.MustExec("drop table if exists mpp_lsj") ++ tk.MustExec("create table mpp_lsj(a int not null, b int null)") ++ tk.MustExec("set @@tidb_allow_mpp = 1") ++ tk.MustExec("set @@tidb_enforce_mpp = 1") ++ tk.MustExec("set @@tidb_broadcast_join_threshold_size = 104857600") ++ tk.MustExec("set @@tidb_opt_broadcast_cartesian_join = 0") ++ ++ dom := domain.GetDomain(tk.Se) ++ is := dom.InfoSchema() ++ db, exists := is.SchemaByName(model.NewCIStr("test")) ++ c.Assert(exists, IsTrue) ++ for _, tblInfo := range db.Tables { ++ if tblInfo.Name.L == "mpp_lsj" { ++ tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{ ++ Count: 1, ++ Available: true, ++ } ++ } ++ } ++} ++ ++func explainPlanAndWarningCount(tk *testkit.TestKit, sql string) (string, int) { ++ rows := tk.MustQuery(sql).Rows() ++ return mppPlanText(rows), mppWarningCount(tk) ++} ++ ++func (s *testIntegrationSerialSuite) TestMPPLeftOuterSemiJoinExplain(c *C) { ++ tk := testkit.NewTestKit(c, s.store) ++ prepareMPPLeftSemiJoinTest(tk, c) ++ ++ cases := []string{ ++ "explain format = 'brief' select * from test.mpp_lsj t1 where t1.a > 1 or t1.a in (select a from test.mpp_lsj)", ++ "explain format = 'brief' select * from test.mpp_lsj t1 where t1.a > 5 or t1.a in (select a from test.mpp_lsj where b < t1.b)", ++ } ++ for _, sql := range cases { ++ plan, warningCount := explainPlanAndWarningCount(tk, sql) ++ assertTiFlashMPPJoin(c, plan, "left outer semi join") ++ c.Assert(warningCount, Equals, 0, Commentf("expected supported MPP plan without warnings for %s:\n%s", sql, plan)) ++ } ++} ++ ++func (s *testIntegrationSerialSuite) TestMPPAntiLeftOuterSemiJoinExplain(c *C) { ++ tk := testkit.NewTestKit(c, s.store) ++ prepareMPPLeftSemiJoinTest(tk, c) ++ ++ cases := []string{ ++ "explain format = 'brief' select * from test.mpp_lsj t1 where t1.a > 1 or t1.a not in (select a from test.mpp_lsj)", ++ "explain format = 'brief' select * from test.mpp_lsj t1 where t1.a > 5 or t1.a not in (select a from test.mpp_lsj where b < t1.b)", ++ } ++ for _, sql := range cases { ++ plan, warningCount := explainPlanAndWarningCount(tk, sql) ++ assertTiFlashMPPJoin(c, plan, "anti left outer semi join") ++ c.Assert(warningCount, Equals, 0, Commentf("expected supported MPP plan without warnings for %s:\n%s", sql, plan)) ++ } ++} ++ ++func (s *testIntegrationSerialSuite) TestMPPCartesianLeftOuterSemiJoinExplain(c *C) { ++ tk := testkit.NewTestKit(c, s.store) ++ prepareMPPLeftSemiJoinTest(tk, c) ++ tk.MustExec("set @@tidb_opt_broadcast_cartesian_join = 1") ++ tk.MustExec("set @@tidb_broadcast_join_threshold_size = 104857600") ++ ++ leftPlan, leftWarningCount := explainPlanAndWarningCount(tk, ++ "explain format = 'brief' select * from test.mpp_lsj t1 where t1.a > 1 or t1.b in (select a from test.mpp_lsj)") ++ assertTiFlashMPPJoin(c, leftPlan, "left outer semi join") ++ c.Assert(strings.Contains(leftPlan, "CARTESIAN"), IsTrue, Commentf("cartesian marker missing from plan:\n%s", leftPlan)) ++ c.Assert(leftWarningCount, Equals, 0, Commentf("expected cartesian MPP plan without warnings:\n%s", leftPlan)) ++ ++ antiPlan, antiWarningCount := explainPlanAndWarningCount(tk, ++ "explain format = 'brief' select * from test.mpp_lsj t1 where t1.a > 1 or t1.b not in (select a from test.mpp_lsj)") ++ assertTiFlashMPPJoin(c, antiPlan, "anti left outer semi join") ++ c.Assert(strings.Contains(antiPlan, "CARTESIAN"), IsTrue, Commentf("cartesian marker missing from plan:\n%s", antiPlan)) ++ c.Assert(antiWarningCount, Equals, 0, Commentf("expected cartesian MPP plan without warnings:\n%s", antiPlan)) ++} ++ ++func setJoinTypeBlacklist(tk *testkit.TestKit, joinType string) { ++ tk.MustExec("delete from mysql.expr_pushdown_blacklist where store_type = 'tiflash'") ++ tk.MustExec("admin reload expr_pushdown_blacklist") ++ tk.MustExec("insert into mysql.expr_pushdown_blacklist values('" + joinType + "', 'tiflash', 'test')") ++ tk.MustExec("admin reload expr_pushdown_blacklist") ++} ++ ++func assertBlacklistBlockedMPPJoin(c *C, plan string, warningCount int, joinType string) { ++ assertNoTiFlashMPPJoin(c, plan, joinType) ++ c.Assert(warningCount > 0, IsTrue, Commentf("blacklisted %s should emit an explain warning; plan:\n%s", joinType, plan)) ++} ++ ++func (s *testIntegrationSerialSuite) TestMPPJoinTypeBlacklistBlocksHashJoin(c *C) { ++ tk := testkit.NewTestKit(c, s.store) ++ prepareMPPLeftSemiJoinTest(tk, c) ++ defer func() { ++ tk.MustExec("delete from mysql.expr_pushdown_blacklist where store_type = 'tiflash'") ++ tk.MustExec("admin reload expr_pushdown_blacklist") ++ }() ++ ++ setJoinTypeBlacklist(tk, "left outer semi join") ++ leftPlan, leftWarningCount := explainPlanAndWarningCount(tk, ++ "explain format = 'brief' select * from test.mpp_lsj t1 where t1.a > 1 or t1.a in (select a from test.mpp_lsj)") ++ assertBlacklistBlockedMPPJoin(c, leftPlan, leftWarningCount, "left outer semi join") ++ ++ setJoinTypeBlacklist(tk, "anti left outer semi join") ++ antiPlan, antiWarningCount := explainPlanAndWarningCount(tk, ++ "explain format = 'brief' select * from test.mpp_lsj t1 where t1.a > 1 or t1.a not in (select a from test.mpp_lsj)") ++ assertBlacklistBlockedMPPJoin(c, antiPlan, antiWarningCount, "anti left outer semi join") ++ ++ setJoinTypeBlacklist(tk, "inner join") ++ innerPlan, innerWarningCount := explainPlanAndWarningCount(tk, ++ "explain format = 'brief' select * from test.mpp_lsj t1 join test.mpp_lsj t2 on t1.a = t2.a") ++ assertBlacklistBlockedMPPJoin(c, innerPlan, innerWarningCount, "inner join") ++} ++ ++func (s *testIntegrationSerialSuite) TestMPPUnsupportedJoinWarningStillReported(c *C) { ++ tk := testkit.NewTestKit(c, s.store) ++ prepareMPPLeftSemiJoinTest(tk, c) ++ ++ plan, warningCount := explainPlanAndWarningCount(tk, ++ "explain format = 'brief' select a from test.mpp_lsj where a not in (select a from test.mpp_lsj s where test.mpp_lsj.a < 1)") ++ assertNoTiFlashMPPJoin(c, plan, "anti left outer semi join") ++ c.Assert(warningCount > 0, IsTrue, Commentf("unsupported MPP join should emit an explain warning; plan:\n%s", plan)) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++ ++case "${1:-}" in ++ base) ++ go test '-ldflags=-checklinkname=0' -v -count=1 -run 'TestT$' ./planner/core/ -args -check.f 'TestMPPJoin$' ++ ;; ++ new) ++ go test '-ldflags=-checklinkname=0' -v -count=1 -run 'TestT$' ./planner/core/ -args -check.f 'TestMPPLeftOuterSemiJoinExplain|TestMPPAntiLeftOuterSemiJoinExplain|TestMPPCartesianLeftOuterSemiJoinExplain|TestMPPJoinTypeBlacklistBlocksHashJoin|TestMPPUnsupportedJoinWarningStillReported' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002270/tests/test.sh b/tasks/format-code-task-002270/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..11fa9cbbf8b3bb099934b4126eaef7b697a6052e --- /dev/null +++ b/tasks/format-code-task-002270/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +planner/core/mpp_left_semi_blacklist_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002270/tests/test_command.sh b/tasks/format-code-task-002270/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002270/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh base && bash /testbed/mimo_test_command.sh new \ No newline at end of file diff --git a/tasks/format-code-task-002271/environment/Dockerfile b/tasks/format-code-task-002271/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..972554c880ccb10b269b3b888a9c7e675a555fcb --- /dev/null +++ b/tasks/format-code-task-002271/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:03b5cb33fc44e07075730da8a0388020f00d1be5a0ddb61c16c10cb40562a23c diff --git a/tasks/format-code-task-002271/environment/setup/files/blocklist b/tasks/format-code-task-002271/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002271/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002271/environment/setup/setup.sh b/tasks/format-code-task-002271/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002271/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002271/tests/test.patch b/tasks/format-code-task-002271/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..83225986aa0d8b1842239d34a56aaafa7c19aa9d --- /dev/null +++ b/tasks/format-code-task-002271/tests/test.patch @@ -0,0 +1,82 @@ +diff --git a/expression/builtin_time_test.go b/expression/builtin_time_test.go +index e09cd5dc0f3a6..b0e99baa16804 100644 +--- a/expression/builtin_time_test.go ++++ b/expression/builtin_time_test.go +@@ -611,6 +611,33 @@ func (s *testEvaluatorSuite) TestCurrentTime(c *C) { + c.Assert(err, NotNil) + } + ++func (s *testEvaluatorSuite) TestUTCTime(c *C) { ++ defer testleak.AfterTest(c)() ++ ++ tfStr := "15:04:05" ++ last := time.Now().UTC() ++ fc := funcs[ast.UTCTime] ++ ++ tests := []struct { ++ param interface{} ++ expect int ++ }{{nil, 8}, {0, 8}, {3, 12}, {6, 15}, {-1, 0}, {7, 0}} ++ ++ for _, test := range tests { ++ f, err := fc.getFunction(datumsToConstants(types.MakeDatums(test.param)), s.ctx) ++ c.Assert(err, IsNil) ++ v, err := f.eval(nil) ++ if test.expect > 0 { ++ c.Assert(err, IsNil) ++ n := v.GetMysqlDuration() ++ c.Assert(n.String(), HasLen, test.expect) ++ c.Assert(n.String(), GreaterEqual, last.Format(tfStr)) ++ } else { ++ c.Assert(err, NotNil) ++ } ++ } ++} ++ + func (s *testEvaluatorSuite) TestUTCDate(c *C) { + defer testleak.AfterTest(c)() + last := time.Now().UTC() +diff --git a/plan/typeinferer_test.go b/plan/typeinferer_test.go +index 7625d9bcdb7b9..2e948fbe0cbb9 100644 +--- a/plan/typeinferer_test.go ++++ b/plan/typeinferer_test.go +@@ -158,6 +158,8 @@ func (ts *testTypeInferrerSuite) TestInferType(c *C) { + {"maketime(12, 15, 30)", mysql.TypeDuration, charset.CharsetBin, mysql.BinaryFlag}, + {"sec_to_time(2378)", mysql.TypeDuration, charset.CharsetBin, mysql.BinaryFlag}, + {"current_timestamp()", mysql.TypeDatetime, charset.CharsetBin, mysql.BinaryFlag}, ++ {"utc_time()", mysql.TypeDuration, charset.CharsetBin, mysql.BinaryFlag}, ++ {"utc_time(3)", mysql.TypeDuration, charset.CharsetBin, mysql.BinaryFlag}, + {"utc_timestamp()", mysql.TypeDatetime, charset.CharsetBin, mysql.BinaryFlag}, + {"microsecond('2009-12-31 23:59:59.000010')", mysql.TypeLonglong, charset.CharsetBin, mysql.BinaryFlag}, + {"second('2009-12-31 23:59:59.000010')", mysql.TypeLonglong, charset.CharsetBin, mysql.BinaryFlag}, +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,15 @@ ++H4sIAAAAAAAAA+2UW2/TMBSA95xfcRhoY2ipm9FuEtKQGOsK0qAI2HPlJqepaWJHtpOtovvvHKft ++1rWUITSEAH8vcexz87m4MShFlvRRVmzrd9Ekjtrt+kusfut11D6IoqPDVrtJclF02DzagvZvi2iJ ++0liuAba0UvZHcved/6U0butv0dh+rPKcy6RhRg/n4576H7SPWjf1bzVbVP/W4fNoC5oPF8Jm/vP6 ++P37EBkKyATejwKCFEIMgTqBuhgEmQfAYLgxCV0HUOHgOTwuNoZCUsyzDZB8kYoIJDJUGOxIGur0P ++rz6/Cckc7RZafcHY7gV4VShtwR0dbzNVWJaq0Nlzvl88cfvbztMnCqAs5kYgVwneWlZZgho+i9MT ++iOnAeVjY7faiKHrXO7047xyr4fB2u3a4uArrVygTpRfHr7u9fuf9q5PzzulxVHuf5JmQY3KHoLFQ ++IKRV9d9McRGXoZPcmTAkZlRWYZCPE6EhLGDVGTM6Zqmwo3LQoNFihZBpzIsgkxCaobyR/1lFZkUy ++cMGeuLGFVE14HAMNLKQoUXOLUHBtUDdSBU+lsmA1j8fkQEggc3vBSrI2ZelOeprkCOqHAkJaUL/M ++Hc98zf9YzoUkv8GSAImzBCsmyyyD8AopSrCYF/2ZZn8oskXEbB74ZEX/7ikFQmbutQEHL3cimE7p +++iUGOodwuK4zaajSFqV1+TwTVzcpTJZzaKwWVFdGrYFAVaaGFhWafRiSRqd3BlaN6VKS57gPPEmW ++rIyQU8/uBW4WQkGjBbtmOrPUeDad7s522GTSUcPX1NNu1TurV7tr1w745Rh2Tzrdt++/FppaE7YZ ++Aye85HEwmbfE9jXMpK7XLcFLsDeZcP87O5BXK3tr7ilHHzFXFbqOEnSHlFqq4plwXql5aFC4XTRk ++zieQIafJcDmAkLo9+l4cd7b6Mam4BqLi3TbNLLgNgmsmFxV30ZayHl57SUPMdUpvi+tx0onHPEXz ++S5MQuUmozYQVbBhPRg8MPQxGKLlRpMi4DP702+/xeDwej8fj8Xg8Ho/H4/F4PB6Px+PxeDyef4dv ++LFF2VgAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002271/tests/test.sh b/tasks/format-code-task-002271/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7280a01f1d395508111ab3dbb1be769f4cbb069b --- /dev/null +++ b/tasks/format-code-task-002271/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +expression/builtin_time_test.go +plan/typeinferer_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002271/tests/test_command.sh b/tasks/format-code-task-002271/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002271/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002276/environment/Dockerfile b/tasks/format-code-task-002276/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..80088155a496b6a31a0972360d2f06947be308f9 --- /dev/null +++ b/tasks/format-code-task-002276/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ee8554c7c197fd50e086ca73e2f3e57e14f645ca07138682e06003028168e52e diff --git a/tasks/format-code-task-002276/environment/setup/files/blocklist b/tasks/format-code-task-002276/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002276/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002276/environment/setup/setup.sh b/tasks/format-code-task-002276/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002276/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002276/tests/test.patch b/tasks/format-code-task-002276/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ead175e48f2c1b71052e78ee68326dc647c21657 --- /dev/null +++ b/tasks/format-code-task-002276/tests/test.patch @@ -0,0 +1,58 @@ +diff --git a/pkg/check/mysql_server_test.go b/pkg/check/mysql_server_test.go +index 6a1c5c7ce..54cf01442 100644 +--- a/pkg/check/mysql_server_test.go ++++ b/pkg/check/mysql_server_test.go +@@ -14,8 +14,9 @@ func (t *testCheckSuite) TestMysqlVersion(c *tc.C) { + {"5.5.0-log", false}, + {"5.6.0-log", true}, + {"5.7.0-log", true}, +- {"5.8.0-log", false}, +- {"8.0.1-log", false}, ++ {"5.8.0-log", true}, ++ {"8.0.1-log", true}, ++ {"8.0.20", true}, + {"5.5.50-MariaDB-1~wheezy", false}, + {"10.1.1-MariaDB-1~wheezy", false}, + {"10.1.2-MariaDB-1~wheezy", true}, +diff --git a/pkg/check/util_test.go b/pkg/check/util_test.go +index 848973d80..43ec78b22 100644 +--- a/pkg/check/util_test.go ++++ b/pkg/check/util_test.go +@@ -14,9 +14,9 @@ func (t *testCheckSuite) TestVersionComparsion(c *tc.C) { + {"5.5.0", false, false, true, true}, + {"5.6.0", true, false, true, true}, + {"5.7.0", true, true, true, true}, +- {"5.8.0", true, true, false, true}, +- {"8.0.1", true, true, false, false}, +- {"255.255.255", true, true, false, false}, ++ {"5.8.0", true, true, true, true}, ++ {"8.0.1", true, true, true, true}, ++ {"255.255.255", true, true, false, true}, + } + + var ( +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+3TzY7TMBAA4JzzFMPupRXKj7tJKyHlsEtLL4WiBc6RE7uNqROH2Anat8cO7S6q ++BHvpCiHmu0w1nnjGdRIWvZAs580QeS8lthZpOkbrPI6/STqLb+I4SeYzLyYkXaQepC820S96bWgH ++4HVKmT/VPbf+jwqf7t9wbfJS1TVtWKiry/V47v4X8/P7T+Yk8SC+3Ai/95/f//WrqBBNVFBd+Zob ++CLhfMhjfhYIz37+Gjx1vacdhr6BWrJccdkJyDRNTCQ12UYE2qrMZU/EaqLaVoa0kkY26r8nUL9tT ++7hiPGbd6jK7TqtG9bbRWQMLZDdjdaWnEwGHyM5W8tu2+8tKMrSCyDd5I0RwaWnMQDSjJeAefxfIO ++GG/11Gd8CPR3YcrKTe82dW3u+waolODOqN1z7WEflRUvDzARTSl7Zs9SP+hvMte8G3iXu8rQ7mA/ ++DOiNkKfE1O4WjE+exshiYELTwv1B2nSiNPA44UClYNQI1cBOdWfTgv3wWrtYCCnMg7/eEkLeb5df ++NqvM1r9db/PVh9u7zWqZEVhv321u15+yq0CynaR7nZ0PceXO64aEYIAwejxg5P/t9w0hhBBCCCGE ++EEIIIYQQQgghhBBCCF3WD+XaPpoAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002276/tests/test.sh b/tasks/format-code-task-002276/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2964363cd4e459594492b40b32ab3c6b9255059e --- /dev/null +++ b/tasks/format-code-task-002276/tests/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/check/mysql_server_test.go +pkg/check/util_test.go +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002276/tests/test_command.sh b/tasks/format-code-task-002276/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002276/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002282/environment/Dockerfile b/tasks/format-code-task-002282/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f2b786e9854811af2542639be973266ce88eba1b --- /dev/null +++ b/tasks/format-code-task-002282/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:59a063b0c025e0bc698eef13016d4949f60ce5785958208d40ca1da0520ae45b diff --git a/tasks/format-code-task-002282/environment/setup/files/blocklist b/tasks/format-code-task-002282/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002282/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002282/environment/setup/setup.sh b/tasks/format-code-task-002282/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002282/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002282/tests/test.patch b/tasks/format-code-task-002282/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..abd6b3e38f1eae3b13780388ab66ce2382ec3171 --- /dev/null +++ b/tasks/format-code-task-002282/tests/test.patch @@ -0,0 +1,52 @@ +diff --git a/smart_open/tests/test_s3.py b/smart_open/tests/test_s3.py +index c213a7cb..8d09d44f 100644 +--- a/smart_open/tests/test_s3.py ++++ b/smart_open/tests/test_s3.py +@@ -521,6 +521,27 @@ def test(self): + self.assertEqual(sorted(keys), sorted(expected)) + + ++ ++ ++ ++ ++@moto.mock_s3 ++class IterBucketCredentialsTest(unittest.TestCase): ++ ++ def test(self): ++ num_keys = 10 ++ populate_bucket(num_keys=num_keys) ++ result = list( ++ smart_open.s3.iter_bucket( ++ BUCKET_NAME, ++ workers=None, ++ aws_access_key_id='access_id', ++ aws_secret_access_key='access_secret' ++ ) ++ ) ++ self.assertEqual(len(result), num_keys) ++ ++ + @maybe_mock_s3 + class DownloadKeyTest(unittest.TestCase): + def setUp(self): +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3S3wqCMBTHca99ir2AtmnLxxH/gUE6cUvw7RsGFUF5U0T4/dycw3ZgB36Ly/Px ++VOdNP+2Cb5FepvVSvee69EonKpFaploFUimdpYHQX9vowdm6YhQiGI1x7+bW7v9UfM/fNdbllem6 ++oq9j237ujdX8M33LP8kSn//+oHz+8nMrvLbx/KtaLMGXTR0Os2tNn4qoE771h8J2xehyMzT9MmSv ++f8Sm8TCLaAp/vTwAAAAAAAAAAAAAAACwcRdOYGCKACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002282/tests/test.sh b/tasks/format-code-task-002282/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..50da19792cab0474aead325e39eb8e4201b6a298 --- /dev/null +++ b/tasks/format-code-task-002282/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +smart_open/tests/test_s3.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002282/tests/test_command.sh b/tasks/format-code-task-002282/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002282/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002285/environment/Dockerfile b/tasks/format-code-task-002285/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..73f5254fe41180ff8ea0f9a87d9a9a81cc48a28c --- /dev/null +++ b/tasks/format-code-task-002285/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c637fb450f014db1bd4b164505aaca5e6ab8c05d2c8c17a578d5105125a8bbb1 diff --git a/tasks/format-code-task-002285/environment/setup/files/blocklist b/tasks/format-code-task-002285/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002285/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002285/environment/setup/setup.sh b/tasks/format-code-task-002285/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002285/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002285/tests/test.patch b/tasks/format-code-task-002285/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f63944573d6675bbebcdaae26dd0fac7de0d2b14 --- /dev/null +++ b/tasks/format-code-task-002285/tests/test.patch @@ -0,0 +1,438 @@ +diff --git a/usercase-test-coderl/encode_gray_test.go b/usercase-test-coderl/encode_gray_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/encode_gray_test.go +@@ -0,0 +1,410 @@ ++ ++ ++ ++ ++ ++ ++package usercase_test_coderl ++ ++import ( ++ "bytes" ++ "errors" ++ "image" ++ "image/color" ++ "os" ++ "path/filepath" ++ "reflect" ++ "sort" ++ "testing" ++ ++ "github.com/pixiv/go-libwebp/webp" ++) ++ ++func mustDefaultConfig(t *testing.T) *webp.Config { ++ t.Helper() ++ c, err := webp.ConfigPreset(webp.PresetDefault, 100) ++ if err != nil { ++ t.Fatalf("ConfigPreset(PresetDefault, 100) returned error: %v", err) ++ } ++ return c ++} ++ ++func invalidConfig(t *testing.T) *webp.Config { ++ t.Helper() ++ c := mustDefaultConfig(t) ++ c.SetQuality(-1) ++ return c ++} ++ ++func oneByTenGradient() *image.Gray { ++ p := image.NewGray(image.Rect(0, 0, 1, 10)) ++ for i := 0; i < 10; i++ { ++ p.SetGray(0, i, color.Gray{Y: uint8(float32(i) / 10 * 255)}) ++ } ++ return p ++} ++ ++func twoByTwoFourValues() *image.Gray { ++ p := image.NewGray(image.Rect(0, 0, 2, 2)) ++ copy(p.Pix, []byte{0, 85, 170, 255}) ++ return p ++} ++ ++func paddedNonZeroRectGray() *image.Gray { ++ return &image.Gray{ ++ Pix: []byte{10, 200, 99, 99, 99, 120, 250, 99, 99, 99}, ++ Stride: 5, ++ Rect: image.Rect(3, 4, 5, 6), ++ } ++} ++ ++func encodeGrayBytes(t *testing.T, p *image.Gray, c *webp.Config) []byte { ++ t.Helper() ++ var out bytes.Buffer ++ if err := webp.EncodeGray(&out, p, c); err != nil { ++ t.Fatalf("EncodeGray returned error: %v", err) ++ } ++ return out.Bytes() ++} ++ ++func encodeGrayWithProgressBytes(t *testing.T, p *image.Gray, c *webp.Config, hook webp.ProgressHook) []byte { ++ t.Helper() ++ var out bytes.Buffer ++ if err := webp.EncodeGrayWithProgress(&out, p, c, hook); err != nil { ++ t.Fatalf("EncodeGrayWithProgress returned error: %v", err) ++ } ++ return out.Bytes() ++} ++ ++func assertWebPDecode(t *testing.T, data []byte, wantWidth int, wantHeight int) *image.RGBA { ++ t.Helper() ++ ++ if len(data) == 0 { ++ t.Fatal("encoded byte length = 0, want WebP bytes") ++ } ++ width, height := webp.GetInfo(data) ++ if width != wantWidth { ++ t.Fatalf("GetInfo width = %d, want %d", width, wantWidth) ++ } ++ if height != wantHeight { ++ t.Fatalf("GetInfo height = %d, want %d", height, wantHeight) ++ } ++ features, err := webp.GetFeatures(data) ++ if err != nil { ++ t.Fatalf("GetFeatures returned error: %v", err) ++ } ++ ++ if features.Width != wantWidth || features.Height != wantHeight { ++ t.Fatalf("features dimensions = %dx%d, want %dx%d", features.Width, features.Height, wantWidth, wantHeight) ++ } ++ decoded, err := webp.DecodeRGBA(data, &webp.DecoderOptions{}) ++ if err != nil { ++ t.Fatalf("DecodeRGBA returned error: %v", err) ++ } ++ if decoded.Rect.Dx() != wantWidth || decoded.Rect.Dy() != wantHeight { ++ t.Fatalf("decoded RGBA bounds = %dx%d, want %dx%d", decoded.Rect.Dx(), decoded.Rect.Dy(), wantWidth, wantHeight) ++ } ++ return decoded ++} ++ ++func grayAt(t *testing.T, img *image.RGBA, x int, y int) int { ++ t.Helper() ++ rgba := img.RGBAAt(x+img.Rect.Min.X, y+img.Rect.Min.Y) ++ ++ if absInt(int(rgba.R)-int(rgba.G)) > 8 || absInt(int(rgba.R)-int(rgba.B)) > 8 || absInt(int(rgba.G)-int(rgba.B)) > 8 { ++ t.Fatalf("decoded pixel (%d,%d) = %#v, want grayscale RGB channels", x, y, rgba) ++ } ++ if rgba.A < 240 { ++ t.Fatalf("decoded pixel (%d,%d) alpha = %d, want opaque image", x, y, rgba.A) ++ } ++ return (int(rgba.R) + int(rgba.G) + int(rgba.B)) / 3 ++} ++ ++func absInt(v int) int { ++ if v < 0 { ++ return -v ++ } ++ return v ++} ++ ++func assertVerticalGrayGradient(t *testing.T, data []byte, wantWidth int, wantHeight int) { ++ t.Helper() ++ img := assertWebPDecode(t, data, wantWidth, wantHeight) ++ values := make([]int, wantHeight) ++ for y := 0; y < wantHeight; y++ { ++ values[y] = grayAt(t, img, 0, y) ++ } ++ ++ if values[0] > 50 || values[len(values)-1] < 200 { ++ t.Fatalf("decoded gradient endpoints = %#v, want dark-to-light gradient", values) ++ } ++ for i := 1; i < len(values); i++ { ++ if values[i]+12 < values[i-1] { ++ t.Fatalf("decoded gradient = %#v, want nondecreasing up to lossy tolerance", values) ++ } ++ } ++} ++ ++func assertFourValueGrayImage(t *testing.T, data []byte) { ++ t.Helper() ++ img := assertWebPDecode(t, data, 2, 2) ++ values := []int{ ++ grayAt(t, img, 0, 0), ++ grayAt(t, img, 1, 0), ++ grayAt(t, img, 0, 1), ++ grayAt(t, img, 1, 1), ++ } ++ ++ if !(values[0] < values[1] && values[1] < values[2] && values[2] < values[3]) { ++ t.Fatalf("decoded gray values = %#v, want increasing values for 0,85,170,255 input", values) ++ } ++ if values[0] > 40 || values[3] < 215 || values[3]-values[0] < 180 { ++ t.Fatalf("decoded gray values = %#v, want dark-to-light contrast", values) ++ } ++} ++ ++func assertPaddedGrayImage(t *testing.T, data []byte) { ++ t.Helper() ++ img := assertWebPDecode(t, data, 2, 2) ++ values := []int{ ++ grayAt(t, img, 0, 0), ++ grayAt(t, img, 1, 0), ++ grayAt(t, img, 0, 1), ++ grayAt(t, img, 1, 1), ++ } ++ ++ if values[0] > 70 || values[1] < 150 || values[2] < 70 || values[2] > 180 || values[3] < 200 { ++ t.Fatalf("decoded padded gray values = %#v, want values matching non-contiguous Gray pixels", values) ++ } ++ if !(values[1] > values[2] && values[2] > values[0] && values[3] > values[2]) { ++ t.Fatalf("decoded padded gray values = %#v, want row/column relationships from source pixels", values) ++ } ++} ++ ++func assertNoSuccessfulWebP(t *testing.T, data []byte, wantWidth int, wantHeight int) { ++ t.Helper() ++ ++ if len(data) == 0 { ++ return ++ } ++ width, height := webp.GetInfo(data) ++ if width > 0 && height > 0 { ++ if _, err := webp.GetFeatures(data); err == nil { ++ t.Fatalf("writer contains a successful %dx%d WebP image after failure; original input was %dx%d", width, height, wantWidth, wantHeight) ++ } ++ } ++} ++ ++func assertValidProgressUpdates(t *testing.T, progress []int) { ++ t.Helper() ++ ++ if len(progress) == 0 { ++ t.Fatal("progress updates = nil, want at least one percentage update") ++ } ++ for _, percent := range progress { ++ if percent < 0 || percent > 100 { ++ t.Fatalf("progress update = %d, want percentage between 0 and 100", percent) ++ } ++ } ++} ++ ++func referenceInvalidConfigError(t *testing.T) string { ++ t.Helper() ++ var out bytes.Buffer ++ err := webp.EncodeRGBA(&out, image.NewRGBA(image.Rect(0, 0, 1, 1)), invalidConfig(t)) ++ if err == nil { ++ t.Fatal("EncodeRGBA invalid config error = nil, want reference invalid configuration error") ++ } ++ assertNoSuccessfulWebP(t, out.Bytes(), 1, 1) ++ return err.Error() ++} ++ ++func snapshotDir(t *testing.T, root string) []string { ++ t.Helper() ++ var paths []string ++ err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error { ++ if err != nil { ++ return err ++ } ++ rel, err := filepath.Rel(root, path) ++ if err != nil { ++ return err ++ } ++ if rel != "." { ++ paths = append(paths, rel) ++ } ++ return nil ++ }) ++ if err != nil { ++ t.Fatalf("snapshotDir(%q) returned error: %v", root, err) ++ } ++ sort.Strings(paths) ++ return paths ++} ++ ++func TestEncodeGrayOneByTenGradient(t *testing.T) { ++ ++ ++ ++ ++ data := encodeGrayBytes(t, oneByTenGradient(), mustDefaultConfig(t)) ++ assertVerticalGrayGradient(t, data, 1, 10) ++} ++ ++func TestEncodeGrayTwoByTwoFourValues(t *testing.T) { ++ ++ ++ ++ ++ data := encodeGrayBytes(t, twoByTwoFourValues(), mustDefaultConfig(t)) ++ assertFourValueGrayImage(t, data) ++} ++ ++func TestEncodeGrayWithProgressContinues(t *testing.T) { ++ ++ ++ ++ ++ var progress []int ++ data := encodeGrayWithProgressBytes(t, twoByTwoFourValues(), mustDefaultConfig(t), func(percent int) bool { ++ progress = append(progress, percent) ++ return true ++ }) ++ assertValidProgressUpdates(t, progress) ++ assertFourValueGrayImage(t, data) ++} ++ ++func TestEncodeGrayWithProgressAbortReturnsEncodeError(t *testing.T) { ++ ++ ++ ++ ++ var out bytes.Buffer ++ var progress []int ++ err := webp.EncodeGrayWithProgress(&out, oneByTenGradient(), mustDefaultConfig(t), func(percent int) bool { ++ progress = append(progress, percent) ++ return false ++ }) ++ var encodeErr *webp.EncodeError ++ if !errors.As(err, &encodeErr) { ++ t.Fatalf("error = %T:%v, want *webp.EncodeError", err, err) ++ } ++ if encodeErr.EncodeErrorCode() != webp.EncodeErrorCodeVP8EncErrorUserAbort { ++ t.Fatalf("EncodeErrorCode = %v, want %v", encodeErr.EncodeErrorCode(), webp.EncodeErrorCodeVP8EncErrorUserAbort) ++ } ++ assertValidProgressUpdates(t, progress) ++ ++ if len(progress) != 1 { ++ t.Fatalf("progress update count after abort = %d, want 1", len(progress)) ++ } ++ assertNoSuccessfulWebP(t, out.Bytes(), 1, 10) ++} ++ ++func TestEncodeGrayInvalidConfigFailsBeforeSuccessfulWrite(t *testing.T) { ++ ++ ++ ++ ++ var out bytes.Buffer ++ err := webp.EncodeGray(&out, oneByTenGradient(), invalidConfig(t)) ++ if err == nil { ++ t.Fatal("EncodeGray invalid config error = nil, want invalid configuration") ++ } ++ ++ if want := referenceInvalidConfigError(t); err.Error() != want { ++ t.Fatalf("EncodeGray invalid config error = %q, want EncodeRGBA invalid config behavior %q", err.Error(), want) ++ } ++ assertNoSuccessfulWebP(t, out.Bytes(), 1, 10) ++} ++ ++func TestEncodeGrayWithProgressInvalidConfigFailsBeforeSuccessfulWrite(t *testing.T) { ++ ++ ++ ++ ++ var out bytes.Buffer ++ var progress []int ++ err := webp.EncodeGrayWithProgress(&out, oneByTenGradient(), invalidConfig(t), func(percent int) bool { ++ progress = append(progress, percent) ++ return true ++ }) ++ if err == nil { ++ t.Fatal("EncodeGrayWithProgress invalid config error = nil, want invalid configuration") ++ } ++ ++ if want := referenceInvalidConfigError(t); err.Error() != want { ++ t.Fatalf("EncodeGrayWithProgress invalid config error = %q, want EncodeRGBA invalid config behavior %q", err.Error(), want) ++ } ++ ++ for _, percent := range progress { ++ if percent < 0 || percent > 100 { ++ t.Fatalf("progress update after invalid config = %d, want percentage between 0 and 100", percent) ++ } ++ } ++ assertNoSuccessfulWebP(t, out.Bytes(), 1, 10) ++} ++ ++func TestEncodeGrayReferentialTransparency(t *testing.T) { ++ first := encodeGrayBytes(t, twoByTwoFourValues(), mustDefaultConfig(t)) ++ second := encodeGrayBytes(t, twoByTwoFourValues(), mustDefaultConfig(t)) ++ ++ assertFourValueGrayImage(t, first) ++ assertFourValueGrayImage(t, second) ++} ++ ++func TestEncodeGrayDoesNotMutateInput(t *testing.T) { ++ img := paddedNonZeroRectGray() ++ wantPix := append([]byte(nil), img.Pix...) ++ wantStride := img.Stride ++ wantRect := img.Rect ++ ++ data := encodeGrayBytes(t, img, mustDefaultConfig(t)) ++ ++ if !bytes.Equal(img.Pix, wantPix) { ++ t.Fatalf("image Pix after EncodeGray = %#v, want %#v", img.Pix, wantPix) ++ } ++ if img.Stride != wantStride { ++ t.Fatalf("image Stride after EncodeGray = %d, want %d", img.Stride, wantStride) ++ } ++ if img.Rect != wantRect { ++ t.Fatalf("image Rect after EncodeGray = %v, want %v", img.Rect, wantRect) ++ } ++ assertPaddedGrayImage(t, data) ++} ++ ++func TestEncodeGrayNoGlobalStateWithNoise(t *testing.T) { ++ baseline := encodeGrayBytes(t, oneByTenGradient(), mustDefaultConfig(t)) ++ _ = encodeGrayBytes(t, twoByTwoFourValues(), mustDefaultConfig(t)) ++ _ = encodeGrayWithProgressBytes(t, twoByTwoFourValues(), mustDefaultConfig(t), func(int) bool { return true }) ++ actual := encodeGrayBytes(t, oneByTenGradient(), mustDefaultConfig(t)) ++ ++ ++ assertVerticalGrayGradient(t, baseline, 1, 10) ++ assertVerticalGrayGradient(t, actual, 1, 10) ++} ++ ++func TestEncodeGrayHasNoUndeclaredFileSideEffects(t *testing.T) { ++ tmp := t.TempDir() ++ oldWD, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("Getwd returned error: %v", err) ++ } ++ if err := os.Chdir(tmp); err != nil { ++ t.Fatalf("Chdir(%q) returned error: %v", tmp, err) ++ } ++ defer func() { ++ if err := os.Chdir(oldWD); err != nil { ++ t.Fatalf("restoring cwd returned error: %v", err) ++ } ++ }() ++ ++ before := snapshotDir(t, tmp) ++ data := encodeGrayBytes(t, twoByTwoFourValues(), mustDefaultConfig(t)) ++ after := snapshotDir(t, tmp) ++ ++ if !reflect.DeepEqual(after, before) { ++ t.Fatalf("cwd entries after EncodeGray = %#v, want %#v", after, before) ++ } ++ ++ assertFourValueGrayImage(t, data) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-002285/tests/test.sh b/tasks/format-code-task-002285/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b597a0a34a27f470a0c376ed77acd08ba236e1d9 --- /dev/null +++ b/tasks/format-code-task-002285/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/encode_gray_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002285/tests/test_command.sh b/tasks/format-code-task-002285/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002285/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002410/environment/Dockerfile b/tasks/format-code-task-002410/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1540f48021308de4ef9282d733ca2073e585eb9e --- /dev/null +++ b/tasks/format-code-task-002410/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:111957f1b0b32c8f6ad7a11a4bb8fb4faf3662f2ce61be317c0f9284846b31cc diff --git a/tasks/format-code-task-002410/environment/setup/files/blocklist b/tasks/format-code-task-002410/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002410/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002410/environment/setup/setup.sh b/tasks/format-code-task-002410/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002410/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002410/tests/test.patch b/tasks/format-code-task-002410/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..97e47e1fa50f53e140b21eea133ca876524b4cce --- /dev/null +++ b/tasks/format-code-task-002410/tests/test.patch @@ -0,0 +1,97 @@ +diff --git a/test/plugins/test_flake8_lint.py b/test/plugins/test_flake8_lint.py +index a72383e..8e118f5 100644 +--- a/test/plugins/test_flake8_lint.py ++++ b/test/plugins/test_flake8_lint.py +@@ -160,6 +160,70 @@ exclude = + os.unlink(os.path.join(workspace.root_path, "setup.cfg")) + + ++def _make_doc(workspace): ++ ++ source = "line1\nline2\nline3\nline4\n" ++ return Document('', workspace, source) ++ ++ ++def _stdout_line(line_no, col, code, msg): ++ return "file.py:{ln}:{c}: {code} {msg}".format(ln=line_no, c=col, code=code, msg=msg) ++ ++ ++def test_parse_stdout_f401_unused_import_is_error(workspace): ++ doc = _make_doc(workspace) ++ stdout = _stdout_line(1, 1, "F401", "'os' imported but unused") + "\n" ++ diags = flake8_lint.parse_stdout(doc, stdout) ++ assert len(diags) == 1 ++ assert diags[0]['code'] == 'F401' ++ assert diags[0]['severity'] == lsp.DiagnosticSeverity.Error ++ ++ ++def test_parse_stdout_f841_unused_variable_is_error(workspace): ++ doc = _make_doc(workspace) ++ stdout = _stdout_line(2, 5, "F841", "local variable 'a' is assigned to but never used") + "\n" ++ diags = flake8_lint.parse_stdout(doc, stdout) ++ assert len(diags) == 1 ++ assert diags[0]['code'] == 'F841' ++ assert diags[0]['severity'] == lsp.DiagnosticSeverity.Error ++ ++ ++def test_parse_stdout_f821_undefined_name_is_error(workspace): ++ doc = _make_doc(workspace) ++ stdout = _stdout_line(1, 1, "F821", "undefined name 'foo'") + "\n" ++ diags = flake8_lint.parse_stdout(doc, stdout) ++ assert len(diags) == 1 ++ assert diags[0]['code'] == 'F821' ++ assert diags[0]['severity'] == lsp.DiagnosticSeverity.Error ++ ++ ++def test_parse_stdout_e999_syntax_error_is_error(workspace): ++ doc = _make_doc(workspace) ++ stdout = _stdout_line(1, 1, "E999", "SyntaxError: invalid syntax") + "\n" ++ diags = flake8_lint.parse_stdout(doc, stdout) ++ assert len(diags) == 1 ++ assert diags[0]['code'] == 'E999' ++ assert diags[0]['severity'] == lsp.DiagnosticSeverity.Error ++ ++ ++def test_parse_stdout_w291_trailing_whitespace_is_warning(workspace): ++ doc = _make_doc(workspace) ++ stdout = _stdout_line(1, 6, "W291", "trailing whitespace") + "\n" ++ diags = flake8_lint.parse_stdout(doc, stdout) ++ assert len(diags) == 1 ++ assert diags[0]['code'] == 'W291' ++ assert diags[0]['severity'] == lsp.DiagnosticSeverity.Warning ++ ++ ++def test_parse_stdout_c901_mccabe_complexity_is_warning(workspace): ++ doc = _make_doc(workspace) ++ stdout = _stdout_line(1, 1, "C901", "'func' is too complex (11)") + "\n" ++ diags = flake8_lint.parse_stdout(doc, stdout) ++ assert len(diags) == 1 ++ assert diags[0]['code'] == 'C901' ++ assert diags[0]['severity'] == lsp.DiagnosticSeverity.Warning ++ ++ + def test_per_file_ignores_alternative_syntax(workspace): + config_str = r"""[flake8] + per-file-ignores = **/__init__.py:F401,E402 +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..f3ec867 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest test/plugins/test_flake8_lint.py -k parse_stdout"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest -rA test/plugins/test_flake8_lint.py::test_parse_stdout_f401_unused_import_is_error test/plugins/test_flake8_lint.py::test_parse_stdout_f841_unused_variable_is_error test/plugins/test_flake8_lint.py::test_parse_stdout_f821_undefined_name_is_error test/plugins/test_flake8_lint.py::test_parse_stdout_e999_syntax_error_is_error test/plugins/test_flake8_lint.py::test_parse_stdout_w291_trailing_whitespace_is_warning test/plugins/test_flake8_lint.py::test_parse_stdout_c901_mccabe_complexity_is_warning ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002410/tests/test.sh b/tasks/format-code-task-002410/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..08af6c19aa7e7f5428210c94ef79e533cbde4f5a --- /dev/null +++ b/tasks/format-code-task-002410/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/plugins/test_flake8_lint.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002410/tests/test_command.sh b/tasks/format-code-task-002410/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002410/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002418/environment/Dockerfile b/tasks/format-code-task-002418/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e23bd1dc1c052b9372a2dbb3f1928828b85fe121 --- /dev/null +++ b/tasks/format-code-task-002418/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f050c59ab4c015e9ac168563d9a90a4aeda20090ca933fc795486353cc35f836 diff --git a/tasks/format-code-task-002418/environment/setup/files/blocklist b/tasks/format-code-task-002418/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002418/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002418/environment/setup/setup.sh b/tasks/format-code-task-002418/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002418/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002418/tests/test.patch b/tasks/format-code-task-002418/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a6d2a4e9cdb903b9e0718b363ab91346398e4abb --- /dev/null +++ b/tasks/format-code-task-002418/tests/test.patch @@ -0,0 +1,79 @@ +diff --git a/tests/unit/semantic_release/changelog/test_changelog_context.py b/tests/unit/semantic_release/changelog/test_changelog_context.py +index 5ed8d300f..39c3897ca 100644 +--- a/tests/unit/semantic_release/changelog/test_changelog_context.py ++++ b/tests/unit/semantic_release/changelog/test_changelog_context.py +@@ -439,3 +439,53 @@ def test_changelog_context_read_file_fails_gracefully( + + # Evaluate + assert expected_changelog == actual_changelog ++ ++ ++def test_changelog_context_autofit_text_width( ++ example_git_https_url: str, ++ artificial_release_history: ReleaseHistory, ++ changelog_md_file: Path, ++): ++ changelog_tpl = """{{ "This is a long line that should be autofitted" | autofit_text_width(20) }}""" ++ expected_changelog = "This is a long line\nthat should be\nautofitted" ++ ++ env = environment(trim_blocks=True, lstrip_blocks=True, keep_trailing_newline=True) ++ context = make_changelog_context( ++ hvcs_client=Gitlab(example_git_https_url), ++ release_history=artificial_release_history, ++ mode=ChangelogMode.UPDATE, ++ prev_changelog_file=changelog_md_file, ++ insertion_flag="", ++ ) ++ context.bind_to_environment(env) ++ ++ ++ actual_changelog = env.from_string(changelog_tpl).render() ++ ++ ++ assert expected_changelog == actual_changelog ++ ++ ++def test_changelog_context_autofit_text_width_w_indent( ++ example_git_https_url: str, ++ artificial_release_history: ReleaseHistory, ++ changelog_md_file: Path, ++): ++ changelog_tpl = """{{ "This is a long line that should be autofitted" | autofit_text_width(20, indent_size=2) }}""" ++ expected_changelog = "This is a long line\n that should be\n autofitted" ++ ++ env = environment(trim_blocks=True, lstrip_blocks=True, keep_trailing_newline=True) ++ context = make_changelog_context( ++ hvcs_client=Gitlab(example_git_https_url), ++ release_history=artificial_release_history, ++ mode=ChangelogMode.UPDATE, ++ prev_changelog_file=changelog_md_file, ++ insertion_flag="", ++ ) ++ context.bind_to_environment(env) ++ ++ ++ actual_changelog = env.from_string(changelog_tpl).render() ++ ++ ++ assert expected_changelog == actual_changelog +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3S0WrDIBQG4FznKXyBRs1m8jjBmEMTSLTEk9C+/WxY2zHYetMyyv7vwqMoKP6n ++aJdh7Bryq8yeRSW1MVtNvtdtrk2pS1VVqqwzpXWqmTBPe9EXS2Q7C5HNIfBv5+7tv6jilj9T5MaF ++abK+K2L/uDvu5V+qt0v+pq50yv+90iYT6nFP+Nk/z991Ygu+pS6PYZkdXdeyWM9t0Q5eWsfDapny ++w4n74MVuEmmWjonzEOXiB5aRUufw4JqZRrKRpOut39MY9p+tdVmmJvNMRy4OJ7Fb87/+AgAAAAAA ++AAAAAAAAAAAAAACAl/UBlSsrMQAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002418/tests/test.sh b/tasks/format-code-task-002418/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bdabaa1faf23e2364dbf3a84f90d7b17f184af56 --- /dev/null +++ b/tasks/format-code-task-002418/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/unit/semantic_release/changelog/test_changelog_context.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002418/tests/test_command.sh b/tasks/format-code-task-002418/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002418/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002419/environment/Dockerfile b/tasks/format-code-task-002419/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0aaf77fea754cf2e727dad619a7305db0965fcf5 --- /dev/null +++ b/tasks/format-code-task-002419/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7044faee08004e8f6b91c7a2ed3bf0c8d7a115b4a10fcbd17fa877777fc55fbc diff --git a/tasks/format-code-task-002419/environment/setup/files/blocklist b/tasks/format-code-task-002419/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002419/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002419/environment/setup/setup.sh b/tasks/format-code-task-002419/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002419/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002419/tests/test.patch b/tasks/format-code-task-002419/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ab7b1d8b5c6a16b1a7b475fe03fa6aacb64fedc3 --- /dev/null +++ b/tasks/format-code-task-002419/tests/test.patch @@ -0,0 +1,97 @@ +diff --git a/tests/test_encoding.py b/tests/test_encoding.py +index 86567ffb..db5bccf8 100644 +--- a/tests/test_encoding.py ++++ b/tests/test_encoding.py +@@ -4,7 +4,71 @@ + import pytest + + # local +-from validators import ValidationError, base58, base64 ++from validators import ValidationError, base16, base32, base58, base64 ++ ++ ++ ++ ++@pytest.mark.parametrize( ++ "value", ++ [ ++ "a3f4b2", ++ "01ef", ++ "abcdef0123456789", ++ "1234567890abcdef", ++ "1a2b3c", ++ "abcdef", ++ "000102030405060708090A0B0C0D0E0F", ++ ], ++) ++def test_returns_true_on_valid_base16(value: str): ++ """Test returns true on valid base16.""" ++ assert base16(value) ++ ++ ++@pytest.mark.parametrize( ++ "value", ++ ["12345g", "hello world", "1234567890abcdeg", "GHIJKL", "12345G", "!@#$%^", "1a2h3c", "a3f4Z1"], ++) ++def test_returns_failed_validation_on_invalid_base16(value: str): ++ """Test returns failed validation on invalid base16.""" ++ assert isinstance(base16(value), ValidationError) ++ ++ ++ ++ ++ ++@pytest.mark.parametrize( ++ "value", ++ [ ++ "JBSWY3DPEHPK3PXP", ++ "MFRGGZDFMZTWQ2LK", ++ "MZXW6YTBOI======", ++ "MFZWIZLTOQ======", ++ "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ", ++ "MFRGGZDFMZTWQ2LKNNWG23Q=", ++ ], ++) ++def test_returns_true_on_valid_base32(value: str): ++ """Test returns true on valid base32.""" ++ assert base32(value) ++ ++ ++@pytest.mark.parametrize( ++ "value", ++ [ ++ "ThisIsNotBase32!", ++ "12345!", ++ "Any==invalid=base32=", ++ "MzXW6yTBOI======", ++ "JBSWY8DPEHPK9PXP", ++ "MfZW3zLT9Q======", ++ ], ++) ++def test_returns_failed_validation_on_invalid_base32(value: str): ++ """Test returns failed validation on invalid base32.""" ++ assert isinstance(base32(value), ValidationError) ++ + + # ==> base58 <== # + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3S0QqCMBTG8V33FHsBzZnTx5F0kkFukTPw7Vt2YQTVjRHR/3exc9gGO/Atrob9 ++wZSNPa/FpyRBofVUg8c69UqnShV5kauNSJTKVSqk/thEd4beb09SipNz/tW9d+c/Kp7z903vy9p1 ++3daauG+Xe+Nt/sWcv87CvsryNOSfLDfCc3+ef23kFHzVmNVx9K2zGxl1MrRhU16X/vYxGls7s7e7 +++DjK6Lz69twAAAAAAAAAAAAAAAAAhLgAPGDymAAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002419/tests/test.sh b/tasks/format-code-task-002419/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6bc1f9669e6180c2109a144f18e3beab62b7dd7a --- /dev/null +++ b/tasks/format-code-task-002419/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/test_encoding.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002419/tests/test_command.sh b/tasks/format-code-task-002419/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002419/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002426/environment/Dockerfile b/tasks/format-code-task-002426/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..513313653b4a2951e9a6ab97d4de302ffa5b010c --- /dev/null +++ b/tasks/format-code-task-002426/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:abf52efd9ccf793e66b052612284f8ab34ec89ac4c353df4bffa2df2ec442dc4 diff --git a/tasks/format-code-task-002426/environment/setup/files/blocklist b/tasks/format-code-task-002426/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002426/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002426/environment/setup/setup.sh b/tasks/format-code-task-002426/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002426/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002426/tests/test.patch b/tasks/format-code-task-002426/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..75f52cbf8c4603f2bf787818cfe0c2d66e866667 --- /dev/null +++ b/tasks/format-code-task-002426/tests/test.patch @@ -0,0 +1,54 @@ +diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py +index a115e60d4e4f08..bb0144b12d4107 100644 +--- a/Lib/test/test_imp.py ++++ b/Lib/test/test_imp.py +@@ -2,6 +2,7 @@ + import importlib.util + import os + import os.path ++import py_compile + import sys + from test import support + from test.support import script_helper +@@ -350,6 +351,20 @@ def test_pyc_invalidation_mode_from_cmdline(self): + res = script_helper.assert_python_ok(*args) + self.assertEqual(res.out.strip().decode('utf-8'), expected) + ++ def test_find_and_load_checked_pyc(self): ++ ++ with support.temp_cwd(): ++ with open('mymod.py', 'wb') as fp: ++ fp.write(b'x = 42\n') ++ py_compile.compile( ++ 'mymod.py', ++ doraise=True, ++ invalidation_mode=py_compile.PycInvalidationMode.CHECKED_HASH, ++ ) ++ file, path, description = imp.find_module('mymod', path=['.']) ++ mod = imp.load_module('mymod', file, path, description) ++ self.assertEqual(mod.x, 42) ++ + + class ReloadTests(unittest.TestCase): + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3R0U7DIBQG4F73Kc6FMXpRKF3prtyrNF1hrlqgobRxbz9sYmY0upstZvH/LuAk ++nMAJP9tOXa9qbWeeXEseraVc9ujrvtRCFkJUlSzXsS9WQiYkrzbRJ9MYGk+UeOfCb33nzm8UO+Uf ++9Bjq1hnTWMXG/eXeOJd/kYtT/qtVzL+sRJlQfrkRfvbP828VLcFvtUoZb53ddc+T15Rlg9e77u3p ++45R3Nv5U39OGuNIzt1Osi829SE3zGvtf7h7s4F37+L2B8eEQ9s5SZuj9tmWpOzNQNqd//QEAAAAA ++AAAAAAAAAAAAAAAAADfsCHJsrWMAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002426/tests/test.sh b/tasks/format-code-task-002426/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..064ae545739305d87143dfcc1bd27c0f6557ce6a --- /dev/null +++ b/tasks/format-code-task-002426/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +Lib/test/test_imp.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002426/tests/test_command.sh b/tasks/format-code-task-002426/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002426/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002427/environment/Dockerfile b/tasks/format-code-task-002427/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..80d086c702df3af2878b0337f353bb9a540c334d --- /dev/null +++ b/tasks/format-code-task-002427/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:cff06be8522b58cd9cd9a7b5adb737422cb46ccd87f9a346215721c6a1fa677f diff --git a/tasks/format-code-task-002427/environment/setup/files/blocklist b/tasks/format-code-task-002427/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002427/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002427/environment/setup/setup.sh b/tasks/format-code-task-002427/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002427/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002427/tests/test.patch b/tasks/format-code-task-002427/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6acb4c1d79eb2038b31138a15a2d7c87c65a9b83 --- /dev/null +++ b/tasks/format-code-task-002427/tests/test.patch @@ -0,0 +1,126 @@ +diff --git a/mypy/test/testdaemoninstalltypes.py b/mypy/test/testdaemoninstalltypes.py +new file mode 100644 +index 000000000..32755aeed +--- /dev/null ++++ b/mypy/test/testdaemoninstalltypes.py +@@ -0,0 +1,98 @@ ++ ++ ++ ++ ++ ++ ++ ++import os ++import tempfile ++ ++import mypy.build ++from mypy.errors import CompileError ++from mypy.modulefinder import BuildSource ++from mypy.options import Options ++from mypy.test.helpers import Suite ++ ++ ++INSTALL_TYPES_HINT = 'mypy --install-types' ++PIP_HINT_PREFIX = 'Hint: "python3 -m pip install types-requests"' ++DOC_LINK_FRAGMENT = 'mypy.readthedocs.io' ++LIBRARY_STUBS_NOT_INSTALLED = 'Library stubs not installed for "requests"' ++ ++ ++def _run_build(tmpdir: str, fine_grained_incremental: bool): ++ src = os.path.join(tmpdir, 't.py') ++ with open(src, 'w') as f: ++ f.write('import requests\n') ++ options = Options() ++ options.cache_dir = os.devnull ++ options.show_traceback = True ++ if fine_grained_incremental: ++ options.incremental = True ++ options.fine_grained_incremental = True ++ sources = [BuildSource(src, 't', None)] ++ try: ++ result = mypy.build.build(sources=sources, options=options) ++ return list(result.errors) ++ except CompileError as e: ++ return list(e.messages) ++ ++ ++class DaemonInstallTypesHintSuite(Suite): ++ ++ def test_non_daemon_includes_install_types_hint(self) -> None: ++ ++ with tempfile.TemporaryDirectory() as td: ++ errors = _run_build(td, fine_grained_incremental=False) ++ joined = '\n'.join(errors) ++ assert INSTALL_TYPES_HINT in joined, ( ++ 'Expected install-types hint in non-daemon output:\n' + joined ++ ) ++ ++ def test_daemon_omits_install_types_hint(self) -> None: ++ ++ with tempfile.TemporaryDirectory() as td: ++ errors = _run_build(td, fine_grained_incremental=True) ++ joined = '\n'.join(errors) ++ assert INSTALL_TYPES_HINT not in joined, ( ++ 'install-types hint must be suppressed in daemon mode:\n' + joined ++ ) ++ ++ def test_daemon_still_reports_library_stub_error(self) -> None: ++ ++ with tempfile.TemporaryDirectory() as td: ++ errors = _run_build(td, fine_grained_incremental=True) ++ joined = '\n'.join(errors) ++ assert LIBRARY_STUBS_NOT_INSTALLED in joined, ( ++ 'Expected library stubs not installed error in daemon output:\n' ++ + joined ++ ) ++ ++ def test_daemon_still_includes_pip_install_hint(self) -> None: ++ ++ with tempfile.TemporaryDirectory() as td: ++ errors = _run_build(td, fine_grained_incremental=True) ++ joined = '\n'.join(errors) ++ assert PIP_HINT_PREFIX in joined, ( ++ 'Expected pip install hint in daemon output:\n' + joined ++ ) ++ ++ def test_daemon_still_includes_doc_link(self) -> None: ++ ++ with tempfile.TemporaryDirectory() as td: ++ errors = _run_build(td, fine_grained_incremental=True) ++ joined = '\n'.join(errors) ++ assert DOC_LINK_FRAGMENT in joined, ( ++ 'Expected docs link in daemon output:\n' + joined ++ ) ++ ++ def test_non_daemon_includes_all_three_notes(self) -> None: ++ ++ with tempfile.TemporaryDirectory() as td: ++ errors = _run_build(td, fine_grained_incremental=False) ++ joined = '\n'.join(errors) ++ assert PIP_HINT_PREFIX in joined ++ assert INSTALL_TYPES_HINT in joined ++ assert DOC_LINK_FRAGMENT in joined ++ assert LIBRARY_STUBS_NOT_INSTALLED in joined +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..19a081709 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest mypy/test/testdaemoninstalltypes.py"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest mypy/test/testdaemoninstalltypes.py ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002427/tests/test.sh b/tasks/format-code-task-002427/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..621496d2dcf9310844502f05249e52f4d889c5f1 --- /dev/null +++ b/tasks/format-code-task-002427/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +mypy/test/testdaemoninstalltypes.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002427/tests/test_command.sh b/tasks/format-code-task-002427/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002427/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002443/environment/Dockerfile b/tasks/format-code-task-002443/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..53acc6b5af0f942ae121c22d99d9eca0941dbc12 --- /dev/null +++ b/tasks/format-code-task-002443/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ba7b1f95ffa76e52ffd04162956c61fef4f8d26d97af092652d42e1ac94f348e diff --git a/tasks/format-code-task-002443/environment/setup/files/blocklist b/tasks/format-code-task-002443/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002443/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002443/environment/setup/setup.sh b/tasks/format-code-task-002443/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002443/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002443/tests/test.patch b/tasks/format-code-task-002443/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ea1ff7d77fabaf4ff4f5e95b7d4357727dd8480c --- /dev/null +++ b/tasks/format-code-task-002443/tests/test.patch @@ -0,0 +1,129 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..3dd62e27a +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m unittest test_stub_ellipsis -v"] ++} +diff --git a/test_stub_ellipsis.py b/test_stub_ellipsis.py +new file mode 100644 +index 000000000..77bf9cee6 +--- /dev/null ++++ b/test_stub_ellipsis.py +@@ -0,0 +1,101 @@ ++ ++ ++import os ++import shutil ++import tempfile ++import unittest ++ ++from mypy.stubgen import generate_stub ++from mypy.stubgenc import generate_c_function_stub, generate_c_type_stub ++ ++ ++def _gen_py_stub(source): ++ tmpdir = tempfile.mkdtemp() ++ try: ++ src_path = os.path.join(tmpdir, 'mod.py') ++ with open(src_path, 'w') as f: ++ f.write(source) ++ out_dir = os.path.join(tmpdir, 'out') ++ os.makedirs(out_dir) ++ generate_stub(src_path, out_dir) ++ with open(os.path.join(out_dir, 'mod.py')) as f: ++ return f.read() ++ finally: ++ shutil.rmtree(tmpdir) ++ ++ ++class StubgenPyEllipsisTests(unittest.TestCase): ++ ++ ++ def test_function_body_uses_ellipsis(self): ++ out = _gen_py_stub('def f():\n x = 1\n') ++ self.assertIn('def f(): ...', out) ++ self.assertNotIn(': pass', out) ++ ++ def test_function_with_args_uses_ellipsis(self): ++ out = _gen_py_stub('def f(a, b=2): return 1\n') ++ self.assertIn('def f(a, b=2): ...', out) ++ self.assertNotIn('pass', out) ++ ++ def test_empty_class_uses_ellipsis(self): ++ out = _gen_py_stub('class A: pass\n') ++ self.assertIn('class A: ...', out) ++ self.assertNotIn(': pass', out) ++ ++ def test_empty_class_with_base_uses_ellipsis(self): ++ out = _gen_py_stub('class A: pass\nclass B(A): pass\n') ++ self.assertIn('class A: ...', out) ++ self.assertIn('class B(A): ...', out) ++ self.assertNotIn(': pass', out) ++ ++ def test_method_inside_class_uses_ellipsis(self): ++ out = _gen_py_stub('class A:\n def m(self, x): return x\n') ++ ++ self.assertIn('def m(self, x): ...', out) ++ self.assertNotIn('pass', out) ++ ++ def test_class_made_empty_after_stripping_uses_ellipsis(self): ++ ++ out = _gen_py_stub('class A:\n def _f(self): pass\n') ++ self.assertIn('class A: ...', out) ++ self.assertNotIn(': pass', out) ++ ++ def test_decorated_function_uses_ellipsis(self): ++ out = _gen_py_stub('@decorator\ndef foo(x): pass\n') ++ self.assertIn('def foo(x): ...', out) ++ self.assertNotIn(': pass', out) ++ ++ ++class StubgencEllipsisTests(unittest.TestCase): ++ ++ ++ def test_c_function_stub_uses_ellipsis(self): ++ out = [] ++ generate_c_function_stub(None, 'myfunc', lambda: None, out) ++ self.assertEqual(out, ['def myfunc(*args, **kwargs): ...']) ++ ++ def test_c_function_stub_no_pass(self): ++ out = [] ++ generate_c_function_stub(None, 'fn', lambda: None, out) ++ self.assertNotIn('pass', out[0]) ++ self.assertTrue(out[0].endswith(': ...')) ++ ++ def test_empty_c_type_stub_uses_ellipsis(self): ++ class Empty: ++ pass ++ out = [] ++ generate_c_type_stub(None, 'Empty', Empty, out) ++ ++ self.assertEqual(len(out), 1) ++ self.assertEqual(out[0], 'class Empty: ...') ++ ++ def test_empty_c_type_stub_no_pass(self): ++ class Empty: ++ pass ++ out = [] ++ generate_c_type_stub(None, 'Empty', Empty, out) ++ self.assertNotIn('pass', out[0]) ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m unittest test_stub_ellipsis -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002443/tests/test.sh b/tasks/format-code-task-002443/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..71cc65bf19430bbe43d1f3ba975d50165f4ac9d8 --- /dev/null +++ b/tasks/format-code-task-002443/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +test_stub_ellipsis.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002443/tests/test_command.sh b/tasks/format-code-task-002443/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002443/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002444/environment/Dockerfile b/tasks/format-code-task-002444/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0643bbd378d3dc50e85624e8f4549e9a9ff6374d --- /dev/null +++ b/tasks/format-code-task-002444/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d95159dc259e273f3f3687442d4fa958d0e1774f5a2708d2283dd24709e56afe diff --git a/tasks/format-code-task-002444/environment/setup/files/blocklist b/tasks/format-code-task-002444/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002444/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002444/environment/setup/setup.sh b/tasks/format-code-task-002444/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002444/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002444/tests/test.patch b/tasks/format-code-task-002444/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a321fe46b68cf7bbc452ec4ec6898643d2d9efe7 --- /dev/null +++ b/tasks/format-code-task-002444/tests/test.patch @@ -0,0 +1,76 @@ +diff --git a/test-data/unit/check-classes.test b/test-data/unit/check-classes.test +index addcc520f..56795c7de 100644 +--- a/test-data/unit/check-classes.test ++++ b/test-data/unit/check-classes.test +@@ -6453,3 +6453,49 @@ reveal_type(Foo().y) # N: Revealed type is 'builtins.list[Any]' + class Foo: + def bad(): # E: Method must have at least one argument + self.x = 0 # E: Name 'self' is not defined ++ ++[case testInitSubclassSuperCallStarArgs] ++class A: ++ def __init_subclass__(cls, *args, **kwargs): ++ pass ++ ++class B(A): ++ pass ++[builtins fixtures/object_with_init_subclass.pyi] ++ ++[case testInitSubclassSuperCallNoArgs] ++class A: ++ def __init_subclass__(cls): ++ super().__init_subclass__() ++ ++class B(A): ++ pass ++[builtins fixtures/object_with_init_subclass.pyi] ++ ++[case testInitSubclassWithRegisterKwarg] ++class A: ++ def __init_subclass__(cls, *args, register: bool = True, **kwargs): ++ pass ++ ++class B(A): ++ pass ++ ++class C(A, register=False): ++ pass ++ ++class D(C): ++ pass ++[builtins fixtures/object_with_init_subclass.pyi] ++ ++[case testInitSubclassMissingRequiredKwargStillErrors] ++class A: ++ def __init_subclass__(cls, *, x: int) -> None: ++ pass ++ ++class B(A): # E: Missing named argument "x" for "__init_subclass__" of "A" ++ pass ++ ++class C(A, x=1): ++ pass ++[builtins fixtures/object_with_init_subclass.pyi] ++ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..af593237a +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest mypy/test/testcheck.py -k 'testInitSubclassSuperCallStarArgs or testInitSubclassSuperCallNoArgs or testInitSubclassWithRegisterKwarg or testInitSubclassMissingRequiredKwargStillErrors'"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m pytest mypy/test/testcheck.py -k 'testInitSubclassSuperCallStarArgs or testInitSubclassSuperCallNoArgs or testInitSubclassWithRegisterKwarg or testInitSubclassMissingRequiredKwargStillErrors' ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002444/tests/test.sh b/tasks/format-code-task-002444/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ef85e6092de0447a38a79628a4badb948b95799c --- /dev/null +++ b/tasks/format-code-task-002444/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test-data/unit/check-classes.test +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002444/tests/test_command.sh b/tasks/format-code-task-002444/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002444/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002472/environment/Dockerfile b/tasks/format-code-task-002472/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..64964311b8bab4eef0a182b0609e3e1a84c8cde8 --- /dev/null +++ b/tasks/format-code-task-002472/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a41b8702287dec796f77fd04dddfd87e2fcf9f03db9e85d0b8fa954e3b9415f6 diff --git a/tasks/format-code-task-002472/environment/setup/files/blocklist b/tasks/format-code-task-002472/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002472/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002472/environment/setup/setup.sh b/tasks/format-code-task-002472/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002472/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002472/tests/test.patch b/tasks/format-code-task-002472/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cb02e85656a9579573f1d7f54d46eabd2217a7ce --- /dev/null +++ b/tasks/format-code-task-002472/tests/test.patch @@ -0,0 +1,99 @@ +diff --git a/src/test/groovy/com/adarshr/gradle/testlogger/theme/MochaThemeSpec.groovy b/src/test/groovy/com/adarshr/gradle/testlogger/theme/MochaThemeSpec.groovy +index f3c6ffd..cf7b9a2 100644 +--- a/src/test/groovy/com/adarshr/gradle/testlogger/theme/MochaThemeSpec.groovy ++++ b/src/test/groovy/com/adarshr/gradle/testlogger/theme/MochaThemeSpec.groovy +@@ -33,18 +33,18 @@ class MochaThemeSpec extends Specification { + given: + System.setProperty('os.name', os) + testResultMock.resultType >> resultType +- testDescriptorMock.name >> 'method' ++ testDescriptorMock.name >> 'test name [escaped]' + when: + def actual = theme.afterTest(testDescriptorMock, testResultMock) + then: + actual == expected + where: + os | resultType | expected +- 'Windows 8.1' | SUCCESS | ' [erase-ahead,green]√[/] method' +- 'Windows 8.1' | FAILURE | ' [erase-ahead,red]X method[/]' +- 'Windows 8.1' | SKIPPED | ' [erase-ahead,yellow]% method[/]' +- 'Linux' | SUCCESS | ' [erase-ahead,green]✔[/] method' +- 'Linux' | FAILURE | ' [erase-ahead,red]✘ method[/]' +- 'Linux' | SKIPPED | ' [erase-ahead,yellow]✂ method[/]' ++ 'Windows 8.1' | SUCCESS | ' [erase-ahead,green]√[/] test name \\[escaped\\]' ++ 'Windows 8.1' | FAILURE | ' [erase-ahead,red]X test name \\[escaped\\][/]' ++ 'Windows 8.1' | SKIPPED | ' [erase-ahead,yellow]% test name \\[escaped\\][/]' ++ 'Linux' | SUCCESS | ' [erase-ahead,green]✔[/] test name \\[escaped\\]' ++ 'Linux' | FAILURE | ' [erase-ahead,red]✘ test name \\[escaped\\][/]' ++ 'Linux' | SKIPPED | ' [erase-ahead,yellow]✂ test name \\[escaped\\][/]' + } + } +diff --git a/src/test/groovy/com/adarshr/gradle/testlogger/theme/PlainThemeSpec.groovy b/src/test/groovy/com/adarshr/gradle/testlogger/theme/PlainThemeSpec.groovy +index 870a45e..29944dd 100644 +--- a/src/test/groovy/com/adarshr/gradle/testlogger/theme/PlainThemeSpec.groovy ++++ b/src/test/groovy/com/adarshr/gradle/testlogger/theme/PlainThemeSpec.groovy +@@ -26,15 +26,15 @@ class PlainThemeSpec extends Specification { + def "after test with result type #resultType"() { + given: + testResultMock.resultType >> resultType +- testDescriptorMock.name >> 'method' ++ testDescriptorMock.name >> 'test name [escaped]' + when: + def actual = theme.afterTest(testDescriptorMock, testResultMock) + then: + actual == expected + where: + resultType | expected +- SUCCESS | ' Test method PASSED' +- FAILURE | ' Test method FAILED' +- SKIPPED | ' Test method SKIPPED' ++ SUCCESS | ' Test test name \\[escaped\\] PASSED' ++ FAILURE | ' Test test name \\[escaped\\] FAILED' ++ SKIPPED | ' Test test name \\[escaped\\] SKIPPED' + } + } +diff --git a/src/test/groovy/com/adarshr/gradle/testlogger/theme/StandardThemeSpec.groovy b/src/test/groovy/com/adarshr/gradle/testlogger/theme/StandardThemeSpec.groovy +index 05c2863..3bb6034 100644 +--- a/src/test/groovy/com/adarshr/gradle/testlogger/theme/StandardThemeSpec.groovy ++++ b/src/test/groovy/com/adarshr/gradle/testlogger/theme/StandardThemeSpec.groovy +@@ -26,15 +26,15 @@ class StandardThemeSpec extends Specification { + def "after test with result type #resultType"() { + given: + testResultMock.resultType >> resultType +- testDescriptorMock.name >> 'method' ++ testDescriptorMock.name >> 'test name [escaped]' + when: + def actual = theme.afterTest(testDescriptorMock, testResultMock) + then: + actual == expected + where: + resultType | expected +- SUCCESS | '[bold] Test [/]method[erase-ahead,green] PASSED[/]' +- FAILURE | '[bold] Test [/]method[erase-ahead,red] FAILED[/]' +- SKIPPED | '[bold] Test [/]method[erase-ahead,yellow] SKIPPED[/]' ++ SUCCESS | '[bold] Test [/]test name \\[escaped\\][erase-ahead,green] PASSED[/]' ++ FAILURE | '[bold] Test [/]test name \\[escaped\\][erase-ahead,red] FAILED[/]' ++ SKIPPED | '[bold] Test [/]test name \\[escaped\\][erase-ahead,yellow] SKIPPED[/]' + } + } +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3S3WrDIBQH8FznKVx3HRPbWa/2CINCd19MlCRgtKhdX3+awb5gK9taxtj/d3MO ++8RyUnEPbw2jUTtuHuriUJhGczzF5H+ec8SVjItUtV0XDGBeiIPxiL3rlEKL0hBTeufhZ3anzP4q+ ++zD/qEHedmyZpFQ3D+e44Nf+V4M/zXzepjt2sWZp/c74nfOyfz//6qm5HW7cyDGWnyLwErVYlrXsv ++ldFHkr+QqsohkEXaDyqV9GHw9KmC5hPj+l57Ggc9aXrnukHe53S7193ia80bI0f73eZtTLsrvXrT ++b12lpJ6cTXnnbHBG3+7zLeVv/3wAAAAAAAAAAAAAAAAAAAAAgB96BA1aOEIAKAAA +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++# Verifier for the opensource-code dataset. Exit 0 means resolved. ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002472/tests/test.sh b/tasks/format-code-task-002472/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cc7f30e107890c1cdb20d0ab42487dc75ebf2580 --- /dev/null +++ b/tasks/format-code-task-002472/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +src/test/groovy/com/adarshr/gradle/testlogger/theme/MochaThemeSpec.groovy +src/test/groovy/com/adarshr/gradle/testlogger/theme/PlainThemeSpec.groovy +src/test/groovy/com/adarshr/gradle/testlogger/theme/StandardThemeSpec.groovy +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002472/tests/test_command.sh b/tasks/format-code-task-002472/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002472/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002475/environment/Dockerfile b/tasks/format-code-task-002475/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b86be2719988273ae9da8565b5ce38bfa2e170fe --- /dev/null +++ b/tasks/format-code-task-002475/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:cf77a0a0622f4e8c9fdd41267ab156eaf907e7b4fbfa5d77cdb4c5f32b3b056b diff --git a/tasks/format-code-task-002475/environment/setup/files/blocklist b/tasks/format-code-task-002475/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002475/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002475/environment/setup/setup.sh b/tasks/format-code-task-002475/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002475/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002475/tests/test.patch b/tasks/format-code-task-002475/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fb832f8cea74378686cbbba105de3d440bdc5c4b --- /dev/null +++ b/tasks/format-code-task-002475/tests/test.patch @@ -0,0 +1,579 @@ +diff --git a/usercase-test-coderl/listview-states.test.js b/usercase-test-coderl/listview-states.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/listview-states.test.js +@@ -0,0 +1,532 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++const assert = require("assert"); ++const childProcess = require("child_process"); ++const fs = require("fs"); ++const Module = require("module"); ++const path = require("path"); ++ ++function installSourceHarness() { ++ if (global.__USERCASE_LISTVIEW_HARNESS__) return; ++ global.__USERCASE_LISTVIEW_HARNESS__ = true; ++ ++ require.extensions[".scss"] = function ignoreScss(module) { ++ module.exports = {}; ++ }; ++ ++ const originalResolve = Module._resolveFilename; ++ const originalLoad = Module._load; ++ ++ function isFile(candidate) { ++ try { ++ return fs.statSync(candidate).isFile(); ++ } catch (_) { ++ return false; ++ } ++ } ++ ++ function resolveSourceFile(base) { ++ const candidates = [ ++ base, ++ `${base}.tsx`, ++ `${base}.ts`, ++ `${base}.jsx`, ++ `${base}.js`, ++ path.join(base, "index.tsx"), ++ path.join(base, "index.ts"), ++ path.join(base, "index.js"), ++ ]; ++ return candidates.find(isFile) || base; ++ } ++ ++ Module._resolveFilename = function resolveWorkspaceSource(request, parent, isMain, options) { ++ if (request === "components") { ++ return "/workspace/repo/src/components/index.ts"; ++ } ++ if (request.startsWith("components/")) { ++ return resolveSourceFile(path.join("/workspace/repo/src/components", request.slice("components/".length))); ++ } ++ if ( ++ (request.startsWith("./") || request.startsWith("../")) && ++ parent && ++ parent.filename && ++ parent.filename.startsWith("/workspace/repo/src/") ++ ) { ++ return resolveSourceFile(path.resolve(path.dirname(parent.filename), request)); ++ } ++ return originalResolve.call(this, request, parent, isMain, options); ++ }; ++ ++ function makeSelectorQuery() { ++ return { ++ in() { ++ return this; ++ }, ++ select() { ++ return this; ++ }, ++ selectAll() { ++ return this; ++ }, ++ boundingClientRect() { ++ return this; ++ }, ++ exec(cb) { ++ if (cb) cb([[]]); ++ }, ++ }; ++ } ++ ++ const taro = { ++ getEnv: () => "WEAPP", ++ createSelectorQuery: makeSelectorQuery, ++ Current: {}, ++ eventCenter: { on() {}, off() {}, trigger() {} }, ++ }; ++ ++ Module._load = function loadHarnessModule(request, parent, isMain) { ++ if (request === "@tarojs/components") { ++ return { View: "View", ScrollView: "ScrollView" }; ++ } ++ if (request === "@tarojs/taro") { ++ return Object.assign({ default: taro }, taro); ++ } ++ return originalLoad.call(this, request, parent, isMain); ++ }; ++ ++ require("@babel/register")({ ++ cache: false, ++ babelrc: false, ++ configFile: false, ++ cwd: "/workspace/repo", ++ extensions: [".js", ".jsx", ".ts", ".tsx"], ++ ignore: [/node_modules/], ++ presets: [ ++ [require.resolve("@babel/preset-typescript"), { isTSX: true, allExtensions: true }], ++ [require.resolve("@babel/preset-react"), { runtime: "classic" }], ++ ], ++ plugins: [require.resolve("@babel/plugin-transform-modules-commonjs")], ++ }); ++} ++ ++installSourceHarness(); ++ ++const React = require("react"); ++const ReactDOMServer = require("react-dom/server"); ++const { ListView } = require("/workspace/repo/src/index.ts"); ++const DEFAULT_ERROR_TEXT = "啊哦,网络悄悄跑到外星球去了~"; ++const RETRY_TEXT = "重新加载"; ++ ++function renderSummary(props) { ++ const summary = renderWithCapturedEvents(props); ++ return { ++ html: summary.html, ++ textContent: summary.textContent, ++ visibleTextContent: summary.visibleTextContent, ++ clickTexts: summary.clickTexts, ++ }; ++} ++ ++function decodeHtml(value) { ++ return String(value) ++ .replace(/ /g, " ") ++ .replace(/&/g, "&") ++ .replace(/</g, "<") ++ .replace(/>/g, ">") ++ .replace(/"/g, '"') ++ .replace(/'/g, "'") ++ .replace(/&#(\d+);/g, (_, code) => String.fromCharCode(Number(code))); ++} ++ ++function textFromHtml(html) { ++ return decodeHtml(String(html).replace(/<[^>]*>/g, "")); ++} ++ ++function visibleTextFromHtml(html) { ++ const tokens = String(html).match(/<[^>]+>|[^<]+/g) || []; ++ const hiddenStack = []; ++ let text = ""; ++ for (const token of tokens) { ++ if (token.startsWith("<")) { ++ if (/^<\//.test(token)) { ++ hiddenStack.pop(); ++ continue; ++ } ++ const styleMatch = token.match(/\sstyle="([^"]*)"/); ++ const style = styleMatch ? styleMatch[1].replace(/\s/g, "").toLowerCase() : ""; ++ const selfHidden = ++ /\shidden(?:\s|=|>)/i.test(token) || ++ style.includes("display:none") || ++ style.includes("visibility:hidden") || ++ style.includes("opacity:0"); ++ const parentHidden = hiddenStack.length > 0 && hiddenStack[hiddenStack.length - 1]; ++ const selfClosing = /\/>$/.test(token); ++ if (!selfClosing) hiddenStack.push(Boolean(parentHidden || selfHidden)); ++ } else if (!(hiddenStack.length > 0 && hiddenStack[hiddenStack.length - 1])) { ++ text += token; ++ } ++ } ++ return decodeHtml(text); ++} ++ ++function textOfReactNode(node) { ++ if (node == null || node === false) return ""; ++ if (typeof node === "string" || typeof node === "number") return String(node); ++ if (Array.isArray(node)) return node.map(textOfReactNode).join(""); ++ if (React.isValidElement(node)) return textOfReactNode(node.props && node.props.children); ++ return ""; ++} ++ ++function renderWithCapturedEvents(props) { ++ const merged = Object.assign({}, ListView.defaultProps || {}, props); ++ const clickTargets = []; ++ const originalCreateElement = React.createElement; ++ const originalConsoleError = console.error; ++ React.createElement = function captureCreateElement(type, elementProps, ...children) { ++ const element = originalCreateElement.apply(this, arguments); ++ if (elementProps && typeof elementProps.onClick === "function") { ++ clickTargets.push({ ++ text: textOfReactNode(children.length <= 1 ? children[0] : children), ++ onClick: elementProps.onClick, ++ }); ++ } ++ return element; ++ }; ++ console.error = (...args) => { ++ if (String(args[0] || "").startsWith("Warning:")) return; ++ originalConsoleError.apply(console, args); ++ }; ++ try { ++ const html = ReactDOMServer.renderToStaticMarkup(React.createElement(ListView, merged)); ++ return { ++ html, ++ textContent: textFromHtml(html), ++ visibleTextContent: visibleTextFromHtml(html), ++ clickTargets, ++ clickTexts: clickTargets.map((target) => target.text), ++ }; ++ } finally { ++ React.createElement = originalCreateElement; ++ console.error = originalConsoleError; ++ } ++} ++ ++function assertVisibleText(summary, text) { ++ assert( ++ summary.visibleTextContent.includes(text), ++ `expected visible text ${JSON.stringify(text)} in ${JSON.stringify(summary.visibleTextContent)}` ++ ); ++} ++ ++function assertNoVisibleText(summary, text) { ++ assert( ++ !summary.visibleTextContent.includes(text), ++ `did not expect visible text ${JSON.stringify(text)} in ${JSON.stringify(summary.visibleTextContent)}` ++ ); ++} ++ ++function assertClickText(summary, text) { ++ assert( ++ summary.clickTexts.includes(text), ++ `expected click target ${JSON.stringify(text)} in ${JSON.stringify(summary.clickTexts)}` ++ ); ++} ++ ++const tests = []; ++function test(name, fn) { ++ tests.push({ name, fn }); ++} ++ ++test("default empty state hides children and loading footer", () => { ++ ++ ++ ++ ++ const actual = renderSummary({ ++ isEmpty: true, ++ isError: false, ++ emptyText: "No orders yet", ++ hasMore: true, ++ footerLoadingText: "Loading more", ++ children: React.createElement("Row", { className: "normal-row" }, "normal row"), ++ launch: {}, ++ }); ++ ++ assertVisibleText(actual, "No orders yet"); ++ assertNoVisibleText(actual, "normal row"); ++ assertNoVisibleText(actual, "Loading more"); ++ assertNoVisibleText(actual, DEFAULT_ERROR_TEXT); ++ assert(!actual.clickTexts.includes(RETRY_TEXT)); ++}); ++ ++test("custom empty state works in autoHeight and hides loaded footer", () => { ++ ++ ++ ++ ++ const actual = renderSummary({ ++ autoHeight: true, ++ isEmpty: true, ++ isError: false, ++ emptyText: "No orders yet", ++ hasMore: false, ++ footerLoadedText: "All loaded", ++ children: React.createElement("Row", { className: "normal-row" }, "normal row"), ++ launch: { launchEmpty: true }, ++ renderEmpty: React.createElement("EmptyCustom", { className: "custom-empty" }, "Custom empty panel"), ++ }); ++ ++ assertVisibleText(actual, "Custom empty panel"); ++ assertNoVisibleText(actual, "No orders yet"); ++ assertNoVisibleText(actual, "normal row"); ++ assertNoVisibleText(actual, "All loaded"); ++ assertNoVisibleText(actual, DEFAULT_ERROR_TEXT); ++ assert(!actual.clickTexts.includes(RETRY_TEXT)); ++}); ++ ++test("default error state takes precedence over empty and exposes retry", () => { ++ ++ ++ ++ ++ const actual = renderSummary({ ++ isEmpty: true, ++ isError: true, ++ emptyText: "No orders yet", ++ hasMore: true, ++ footerLoadingText: "Loading more", ++ children: React.createElement("Row", { className: "normal-row" }, "normal row"), ++ launch: {}, ++ }); ++ ++ assertVisibleText(actual, DEFAULT_ERROR_TEXT); ++ assertVisibleText(actual, RETRY_TEXT); ++ assertClickText(actual, RETRY_TEXT); ++ assertNoVisibleText(actual, "No orders yet"); ++ assertNoVisibleText(actual, "normal row"); ++ assertNoVisibleText(actual, "Loading more"); ++}); ++ ++test("custom error state wins over custom empty in autoHeight", () => { ++ ++ ++ ++ ++ const actual = renderSummary({ ++ autoHeight: true, ++ isEmpty: true, ++ isError: true, ++ emptyText: "No orders yet", ++ hasMore: false, ++ footerLoadedText: "All loaded", ++ children: React.createElement("Row", { className: "normal-row" }, "normal row"), ++ launch: { launchError: true, launchEmpty: true }, ++ renderError: React.createElement("ErrorCustom", { className: "custom-error" }, "Custom error panel"), ++ renderEmpty: React.createElement("EmptyCustom", { className: "custom-empty" }, "Custom empty panel"), ++ }); ++ ++ assertVisibleText(actual, "Custom error panel"); ++ assertNoVisibleText(actual, "Custom empty panel"); ++ assertNoVisibleText(actual, "No orders yet"); ++ assertNoVisibleText(actual, "normal row"); ++ assertNoVisibleText(actual, "All loaded"); ++ assertNoVisibleText(actual, DEFAULT_ERROR_TEXT); ++ assert(!actual.clickTexts.includes(RETRY_TEXT)); ++}); ++ ++test("error state is visible while isLoaded is false", () => { ++ ++ ++ ++ ++ const actual = renderSummary({ ++ isError: true, ++ isLoaded: false, ++ hasMore: true, ++ children: React.createElement("Row", null, "normal row"), ++ launch: {}, ++ }); ++ ++ assertVisibleText(actual, DEFAULT_ERROR_TEXT); ++ assertVisibleText(actual, RETRY_TEXT); ++ assertClickText(actual, RETRY_TEXT); ++ assertNoVisibleText(actual, "normal row"); ++}); ++ ++test("normal loaded footer still renders when no empty or error state is active", () => { ++ ++ ++ ++ ++ const actual = renderSummary({ ++ isEmpty: false, ++ isError: false, ++ hasMore: false, ++ footerLoadedText: "All loaded", ++ children: React.createElement("Row", { className: "normal-row" }, "normal row"), ++ launch: {}, ++ }); ++ ++ assertVisibleText(actual, "normal row"); ++ assertVisibleText(actual, "All loaded"); ++ assertNoVisibleText(actual, DEFAULT_ERROR_TEXT); ++ assert(!actual.clickTexts.includes(RETRY_TEXT)); ++}); ++ ++test("normal loading footer still renders when no empty or error state is active", () => { ++ ++ ++ ++ ++ const actual = renderSummary({ ++ isEmpty: false, ++ isError: false, ++ hasMore: true, ++ footerLoadingText: "Loading more", ++ children: React.createElement("Row", { className: "normal-row" }, "normal row"), ++ launch: {}, ++ }); ++ ++ assertVisibleText(actual, "normal row"); ++ assertVisibleText(actual, "Loading more"); ++ assertNoVisibleText(actual, DEFAULT_ERROR_TEXT); ++ assert(!actual.clickTexts.includes(RETRY_TEXT)); ++}); ++ ++test("retry control invokes the refresh flow", async () => { ++ ++ ++ ++ ++ let refreshCalls = 0; ++ const actual = renderWithCapturedEvents({ ++ isError: true, ++ onPullDownRefresh: async () => { ++ refreshCalls += 1; ++ return "ok"; ++ }, ++ launch: {}, ++ }); ++ ++ assertVisibleText(actual, DEFAULT_ERROR_TEXT); ++ assertClickText(actual, RETRY_TEXT); ++ const clickRetry = actual.clickTargets.find((target) => target.text === RETRY_TEXT); ++ assert(clickRetry, "expected retry click target to be captured"); ++ assert.strictEqual(typeof clickRetry.onClick, "function"); ++ await clickRetry.onClick(); ++ assert.strictEqual(refreshCalls, 1); ++}); ++ ++test("referential transparency for identical props", () => { ++ const props = { ++ isEmpty: true, ++ isError: false, ++ emptyText: "Stable empty", ++ hasMore: true, ++ footerLoadingText: "Loading more", ++ children: React.createElement("Row", { className: "normal-row" }, "normal row"), ++ launch: {}, ++ }; ++ ++ for (const actual of [renderSummary(props), renderSummary(props)]) { ++ assertVisibleText(actual, "Stable empty"); ++ assertNoVisibleText(actual, "normal row"); ++ assertNoVisibleText(actual, "Loading more"); ++ } ++}); ++ ++test("does not mutate caller props", () => { ++ const props = { ++ isEmpty: true, ++ isError: false, ++ emptyText: "Mutation empty", ++ hasMore: false, ++ footerLoadedText: "Done", ++ launch: { launchEmpty: false }, ++ children: "caller child", ++ }; ++ const actual = renderSummary(props); ++ ++ assertVisibleText(actual, "Mutation empty"); ++ assertNoVisibleText(actual, "caller child"); ++ assertNoVisibleText(actual, "Done"); ++}); ++ ++test("fresh process render matches in-process render", () => { ++ const props = { ++ isEmpty: true, ++ isError: true, ++ emptyText: "Fresh process empty", ++ hasMore: true, ++ footerLoadingText: "Loading more", ++ children: React.createElement("Row", { className: "normal-row" }, "normal row"), ++ launch: {}, ++ }; ++ const inProcess = renderSummary(props); ++ const childOutput = childProcess.execFileSync(process.execPath, [__filename, "--child-summary"], { ++ cwd: "/workspace/repo", ++ encoding: "utf8", ++ }); ++ const childSummary = JSON.parse(childOutput); ++ ++ for (const actual of [inProcess, childSummary]) { ++ assertVisibleText(actual, DEFAULT_ERROR_TEXT); ++ assertVisibleText(actual, RETRY_TEXT); ++ assertNoVisibleText(actual, "Fresh process empty"); ++ assertNoVisibleText(actual, "normal row"); ++ assertNoVisibleText(actual, "Loading more"); ++ } ++}); ++ ++test("default empty state works with minimal props", () => { ++ const actual = renderSummary({ ++ isEmpty: true, ++ isError: false, ++ emptyText: "Minimal empty", ++ hasMore: true, ++ launch: {}, ++ }); ++ ++ assertVisibleText(actual, "Minimal empty"); ++ assertNoVisibleText(actual, DEFAULT_ERROR_TEXT); ++ assert(!actual.clickTexts.includes(RETRY_TEXT)); ++}); ++ ++async function runTests() { ++ if (process.argv[2] === "--child-summary") { ++ const summary = renderSummary({ ++ isEmpty: true, ++ isError: true, ++ emptyText: "Fresh process empty", ++ hasMore: true, ++ footerLoadingText: "Loading more", ++ children: React.createElement("Row", { className: "normal-row" }, "normal row"), ++ launch: {}, ++ }); ++ process.stdout.write(JSON.stringify(summary)); ++ return; ++ } ++ ++ for (const entry of tests) { ++ await entry.fn(); ++ process.stdout.write(`ok - ${entry.name}\n`); ++ } ++ process.stdout.write(`${tests.length} tests passed\n`); ++} ++ ++runTests().catch((error) => { ++ console.error(error && error.stack ? error.stack : error); ++ process.exit(1); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,37 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++export npm_config_offline=true ++export npm_config_audit=false ++export npm_config_fund=false ++export YARN_ENABLE_NETWORK=0 ++ ++if [ ! -d node_modules ]; then ++ echo "node_modules is required for offline test execution" >&2 ++ exit 1 ++fi ++ ++node - <<'NODE' ++const required = [ ++ "@babel/register", ++ "@babel/preset-typescript", ++ "@babel/preset-react", ++ "@babel/plugin-transform-modules-commonjs", ++ "@babel/runtime/helpers/interopRequireDefault", ++ "react", ++ "classnames", ++]; ++for (const id of required) { ++ require.resolve(id); ++} ++NODE ++exec node /workspace/repo/usercase-test-coderl/listview-states.test.js diff --git a/tasks/format-code-task-002475/tests/test.sh b/tasks/format-code-task-002475/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..36e5690f228dcb1840adb601f3fe82882a23f0f0 --- /dev/null +++ b/tasks/format-code-task-002475/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/listview-states.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002475/tests/test_command.sh b/tasks/format-code-task-002475/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002475/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002481/environment/Dockerfile b/tasks/format-code-task-002481/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..91b6becba672ca0442f56dc761f1d7cc137d5358 --- /dev/null +++ b/tasks/format-code-task-002481/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e3340b4b03583a49c3b3f1f98574a92d6f975c5e7fc2a6acd2ed0fcaa9f95214 diff --git a/tasks/format-code-task-002481/environment/setup/files/blocklist b/tasks/format-code-task-002481/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002481/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002481/environment/setup/setup.sh b/tasks/format-code-task-002481/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002481/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002481/tests/test.patch b/tasks/format-code-task-002481/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4cbf6a3329a1926e4320208276b4428958020fbd --- /dev/null +++ b/tasks/format-code-task-002481/tests/test.patch @@ -0,0 +1,323 @@ +diff --git a/usercase-test-coderl/tag_extractor.test.js b/usercase-test-coderl/tag_extractor.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/tag_extractor.test.js +@@ -0,0 +1,299 @@ ++ ++ ++ ++import test from 'node:test'; ++import assert from 'node:assert/strict'; ++import { execFileSync } from 'node:child_process'; ++import fs from 'node:fs'; ++import os from 'node:os'; ++import path from 'node:path'; ++import net from 'node:net'; ++import http from 'node:http'; ++import https from 'node:https'; ++import { extractTagContent } from '../src/utils/tagExtractor.js'; ++ ++function snapshotDirectory(root) { ++ const entries = []; ++ ++ function walk(dir, prefix = '') { ++ for (const name of fs.readdirSync(dir).sort()) { ++ const fullPath = path.join(dir, name); ++ const relativePath = prefix ? `${prefix}/${name}` : name; ++ const stat = fs.statSync(fullPath); ++ entries.push(stat.isDirectory() ? `${relativePath}/` : relativePath); ++ if (stat.isDirectory()) { ++ walk(fullPath, relativePath); ++ } ++ } ++ } ++ ++ walk(root); ++ return entries; ++} ++ ++test('empty rules return original text unchanged', () => { ++ ++ ++ const actual = extractTagContent('raw Hello', [], []); ++ ++ assert.equal(actual, 'raw Hello'); ++}); ++ ++test('missing rules return original text unchanged', () => { ++ ++ ++ const actual = extractTagContent('plain still raw'); ++ ++ assert.equal(actual, 'plain still raw'); ++}); ++ ++test('exclude rules remove XML-like blocks before include collection', () => { ++ ++ ++ const rules = [ ++ { type: 'exclude', value: 'thinking', enabled: true }, ++ { type: 'include', value: 'content', enabled: true }, ++ ]; ++ const actual = extractTagContent( ++ 'prefix Hidden middle Visible', ++ rules, ++ [], ++ ); ++ ++ assert.equal(actual, 'Visible'); ++}); ++ ++test('include rules collect XML and brace-pipe content, then cleanup and blacklist apply', () => { ++ ++ ++ const rules = [ ++ { type: 'exclude', value: 'thinking', enabled: true }, ++ { type: 'include', value: 'content', enabled: true }, ++ { type: 'regex_exclude', value: '\\s*\\[draft\\]', enabled: true }, ++ ]; ++ const actual = extractTagContent( ++ 'intro hide Hello [draft] {content|Second {nested} part} Skip secret', ++ rules, ++ ['secret'], ++ ); ++ ++ assert.equal(actual, 'Hello\n\nSecond {nested} part'); ++}); ++ ++test('regex include rules collect first capture group from every match', () => { ++ ++ ++ const rules = [ ++ { type: 'regex_include', value: '\\[\\[(.*?)\\]\\]', enabled: true }, ++ ]; ++ const actual = extractTagContent('A [[keep one]] B [[keep two]]', rules, []); ++ ++ assert.equal(actual, 'keep one\n\nkeep two'); ++}); ++ ++test('disabled rules are ignored while enabled include rules still apply', () => { ++ ++ ++ const rules = [ ++ { type: 'exclude', value: 'content', enabled: false }, ++ { type: 'include', value: 'noise', enabled: false }, ++ { type: 'regex_include', value: '\\[\\[(.*?)\\]\\]', enabled: false }, ++ { type: 'include', value: 'content', enabled: true }, ++ ]; ++ const actual = extractTagContent('drop? Used [[ignored]]', rules, []); ++ ++ assert.equal(actual, 'Used'); ++}); ++ ++test('malformed enabled patterns are skipped while valid rules still apply', () => { ++ ++ ++ const rules = [ ++ { type: 'regex_include', value: '[[oops', enabled: true }, ++ { type: 'include', value: 'content', enabled: true }, ++ { type: 'regex_exclude', value: '(', enabled: true }, ++ { type: 'regex_exclude', value: '\\s*\\[drop\\]', enabled: true }, ++ ]; ++ let actual; ++ const originalConsoleError = console.error; ++ ++ ++ console.error = () => {}; ++ try { ++ assert.doesNotThrow(() => { ++ actual = extractTagContent('Alpha [drop] [[Beta]]', rules, []); ++ }); ++ } finally { ++ console.error = originalConsoleError; ++ } ++ ++ assert.equal(actual, 'Alpha'); ++}); ++ ++test('blacklist drops matching blocks case-insensitively', () => { ++ ++ ++ const rules = [ ++ { type: 'include', value: 'content', enabled: true }, ++ ]; ++ const actual = extractTagContent( ++ 'Public noteContains SeCrEt markerAnother public', ++ rules, ++ ['secret'], ++ ); ++ ++ assert.equal(actual, 'Public note\n\nAnother public'); ++}); ++ ++test('final output collapses excessive blank lines', () => { ++ ++ ++ const rules = [ ++ { type: 'include', value: 'content', enabled: true }, ++ ]; ++ const actual = extractTagContent( ++ 'First\n\n\n\nSecond\n\n\nThird', ++ rules, ++ [], ++ ); ++ ++ assert.equal(actual, 'First\n\nSecond\n\nThird'); ++}); ++ ++test('regex cleanup applies to collected blocks', () => { ++ ++ ++ const rules = [ ++ { type: 'include', value: 'content', enabled: true }, ++ { type: 'regex_exclude', value: '\\s*\\[draft\\]', enabled: true }, ++ ]; ++ ++ const actual = extractTagContent('A [draft]\n\n\nB', rules, []); ++ ++ assert.equal(actual, 'A\n\nB'); ++}); ++ ++test('referential transparency returns the same literal for repeated equal calls', () => { ++ const rules = [ ++ { type: 'include', value: 'content', enabled: true }, ++ { type: 'regex_exclude', value: '\\s*\\(temp\\)', enabled: true }, ++ ]; ++ const first = extractTagContent('Stable (temp)', rules, []); ++ const second = extractTagContent('Stable (temp)', rules, []); ++ ++ assert.equal(first, 'Stable'); ++ assert.equal(second, 'Stable'); ++ assert.equal(first, second); ++}); ++ ++test('does not mutate caller-provided inputs', () => { ++ const text = 'Keep [draft]Skip secret'; ++ const rules = [ ++ { type: 'include', value: 'content', enabled: true }, ++ { type: 'regex_exclude', value: '\\s*\\[draft\\]', enabled: true }, ++ ]; ++ const blacklist = ['secret']; ++ const originalRules = JSON.parse(JSON.stringify(rules)); ++ const originalBlacklist = JSON.parse(JSON.stringify(blacklist)); ++ ++ const actual = extractTagContent(text, rules, blacklist); ++ ++ assert.equal(actual, 'Keep'); ++ assert.equal(text, 'Keep [draft]Skip secret'); ++ assert.deepEqual(rules, originalRules); ++ assert.deepEqual(blacklist, originalBlacklist); ++}); ++ ++test('fresh-process result matches in-process result for the same input', () => { ++ const rules = [ ++ { type: 'include', value: 'content', enabled: true }, ++ ]; ++ const inProcess = extractTagContent('Cache Target', rules, []); ++ const script = ` ++ import { extractTagContent } from '/workspace/repo/src/utils/tagExtractor.js'; ++ const rules = [{ type: 'include', value: 'content', enabled: true }]; ++ process.stdout.write(JSON.stringify(extractTagContent('Cache Target', rules, []))); ++ `; ++ const freshProcess = JSON.parse(execFileSync( ++ process.execPath, ++ ['--experimental-default-type=module', '-e', script], ++ { encoding: 'utf8' }, ++ )); ++ ++ assert.equal(inProcess, 'Cache Target'); ++ assert.equal(freshProcess, 'Cache Target'); ++ assert.equal(freshProcess, inProcess); ++}); ++ ++test('does not perform filesystem or network work during extraction', () => { ++ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tag-extractor-side-effects-')); ++ const originalCwd = process.cwd(); ++ const originalFetch = globalThis.fetch; ++ const originalSocketConnect = net.Socket.prototype.connect; ++ const originalHttpRequest = http.request; ++ const originalHttpsRequest = https.request; ++ const originalReadFileSync = fs.readFileSync; ++ const originalWriteFileSync = fs.writeFileSync; ++ const originalAppendFileSync = fs.appendFileSync; ++ const originalOpenSync = fs.openSync; ++ const sideEffectAttempts = []; ++ ++ globalThis.fetch = (...args) => { ++ sideEffectAttempts.push(`fetch:${String(args[0])}`); ++ throw new Error('network fetch attempted'); ++ }; ++ net.Socket.prototype.connect = function blockedConnect(...args) { ++ sideEffectAttempts.push(`socket:${String(args[0])}`); ++ throw new Error('network socket attempted'); ++ }; ++ http.request = (...args) => { ++ sideEffectAttempts.push(`http:${String(args[0])}`); ++ throw new Error('http request attempted'); ++ }; ++ https.request = (...args) => { ++ sideEffectAttempts.push(`https:${String(args[0])}`); ++ throw new Error('https request attempted'); ++ }; ++ fs.readFileSync = (...args) => { ++ sideEffectAttempts.push(`readFileSync:${String(args[0])}`); ++ throw new Error('filesystem read attempted'); ++ }; ++ fs.writeFileSync = (...args) => { ++ sideEffectAttempts.push(`writeFileSync:${String(args[0])}`); ++ throw new Error('filesystem write attempted'); ++ }; ++ fs.appendFileSync = (...args) => { ++ sideEffectAttempts.push(`appendFileSync:${String(args[0])}`); ++ throw new Error('filesystem append attempted'); ++ }; ++ fs.openSync = (...args) => { ++ sideEffectAttempts.push(`openSync:${String(args[0])}`); ++ throw new Error('filesystem open attempted'); ++ }; ++ ++ try { ++ process.chdir(tempDir); ++ const before = snapshotDirectory(tempDir); ++ const actual = extractTagContent( ++ 'No side effects', ++ [{ type: 'include', value: 'content', enabled: true }], ++ [], ++ ); ++ const after = snapshotDirectory(tempDir); ++ ++ assert.equal(actual, 'No side effects'); ++ assert.deepEqual(sideEffectAttempts, []); ++ assert.deepEqual(after, before); ++ } finally { ++ process.chdir(originalCwd); ++ globalThis.fetch = originalFetch; ++ net.Socket.prototype.connect = originalSocketConnect; ++ http.request = originalHttpRequest; ++ https.request = originalHttpsRequest; ++ fs.readFileSync = originalReadFileSync; ++ fs.writeFileSync = originalWriteFileSync; ++ fs.appendFileSync = originalAppendFileSync; ++ fs.openSync = originalOpenSync; ++ fs.rmSync(tempDir, { recursive: true, force: true }); ++ } ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,14 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++exec node --experimental-default-type=module --test /workspace/repo/usercase-test-coderl/tag_extractor.test.js diff --git a/tasks/format-code-task-002481/tests/test.sh b/tasks/format-code-task-002481/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6459de90bbc10c42791c36b97d2ff263adea3716 --- /dev/null +++ b/tasks/format-code-task-002481/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/tag_extractor.test.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002481/tests/test_command.sh b/tasks/format-code-task-002481/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002481/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002486/environment/Dockerfile b/tasks/format-code-task-002486/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cd497e64821ee6fa5352038b0149fb4676381491 --- /dev/null +++ b/tasks/format-code-task-002486/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b2f741c0788f3d212a94bc5f67e48c17657fc92035a1f0acacd8ef90dfc53183 diff --git a/tasks/format-code-task-002486/environment/setup/files/blocklist b/tasks/format-code-task-002486/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002486/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002486/environment/setup/setup.sh b/tasks/format-code-task-002486/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002486/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/workspace/repo +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002486/tests/test.patch b/tasks/format-code-task-002486/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..365ffbbe890b35c9e77950680f84f95fad06f2bc --- /dev/null +++ b/tasks/format-code-task-002486/tests/test.patch @@ -0,0 +1,555 @@ +diff --git a/usercase-test-coderl/fixtures/list_args_presets/list-args.json b/usercase-test-coderl/fixtures/list_args_presets/list-args.json +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/list_args_presets/list-args.json +@@ -0,0 +1,37 @@ ++{ ++ "preset_key": "list-args", ++ "preset_name": "List Args", ++ "version": 1, ++ "items": [ ++ { ++ "key": "developer-mode", ++ "text": "Developer switch", ++ "tooltip": "Turns on developer mode", ++ "enabled": true ++ }, ++ { ++ "key": "browser-installation", ++ "text": "Install a browser", ++ "tooltip": "Uses Chocolatey", ++ "enabled": true ++ }, ++ { ++ "key": "registry-tweaks", ++ "enabled": false ++ } ++ ], ++ "winutil_config": { ++ "WPFTweaks": [ ++ "Alpha", ++ "Beta" ++ ] ++ }, ++ "win11debloat_args": [ ++ " -Silent ", ++ "", ++ "-RemoveApps", ++ " -DisableWidgets " ++ ], ++ "registry_changes": null, ++ "applied_background_path": " C:/Wallpapers/talon.png " ++} +diff --git a/usercase-test-coderl/test_build_install_plan.py b/usercase-test-coderl/test_build_install_plan.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_build_install_plan.py +@@ -0,0 +1,484 @@ ++ ++ ++ ++ ++ ++ ++ ++import copy ++import json ++import os ++import socket ++import subprocess ++import sys ++ ++import pytest ++ ++sys.path.insert(0, "/workspace/repo") ++ ++from configuration_components import step_catalog ++from configuration_components.install_plan import build_install_plan ++ ++ ++FIXTURES = "/workspace/repo/usercase-test-coderl/fixtures" ++ ++EXPECTED_ITEM_ORDER = [ ++ "developer-mode", ++ "remove-edge-permanently", ++ "uninstall-outlook-onedrive", ++ "browser-installation", ++ "debloat-windows-phase-one", ++ "debloat-windows-phase-two", ++ "registry-tweaks", ++ "configure-updates", ++ "apply-background", ++] ++ ++DEFAULT_REGISTRY_CHANGES = [ ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", ++ "name": "TaskbarAl", ++ "value_type": "REG_DWORD", ++ "value": 0, ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", ++ "name": "AppsUseLightTheme", ++ "value_type": "REG_DWORD", ++ "value": 0, ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", ++ "name": "SystemUsesLightTheme", ++ "value_type": "REG_DWORD", ++ "value": 0, ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Software\\Microsoft\\Windows\\CurrentVersion\\GameDVR", ++ "name": "AppCaptureEnabled", ++ "value_type": "REG_DWORD", ++ "value": 0, ++ }, ++ { ++ "hive": "HKEY_LOCAL_MACHINE", ++ "key_path": "SOFTWARE\\Microsoft\\PolicyManager\\default\\ApplicationManagement\\AllowGameDVR", ++ "name": "Value", ++ "value_type": "REG_DWORD", ++ "value": 0, ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Control Panel\\Desktop", ++ "name": "MenuShowDelay", ++ "value_type": "REG_SZ", ++ "value": "0", ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Control Panel\\Desktop\\WindowMetrics", ++ "name": "MinAnimate", ++ "value_type": "REG_DWORD", ++ "value": 0, ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", ++ "name": "ExtendedUIHoverTime", ++ "value_type": "REG_DWORD", ++ "value": 1, ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", ++ "name": "HideFileExt", ++ "value_type": "REG_DWORD", ++ "value": 0, ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Control Panel\\Desktop", ++ "name": "DragFullWindows", ++ "value_type": "REG_SZ", ++ "value": "1", ++ }, ++] ++ ++STANDARD_WINUTIL_CONFIG = { ++ "WPFTweaks": [ ++ "WPFTweaksActivity", ++ "WPFTweaksConsumerFeatures", ++ "WPFTweaksDisableBGapps", ++ "WPFTweaksTelemetry", ++ "WPFTweaksWPBT", ++ "WPFTweaksWidget", ++ "WPFTweaksServices", ++ "WPFTweaksDisableExplorerAutoDiscovery", ++ "WPFTweaksDisplay", ++ "WPFTweaksRightClickMenu", ++ "WPFTweaksRevertStartMenu", ++ "WPFTweaksRemoveOneDrive", ++ "WPFTweaksXboxRemoval", ++ "WPFTweaksRemoveHome", ++ "WPFTweaksDeBloat", ++ "WPFTweaksWindowsAI", ++ "WPFTweaksDisableStoreSearch", ++ ] ++} ++ ++STANDARD_WIN11_ARGS = ( ++ "-Silent -RemoveApps -RemoveGamingApps -DisableTelemetry -DisableBing " ++ "-DisableSuggestions -DisableLockscreenTips -RevertContextMenu " ++ "-TaskbarAlignLeft -HideSearchTb -DisableWidgets -DisableCopilot " ++ "-ClearStartAllUsers -DisableDVR -DisableStartRecommended -ExplorerToThisPC " ++ "-DisableMouseAcceleration -DisableDesktopSpotlight -DisableSettings365Ads " ++ "-DisableSettingsHome -DisablePaintAI -DisableNotepadAI -DisableEdgeAI " ++ "-DisableStickyKeys -DisableEdgeAds -DisableBraveBloat -DisableRecall " ++ "-DisableAISvcAutoStart -DisableClickToDo -DisableSnapLayouts " ++ "-DisableSearchHistory -DisableDeliveryOptimization" ++) ++ ++EXPECTED_STANDARD_NO_BROWSER_PLAN = { ++ "version": 1, ++ "selected_preset_key": "standard", ++ "selected_browser_name": "None", ++ "selected_browser_package": "", ++ "include_browser_install": False, ++ "items": [ ++ {"key": "developer-mode", "text": "", "tooltip": "", "enabled": False}, ++ {"key": "remove-edge-permanently", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "uninstall-outlook-onedrive", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "browser-installation", "text": "", "tooltip": "", "enabled": False}, ++ {"key": "debloat-windows-phase-one", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "debloat-windows-phase-two", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "registry-tweaks", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "configure-updates", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "apply-background", "text": "", "tooltip": "", "enabled": True}, ++ ], ++ "winutil_config": STANDARD_WINUTIL_CONFIG, ++ "win11debloat_args": STANDARD_WIN11_ARGS, ++ "registry_changes": DEFAULT_REGISTRY_CHANGES, ++ "applied_background_path": "", ++} ++ ++EXPECTED_STANDARD_FIREFOX_PLAN = { ++ **EXPECTED_STANDARD_NO_BROWSER_PLAN, ++ "selected_browser_name": "Firefox", ++ "selected_browser_package": "firefox", ++ "include_browser_install": True, ++ "items": [ ++ {"key": "developer-mode", "text": "", "tooltip": "", "enabled": False}, ++ {"key": "remove-edge-permanently", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "uninstall-outlook-onedrive", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "browser-installation", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "debloat-windows-phase-one", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "debloat-windows-phase-two", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "registry-tweaks", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "configure-updates", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "apply-background", "text": "", "tooltip": "", "enabled": True}, ++ ], ++} ++ ++EXPECTED_DEBLOAT_LITE_PLAN = { ++ "version": 1, ++ "selected_preset_key": "debloat-lite", ++ "selected_browser_name": "None", ++ "selected_browser_package": "", ++ "include_browser_install": False, ++ "items": [ ++ {"key": "developer-mode", "text": "", "tooltip": "", "enabled": False}, ++ {"key": "remove-edge-permanently", "text": "", "tooltip": "", "enabled": False}, ++ {"key": "uninstall-outlook-onedrive", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "browser-installation", "text": "", "tooltip": "", "enabled": False}, ++ {"key": "debloat-windows-phase-one", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "debloat-windows-phase-two", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "registry-tweaks", "text": "", "tooltip": "", "enabled": False}, ++ {"key": "configure-updates", "text": "", "tooltip": "", "enabled": False}, ++ {"key": "apply-background", "text": "", "tooltip": "", "enabled": False}, ++ ], ++ "winutil_config": { ++ "WPFTweaks": [ ++ "WPFTweaksActivity", ++ "WPFTweaksConsumerFeatures", ++ "WPFTweaksDisableBGapps", ++ "WPFTweaksTelemetry", ++ "WPFTweaksWPBT", ++ "WPFTweaksServices", ++ "WPFTweaksDisableExplorerAutoDiscovery", ++ "WPFTweaksDisplay", ++ "WPFTweaksRightClickMenu", ++ "WPFTweaksRevertStartMenu", ++ "WPFTweaksRemoveOneDrive", ++ "WPFTweaksDeBloat", ++ "WPFTweaksWindowsAI", ++ "WPFTweaksDisableStoreSearch", ++ ] ++ }, ++ "win11debloat_args": ( ++ "-Silent -RemoveApps -DisableTelemetry -DisableBing -DisableSuggestions " ++ "-DisableLockscreenTips -RevertContextMenu -DisableWidgets " ++ "-DisableCopilot -DisableDVR -DisableMouseAcceleration " ++ "-DisableDesktopSpotlight -DisableSettings365Ads -DisableSettingsHome " ++ "-DisablePaintAI -DisableNotepadAI -DisableEdgeAI -DisableStickyKeys " ++ "-DisableRecall -DisableAISvcAutoStart -DisableClickToDo " ++ "-DisableSearchHistory -DisableDeliveryOptimization" ++ ), ++ "registry_changes": [ ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Software\\Microsoft\\Windows\\CurrentVersion\\GameDVR", ++ "name": "AppCaptureEnabled", ++ "value_type": "REG_DWORD", ++ "value": 0, ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Control Panel\\Desktop", ++ "name": "MenuShowDelay", ++ "value_type": "REG_SZ", ++ "value": "0", ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Control Panel\\Desktop\\WindowMetrics", ++ "name": "MinAnimate", ++ "value_type": "REG_DWORD", ++ "value": 0, ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", ++ "name": "ExtendedUIHoverTime", ++ "value_type": "REG_DWORD", ++ "value": 1, ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced", ++ "name": "HideFileExt", ++ "value_type": "REG_DWORD", ++ "value": 0, ++ }, ++ { ++ "hive": "HKEY_CURRENT_USER", ++ "key_path": "Control Panel\\Desktop", ++ "name": "DragFullWindows", ++ "value_type": "REG_SZ", ++ "value": "1", ++ }, ++ ], ++ "applied_background_path": "", ++} ++ ++EXPECTED_LIST_ARGS_PLAN = { ++ "version": 1, ++ "selected_preset_key": "list-args", ++ "selected_browser_name": "Brave", ++ "selected_browser_package": "brave", ++ "include_browser_install": True, ++ "items": [ ++ { ++ "key": "developer-mode", ++ "text": "Developer switch", ++ "tooltip": "Turns on developer mode", ++ "enabled": True, ++ }, ++ {"key": "remove-edge-permanently", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "uninstall-outlook-onedrive", "text": "", "tooltip": "", "enabled": True}, ++ { ++ "key": "browser-installation", ++ "text": "Install a browser", ++ "tooltip": "Uses Chocolatey", ++ "enabled": True, ++ }, ++ {"key": "debloat-windows-phase-one", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "debloat-windows-phase-two", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "registry-tweaks", "text": "", "tooltip": "", "enabled": False}, ++ {"key": "configure-updates", "text": "", "tooltip": "", "enabled": True}, ++ {"key": "apply-background", "text": "", "tooltip": "", "enabled": True}, ++ ], ++ "winutil_config": {"WPFTweaks": ["Alpha", "Beta"]}, ++ "win11debloat_args": "-Silent -RemoveApps -DisableWidgets", ++ "registry_changes": DEFAULT_REGISTRY_CHANGES, ++ "applied_background_path": "C:/Wallpapers/talon.png", ++} ++ ++ ++@pytest.fixture ++def list_args_preset_catalog(monkeypatch): ++ monkeypatch.setattr( ++ step_catalog, ++ "presets_dir", ++ lambda: os.path.join(FIXTURES, "list_args_presets"), ++ ) ++ ++ ++def assert_plan_matches_required_fields(plan, expected): ++ ++ for key, expected_value in expected.items(): ++ assert key in plan ++ if key != "items": ++ assert plan[key] == expected_value ++ ++ assert isinstance(plan["items"], list) ++ assert [item["key"] for item in plan["items"]] == EXPECTED_ITEM_ORDER ++ assert len(plan["items"]) == len(expected["items"]) ++ for actual_item, expected_item in zip(plan["items"], expected["items"]): ++ for key, expected_value in expected_item.items(): ++ assert key in actual_item ++ assert actual_item[key] == expected_value ++ ++ ++def test_default_standard_plan_has_expected_top_level_fields_order_and_enabled_states(): ++ ++ ++ ++ ++ plan = build_install_plan() ++ ++ assert_plan_matches_required_fields(plan, EXPECTED_STANDARD_NO_BROWSER_PLAN) ++ ++ ++def test_standard_plan_preserves_requested_firefox_install(): ++ ++ ++ ++ ++ plan = build_install_plan( ++ browser_name="Firefox", ++ browser_package="firefox", ++ include_browser_install=True, ++ preset_key="standard", ++ ) ++ ++ assert_plan_matches_required_fields(plan, EXPECTED_STANDARD_FIREFOX_PLAN) ++ ++ ++def test_unknown_preset_key_falls_back_to_standard_output(): ++ ++ ++ ++ ++ plan = build_install_plan(preset_key="does-not-exist") ++ ++ assert_plan_matches_required_fields(plan, EXPECTED_STANDARD_NO_BROWSER_PLAN) ++ ++ ++def test_debloat_lite_preset_copies_preset_metadata_and_enabled_map(): ++ ++ ++ ++ ++ plan = build_install_plan(preset_key="debloat-lite") ++ ++ assert_plan_matches_required_fields(plan, EXPECTED_DEBLOAT_LITE_PLAN) ++ ++ ++def test_list_win11debloat_args_are_whitespace_normalized_and_null_registry_defaults( ++ list_args_preset_catalog, ++): ++ ++ ++ ++ ++ plan = build_install_plan( ++ browser_name="Brave", ++ browser_package="brave", ++ include_browser_install=True, ++ preset_key="list-args", ++ ) ++ ++ expected = copy.deepcopy(EXPECTED_LIST_ARGS_PLAN) ++ expected.pop("applied_background_path") ++ assert_plan_matches_required_fields(plan, expected) ++ ++ assert plan["applied_background_path"].strip() == EXPECTED_LIST_ARGS_PLAN["applied_background_path"] ++ ++ ++def test_referential_transparency_for_same_arguments(): ++ left = build_install_plan( ++ browser_name="Firefox", ++ browser_package="firefox", ++ include_browser_install=True, ++ preset_key="standard", ++ ) ++ right = build_install_plan( ++ browser_name="Firefox", ++ browser_package="firefox", ++ include_browser_install=True, ++ preset_key="standard", ++ ) ++ ++ assert left == right ++ ++ assert_plan_matches_required_fields(left, EXPECTED_STANDARD_FIREFOX_PLAN) ++ ++ ++def test_mutating_one_returned_plan_does_not_affect_later_calls(): ++ first = build_install_plan() ++ before_mutation = copy.deepcopy(first) ++ ++ first["items"][0]["enabled"] = True ++ first["winutil_config"]["WPFTweaks"].append("MutatedByCaller") ++ first["registry_changes"][0]["value"] = 99 ++ ++ ++ assert_plan_matches_required_fields(before_mutation, EXPECTED_STANDARD_NO_BROWSER_PLAN) ++ assert_plan_matches_required_fields(build_install_plan(), EXPECTED_STANDARD_NO_BROWSER_PLAN) ++ ++ ++def test_no_global_state_across_fresh_python_process(): ++ in_process = build_install_plan( ++ browser_name="Firefox", ++ browser_package="firefox", ++ include_browser_install=True, ++ preset_key="standard", ++ ) ++ script = """ ++import json, sys ++sys.path.insert(0, '/workspace/repo') ++from configuration_components.install_plan import build_install_plan ++plan = build_install_plan( ++ browser_name='Firefox', ++ browser_package='firefox', ++ include_browser_install=True, ++ preset_key='standard', ++) ++sys.stdout.write(json.dumps(plan, sort_keys=True)) ++""" ++ ++ completed = subprocess.run( ++ [sys.executable, "-c", script], ++ check=True, ++ text=True, ++ capture_output=True, ++ ) ++ fresh_process = json.loads(completed.stdout) ++ ++ assert in_process == fresh_process ++ ++ assert_plan_matches_required_fields(in_process, EXPECTED_STANDARD_FIREFOX_PLAN) ++ ++ ++def test_no_undeclared_cwd_file_writes_or_network(monkeypatch, tmp_path): ++ original_cwd = os.getcwd() ++ ++ def fail_socket(*args, **kwargs): ++ raise AssertionError("build_install_plan must not open network sockets") ++ ++ monkeypatch.setattr(socket, "socket", fail_socket) ++ ++ try: ++ os.chdir(tmp_path) ++ before = sorted(path.relative_to(tmp_path).as_posix() for path in tmp_path.rglob("*")) ++ plan = build_install_plan() ++ after = sorted(path.relative_to(tmp_path).as_posix() for path in tmp_path.rglob("*")) ++ finally: ++ os.chdir(original_cwd) ++ ++ assert_plan_matches_required_fields(plan, EXPECTED_STANDARD_NO_BROWSER_PLAN) ++ assert before == after == [] ++ +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++VENV=/opt/talon-stage4a-venv ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++"$VENV/bin/python" - <<'PY' >/dev/null 2>&1 || true ++import PyQt5 ++PY ++"$VENV/bin/python" -m pytest /workspace/repo/usercase-test-coderl/test_build_install_plan.py -v diff --git a/tasks/format-code-task-002486/tests/test.sh b/tasks/format-code-task-002486/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..762a2ff5356e40fba3967b73ee0e66f283747167 --- /dev/null +++ b/tasks/format-code-task-002486/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/list_args_presets/list-args.json +usercase-test-coderl/test_build_install_plan.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002486/tests/test_command.sh b/tasks/format-code-task-002486/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002486/tests/test_command.sh @@ -0,0 +1 @@ +bash /workspace/repo/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002488/environment/Dockerfile b/tasks/format-code-task-002488/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..47cdbb08c712551cd5af477c20eaa20946cb8e38 --- /dev/null +++ b/tasks/format-code-task-002488/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:66a5eaad2b94a16ec5324f327fb3cc025d2217752288616ea68b2a7ac036a44d diff --git a/tasks/format-code-task-002488/environment/setup/files/blocklist b/tasks/format-code-task-002488/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002488/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002488/environment/setup/setup.sh b/tasks/format-code-task-002488/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002488/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002488/tests/test.patch b/tasks/format-code-task-002488/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f3a320e00f4d68b4359977f5ade7d60c89254ad0 --- /dev/null +++ b/tasks/format-code-task-002488/tests/test.patch @@ -0,0 +1,301 @@ +diff --git a/python/ray/tests/test_tempfile.py b/python/ray/tests/test_tempfile.py +index 191c9287e5..dafdc5caa7 100644 +--- a/python/ray/tests/test_tempfile.py ++++ b/python/ray/tests/test_tempfile.py +@@ -3,7 +3,10 @@ from __future__ import division + from __future__ import print_function + + import os ++import re + import shutil ++import subprocess ++import tempfile + import time + import pytest + import ray +@@ -16,6 +19,35 @@ except NameError: + FileNotFoundError = OSError + + ++_OLD_SECONDS_ONLY_SESSION_RE = re.compile( ++ r"^session_\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}_\d+$") ++ ++ ++def _make_temp_root(): ++ return tempfile.mkdtemp(prefix="ray-session-root-") ++ ++ ++def _session_dir_from_node(node): ++ logs_dir = os.path.abspath(node.get_logs_dir_path()) ++ sockets_dir = os.path.abspath(node.get_sockets_dir_path()) ++ assert os.path.basename(logs_dir) == "logs" ++ assert os.path.basename(sockets_dir) == "sockets" ++ session_from_logs = os.path.dirname(logs_dir) ++ session_from_sockets = os.path.dirname(sockets_dir) ++ assert session_from_logs == session_from_sockets ++ return session_from_logs ++ ++ ++def _assert_session_layout(root, session_dir): ++ root = os.path.abspath(root) ++ session_dir = os.path.abspath(session_dir) ++ assert os.path.dirname(session_dir) == root ++ assert os.path.basename(session_dir).startswith("session_") ++ assert os.path.isdir(session_dir) ++ assert os.path.isdir(os.path.join(session_dir, "logs")) ++ assert os.path.isdir(os.path.join(session_dir, "sockets")) ++ ++ + def test_conn_cluster(): + # plasma_store_socket_name + with pytest.raises(Exception) as exc_info: +@@ -44,12 +78,99 @@ def test_conn_cluster(): + "temp_dir must not be provided.") + + +-def test_tempdir(): +- ray.init(temp_dir="/tmp/i_am_a_temp_dir") +- assert os.path.exists( +- "/tmp/i_am_a_temp_dir"), "Specified temp dir not found." +- ray.shutdown() +- shutil.rmtree("/tmp/i_am_a_temp_dir", ignore_errors=True) ++def test_explicit_temp_dir_uses_session_subdir_for_runtime_files(): ++ root = _make_temp_root() ++ try: ++ ray.init(temp_dir=root, num_cpus=0) ++ session_dir = _session_dir_from_node(ray.worker._global_node) ++ _assert_session_layout(root, session_dir) ++ assert not os.path.isdir(os.path.join(root, "logs")) ++ assert not os.path.isdir(os.path.join(root, "sockets")) ++ finally: ++ ray.shutdown() ++ shutil.rmtree(root, ignore_errors=True) ++ ++ ++def test_session_directory_name_has_high_precision_timestamp(): ++ root = _make_temp_root() ++ try: ++ ray.init(temp_dir=root, num_cpus=0) ++ session_name = os.path.basename( ++ _session_dir_from_node(ray.worker._global_node)) ++ assert session_name.startswith("session_") ++ assert not _OLD_SECONDS_ONLY_SESSION_RE.match(session_name) ++ finally: ++ ray.shutdown() ++ shutil.rmtree(root, ignore_errors=True) ++ ++ ++def test_multiple_starts_create_distinct_session_dirs_under_same_root(): ++ root = _make_temp_root() ++ session_dirs = set() ++ try: ++ for _ in range(3): ++ ray.init(temp_dir=root, num_cpus=0) ++ session_dir = _session_dir_from_node(ray.worker._global_node) ++ _assert_session_layout(root, session_dir) ++ session_dirs.add(session_dir) ++ ray.shutdown() ++ assert len(session_dirs) == 3 ++ finally: ++ ray.shutdown() ++ shutil.rmtree(root, ignore_errors=True) ++ ++ ++def test_cli_temp_dir_uses_session_subdir(): ++ root = _make_temp_root() ++ try: ++ subprocess.check_call( ++ ["ray", "start", "--head", "--temp-dir={}".format(root)]) ++ session_dirs = [ ++ os.path.join(root, entry) ++ for entry in os.listdir(root) ++ if entry.startswith("session_") ++ and os.path.isdir(os.path.join(root, entry)) ++ ] ++ usable_session_dirs = [ ++ session_dir for session_dir in session_dirs ++ if os.path.isdir(os.path.join(session_dir, "logs")) ++ and os.path.isdir(os.path.join(session_dir, "sockets")) ++ ] ++ assert usable_session_dirs ++ assert not os.path.isdir(os.path.join(root, "logs")) ++ assert not os.path.isdir(os.path.join(root, "sockets")) ++ finally: ++ subprocess.call(["ray", "stop"]) ++ shutil.rmtree(root, ignore_errors=True) ++ ++ ++def test_default_temp_dir_creates_session_under_tmp_ray(): ++ ray.init(num_cpus=0) ++ try: ++ session_dir = _session_dir_from_node(ray.worker._global_node) ++ _assert_session_layout("/tmp/ray", session_dir) ++ finally: ++ ray.shutdown() ++ ++ ++def test_worker_nodes_share_head_session_directory(): ++ root = _make_temp_root() ++ stale_session_dir = os.path.join( ++ root, "session_2000-01-01_00-00-00_extra_1") ++ os.makedirs(os.path.join(stale_session_dir, "logs")) ++ os.makedirs(os.path.join(stale_session_dir, "sockets")) ++ cluster = Cluster(False) ++ try: ++ head = cluster.add_node(num_cpus=0, temp_dir=root) ++ worker = cluster.add_node(num_cpus=0) ++ head_session_dir = _session_dir_from_node(head) ++ worker_session_dir = _session_dir_from_node(worker) ++ assert head_session_dir == worker_session_dir ++ assert head_session_dir != stale_session_dir ++ _assert_session_layout(root, head_session_dir) ++ finally: ++ cluster.shutdown() ++ shutil.rmtree(root, ignore_errors=True) + + + def test_raylet_socket_name(): +@@ -95,7 +216,8 @@ def test_temp_plasma_store_socket(): + def test_raylet_tempfiles(): + ray.init(num_cpus=0) + node = ray.worker._global_node +- top_levels = set(os.listdir(node.get_temp_dir_path())) ++ session_dir = _session_dir_from_node(node) ++ top_levels = set(os.listdir(session_dir)) + assert top_levels.issuperset({"sockets", "logs"}) + log_files = set(os.listdir(node.get_logs_dir_path())) + assert log_files.issuperset({ +@@ -110,7 +232,9 @@ def test_raylet_tempfiles(): + + ray.init(num_cpus=2) + node = ray.worker._global_node +- top_levels = set(os.listdir(node.get_temp_dir_path())) ++ session_dir = _session_dir_from_node(node) ++ assert os.path.basename(session_dir).startswith("session_") ++ top_levels = set(os.listdir(session_dir)) + assert top_levels.issuperset({"sockets", "logs"}) + time.sleep(3) # wait workers to start + log_files = set(os.listdir(node.get_logs_dir_path())) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,118 @@ ++#!/usr/bin/env bash ++set -uo pipefail ++cd /testbed ++ ++ ++trap '' USR1 ++ ++ ++if [ -z "${_IN_SETSID:-}" ]; then ++ export _IN_SETSID=1 ++ exec setsid bash "$0" "$@" ++fi ++ ++ ++set +u ++export PATH="$HOME/.pyenv/bin:$PATH" ++eval "$(pyenv init -)" ++pyenv global 3.7.17 ++python - <<'PY' ++import importlib.util ++import subprocess ++import sys ++ ++packages = [] ++if importlib.util.find_spec("pyarrow") is None: ++ packages.append("pyarrow==0.14.1") ++if packages: ++ subprocess.check_call([sys.executable, "-m", "pip", "install"] + packages) ++PY ++python - <<'PY' ++import os ++import shutil ++import site ++ ++target = "/testbed/python/ray/_raylet.so" ++if not os.path.exists(target): ++ for root in site.getsitepackages(): ++ candidate = os.path.join(root, "ray", "_raylet.so") ++ if os.path.exists(candidate): ++ shutil.copy2(candidate, target) ++ break ++generated_target = "/testbed/python/ray/core/generated" ++if not os.path.exists(os.path.join(generated_target, "ErrorTableData.py")): ++ for root in site.getsitepackages(): ++ candidate = os.path.join(root, "ray", "core", "generated") ++ if os.path.exists(os.path.join(candidate, "ErrorTableData.py")): ++ for current_root, dirs, files in os.walk(candidate): ++ rel = os.path.relpath(current_root, candidate) ++ dest_root = (generated_target if rel == "." else ++ os.path.join(generated_target, rel)) ++ if not os.path.exists(dest_root): ++ os.makedirs(dest_root) ++ for filename in files: ++ dest = os.path.join(dest_root, filename) ++ if not os.path.exists(dest): ++ shutil.copy2(os.path.join(current_root, filename), dest) ++ break ++ray_core_src_target = "/testbed/python/ray/core/src" ++if (not os.path.exists(os.path.join( ++ ray_core_src_target, "ray", "thirdparty", "redis", "src", ++ "redis-server")) or not os.path.exists(os.path.join( ++ ray_core_src_target, "plasma", "plasma_store_server"))): ++ for root in site.getsitepackages(): ++ candidate = os.path.join(root, "ray", "core", "src") ++ if os.path.exists(os.path.join( ++ candidate, "ray", "thirdparty", "redis", "src", ++ "redis-server")): ++ for current_root, dirs, files in os.walk(candidate): ++ rel = os.path.relpath(current_root, candidate) ++ dest_root = (ray_core_src_target if rel == "." else ++ os.path.join(ray_core_src_target, rel)) ++ if not os.path.exists(dest_root): ++ os.makedirs(dest_root) ++ for filename in files: ++ dest = os.path.join(dest_root, filename) ++ if not os.path.exists(dest): ++ shutil.copy2(os.path.join(current_root, filename), dest) ++ break ++PY ++export PYTHONPATH=/testbed/python:${PYTHONPATH:-} ++set -u ++ ++ ++cd /testbed/python ++ ++run_pytest() { ++ local tests_expr="$1" ++ python - <