diff --git a/tasks/format-code-task-000019/environment/Dockerfile b/tasks/format-code-task-000019/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fcaf20530694f7d4ca6202c000c03d86c2320013 --- /dev/null +++ b/tasks/format-code-task-000019/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:78f404abfd84d841daf74e13995a6fc5c6f7fc25031414ddfa21030eca5aea78 diff --git a/tasks/format-code-task-000019/environment/setup/files/blocklist b/tasks/format-code-task-000019/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000019/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000019/environment/setup/setup.sh b/tasks/format-code-task-000019/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000019/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000019/tests/test.patch b/tasks/format-code-task-000019/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5651e7ae9578d892a6dc16dc705a2d9b700c4fd1 --- /dev/null +++ b/tasks/format-code-task-000019/tests/test.patch @@ -0,0 +1,252 @@ +diff --git a/covalent_ui/api/v1/tests/delete_all_dispatches_test.py b/covalent_ui/api/v1/tests/delete_all_dispatches_test.py +new file mode 100644 +index 00000000..9b7dfac5 +--- /dev/null ++++ b/covalent_ui/api/v1/tests/delete_all_dispatches_test.py +@@ -0,0 +1,225 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import datetime ++import uuid ++ ++import pytest ++from sqlalchemy import create_engine ++from sqlalchemy.orm import Session ++ ++from covalent._data_store.models import Base as ModelsBase ++from covalent_ui.api.v1.data_layer.summary_dal import Summary ++from covalent_ui.api.v1.database.config.db import Base as UIBase ++from covalent_ui.api.v1.database.schema.electron import Electron ++from covalent_ui.api.v1.database.schema.lattices import Lattice ++from covalent_ui.api.v1.models.dispatch_model import DeleteAllDispatchesRequest ++from covalent_ui.api.v1.utils.status import Status ++ ++NOW = datetime.datetime(2022, 1, 1, 0, 0, 0) ++ ++ ++@pytest.fixture ++def session(): ++ ++ engine = create_engine("sqlite+pysqlite:///:memory:") ++ UIBase.metadata.create_all(engine) ++ ++ ModelsBase.metadata.tables["electron_dependency"].create(engine) ++ with Session(engine) as sess: ++ yield sess ++ ++ ++def _add_dispatch(sess, status, name=None, dispatch_id=None, is_active=True): ++ dispatch_id = dispatch_id or str(uuid.uuid4()) ++ name = name or f"workflow_{status.lower()}" ++ lattice = Lattice( ++ dispatch_id=dispatch_id, ++ name=name, ++ status=status, ++ electron_num=1, ++ completed_electron_num=1, ++ is_active=is_active, ++ started_at=NOW, ++ completed_at=NOW, ++ electron_id=None, ++ ) ++ sess.add(lattice) ++ sess.flush() ++ sess.add( ++ Electron( ++ parent_lattice_id=lattice.id, ++ transport_graph_node_id=0, ++ type="function", ++ name=f"node_{status.lower()}", ++ status=status, ++ is_active=is_active, ++ ) ++ ) ++ sess.commit() ++ return dispatch_id ++ ++ ++def _active_status_map(sess): ++ return {row.status: row.is_active for row in sess.query(Lattice).all()} ++ ++ ++def _active_electron_map(sess): ++ return {row.status: row.is_active for row in sess.query(Electron).all()} ++ ++ ++def test_delete_all_with_all_filter_removes_every_active_dispatch(session): ++ ids = { ++ st: _add_dispatch(session, st) ++ for st in ["RUNNING", "COMPLETED", "FAILED", "CANCELLED"] ++ } ++ ++ resp = Summary(session).delete_all_dispatches( ++ DeleteAllDispatchesRequest(status_filter=Status.ALL) ++ ) ++ ++ assert {uuid.UUID(d) for d in ids.values()} == set(resp.success_items) ++ assert resp.message == "Dispatch(es) have been deleted successfully!" ++ ++ assert all(active is False for active in _active_status_map(session).values()) ++ ++ ++def test_completed_filter_includes_postprocessing_states(session): ++ grouped = ["COMPLETED", "POSTPROCESSING", "POSTPROCESSING_FAILED", "PENDING_POSTPROCESSING"] ++ untouched = ["RUNNING", "FAILED", "CANCELLED", "NEW_OBJECT"] ++ for st in grouped + untouched: ++ _add_dispatch(session, st) ++ ++ resp = Summary(session).delete_all_dispatches( ++ DeleteAllDispatchesRequest(status_filter=Status.COMPLETED) ++ ) ++ ++ status_active = _active_status_map(session) ++ for st in grouped: ++ assert status_active[st] is False, f"{st} should have been deleted" ++ for st in untouched: ++ assert status_active[st] is True, f"{st} should be untouched" ++ assert len(resp.success_items) == len(grouped) ++ ++ ++def test_specific_status_filter_deletes_only_that_status(session): ++ for st in ["RUNNING", "COMPLETED", "FAILED"]: ++ _add_dispatch(session, st) ++ ++ resp = Summary(session).delete_all_dispatches( ++ DeleteAllDispatchesRequest(status_filter=Status.FAILED) ++ ) ++ ++ status_active = _active_status_map(session) ++ assert status_active["FAILED"] is False ++ assert status_active["RUNNING"] is True ++ assert status_active["COMPLETED"] is True ++ assert len(resp.success_items) == 1 ++ ++ ++def test_completed_postprocessing_only_does_not_touch_running_or_failed(session): ++ ++ _add_dispatch(session, "POSTPROCESSING") ++ _add_dispatch(session, "RUNNING") ++ ++ Summary(session).delete_all_dispatches( ++ DeleteAllDispatchesRequest(status_filter=Status.COMPLETED) ++ ) ++ ++ status_active = _active_status_map(session) ++ assert status_active["POSTPROCESSING"] is False ++ assert status_active["RUNNING"] is True ++ ++ ++def test_deletion_cascades_to_electrons(session): ++ _add_dispatch(session, "COMPLETED") ++ _add_dispatch(session, "RUNNING") ++ ++ Summary(session).delete_all_dispatches( ++ DeleteAllDispatchesRequest(status_filter=Status.COMPLETED) ++ ) ++ ++ electron_active = _active_electron_map(session) ++ assert electron_active["COMPLETED"] is False ++ assert electron_active["RUNNING"] is True ++ ++ ++def test_search_string_narrows_selection(session): ++ keep = _add_dispatch(session, "COMPLETED", name="alpha_pipeline") ++ _add_dispatch(session, "COMPLETED", name="beta_pipeline") ++ ++ resp = Summary(session).delete_all_dispatches( ++ DeleteAllDispatchesRequest(status_filter=Status.ALL, search_string="alpha") ++ ) ++ ++ assert set(resp.success_items) == {uuid.UUID(keep)} ++ status_for = {row.dispatch_id: row.is_active for row in session.query(Lattice).all()} ++ assert status_for[keep] is False ++ ++ assert all( ++ active is True for did, active in status_for.items() if did != keep ++ ) ++ ++ ++def test_search_string_matches_dispatch_id(session): ++ target = _add_dispatch(session, "COMPLETED") ++ _add_dispatch(session, "COMPLETED") ++ ++ resp = Summary(session).delete_all_dispatches( ++ DeleteAllDispatchesRequest(status_filter=Status.ALL, search_string=target) ++ ) ++ ++ assert set(resp.success_items) == {uuid.UUID(target)} ++ ++ ++def test_no_matching_dispatches_reports_nothing_deleted(session): ++ _add_dispatch(session, "RUNNING") ++ ++ resp = Summary(session).delete_all_dispatches( ++ DeleteAllDispatchesRequest(status_filter=Status.FAILED) ++ ) ++ ++ assert list(resp.success_items) == [] ++ assert resp.message == "No dispatches were deleted" ++ assert _active_status_map(session)["RUNNING"] is True ++ ++ ++def test_already_inactive_dispatches_are_excluded(session): ++ active = _add_dispatch(session, "COMPLETED", name="active_one") ++ _add_dispatch(session, "COMPLETED", name="already_gone", is_active=False) ++ ++ resp = Summary(session).delete_all_dispatches( ++ DeleteAllDispatchesRequest(status_filter=Status.ALL) ++ ) ++ ++ assert set(resp.success_items) == {uuid.UUID(active)} ++ ++ ++def test_defaults_select_all_active_dispatches(session): ++ for st in ["RUNNING", "COMPLETED", "FAILED"]: ++ _add_dispatch(session, st) ++ ++ ++ resp = Summary(session).delete_all_dispatches(DeleteAllDispatchesRequest()) ++ ++ assert len(resp.success_items) == 3 ++ assert all(active is False for active in _active_status_map(session).values()) +diff --git 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 ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++python -m pytest tests/covalent_tests/data_store/data_store_test.py -q ++ ++ ++python -m pytest covalent_ui/api/v1/tests/delete_all_dispatches_test.py -q diff --git a/tasks/format-code-task-000019/tests/test.sh b/tasks/format-code-task-000019/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b35efdd879c1ca559b331145f64c7ac73651e82f --- /dev/null +++ b/tasks/format-code-task-000019/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' +covalent_ui/api/v1/tests/delete_all_dispatches_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-000019/tests/test_command.sh b/tasks/format-code-task-000019/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000019/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000026/environment/Dockerfile b/tasks/format-code-task-000026/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..780c09c2efdc4282e14cf941155f9fbc53d847d1 --- /dev/null +++ b/tasks/format-code-task-000026/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:77d20cca70ee937251907e49fbfead1a4d3e80f34905562725c99d78f9d1bd4f diff --git a/tasks/format-code-task-000026/environment/setup/files/blocklist b/tasks/format-code-task-000026/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000026/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000026/environment/setup/setup.sh b/tasks/format-code-task-000026/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000026/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000026/tests/test.patch b/tasks/format-code-task-000026/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6fbcbac9a17b2e218aebd9d8095acaf5398dc939 --- /dev/null +++ b/tasks/format-code-task-000026/tests/test.patch @@ -0,0 +1,140 @@ +diff --git a/test/types/lean.test.ts b/test/types/lean.test.ts +index 745999d3a..05f34d96f 100644 +--- a/test/types/lean.test.ts ++++ b/test/types/lean.test.ts +@@ -1,4 +1,4 @@ +-import { Schema, model, Types, InferSchemaType, FlattenMaps } from 'mongoose'; ++import { Schema, model, Types, InferSchemaType, FlattenMaps, Require_id } from 'mongoose'; + import { expectAssignable, expectError, expectType } from 'tsd'; + + function gh10345() { +@@ -206,3 +206,107 @@ async function gh13382() { + const res = await Test.updateOne({}, { name: 'bar' }).lean(); + expectAssignable<{ matchedCount: number, modifiedCount: number }>(res); + } ++ ++async function gh13702_findById_lean_option() { ++ interface User { name: string; } ++ const UserModel = model('User', new Schema({ name: String })); ++ ++ const a = await UserModel.findById('id', undefined, { lean: true }); ++ const b = await UserModel.findById('id').lean(); ++ expectType(a); ++ expectType<(FlattenMaps & { _id: Types.ObjectId }) | null>(a); ++ ++ const a2 = await UserModel.findById('id', null, { lean: true }); ++ expectType<(FlattenMaps & { _id: Types.ObjectId }) | null>(a2); ++} ++ ++async function gh13702_findById_no_lean_preserves_hydrated() { ++ interface User { name: string; } ++ const UserModel = model('User', new Schema({ name: String })); ++ ++ const a = await UserModel.findById('id'); ++ if (a) { ++ ++ expectAssignable(a.save); ++ } ++} ++ ++async function gh13702_findOne_lean_option() { ++ interface User { name: string; } ++ const UserModel = model('User', new Schema({ name: String })); ++ ++ const a = await UserModel.findOne({}, undefined, { lean: true }); ++ const b = await UserModel.findOne({}).lean(); ++ expectType(a); ++ expectType<(FlattenMaps & { _id: Types.ObjectId }) | null>(a); ++} ++ ++async function gh13702_find_lean_option() { ++ interface User { name: string; } ++ const UserModel = model('User', new Schema({ name: String })); ++ ++ const a = await UserModel.find({}, undefined, { lean: true }); ++ const b = await UserModel.find({}).lean(); ++ expectType(a); ++ expectType & { _id: Types.ObjectId }>>(a); ++} ++ ++async function gh13702_findOneAndDelete_lean_option() { ++ interface User { name: string; } ++ const UserModel = model('User', new Schema({ name: String })); ++ ++ const a = await UserModel.findOneAndDelete({}, { lean: true }); ++ const b = await UserModel.findOneAndDelete({}).lean(); ++ expectType(a); ++ expectType<(FlattenMaps & { _id: Types.ObjectId }) | null>(a); ++} ++ ++async function gh13702_findOneAndUpdate_lean_option() { ++ interface User { name: string; } ++ const UserModel = model('User', new Schema({ name: String })); ++ ++ const a = await UserModel.findOneAndUpdate({}, { name: 'x' }, { lean: true }); ++ const b = await UserModel.findOneAndUpdate({}, { name: 'x' }).lean(); ++ expectType(a); ++ expectType<(FlattenMaps & { _id: Types.ObjectId }) | null>(a); ++} ++ ++async function gh13702_findOneAndReplace_lean_option() { ++ interface User { name: string; } ++ const UserModel = model('User', new Schema({ name: String })); ++ ++ const a = await UserModel.findOneAndReplace({}, { name: 'x' }, { lean: true }); ++ const b = await UserModel.findOneAndReplace({}, { name: 'x' }).lean(); ++ expectType(a); ++ expectType<(FlattenMaps & { _id: Types.ObjectId }) | null>(a); ++} ++ ++async function gh13702_findByIdAndDelete_lean_option() { ++ interface User { name: string; } ++ const UserModel = model('User', new Schema({ name: String })); ++ ++ const a = await UserModel.findByIdAndDelete('id', { lean: true }); ++ const b = await UserModel.findByIdAndDelete('id').lean(); ++ expectType(a); ++ expectType<(FlattenMaps & { _id: Types.ObjectId }) | null>(a); ++} ++ ++async function gh13702_findByIdAndRemove_lean_option() { ++ interface User { name: string; } ++ const UserModel = model('User', new Schema({ name: String })); ++ ++ const a = await UserModel.findByIdAndRemove('id', { lean: true }); ++ const b = await UserModel.findByIdAndRemove('id').lean(); ++ expectType(a); ++ expectType<(FlattenMaps & { _id: Types.ObjectId }) | null>(a); ++} ++ ++async function gh13702_findByIdAndUpdate_lean_option() { ++ interface User { name: string; } ++ const UserModel = model('User', new Schema({ name: String })); ++ ++ const a = await UserModel.findByIdAndUpdate('id', { name: 'x' }, { lean: true }); ++ const b = await UserModel.findByIdAndUpdate('id', { name: 'x' }).lean(); ++ expectType(a); ++ expectType<(FlattenMaps & { _id: Types.ObjectId }) | null>(a); ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..8fcadc25d +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/tsd"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++./node_modules/.bin/tsd ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000026/tests/test.sh b/tasks/format-code-task-000026/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9d155cde216632343a0d7fde1be403855d664658 --- /dev/null +++ b/tasks/format-code-task-000026/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/types/lean.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-000026/tests/test_command.sh b/tasks/format-code-task-000026/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000026/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000028/environment/Dockerfile b/tasks/format-code-task-000028/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2528d771699f7f3f8747b5c207dc8dff0c4fd4f5 --- /dev/null +++ b/tasks/format-code-task-000028/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:233c258f8339f4f14aa2ba6fc7b2ed89c16f92a03f87c35f254bfbc2eb35f18f diff --git a/tasks/format-code-task-000028/environment/setup/files/blocklist b/tasks/format-code-task-000028/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000028/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000028/environment/setup/setup.sh b/tasks/format-code-task-000028/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000028/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000028/tests/test.patch b/tasks/format-code-task-000028/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2315ef0fb946ceee44d3b8ba733b222956dddc9a --- /dev/null +++ b/tasks/format-code-task-000028/tests/test.patch @@ -0,0 +1,166 @@ +diff --git a/test/document.validateAllPaths.test.js b/test/document.validateAllPaths.test.js +new file mode 100644 +index 000000000..d6445486a +--- /dev/null ++++ b/test/document.validateAllPaths.test.js +@@ -0,0 +1,133 @@ ++'use strict'; ++ ++const start = require('./common'); ++ ++const assert = require('assert'); ++ ++const mongoose = start.mongoose; ++const Schema = mongoose.Schema; ++ ++describe('document validateAllPaths option', function() { ++ let modelCounter = 0; ++ function makeModel(definition, schemaOptions) { ++ const schema = new Schema(definition, schemaOptions); ++ return mongoose.model('validateAllPaths_' + (++modelCounter), schema); ++ } ++ ++ describe('with schema-level validateModifiedOnly', function() { ++ let Test; ++ function makeInvalidDoc() { ++ return Test.hydrate({ name: '', age: -1, tags: ['z'], okField: 'fine' }); ++ } ++ ++ beforeEach(function() { ++ Test = makeModel({ ++ name: { type: String, required: true }, ++ age: { type: Number, min: [0, 'too small'] }, ++ tags: [{ type: String, enum: ['a', 'b'] }], ++ okField: { type: String } ++ }, { validateModifiedOnly: true }); ++ }); ++ ++ it('validateSync does not report unmodified paths by default', function() { ++ const doc = makeInvalidDoc(); ++ assert.strictEqual(doc.modifiedPaths().length, 0); ++ assert.strictEqual(doc.validateSync(), undefined); ++ }); ++ ++ it('validateSync({ validateAllPaths: true }) validates every path', function() { ++ const doc = makeInvalidDoc(); ++ const err = doc.validateSync({ validateAllPaths: true }); ++ assert.ok(err); ++ assert.equal(err.name, 'ValidationError'); ++ assert.ok(err.errors['name']); ++ assert.ok(err.errors['age']); ++ assert.ok(err.errors['tags.0']); ++ assert.ok(!err.errors['okField']); ++ }); ++ ++ it('validateSync({ validateAllPaths: true }) returns undefined when all paths are valid', function() { ++ const doc = Test.hydrate({ name: 'valid', age: 5, tags: ['a'], okField: 'fine' }); ++ assert.strictEqual(doc.validateSync({ validateAllPaths: true }), undefined); ++ }); ++ ++ it('validate() does not report unmodified paths by default', async function() { ++ const doc = makeInvalidDoc(); ++ await doc.validate(); ++ }); ++ ++ it('validate({ validateAllPaths: true }) rejects with every failing path', async function() { ++ const doc = makeInvalidDoc(); ++ const err = await doc.validate({ validateAllPaths: true }).then(() => null, e => e); ++ assert.ok(err); ++ assert.equal(err.name, 'ValidationError'); ++ assert.ok(err.errors['name']); ++ assert.ok(err.errors['age']); ++ assert.ok(err.errors['tags.0']); ++ assert.ok(!err.errors['okField']); ++ }); ++ ++ it('validate({ validateAllPaths: true }) resolves when all paths are valid', async function() { ++ const doc = Test.hydrate({ name: 'valid', age: 5, tags: ['a'], okField: 'fine' }); ++ await doc.validate({ validateAllPaths: true }); ++ }); ++ }); ++ ++ describe('error contracts', function() { ++ let Test; ++ beforeEach(function() { ++ Test = makeModel({ ++ name: { type: String, required: true }, ++ age: { type: Number } ++ }); ++ }); ++ ++ it('validateSync throws when combining validateAllPaths and pathsToSkip', function() { ++ const doc = Test.hydrate({ name: 'x', age: 1 }); ++ assert.throws( ++ () => doc.validateSync({ validateAllPaths: true, pathsToSkip: 'name' }), ++ err => err instanceof TypeError && ++ err.message === 'Cannot set both `validateAllPaths` and `pathsToSkip`' ++ ); ++ }); ++ ++ it('validateSync throws when combining validateAllPaths and pathsToValidate', function() { ++ const doc = Test.hydrate({ name: 'x', age: 1 }); ++ assert.throws( ++ () => doc.validateSync(['name'], { validateAllPaths: true }), ++ err => err instanceof TypeError && ++ err.message === 'Cannot set both `validateAllPaths` and `pathsToValidate`' ++ ); ++ }); ++ ++ it('validateSync throws when combining validateAllPaths and validateModifiedOnly', function() { ++ const doc = Test.hydrate({ name: 'x', age: 1 }); ++ assert.throws( ++ () => doc.validateSync({ validateAllPaths: true, validateModifiedOnly: true }), ++ err => err instanceof TypeError && ++ err.message === 'Cannot set both `validateAllPaths` and `validateModifiedOnly`' ++ ); ++ }); ++ ++ it('validate rejects when combining validateAllPaths and pathsToSkip', async function() { ++ const doc = Test.hydrate({ name: 'x', age: 1 }); ++ const err = await doc.validate({ validateAllPaths: true, pathsToSkip: 'name' }).then(() => null, e => e); ++ assert.ok(err instanceof TypeError); ++ assert.equal(err.message, 'Cannot set both `validateAllPaths` and `pathsToSkip`'); ++ }); ++ ++ it('validate rejects when combining validateAllPaths and pathsToValidate', async function() { ++ const doc = Test.hydrate({ name: 'x', age: 1 }); ++ const err = await doc.validate(['name'], { validateAllPaths: true }).then(() => null, e => e); ++ assert.ok(err instanceof TypeError); ++ assert.equal(err.message, 'Cannot set both `validateAllPaths` and `pathsToValidate`'); ++ }); ++ ++ it('validate rejects when combining validateAllPaths and validateModifiedOnly', async function() { ++ const doc = Test.hydrate({ name: 'x', age: 1 }); ++ const err = await doc.validate({ validateAllPaths: true, validateModifiedOnly: true }).then(() => null, e => e); ++ assert.ok(err instanceof TypeError); ++ assert.equal(err.message, 'Cannot set both `validateAllPaths` and `validateModifiedOnly`'); ++ }); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,22 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++export MONGOMS_VERSION=8.0.0 ++ ++ ++npx mocha --exit ./test/document.test.js ++ ++ ++npx mocha --exit ./test/document.validateAllPaths.test.js diff --git a/tasks/format-code-task-000028/tests/test.sh b/tasks/format-code-task-000028/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9d5630bfaf8c470b6944480c73eee3575d56ac68 --- /dev/null +++ b/tasks/format-code-task-000028/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/document.validateAllPaths.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-000028/tests/test_command.sh b/tasks/format-code-task-000028/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000028/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000072/environment/Dockerfile b/tasks/format-code-task-000072/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..740dff6e490f4f650dc6f3bf5c18a709661c71a2 --- /dev/null +++ b/tasks/format-code-task-000072/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:84c6874aa8a23cdd4015851adbb0a016f40f74bc5489fa540974537a253114a3 diff --git a/tasks/format-code-task-000072/environment/setup/files/blocklist b/tasks/format-code-task-000072/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000072/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000072/environment/setup/setup.sh b/tasks/format-code-task-000072/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000072/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000072/tests/test.patch b/tasks/format-code-task-000072/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..15ed3b3037ad67f1cbe64b3f2c3d9e7bfe36b55e --- /dev/null +++ b/tasks/format-code-task-000072/tests/test.patch @@ -0,0 +1,1032 @@ +diff --git a/datadog/tests/cassettes/TestAccDatadogIntegrationAzure.freeze b/datadog/tests/cassettes/TestAccDatadogIntegrationAzure.freeze +index 2f181d5c51..640da7bc9b 100644 +--- a/datadog/tests/cassettes/TestAccDatadogIntegrationAzure.freeze ++++ b/datadog/tests/cassettes/TestAccDatadogIntegrationAzure.freeze +@@ -1 +1 @@ +-2021-10-28T16:26:13.057136-04:00 +\ No newline at end of file ++2021-11-09T17:40:54.549623+01:00 +\ No newline at end of file +diff --git a/datadog/tests/cassettes/TestAccDatadogIntegrationAzure.yaml b/datadog/tests/cassettes/TestAccDatadogIntegrationAzure.yaml +index 7be2867f1c..16c0cf056e 100644 +--- a/datadog/tests/cassettes/TestAccDatadogIntegrationAzure.yaml ++++ b/datadog/tests/cassettes/TestAccDatadogIntegrationAzure.yaml +@@ -3,19 +3,19 @@ version: 1 + interactions: + - request: + body: | +- {"client_id":"testc7f6-1234-5678-9101-3fcbf464test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"foo:bar,buzz:lightyear","tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773"} ++ {"automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"foo:bar,buzz:lightyear","tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054"} + form: {} + headers: + Accept: + - application/json + Content-Length: +- - "211" ++ - "228" + Content-Type: + - application/json + Dd-Operation-Id: + - CreateAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: POST + response: +@@ -32,13 +32,15 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:16 GMT ++ - Tue, 09 Nov 2021 16:40:58 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=15724800; + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "1692" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -53,11 +55,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451360","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451660","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452319","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452663","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-73061-1629707067","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' ++ body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636473129","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80208-1636035966","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80608-1636466533","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -68,7 +70,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:16 GMT ++ - Tue, 09 Nov 2021 16:40:58 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -77,6 +79,8 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "109" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -84,19 +88,19 @@ interactions: + duration: "" + - request: + body: | +- {"client_id":"testc7f6-1234-5678-9101-3fcbf123test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"foo:bar,buzz:lightyear","tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773"} ++ {"automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"foo:bar,buzz:lightyear","tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054"} + form: {} + headers: + Accept: + - application/json + Content-Length: +- - "211" ++ - "228" + Content-Type: + - application/json + Dd-Operation-Id: + - CreateAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: POST + response: +@@ -113,13 +117,15 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:18 GMT ++ - Tue, 09 Nov 2021 16:40:59 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=15724800; + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "1449" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -134,11 +140,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451360","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451660","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452319","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452663","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-73061-1629707067","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' ++ body: '[{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636473129","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80208-1636035966","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80608-1636466533","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -149,7 +155,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:19 GMT ++ - Tue, 09 Nov 2021 16:40:59 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -158,6 +164,8 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "96" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -172,11 +180,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451360","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451660","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452319","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452663","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-73061-1629707067","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' ++ body: '[{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636473129","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80208-1636035966","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80608-1636466533","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -187,7 +195,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:19 GMT ++ - Tue, 09 Nov 2021 16:41:00 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -196,6 +204,8 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "83" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -210,11 +220,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451360","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451660","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452319","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452663","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-73061-1629707067","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' ++ body: '[{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636473129","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80208-1636035966","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80608-1636466533","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -225,7 +235,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:19 GMT ++ - Tue, 09 Nov 2021 16:41:00 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -234,6 +244,8 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "90" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -248,11 +260,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451360","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451660","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452319","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452663","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-73061-1629707067","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' ++ body: '[{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636473129","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80208-1636035966","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80608-1636466533","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -263,7 +275,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:20 GMT ++ - Tue, 09 Nov 2021 16:41:01 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -272,6 +284,8 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "66" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -286,11 +300,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451360","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451660","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452319","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452663","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-73061-1629707067","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' ++ body: '[{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636473129","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80208-1636035966","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80608-1636466533","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -301,7 +315,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:20 GMT ++ - Tue, 09 Nov 2021 16:41:01 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -310,6 +324,8 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "73" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -324,11 +340,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451360","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451660","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452319","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452663","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-73061-1629707067","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' ++ body: '[{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636473129","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80208-1636035966","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80608-1636466533","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -339,7 +355,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:20 GMT ++ - Tue, 09 Nov 2021 16:41:01 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -348,6 +364,8 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "81" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -355,19 +373,19 @@ interactions: + duration: "" + - request: + body: | +- {"client_id":"testc7f6-1234-5678-9101-3fcbf123test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"foo:bar,buzz:lightyear","tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773"} ++ {"automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"foo:bar,buzz:lightyear","tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054"} + form: {} + headers: + Accept: + - application/json + Content-Length: +- - "211" ++ - "228" + Content-Type: + - application/json + Dd-Operation-Id: + - DeleteAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: DELETE + response: +@@ -384,13 +402,15 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:21 GMT ++ - Tue, 09 Nov 2021 16:41:02 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=15724800; + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "128" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -398,19 +418,19 @@ interactions: + duration: "" + - request: + body: | +- {"client_id":"testc7f6-1234-5678-9101-3fcbf464test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"","new_client_id":"testc7f6-1234-5678-9101-3fcbf464test","new_tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773"} ++ {"automute":true,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"","new_client_id":"testc7f6-1234-5678-9101-3fcbf464test","new_tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054"} + form: {} + headers: + Accept: + - application/json + Content-Length: +- - "315" ++ - "331" + Content-Type: + - application/json + Dd-Operation-Id: + - UpdateAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: PUT + response: +@@ -427,7 +447,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:23 GMT ++ - Tue, 09 Nov 2021 16:41:04 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -448,11 +468,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451360","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451660","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452319","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452663","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-73061-1629707067","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' ++ body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636473129","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":true,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80208-1636035966","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80608-1636466533","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -463,7 +483,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:23 GMT ++ - Tue, 09 Nov 2021 16:41:04 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -472,6 +492,8 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "100" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -486,11 +508,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451360","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451660","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452319","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452663","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-73061-1629707067","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' ++ body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636473129","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":true,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80208-1636035966","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80608-1636466533","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -501,7 +523,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:23 GMT ++ - Tue, 09 Nov 2021 16:41:04 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -510,6 +532,8 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "80" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -524,11 +548,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451360","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451660","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452319","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452663","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-73061-1629707067","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' ++ body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636473129","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054","automute":true,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80208-1636035966","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80608-1636466533","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -539,7 +563,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:24 GMT ++ - Tue, 09 Nov 2021 16:41:05 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -548,6 +572,8 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "231" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -555,19 +581,19 @@ interactions: + duration: "" + - request: + body: | +- {"client_id":"testc7f6-1234-5678-9101-3fcbf464test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"","tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452773"} ++ {"automute":true,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"","tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636476054"} + form: {} + headers: + Accept: + - application/json + Content-Length: +- - "189" ++ - "205" + Content-Type: + - application/json + Dd-Operation-Id: + - DeleteAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: DELETE + response: +@@ -584,13 +610,15 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:24 GMT ++ - Tue, 09 Nov 2021 16:41:06 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=15724800; + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "105" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -605,11 +633,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.5.1+dev (go go1.16.5; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451360","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451660","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452319","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635452663","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf123test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1635451549","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-73061-1629707067","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' ++ body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogIntegrationAzure-local-1636473129","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":"foo:bar,buzz:lightyear"},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80208-1636035966","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-80608-1636466533","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -620,7 +648,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Thu, 28 Oct 2021 20:26:24 GMT ++ - Tue, 09 Nov 2021 16:41:06 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -629,6 +657,8 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff ++ X-Envoy-Upstream-Service-Time: ++ - "117" + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +diff --git a/datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.freeze b/datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.freeze +index 14c734444a..db2b5de8b6 100644 +--- a/datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.freeze ++++ b/datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.freeze +@@ -1 +1 @@ +-2021-06-29T17:45:38.413586+02:00 +\ No newline at end of file ++2021-11-01T16:22:40.665642-04:00 +\ No newline at end of file +diff --git a/datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.yaml b/datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.yaml +index d62f4e57df..04b1be9188 100644 +--- a/datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.yaml ++++ b/datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.yaml +@@ -3,17 +3,19 @@ version: 1 + interactions: + - request: + body: | +- {"client_id":"testc7f6-1234-5678-9101-3fcbf464test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"","tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1624981538"} ++ {"automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"","tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1635798160"} + form: {} + headers: + Accept: + - application/json ++ Content-Length: ++ - "212" + Content-Type: + - application/json + Dd-Operation-Id: + - CreateAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.1.1+dev (go go1.16; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: POST + response: +@@ -30,15 +32,13 @@ interactions: + Content-Type: + - application/json + Date: +- - Tue, 29 Jun 2021 15:45:41 GMT ++ - Mon, 01 Nov 2021 20:22:43 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=15724800; + X-Content-Type-Options: + - nosniff +- X-Dd-Debug: +- - F5gm0Rce1/Abr9/0Fw8HAqWfiz0FdiH8er/AXnN6lOn3L6KyGgbsLCwgPlob1No8 + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -53,11 +53,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.1.1+dev (go go1.16; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1624981538","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"Test-Go-TestAzureListandDelete-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-tt1620302652","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"Test-Go-TestUpdateAzureAccount-1620842745-updated","automute":false,"client_id":"testc7f6-1234-5678-9101-uu1620842745","host_filters":"test:foo,test:bar"}]' ++ body: '[{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1635798160","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -68,7 +68,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Tue, 29 Jun 2021 15:45:41 GMT ++ - Mon, 01 Nov 2021 20:22:43 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -77,8 +77,6 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff +- X-Dd-Debug: +- - JpIJLwIH2nFlZOC+u71rq7aAOL43MLZN3MUsL+gpYHdZz5QLUOG8Jysf8kVK6tPU + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -86,21 +84,23 @@ interactions: + duration: "" + - request: + body: | +- {"data":{"attributes":{"destination":{"container":"my-container","integration":{"client_id":"testc7f6-1234-5678-9101-3fcbf464test","tenant_id":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1624981538"},"path":"/path/blou","storage_account":"storageaccount","type":"azure"},"include_tags":false,"name":"my first azure archive","query":"service:toto","rehydration_tags":[]},"type":"archives"}} ++ {"data":{"attributes":{"destination":{"container":"my-container","integration":{"client_id":"testc7f6-1234-5678-9101-3fcbf464test","tenant_id":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1635798160"},"path":"/path/blou","storage_account":"storageaccount","type":"azure"},"include_tags":false,"name":"my first azure archive","query":"service:toto","rehydration_tags":[]},"type":"archives"}} + form: {} + headers: + Accept: + - application/json ++ Content-Length: ++ - "393" + Content-Type: + - application/json + Dd-Operation-Id: + - CreateLogsArchive + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.1.1+dev (go go1.16; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v2/logs/config/archives + method: POST + response: +- body: '{"data":{"type":"archives","id":"n_XDSxVpScepiBnyhysj_A","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1624981538","client_id":"testc7f6-1234-5678-9101-3fcbf464test"}},"rehydration_tags":[],"include_tags":false}}}' ++ body: '{"data":{"type":"archives","id":"EKb3-dVIS-KPD2tuPjavSg","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1635798160","client_id":"testc7f6-1234-5678-9101-3fcbf464test"}},"rehydration_tags":[],"include_tags":false}}}' + headers: + Cache-Control: + - no-cache +@@ -111,7 +111,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Tue, 29 Jun 2021 15:45:41 GMT ++ - Mon, 01 Nov 2021 20:22:44 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -120,8 +120,6 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff +- X-Dd-Debug: +- - HbtaOKlJ6OCrx9tMXO6ivMTrEM+g0c93HDp08trmOmgdHozC5J+vn10F0H4WPjCU + X-Frame-Options: + - SAMEORIGIN + X-Ratelimit-Limit: +@@ -131,7 +129,7 @@ interactions: + X-Ratelimit-Remaining: + - "29" + X-Ratelimit-Reset: +- - "9" ++ - "6" + status: 200 OK + code: 200 + duration: "" +@@ -144,11 +142,11 @@ interactions: + Dd-Operation-Id: + - GetLogsArchive + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.1.1+dev (go go1.16; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v2/logs/config/archives/n_XDSxVpScepiBnyhysj_A ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v2/logs/config/archives/EKb3-dVIS-KPD2tuPjavSg + method: GET + response: +- body: '{"data":{"type":"archives","id":"n_XDSxVpScepiBnyhysj_A","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1624981538","client_id":"testc7f6-1234-5678-9101-3fcbf464test"}},"rehydration_tags":[],"include_tags":false}}}' ++ body: '{"data":{"type":"archives","id":"EKb3-dVIS-KPD2tuPjavSg","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1635798160","client_id":"testc7f6-1234-5678-9101-3fcbf464test"}},"rehydration_tags":[],"include_tags":false}}}' + headers: + Cache-Control: + - no-cache +@@ -159,7 +157,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Tue, 29 Jun 2021 15:45:41 GMT ++ - Mon, 01 Nov 2021 20:22:44 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -168,8 +166,6 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff +- X-Dd-Debug: +- - PhosSd3Ch1B6B0DXI71steKUi7XhPDttnPiIP1NdXTw0VJNWpoUnYyBmODS5ne3q + X-Frame-Options: + - SAMEORIGIN + X-Ratelimit-Limit: +@@ -179,7 +175,7 @@ interactions: + X-Ratelimit-Remaining: + - "29" + X-Ratelimit-Reset: +- - "9" ++ - "6" + status: 200 OK + code: 200 + duration: "" +@@ -192,11 +188,11 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.1.1+dev (go go1.16; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1624981538","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"Test-Go-TestAzureListandDelete-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-tt1620302652","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"Test-Go-TestUpdateAzureAccount-1620842745-updated","automute":false,"client_id":"testc7f6-1234-5678-9101-uu1620842745","host_filters":"test:foo,test:bar"}]' ++ body: '[{"errors":[],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1635798160","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""}]' + headers: + Cache-Control: + - no-cache +@@ -207,7 +203,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Tue, 29 Jun 2021 15:45:42 GMT ++ - Mon, 01 Nov 2021 20:22:45 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -216,8 +212,6 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff +- X-Dd-Debug: +- - tpRCH6w417YjBovRJ8VmtuXmNONVYiRp2c8d2AxjPdGBn8PCtgG4vAztrx3qUZAN + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -232,11 +226,11 @@ interactions: + Dd-Operation-Id: + - GetLogsArchive + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.1.1+dev (go go1.16; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v2/logs/config/archives/n_XDSxVpScepiBnyhysj_A ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v2/logs/config/archives/EKb3-dVIS-KPD2tuPjavSg + method: GET + response: +- body: '{"data":{"type":"archives","id":"n_XDSxVpScepiBnyhysj_A","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1624981538","client_id":"testc7f6-1234-5678-9101-3fcbf464test"}},"rehydration_tags":[],"include_tags":false}}}' ++ body: '{"data":{"type":"archives","id":"EKb3-dVIS-KPD2tuPjavSg","attributes":{"name":"my first azure archive","query":"service:toto","state":"UNKNOWN","destination":{"container":"my-container","storage_account":"storageaccount","path":"/path/blou","type":"azure","integration":{"tenant_id":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1635798160","client_id":"testc7f6-1234-5678-9101-3fcbf464test"}},"rehydration_tags":[],"include_tags":false}}}' + headers: + Cache-Control: + - no-cache +@@ -247,7 +241,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Tue, 29 Jun 2021 15:45:42 GMT ++ - Mon, 01 Nov 2021 20:22:45 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -256,8 +250,6 @@ interactions: + - Accept-Encoding + X-Content-Type-Options: + - nosniff +- X-Dd-Debug: +- - SY1h8ScsWq+kYmtbh63ltMLFAZsQjqfrgvdfAoRX+9TzT1sgMBRYaFRwfWWRRe9a + X-Frame-Options: + - SAMEORIGIN + X-Ratelimit-Limit: +@@ -267,7 +259,7 @@ interactions: + X-Ratelimit-Remaining: + - "28" + X-Ratelimit-Reset: +- - "8" ++ - "5" + status: 200 OK + code: 200 + duration: "" +@@ -280,8 +272,8 @@ interactions: + Dd-Operation-Id: + - DeleteLogsArchive + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.1.1+dev (go go1.16; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v2/logs/config/archives/n_XDSxVpScepiBnyhysj_A ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v2/logs/config/archives/EKb3-dVIS-KPD2tuPjavSg + method: DELETE + response: + body: "" +@@ -294,18 +286,14 @@ interactions: + - "0" + Content-Security-Policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report +- Content-Type: +- - application/json + Date: +- - Tue, 29 Jun 2021 15:45:43 GMT ++ - Mon, 01 Nov 2021 20:22:46 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=15724800; + X-Content-Type-Options: + - nosniff +- X-Dd-Debug: +- - LcgNasIYBRkNppmD6mCKE9J6iv0eEjosuuHR5V5zw2fWbR54i39C8dhdK8zDq/40 + X-Frame-Options: + - SAMEORIGIN + X-Ratelimit-Limit: +@@ -315,23 +303,25 @@ interactions: + X-Ratelimit-Remaining: + - "28" + X-Ratelimit-Reset: +- - "7" ++ - "4" + status: 204 No Content + code: 204 + duration: "" + - request: + body: | +- {"client_id":"testc7f6-1234-5678-9101-3fcbf464test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"","tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1624981538"} ++ {"automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","client_secret":"testingx./Sw*g/Y33t..R1cH+hScMDt","host_filters":"","tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-local-1635798160"} + form: {} + headers: + Accept: + - application/json ++ Content-Length: ++ - "212" + Content-Type: + - application/json + Dd-Operation-Id: + - DeleteAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.1.1+dev (go go1.16; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: DELETE + response: +@@ -348,15 +338,13 @@ interactions: + Content-Type: + - application/json + Date: +- - Tue, 29 Jun 2021 15:45:43 GMT ++ - Mon, 01 Nov 2021 20:22:47 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=15724800; + X-Content-Type-Options: + - nosniff +- X-Dd-Debug: +- - EFjE6I+AUQmTiNqZcuE1nqoFeAjWD0Xtzy3edDrinkwlU/Wzr/2Dbl5kWk3qLVaQ + X-Frame-Options: + - SAMEORIGIN + status: 200 OK +@@ -371,11 +359,11 @@ interactions: + Dd-Operation-Id: + - GetLogsArchive + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.1.1+dev (go go1.16; os darwin; arch amd64) +- url: https://api.datadoghq.com/api/v2/logs/config/archives/n_XDSxVpScepiBnyhysj_A ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) ++ url: https://api.datadoghq.com/api/v2/logs/config/archives/EKb3-dVIS-KPD2tuPjavSg + method: GET + response: +- body: '{"errors": ["Archive n_XDSxVpScepiBnyhysj_A not found"]}' ++ body: '{"errors": ["Archive EKb3-dVIS-KPD2tuPjavSg not found"]}' + headers: + Cache-Control: + - no-cache +@@ -386,7 +374,7 @@ interactions: + Content-Type: + - application/json + Date: +- - Tue, 29 Jun 2021 15:45:43 GMT ++ - Mon, 01 Nov 2021 20:22:47 GMT + Pragma: + - no-cache + Strict-Transport-Security: +@@ -404,7 +392,7 @@ interactions: + X-Ratelimit-Remaining: + - "27" + X-Ratelimit-Reset: +- - "7" ++ - "3" + status: 404 Not Found + code: 404 + duration: "" +@@ -417,34 +405,32 @@ interactions: + Dd-Operation-Id: + - ListAzureIntegration + User-Agent: +- - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 1.0.0) datadog-api-client-go/1.1.1+dev (go go1.16; os darwin; arch amd64) ++ - terraform-provider-datadog/dev (terraform 2.7.0; terraform-cli 0.14.7) datadog-api-client-go/1.5.1+dev (go go1.17; os darwin; arch amd64) + url: https://api.datadoghq.com/api/v1/integration/azure + method: GET + response: +- body: '[{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basic-62270-1620302653","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"tf-TestAccDatadogLogsArchiveAzure_basicDeprecated-62270-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-3fcbf464test","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"Test-Go-TestAzureListandDelete-1620302652","automute":false,"client_id":"testc7f6-1234-5678-9101-tt1620302652","host_filters":""},{"errors":["Invalid credentials. Datadog could not authenticate with Azure."],"warnings":[],"tenant_name":"Test-Go-TestUpdateAzureAccount-1620842745-updated","automute":false,"client_id":"testc7f6-1234-5678-9101-uu1620842745","host_filters":"test:foo,test:bar"}]' ++ body: '{"errors": ["Azure Integration not yet installed. Please install before performing this action."]}' + headers: + Cache-Control: + - no-cache + Connection: + - keep-alive ++ Content-Length: ++ - "98" + Content-Security-Policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + Content-Type: + - application/json + Date: +- - Tue, 29 Jun 2021 15:45:43 GMT ++ - Mon, 01 Nov 2021 20:22:47 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=15724800; +- Vary: +- - Accept-Encoding + X-Content-Type-Options: + - nosniff +- X-Dd-Debug: +- - vdJ3/nHEY1ioXQ6pQrBVvsQK1s4yyc+wufBMPSoXql71qZVuP/xMdtNo6DafhOAk + X-Frame-Options: + - SAMEORIGIN +- status: 200 OK +- code: 200 ++ status: 400 Bad Request ++ code: 400 + duration: "" +diff --git a/datadog/tests/resource_datadog_integration_azure_test.go b/datadog/tests/resource_datadog_integration_azure_test.go +index 531344289a..6286690034 100644 +--- a/datadog/tests/resource_datadog_integration_azure_test.go ++++ b/datadog/tests/resource_datadog_integration_azure_test.go +@@ -25,6 +25,7 @@ resource "datadog_integration_azure" "an_azure_integration" { + } + + resource "datadog_integration_azure" "an_azure_integration_two" { ++ depends_on = [datadog_integration_azure.an_azure_integration] + tenant_name = "%[1]s" + client_id = "testc7f6-1234-5678-9101-3fcbf123test" + client_secret = "testingx./Sw*g/Y33t..R1cH+hScMDt" +@@ -38,6 +39,7 @@ resource "datadog_integration_azure" "an_azure_integration" { + tenant_name = "%s" + client_id = "testc7f6-1234-5678-9101-3fcbf464test" + client_secret = "testingx./Sw*g/Y33t..R1cH+hScMDt" ++ automute = true + }`, uniq) + } + +@@ -68,7 +70,9 @@ func TestAccDatadogIntegrationAzure(t *testing.T) { + "datadog_integration_azure.an_azure_integration", + "host_filters", "foo:bar,buzz:lightyear"), + resource.TestCheckResourceAttr( +- "datadog_integration_azure.an_azure_integration_two", ++ "datadog_integration_azure.an_azure_integration", ++ "automute", "false"), ++ resource.TestCheckResourceAttr("datadog_integration_azure.an_azure_integration_two", + "tenant_name", tenantName), + resource.TestCheckResourceAttr( + "datadog_integration_azure.an_azure_integration_two", +@@ -91,6 +95,9 @@ func TestAccDatadogIntegrationAzure(t *testing.T) { + resource.TestCheckResourceAttr( + "datadog_integration_azure.an_azure_integration", + "host_filters", ""), ++ resource.TestCheckResourceAttr( ++ "datadog_integration_azure.an_azure_integration", ++ "automute", "true"), + ), + }, + }, +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,12 @@ ++H4sIAAAAAAAAA+2Tb0/bMBDG+zqf4tCkFbQlaQpppU1MqihsaExMpS8nRa5zTTKldmY75Y/48Luk ++0AIa4w1omrjfmyRn5+7xPedgVhdlmqBahp2XokcM47h9Eg+f7XsU96NosBsNm3gUxcO4A/GLKbpD ++bZ0wAB2jtfvbvqfW/1OCjf8OrUukXiyESgObP1+NJ/yP4t3+2v+9YeP/3iAadKD3fBIe55X7L1No ++jZ9h6nlv4FDZ2iBIbQxKB581LNHYQisvxaVvzwsnc8g0REF/F/qfQoqGqi5LuL4GZ2pschwraimF ++pmiMmGuzgF4QxUEMxRyUdlAZtKgcbJ+Nv0Kqz1WpRWqhFI0OmF1CinNRl+495TrPCypYW7RASR1C ++k0+4W1WkoweFoqGthCtmJQIpzMHdVvZ/Wtq0pPr9oLfjkYAtuJlw8JebffD2/lG27izdlrp3WsgM ++VuD/gm6TPO5+BJej8oCQtSnBt2cn4Gvq7aIK17mCq6KC3LnKfghDgyUKOliQC0un1KYKSNpmc7jq ++2iaQrAJJWaj6IhGLdLDXJGyL1qpJ/eeCPllcWxOWWooynBUqXOnMFzqFdxcPF9c/e/OisXN841Az ++DPRHTU1OsUKVopIFWi9rw2sjm18mtWr6AXSzMnQgpMTKCSUpQhZb8rNQGUhhLTrylFpZikvYnhwe ++nE7G+3NRWtzxpkfJ6OBgP4LVSzI9nExGR6eTb8n30fTL/mOq4W4W+NEelSS2s0WW+4a0daf0NZJy ++LJxIdXasHGaGBkir0RWN//X95ROd2ZGRebHEdrl7kzUI09WG9gLZEHxXLFDXDqJ+b+H965vNMAzD ++MAzDMAzDMAzDMAzDMAzDMAzDMMxr4TfczteTACgAAA== +diff --git 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-000072/tests/test.sh b/tasks/format-code-task-000072/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c6ac6bbdd4369aff756427e0c32d085161bfa871 --- /dev/null +++ b/tasks/format-code-task-000072/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' +datadog/tests/cassettes/TestAccDatadogIntegrationAzure.freeze +datadog/tests/cassettes/TestAccDatadogIntegrationAzure.yaml +datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.freeze +datadog/tests/cassettes/TestAccDatadogLogsArchiveAzure_basic.yaml +datadog/tests/resource_datadog_integration_azure_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-000072/tests/test_command.sh b/tasks/format-code-task-000072/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000072/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000073/environment/Dockerfile b/tasks/format-code-task-000073/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0e469fa3675c9be158cc0b874206a43d5c2a455b --- /dev/null +++ b/tasks/format-code-task-000073/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:942c824088d3f8711fae9910bd12d3f7e6c70adc5d086b61a828fb154b33b895 diff --git a/tasks/format-code-task-000073/environment/setup/files/blocklist b/tasks/format-code-task-000073/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000073/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000073/environment/setup/setup.sh b/tasks/format-code-task-000073/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000073/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000073/tests/test.patch b/tasks/format-code-task-000073/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..35a28942102410ed6e309921de969f4ed0b65ab2 --- /dev/null +++ b/tasks/format-code-task-000073/tests/test.patch @@ -0,0 +1,36 @@ +diff --git a/test/ordered_list_in_blockquote.md b/test/ordered_list_in_blockquote.md +new file mode 100644 +index 000000000..1cc5d9163 +--- /dev/null ++++ b/test/ordered_list_in_blockquote.md +@@ -0,0 +1,9 @@ ++> 1. The simplest ordered list in blockquote ++ ++1. ol ++ ++ > 1. ol-li-blockquote-ol-li ++ > 1. ol-li-blockquote-ol-li-ol-li {MD027} ++ ++> 1. blockquote-ol-li ++> 1. blockquote-ol-li-ol-li {MD027} +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+3SUY6DIBAGYJ97irlAKWiV4xh1SMpWoUXc3eMvmjRtNtn1pU3T9P9eZgKTAPkR ++7WR7ro373GWPIhNdlktNftelV2WuVKW1lEUmU5cKlQ+70Y1pjE0gyoL38b+5tf0XJa75RzPGuvPD ++0DgW4+F+Z6zlr/L9Jf9KF2lO7atcZyTvd4W/vXn+HdMSfGt4407f5DybydlI8+JuaMKR/ZfrrYvb ++eUV8jLSN5AObYLjubfoy1tVt77vjefLRiIE3z34TAAAAAAAAAAAAAAAAAAAAAMC7+AGUwv93ACgA ++AA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000073/tests/test.sh b/tasks/format-code-task-000073/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2819765b132e954cc18a4c65a3fcc24b6b745a50 --- /dev/null +++ b/tasks/format-code-task-000073/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/ordered_list_in_blockquote.md +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-000073/tests/test_command.sh b/tasks/format-code-task-000073/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000073/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000075/environment/Dockerfile b/tasks/format-code-task-000075/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9435fecccaa28528799372acc89dd1a97fb7b1e9 --- /dev/null +++ b/tasks/format-code-task-000075/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c7dab750bea597d686b55b6072e32cbc6daec8afd526ba9645c5b26715b8ec70 diff --git a/tasks/format-code-task-000075/environment/setup/files/blocklist b/tasks/format-code-task-000075/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000075/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000075/environment/setup/setup.sh b/tasks/format-code-task-000075/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000075/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000075/tests/test.patch b/tasks/format-code-task-000075/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ddd22a660024f74a9a028550e8886f28f4f1d37b --- /dev/null +++ b/tasks/format-code-task-000075/tests/test.patch @@ -0,0 +1,427 @@ +diff --git a/config/lfu_defaults_test.go b/config/lfu_defaults_test.go +new file mode 100644 +index 000000000..5d1fdfe25 +--- /dev/null ++++ b/config/lfu_defaults_test.go +@@ -0,0 +1,83 @@ ++package config ++ ++import ( ++ "reflect" ++ "testing" ++) ++ ++func serverNumericFieldWithDefault(t *testing.T, want int64) reflect.Value { ++ t.Helper() ++ server := reflect.ValueOf(&DiceConfig.Server).Elem() ++ for i := 0; i < server.NumField(); i++ { ++ field := server.Field(i) ++ switch field.Kind() { ++ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: ++ if field.Int() == want { ++ return field ++ } ++ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: ++ if field.Uint() == uint64(want) { ++ return field ++ } ++ case reflect.Float32, reflect.Float64: ++ if field.Float() == float64(want) { ++ return field ++ } ++ } ++ } ++ t.Fatalf("server config option with numeric default %d is not available", want) ++ return reflect.Value{} ++} ++ ++func numericFieldValue(t *testing.T, field reflect.Value) float64 { ++ t.Helper() ++ switch field.Kind() { ++ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: ++ return float64(field.Int()) ++ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: ++ return float64(field.Uint()) ++ case reflect.Float32, reflect.Float64: ++ return field.Float() ++ default: ++ t.Fatalf("server config field kind = %s, want numeric", field.Kind()) ++ return 0 ++ } ++} ++ ++func setNumericField(t *testing.T, field reflect.Value, value float64) { ++ t.Helper() ++ switch field.Kind() { ++ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: ++ field.SetInt(int64(value)) ++ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: ++ if value < 0 { ++ t.Fatalf("cannot set unsigned server config field to %g", value) ++ } ++ field.SetUint(uint64(value)) ++ case reflect.Float32, reflect.Float64: ++ field.SetFloat(value) ++ default: ++ t.Fatalf("server config field kind = %s, want numeric", field.Kind()) ++ } ++} ++ ++func TestDefaultEvictionPolicyIsAllKeysLFU(t *testing.T) { ++ if DiceConfig.Server.EvictionPolicy != "allkeys-lfu" { ++ t.Fatalf("default eviction policy = %q, want allkeys-lfu", DiceConfig.Server.EvictionPolicy) ++ } ++} ++ ++func TestLFULogFactorDefaultAndCanBeSet(t *testing.T) { ++ field := serverNumericFieldWithDefault(t, 10) ++ if got := numericFieldValue(t, field); got != 10 { ++ t.Fatalf("default LFU growth factor = %g, want 10", got) ++ } ++ ++ original := numericFieldValue(t, field) ++ t.Cleanup(func() { setNumericField(t, field, original) }) ++ ++ setNumericField(t, field, 37) ++ if got := numericFieldValue(t, field); got != 37 { ++ t.Fatalf("LFU growth factor config did not retain runtime value, got %g", got) ++ } ++} +diff --git a/internal/store/lfu_behavior_test.go b/internal/store/lfu_behavior_test.go +new file mode 100644 +index 000000000..ccb247774 +--- /dev/null ++++ b/internal/store/lfu_behavior_test.go +@@ -0,0 +1,291 @@ ++package store ++ ++import ( ++ "reflect" ++ "testing" ++ "time" ++ ++ "github.com/dicedb/dice/config" ++ "github.com/dicedb/dice/internal/object" ++) ++ ++func serverNumericFieldWithDefault(t *testing.T, want int64) reflect.Value { ++ t.Helper() ++ server := reflect.ValueOf(&config.DiceConfig.Server).Elem() ++ for i := 0; i < server.NumField(); i++ { ++ field := server.Field(i) ++ switch field.Kind() { ++ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: ++ if field.Int() == want { ++ return field ++ } ++ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: ++ if field.Uint() == uint64(want) { ++ return field ++ } ++ case reflect.Float32, reflect.Float64: ++ if field.Float() == float64(want) { ++ return field ++ } ++ } ++ } ++ t.Fatalf("server config option with numeric default %d is not available", want) ++ return reflect.Value{} ++} ++ ++func numericFieldValue(t *testing.T, field reflect.Value) float64 { ++ t.Helper() ++ switch field.Kind() { ++ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: ++ return float64(field.Int()) ++ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: ++ return float64(field.Uint()) ++ case reflect.Float32, reflect.Float64: ++ return field.Float() ++ default: ++ t.Fatalf("server config field kind = %s, want numeric", field.Kind()) ++ return 0 ++ } ++} ++ ++func setNumericField(t *testing.T, field reflect.Value, value float64) { ++ t.Helper() ++ switch field.Kind() { ++ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: ++ field.SetInt(int64(value)) ++ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: ++ if value < 0 { ++ t.Fatalf("cannot set unsigned server config field to %g", value) ++ } ++ field.SetUint(uint64(value)) ++ case reflect.Float32, reflect.Float64: ++ field.SetFloat(value) ++ default: ++ t.Fatalf("server config field kind = %s, want numeric", field.Kind()) ++ } ++} ++ ++func withEvictionSettings(t *testing.T, policy string, ratio float64, keysLimit int, logFactor int) { ++ t.Helper() ++ originalPolicy := config.DiceConfig.Server.EvictionPolicy ++ originalRatio := config.DiceConfig.Server.EvictionRatio ++ originalKeysLimit := config.DiceConfig.Server.KeysLimit ++ growthFactorField := serverNumericFieldWithDefault(t, 10) ++ originalLogFactorValue := numericFieldValue(t, growthFactorField) ++ t.Cleanup(func() { ++ config.DiceConfig.Server.EvictionPolicy = originalPolicy ++ config.DiceConfig.Server.EvictionRatio = originalRatio ++ config.DiceConfig.Server.KeysLimit = originalKeysLimit ++ setNumericField(t, growthFactorField, originalLogFactorValue) ++ }) ++ if policy != "" { ++ config.DiceConfig.Server.EvictionPolicy = policy ++ } ++ config.DiceConfig.Server.EvictionRatio = ratio ++ config.DiceConfig.Server.KeysLimit = keysLimit ++ setNumericField(t, growthFactorField, float64(logFactor)) ++} ++ ++func putTestKey(s *Store, key string) { ++ s.Put(key, &object.Obj{}) ++} ++ ++func touchKeyManyTimes(t *testing.T, s *Store, key string, count int) { ++ t.Helper() ++ for i := 0; i < count; i++ { ++ if got := s.Get(key); got == nil { ++ t.Fatalf("expected key %q to exist while building access frequency", key) ++ } ++ } ++} ++ ++func assertKeyPresent(t *testing.T, s *Store, key string) { ++ t.Helper() ++ if got := s.Get(key); got == nil { ++ t.Fatalf("expected key %q to survive eviction", key) ++ } ++} ++ ++func assertKeyMissing(t *testing.T, s *Store, key string) { ++ t.Helper() ++ if got := s.Get(key); got != nil { ++ t.Fatalf("expected key %q to be evicted", key) ++ } ++} ++ ++func countMissing(t *testing.T, s *Store, keys ...string) int { ++ t.Helper() ++ missing := 0 ++ for _, key := range keys { ++ if s.Get(key) == nil { ++ missing++ ++ } ++ } ++ return missing ++} ++ ++func TestAllKeysLFUPreservesFrequentlyAccessedKeysAgainstRecentColdKeys(t *testing.T) { ++ withEvictionSettings(t, "allkeys-lfu", 0.40, 5, 1) ++ s := NewStore(nil) ++ ++ hotKeys := []string{"alpha-hot-1", "alpha-hot-2"} ++ coldKeys := []string{"beta-cold-1", "beta-cold-2", "beta-cold-3"} ++ for _, key := range hotKeys { ++ putTestKey(s, key) ++ touchKeyManyTimes(t, s, key, 220) ++ } ++ ++ time.Sleep(1100 * time.Millisecond) ++ for _, key := range coldKeys { ++ putTestKey(s, key) ++ } ++ putTestKey(s, "alpha-trigger") ++ ++ assertKeyPresent(t, s, "alpha-hot-1") ++ assertKeyPresent(t, s, "alpha-hot-2") ++ if missing := countMissing(t, s, coldKeys...); missing < 2 { ++ t.Fatalf("LFU eviction removed %d cold keys, want at least 2; this looks like recency-only eviction", missing) ++ } ++} ++ ++func TestAllKeysLFUUsesAccessFrequencyForNeutralKeyNames(t *testing.T) { ++ withEvictionSettings(t, "allkeys-lfu", 0.50, 2, 1) ++ s := NewStore(nil) ++ ++ putTestKey(s, "session:primary") ++ touchKeyManyTimes(t, s, "session:primary", 220) ++ time.Sleep(1100 * time.Millisecond) ++ putTestKey(s, "session:secondary") ++ putTestKey(s, "session:trigger") ++ ++ assertKeyPresent(t, s, "session:primary") ++ assertKeyMissing(t, s, "session:secondary") ++} ++ ++func TestAllKeysLFUTieBreaksByIdleTime(t *testing.T) { ++ withEvictionSettings(t, "allkeys-lfu", 0.50, 2, 10) ++ s := NewStore(nil) ++ ++ putTestKey(s, "same-frequency-old") ++ time.Sleep(1100 * time.Millisecond) ++ putTestKey(s, "same-frequency-new") ++ putTestKey(s, "same-frequency-trigger") ++ ++ assertKeyMissing(t, s, "same-frequency-old") ++ assertKeyPresent(t, s, "same-frequency-new") ++} ++ ++func TestDefaultPolicyUsesLFUBehaviorWhenUnspecified(t *testing.T) { ++ withEvictionSettings(t, "", 0.50, 2, 1) ++ if config.DiceConfig.Server.EvictionPolicy != "allkeys-lfu" { ++ t.Fatalf("test requires the package default policy to be allkeys-lfu, got %q", config.DiceConfig.Server.EvictionPolicy) ++ } ++ s := NewStore(nil) ++ ++ putTestKey(s, "default-hot") ++ touchKeyManyTimes(t, s, "default-hot", 220) ++ time.Sleep(1100 * time.Millisecond) ++ putTestKey(s, "default-recent-cold") ++ putTestKey(s, "default-trigger") ++ ++ assertKeyPresent(t, s, "default-hot") ++ assertKeyMissing(t, s, "default-recent-cold") ++} ++ ++func TestLFULogFactorLowProtectsFrequentlyAccessedKey(t *testing.T) { ++ withEvictionSettings(t, "allkeys-lfu", 0.50, 2, 1) ++ s := NewStore(nil) ++ ++ putTestKey(s, "low-factor-hot") ++ touchKeyManyTimes(t, s, "low-factor-hot", 200) ++ time.Sleep(1100 * time.Millisecond) ++ putTestKey(s, "low-factor-cold") ++ touchKeyManyTimes(t, s, "low-factor-cold", 1) ++ putTestKey(s, "low-factor-trigger") ++ ++ assertKeyPresent(t, s, "low-factor-hot") ++ assertKeyMissing(t, s, "low-factor-cold") ++} ++ ++func TestLFULogFactorHighSlowsFrequencyGrowth(t *testing.T) { ++ withEvictionSettings(t, "allkeys-lfu", 0.50, 2, 100) ++ s := NewStore(nil) ++ ++ putTestKey(s, "high-factor-hot") ++ touchKeyManyTimes(t, s, "high-factor-hot", 1) ++ time.Sleep(1100 * time.Millisecond) ++ putTestKey(s, "high-factor-cold") ++ touchKeyManyTimes(t, s, "high-factor-cold", 1) ++ putTestKey(s, "high-factor-trigger") ++ ++ assertKeyMissing(t, s, "high-factor-hot") ++ assertKeyPresent(t, s, "high-factor-cold") ++} ++ ++func TestLFULogFactorZeroMakesRepeatedAccessesDeterministicallyStronger(t *testing.T) { ++ withEvictionSettings(t, "allkeys-lfu", 0.50, 2, 0) ++ ++ cases := [][3]string{ ++ {"factor-zero-a-primary", "factor-zero-a-secondary", "factor-zero-a-trigger"}, ++ {"factor-zero-b-primary", "factor-zero-b-secondary", "factor-zero-b-trigger"}, ++ {"factor-zero-c-primary", "factor-zero-c-secondary", "factor-zero-c-trigger"}, ++ } ++ ++ for _, keys := range cases { ++ s := NewStore(nil) ++ putTestKey(s, keys[0]) ++ touchKeyManyTimes(t, s, keys[0], 2) ++ time.Sleep(1100 * time.Millisecond) ++ putTestKey(s, keys[1]) ++ touchKeyManyTimes(t, s, keys[1], 1) ++ putTestKey(s, keys[2]) ++ ++ assertKeyPresent(t, s, keys[0]) ++ assertKeyMissing(t, s, keys[1]) ++ } ++} ++ ++func TestLFUFrequencyDoesNotWrapAfterManyAccesses(t *testing.T) { ++ withEvictionSettings(t, "allkeys-lfu", 0.50, 2, 1) ++ s := NewStore(nil) ++ ++ putTestKey(s, "wrap-resistant-hot") ++ touchKeyManyTimes(t, s, "wrap-resistant-hot", 512) ++ time.Sleep(1100 * time.Millisecond) ++ putTestKey(s, "wrap-resistant-cold") ++ putTestKey(s, "wrap-resistant-trigger") ++ ++ assertKeyPresent(t, s, "wrap-resistant-hot") ++ assertKeyMissing(t, s, "wrap-resistant-cold") ++} ++ ++func TestLFUFrequencySaturatesInsteadOfWrappingUnderDeterministicGrowth(t *testing.T) { ++ withEvictionSettings(t, "allkeys-lfu", 0.50, 2, 0) ++ s := NewStore(nil) ++ ++ putTestKey(s, "wrap-neutral-primary") ++ touchKeyManyTimes(t, s, "wrap-neutral-primary", 260) ++ time.Sleep(1100 * time.Millisecond) ++ putTestKey(s, "wrap-neutral-secondary") ++ touchKeyManyTimes(t, s, "wrap-neutral-secondary", 20) ++ putTestKey(s, "wrap-neutral-trigger") ++ ++ assertKeyPresent(t, s, "wrap-neutral-primary") ++ assertKeyMissing(t, s, "wrap-neutral-secondary") ++} ++ ++func TestLFUBookkeepingDoesNotCorruptLRUIdleOrdering(t *testing.T) { ++ withEvictionSettings(t, "allkeys-lfu", 0.50, 2, 1) ++ s := NewStore(nil) ++ ++ putTestKey(s, "lfu-metadata-old") ++ touchKeyManyTimes(t, s, "lfu-metadata-old", 220) ++ ++ time.Sleep(1100 * time.Millisecond) ++ config.DiceConfig.Server.EvictionPolicy = "allkeys-lru" ++ putTestKey(s, "plain-lru-new") ++ putTestKey(s, "plain-lru-trigger") ++ ++ assertKeyMissing(t, s, "lfu-metadata-old") ++ assertKeyPresent(t, s, "plain-lru-new") ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,36 @@ ++#!/bin/bash ++set -euo pipefail ++ ++cd /testbed ++ ++ ++dev-switch go 1.23 ++ ++ ++case "${1:-}" in ++ base) ++ go test -v -race -count=1 ./internal/server/utils/... ++ go test -v -race -count=1 ./internal/store -run '^(TestDelExpiry|TestAOF|TestAOFWithExat)$' ++ ;; ++ new) ++ go test -v -race -count=1 ./config -run '^(TestDefaultEvictionPolicyIsAllKeysLFU|TestLFULogFactorDefaultAndCanBeSet)$' ++ for test_name in \ ++ TestAllKeysLFUPreservesFrequentlyAccessedKeysAgainstRecentColdKeys \ ++ TestAllKeysLFUUsesAccessFrequencyForNeutralKeyNames \ ++ TestAllKeysLFUTieBreaksByIdleTime \ ++ TestDefaultPolicyUsesLFUBehaviorWhenUnspecified \ ++ TestLFULogFactorLowProtectsFrequentlyAccessedKey \ ++ TestLFULogFactorHighSlowsFrequencyGrowth \ ++ TestLFULogFactorZeroMakesRepeatedAccessesDeterministicallyStronger \ ++ TestLFUFrequencyDoesNotWrapAfterManyAccesses \ ++ TestLFUFrequencySaturatesInsteadOfWrappingUnderDeterministicGrowth \ ++ TestLFUBookkeepingDoesNotCorruptLRUIdleOrdering ++ do ++ go test -v -race -count=1 ./internal/store -run "^${test_name}$" ++ done ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000075/tests/test.sh b/tasks/format-code-task-000075/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..dd47c100605625a824f0b05386be11e4826e7b10 --- /dev/null +++ b/tasks/format-code-task-000075/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' +config/lfu_defaults_test.go +internal/store/lfu_behavior_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-000075/tests/test_command.sh b/tasks/format-code-task-000075/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000075/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-000080/environment/Dockerfile b/tasks/format-code-task-000080/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..72e89d3335bf72405387afedc2a533a474dda339 --- /dev/null +++ b/tasks/format-code-task-000080/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a3b7c0a528714bb1188a746b1313d6cfb39977fb528582821d54458706181c5b diff --git a/tasks/format-code-task-000080/environment/setup/files/blocklist b/tasks/format-code-task-000080/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000080/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000080/environment/setup/setup.sh b/tasks/format-code-task-000080/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000080/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000080/tests/test.patch b/tasks/format-code-task-000080/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..613df375ff254e5db262926a1f0575bfa6e6488a --- /dev/null +++ b/tasks/format-code-task-000080/tests/test.patch @@ -0,0 +1,193 @@ +diff --git a/tests/test_hsmtool_encryption.py b/tests/test_hsmtool_encryption.py +new file mode 100644 +index 000000000..bca7030fb +--- /dev/null ++++ b/tests/test_hsmtool_encryption.py +@@ -0,0 +1,161 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++import os ++import select ++import subprocess ++import time ++ ++HSMTOOL = "tools/hsmtool" ++PLAINTEXT_LEN = 32 ++ENCRYPTED_LEN = 73 ++ ++ ++def _run_hsmtool(args, inputs, timeout=60): ++ ++ ++ ++ ++ ++ ++ ++ ++ inputs = list(inputs) ++ master, slave = os.openpty() ++ proc = subprocess.Popen( ++ [HSMTOOL, *args], ++ stdin=slave, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.STDOUT, ++ ) ++ os.close(slave) ++ ++ out = b"" ++ handled_newlines = 0 ++ fd = proc.stdout.fileno() ++ deadline = time.time() + timeout ++ try: ++ while True: ++ if time.time() > deadline: ++ proc.kill() ++ out += b"" ++ break ++ ready, _, _ = select.select([fd], [], [], 0.2) ++ if ready: ++ chunk = os.read(fd, 4096) ++ if not chunk: ++ break ++ out += chunk ++ seen = out.count(b"\n") ++ ++ ++ while inputs and seen > handled_newlines: ++ line = inputs.pop(0) ++ ++ ++ time.sleep(0.05) ++ try: ++ os.write(master, line.encode()) ++ except OSError: ++ pass ++ handled_newlines += 1 ++ elif proc.poll() is not None: ++ try: ++ while True: ++ chunk = os.read(fd, 4096) ++ if not chunk: ++ break ++ out += chunk ++ except OSError: ++ pass ++ break ++ finally: ++ proc.stdout.close() ++ rc = proc.wait() ++ os.close(master) ++ return rc, out.decode(errors="replace") ++ ++ ++def _write_secret(path, data): ++ with open(path, "wb") as f: ++ f.write(data) ++ ++ ++def test_encrypt_password_mismatch_aborts(tmp_path): ++ ++ seed = bytes(range(PLAINTEXT_LEN)) ++ path = str(tmp_path / "hsm_secret") ++ _write_secret(path, seed) ++ ++ rc, out = _run_hsmtool(["encrypt", path], ["hunter2cool\n", "hunter2typo\n"]) ++ ++ ++ assert rc != 0, out ++ ++ with open(path, "rb") as f: ++ after = f.read() ++ assert after == seed ++ assert len(after) == PLAINTEXT_LEN ++ ++ ++def test_encrypt_then_decrypt_roundtrip(tmp_path): ++ ++ seed = bytes((i * 7 + 3) % 256 for i in range(PLAINTEXT_LEN)) ++ path = str(tmp_path / "hsm_secret") ++ _write_secret(path, seed) ++ ++ password = "a-correct-horse-battery-staple" ++ ++ rc, out = _run_hsmtool(["encrypt", path], [password + "\n", password + "\n"]) ++ assert rc == 0, out ++ with open(path, "rb") as f: ++ encrypted = f.read() ++ ++ assert len(encrypted) == ENCRYPTED_LEN ++ assert encrypted != seed ++ ++ rc, out = _run_hsmtool(["decrypt", path], [password + "\n"]) ++ assert rc == 0, out ++ with open(path, "rb") as f: ++ recovered = f.read() ++ assert recovered == seed ++ ++ ++def test_invalid_size_rejected_on_encrypt(tmp_path): ++ ++ password = "some-decent-password" ++ for size in (16, 40, 64, 100): ++ path = str(tmp_path / f"hsm_secret_{size}") ++ data = bytes((i + 1) % 256 for i in range(size)) ++ _write_secret(path, data) ++ ++ rc, out = _run_hsmtool( ++ ["encrypt", path], [password + "\n", password + "\n"] ++ ) ++ ++ assert rc != 0, (size, out) ++ assert "invalid" in out.lower(), (size, out) ++ ++ with open(path, "rb") as f: ++ assert f.read() == data, size ++ ++ ++def test_invalid_size_rejected_on_decrypt(tmp_path): ++ ++ password = "some-decent-password" ++ for size in (16, 40, 64, 100): ++ path = str(tmp_path / f"hsm_secret_{size}") ++ data = bytes((i * 3 + 5) % 256 for i in range(size)) ++ _write_secret(path, data) ++ ++ rc, out = _run_hsmtool(["decrypt", path], [password + "\n"]) ++ ++ assert rc != 0, (size, out) ++ assert "invalid" in out.lower(), (size, out) ++ with open(path, "rb") as f: ++ assert f.read() == data, 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,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++make tools/hsmtool ++ ++ ++ ++make common/test/run-derive_basepoints ++./common/test/run-derive_basepoints ++ ++ ++python3 -m pytest tests/test_hsmtool_encryption.py -q -p no:cacheprovider diff --git a/tasks/format-code-task-000080/tests/test.sh b/tasks/format-code-task-000080/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..aafbe7100b6b139cd7f87323bc4e02383085ae9e --- /dev/null +++ b/tasks/format-code-task-000080/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_hsmtool_encryption.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-000080/tests/test_command.sh b/tasks/format-code-task-000080/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000080/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000081/environment/Dockerfile b/tasks/format-code-task-000081/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6762538a0a4139b6f88ff0caa80969699d240e5f --- /dev/null +++ b/tasks/format-code-task-000081/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:18ac41f5a2e66c62b657c71671521f8d8a9dead4a8676bae43908df5bfeb1779 diff --git a/tasks/format-code-task-000081/environment/setup/files/blocklist b/tasks/format-code-task-000081/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000081/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000081/environment/setup/setup.sh b/tasks/format-code-task-000081/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000081/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000081/tests/test.patch b/tasks/format-code-task-000081/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4a070e41e77bd957e26ace502b72b144941ac251 --- /dev/null +++ b/tasks/format-code-task-000081/tests/test.patch @@ -0,0 +1,250 @@ +diff --git a/testing/test_runner.py b/testing/test_runner.py +index eef1d5ed..d7f3cf2f 100644 +--- a/testing/test_runner.py ++++ b/testing/test_runner.py +@@ -47,7 +47,7 @@ def non_zero_args5(a, b=1, **kwargs): + + with utils.TempDir() as temp: + dpath = temp.dpath +- modpath = join(dpath, 'test_zero.py') ++ modpath = join(dpath, 'test_zero_args.py') + + with open(modpath, 'w') as file: + file.write(source) +@@ -60,6 +60,212 @@ def non_zero_args5(a, b=1, **kwargs): + 'zero_args3', 'zero_args4']) + + ++def test_list(): ++ from xdoctest import runner ++ ++ source = utils.codeblock( ++ ''' ++ # --- HELPERS --- ++ def real_test1(a=1): ++ """ ++ Example: ++ >>> pass ++ """ ++ pass ++ ++ def fake_test1(a=1): ++ pass ++ ++ def real_test2(): ++ """ ++ Example: ++ >>> pass ++ """ ++ pass ++ ++ def fake_test2(): ++ pass ++ ''') ++ ++ with utils.TempDir() as temp: ++ dpath = temp.dpath ++ modpath = join(dpath, 'test_list.py') ++ ++ with open(modpath, 'w') as file: ++ file.write(source) ++ ++ with utils.CaptureStdout() as cap: ++ runner.doctest_module(modpath, 'list', argv=['']) ++ ++ assert 'real_test1' in cap.text ++ assert 'real_test2' in cap.text ++ assert 'fake_test1' not in cap.text ++ assert 'fake_test2' not in cap.text ++ ++ ++ with utils.CaptureStdout() as cap: ++ runner.doctest_module(modpath, None, argv=['']) ++ ++ assert 'real_test1' in cap.text ++ assert 'real_test2' in cap.text ++ assert 'fake_test1' not in cap.text ++ assert 'fake_test2' not in cap.text ++ ++ ++def test_example_run(): ++ from xdoctest import runner ++ ++ source = utils.codeblock( ++ ''' ++ def foo(): ++ """ ++ Example: ++ >>> print('i wanna see this') ++ """ ++ ''') ++ ++ with utils.TempDir() as temp: ++ dpath = temp.dpath ++ modpath = join(dpath, 'test_example_run.py') ++ ++ with open(modpath, 'w') as file: ++ file.write(source) ++ ++ with utils.CaptureStdout() as cap: ++ runner.doctest_module(modpath, 'foo', argv=['']) ++ ++ assert 'i wanna see this' in cap.text ++ ++ ++def test_all_disabled(): ++ """ ++ pytest testing/test_runner.py::test_all_disabled -s ++ """ ++ from xdoctest import runner ++ ++ source = utils.codeblock( ++ ''' ++ def foo(): ++ """ ++ Example: ++ >>> # DISABLE_DOCTEST ++ >>> print('all will not print this') ++ """ ++ ++ def bar(): ++ """ ++ Example: ++ >>> print('all will print this') ++ """ ++ ''') ++ ++ with utils.TempDir() as temp: ++ dpath = temp.dpath ++ modpath = join(dpath, 'test_all_disabled.py') ++ ++ with open(modpath, 'w') as file: ++ file.write(source) ++ ++ ++ with utils.CaptureStdout() as cap: ++ runner.doctest_module(modpath, 'all', argv=['']) ++ assert 'all will print this' in cap.text ++ assert 'all will not print this' not in cap.text ++ ++ ++ with utils.CaptureStdout() as cap: ++ runner.doctest_module(modpath, 'foo', argv=['']) ++ assert 'all will not print this' in cap.text ++ ++ ++def test_failure(): ++ """ ++ pytest testing/test_runner.py::test_all_disabled -s ++ """ ++ from xdoctest import runner ++ ++ source = utils.codeblock( ++ ''' ++ def test1(): ++ """ ++ Example: ++ >>> pass ++ """ ++ ++ def test2(): ++ """ ++ Example: ++ >>> assert False ++ """ ++ ''') ++ ++ with utils.TempDir() as temp: ++ dpath = temp.dpath ++ modpath = join(dpath, 'test_failure.py') ++ ++ with open(modpath, 'w') as file: ++ file.write(source) ++ ++ ++ with utils.CaptureStdout() as cap: ++ try: ++ runner.doctest_module(modpath, 'all', argv=[''], verbose=0) ++ except Exception: ++ pass ++ ++ assert '.F' in cap.text ++ assert '1 / 2 passed' in cap.text ++ ++ ++def test_run_zero_arg(): ++ """ ++ pytest testing/test_runner.py::test_run_zero_arg -s ++ """ ++ from xdoctest import runner ++ ++ source = utils.codeblock( ++ ''' ++ def zero_arg_print(): ++ print('running zero arg') ++ ''') ++ ++ with utils.TempDir() as temp: ++ dpath = temp.dpath ++ modpath = join(dpath, 'test_run_zero_arg.py') ++ ++ with open(modpath, 'w') as file: ++ file.write(source) ++ ++ ++ with utils.CaptureStdout() as cap: ++ try: ++ runner.doctest_module(modpath, 'all', argv=[''], verbose=3) ++ except Exception: ++ pass ++ assert 'running zero arg' not in cap.text ++ ++ with utils.CaptureStdout() as cap: ++ try: ++ runner.doctest_module(modpath, 'zero_arg_print', argv=[''], verbose=3) ++ except Exception: ++ pass ++ ++ assert 'running zero arg' in cap.text ++ ++ ++def test_parse_cmdline(): ++ """ ++ pytest testing/test_runner.py::test_parse_cmdline -s ++ """ ++ from xdoctest import runner ++ ++ runner._parse_commandline(command=None, style=None, verbose=None, argv=None) ++ ++ assert 'freeform' == runner._parse_commandline(command=None, style=None, verbose=None, argv=['--freeform'])[1] ++ assert 'google' == runner._parse_commandline(command=None, style=None, verbose=None, argv=['--google'])[1] ++ assert None is runner._parse_commandline(command=None, style=None, verbose=None, argv=['--google'])[0] ++ ++ + if __name__ == '__main__': + r""" + CommandLine: +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+3TzYrbMBAA4Jz9FMP2khz8l42zUGihb1D6AkG2Zu2hiiT0423evvJP0lJo97Kh ++lM53iEI0nhl5lKKNpOQJ9Vhu7qVKnppmXpNf1/l73ezr/aGp60OKq+tjVW+guVtHP4k+CAewccaE ++P8W9tv+PKn7MP6APp86cz0LLwg9vV+O1+T89Hm7zr+b5H477agPV27Xwe//5/DsJ8+BblFn2Dj51 ++gUYREMKAYNF58gF1gM+XMBgNj8URRnIhCpVuDGw1okQJz8aBwwJ9JyxCukJWhF3mTXQdQjm9ubIY ++0wOnb9J0U7WyJV2KtdZU9wuSToNQCq4h8OzMGdYcW5QURKtwB8EAah8dAvZ9rkh/BfIpGP2QWbJw ++zZPj7WCQ59rkpG0MsP9YShxLHZWa60Y9HzXdgR4DLIVJIbxQGOadWz/2siwq9qRBkp/6kSnHdn5X ++y8+D8Ov5qSVF4ZKa8xH9kk/jC7o10S6zyzvNz9fU0wfpfvkjuqg1usJeIB8ht6DN+1sruYEHIaWx ++wX9IW8vjKfMStkY9ZH/7bjHGGGOMMcYYY4wxxhhjjDHGGGOMsfv7Dv3spYUAKAAA +diff --git 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-000081/tests/test.sh b/tasks/format-code-task-000081/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1d0e4fefad2e5dec272a4f1fd931364a46aec7ab --- /dev/null +++ b/tasks/format-code-task-000081/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' +testing/test_runner.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000081/tests/test_command.sh b/tasks/format-code-task-000081/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000081/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000087/environment/Dockerfile b/tasks/format-code-task-000087/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..493809c3f194283584e15e946eaf402c581ae65e --- /dev/null +++ b/tasks/format-code-task-000087/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7ccc494b08b3f8f4b2dd67c2957845ff95ce2a2af29201ad9abe4ed14d548399 diff --git a/tasks/format-code-task-000087/environment/setup/files/blocklist b/tasks/format-code-task-000087/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000087/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000087/environment/setup/setup.sh b/tasks/format-code-task-000087/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000087/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000087/tests/test.patch b/tasks/format-code-task-000087/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b8afc8cb4cc3e9ff7e52a7cb7afb3ce405b8cc52 --- /dev/null +++ b/tasks/format-code-task-000087/tests/test.patch @@ -0,0 +1,43 @@ +diff --git a/tests/test_misc.py b/tests/test_misc.py +index 16c8e5a..301b6c5 100755 +--- a/tests/test_misc.py ++++ b/tests/test_misc.py +@@ -21,6 +21,17 @@ def test_reloadCollection(setup): + ac.reloadCollection() + + ++def test_apiReflect(setup): ++ result = ac.apiReflect( ++ scopes=["actions", "invalidType"], ++ actions=["apiReflect", "invalidMethod"] ++ ) ++ assert result == { ++ "scopes": ["actions"], ++ "actions": ["apiReflect"] ++ } ++ ++ + class TestProfiles: + def test_getProfiles(self, session_with_profile_loaded): + result = ac.getProfiles() +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+3ST2uDMBgGcM9+itB7rHFVTz1sw7WF2bJ/7ChVMywsiZgo9tsvdZSNwtZLyyh7 ++fofkhTckIU+8vN28lxmX3dg5F9+Kw3CYrcN5qFkYMBb7URzbdYxFbOKQ8Gw3+qbVZt0Q4jRKmd/W ++HetfKO8rf8O1yQolxFqWnq5Od8ax/AMb9j7/aMh/EgU2f/90V/jZP8+/KMkQfM5Ll/e1agyZr9Jk ++OjaiHhq0UoLvWw/Pr8lNspwtlkl2O39cpYuXNLu7v549TUeUSkW1/Tu56kdu373ltGklqbemUvKK ++ULEr7YZkN+jP3yY2uvDqLaE9oZ37128BAAAAAAAAAAAAAAAAAAAAAHBpPgAXDa0wACgAAA== +diff --git 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-000087/tests/test.sh b/tasks/format-code-task-000087/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7250a577648f39b17c3e075dc51f82accedc057a --- /dev/null +++ b/tasks/format-code-task-000087/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_misc.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-000087/tests/test_command.sh b/tasks/format-code-task-000087/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000087/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000213/environment/Dockerfile b/tasks/format-code-task-000213/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..901b16194da016ed587d4de33cf795cbbc20090c --- /dev/null +++ b/tasks/format-code-task-000213/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c7696eba171dcc973c259967822610a8445998aabd3f3f35a29fc743b3619614 diff --git a/tasks/format-code-task-000213/environment/setup/files/blocklist b/tasks/format-code-task-000213/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000213/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000213/environment/setup/setup.sh b/tasks/format-code-task-000213/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000213/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000213/tests/test.patch b/tasks/format-code-task-000213/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a3ed543b6eb79e44c608cad486409689f64f8f88 --- /dev/null +++ b/tasks/format-code-task-000213/tests/test.patch @@ -0,0 +1,271 @@ +diff --git a/tests/client/test_client.py b/tests/client/test_client.py +index fdacb380b3..d2cea42243 100644 +--- a/tests/client/test_client.py ++++ b/tests/client/test_client.py +@@ -305,6 +305,10 @@ def test_get_flow_run_info(monkeypatch): + "flow_run_by_pk": { + "version": 0, + "parameters": {}, ++ "context": { ++ "client_context": "visible", ++ "other_value": 17 ++ }, + "scheduled_start_time": "2019-01-25T19:15:58.632412+00:00", + "serialized_state": { + "type": "Pending", +@@ -342,6 +346,7 @@ def test_get_flow_run_info(monkeypatch): + client = Client() + result = client.get_flow_run_info(flow_run_id="74-salt") + assert isinstance(result, FlowRunInfoResult) ++ assert result.context == {"client_context": "visible", "other_value": 17} + assert isinstance(result.scheduled_start_time, datetime.datetime) + assert result.scheduled_start_time.minute == 15 + assert result.scheduled_start_time.year == 2019 +@@ -352,6 +357,45 @@ def test_get_flow_run_info(monkeypatch): + assert result.parameters == dict() + + ++def test_flow_run_info_returns_dynamic_context_field(monkeypatch): ++ context_payload = {"dynamic_context": "from-cloud", "window": {"days": 3}} ++ ++ def post_response(url, headers=None, json=None): ++ flow_run = { ++ "version": 11, ++ "parameters": {}, ++ "scheduled_start_time": "2019-01-25T19:15:58.632412+00:00", ++ "serialized_state": { ++ "type": "Pending", ++ "_result": { ++ "type": "SafeResult", ++ "value": "42", ++ "result_handler": {"type": "JSONResultHandler"}, ++ }, ++ "message": None, ++ "__version__": "0.3.3+309.gf1db024", ++ "cached_inputs": None, ++ }, ++ "task_runs": [], ++ } ++ if "context" in json["query"]: ++ flow_run["context"] = context_payload ++ return MagicMock( ++ json=MagicMock(return_value={"data": {"flow_run_by_pk": flow_run}}) ++ ) ++ ++ post = MagicMock(side_effect=post_response) ++ monkeypatch.setattr("requests.post", post) ++ with set_temporary_config( ++ {"cloud.graphql": "http://my-cloud.foo", "cloud.auth_token": "secret_token"} ++ ): ++ client = Client() ++ ++ result = client.get_flow_run_info(flow_run_id="74-salt") ++ ++ assert result.context == context_payload ++ ++ + def test_get_flow_run_info_raises_informative_error(monkeypatch): + response = """ + { +diff --git a/tests/engine/cloud/test_cloud_flow_runner.py b/tests/engine/cloud/test_cloud_flow_runner.py +index 1978eed62c..caec430ade 100644 +--- a/tests/engine/cloud/test_cloud_flow_runner.py ++++ b/tests/engine/cloud/test_cloud_flow_runner.py +@@ -3,6 +3,7 @@ import time + from datetime import timedelta + from unittest.mock import MagicMock + ++import pendulum + import pytest + + import prefect +@@ -201,6 +202,134 @@ def test_flow_runner_prioritizes_kwarg_states_over_db_states(monkeypatch, state) + assert states == [Running(), Success(result={})] + + ++def test_flow_runner_loads_context_from_cloud(monkeypatch): ++ flow = prefect.Flow(name="test") ++ scheduled_start_time = pendulum.parse("2019-01-25T19:15:58.632412+00:00") ++ get_flow_run_info = MagicMock( ++ return_value=MagicMock( ++ parameters={}, ++ context={ ++ "my_var": "cloud-value", ++ "secondary_context": {"nested": True}, ++ }, ++ version=3, ++ scheduled_start_time=scheduled_start_time, ++ state=Pending(), ++ ) ++ ) ++ set_flow_run_state = MagicMock() ++ client = MagicMock( ++ get_flow_run_info=get_flow_run_info, set_flow_run_state=set_flow_run_state ++ ) ++ monkeypatch.setattr( ++ "prefect.engine.cloud.flow_runner.Client", MagicMock(return_value=client) ++ ) ++ ++ res = CloudFlowRunner(flow=flow).initialize_run( ++ state=Pending(), task_states={}, context={}, task_contexts={}, parameters={} ++ ) ++ ++ assert res.context["my_var"] == "cloud-value" ++ assert res.context["secondary_context"] == {"nested": True} ++ ++ ++def test_flow_runner_prefers_runtime_metadata_over_cloud_context(monkeypatch): ++ flow = prefect.Flow(name="test") ++ runtime_scheduled_start_time = pendulum.parse("2019-01-25T19:15:58.632412+00:00") ++ get_flow_run_info = MagicMock( ++ return_value=MagicMock( ++ parameters={}, ++ context={ ++ "custom_marker": "kept", ++ "scheduled_start_time": "not the runtime scheduled time", ++ "flow_run_version": "not the runtime version", ++ }, ++ version=42, ++ scheduled_start_time=runtime_scheduled_start_time, ++ state=Pending(), ++ ) ++ ) ++ set_flow_run_state = MagicMock() ++ client = MagicMock( ++ get_flow_run_info=get_flow_run_info, set_flow_run_state=set_flow_run_state ++ ) ++ monkeypatch.setattr( ++ "prefect.engine.cloud.flow_runner.Client", MagicMock(return_value=client) ++ ) ++ ++ res = CloudFlowRunner(flow=flow).initialize_run( ++ state=Pending(), task_states={}, context={}, task_contexts={}, parameters={} ++ ) ++ ++ assert res.context["custom_marker"] == "kept" ++ assert res.context["scheduled_start_time"] == runtime_scheduled_start_time ++ assert res.context["flow_run_version"] == 42 ++ ++ ++def test_cloud_run_context_accepts_unexpected_keys_and_versions(monkeypatch): ++ flow = prefect.Flow(name="test") ++ scheduled_start_time = pendulum.parse("2019-01-25T19:15:58.632412+00:00") ++ context_payload = { ++ "feature_flag": True, ++ "date_window": {"start": "2019-01-01", "end": "2019-01-31"}, ++ } ++ get_flow_run_info = MagicMock( ++ return_value=MagicMock( ++ parameters={}, ++ context=context_payload, ++ version=9, ++ scheduled_start_time=scheduled_start_time, ++ state=Pending(), ++ task_runs=[], ++ ) ++ ) ++ client = MagicMock(get_flow_run_info=get_flow_run_info, set_flow_run_state=MagicMock()) ++ monkeypatch.setattr( ++ "prefect.engine.cloud.flow_runner.Client", MagicMock(return_value=client) ++ ) ++ ++ res = CloudFlowRunner(flow=flow).initialize_run( ++ state=Pending(), task_states={}, context={}, task_contexts={}, parameters={} ++ ) ++ ++ assert res.context["feature_flag"] is True ++ assert res.context["date_window"] == { ++ "start": "2019-01-01", ++ "end": "2019-01-31", ++ } ++ ++ ++def test_cloud_runtime_metadata_wins_for_arbitrary_conflicts(monkeypatch): ++ flow = prefect.Flow(name="test") ++ runtime_scheduled_start_time = pendulum.parse("2019-02-01T00:00:00+00:00") ++ get_flow_run_info = MagicMock( ++ return_value=MagicMock( ++ parameters={}, ++ context={ ++ "custom_marker": "kept", ++ "scheduled_start_time": "cloud supplied conflict", ++ "flow_run_version": -999, ++ }, ++ version=13, ++ scheduled_start_time=runtime_scheduled_start_time, ++ state=Pending(), ++ task_runs=[], ++ ) ++ ) ++ client = MagicMock(get_flow_run_info=get_flow_run_info, set_flow_run_state=MagicMock()) ++ monkeypatch.setattr( ++ "prefect.engine.cloud.flow_runner.Client", MagicMock(return_value=client) ++ ) ++ ++ res = CloudFlowRunner(flow=flow).initialize_run( ++ state=Pending(), task_states={}, context={}, task_contexts={}, parameters={} ++ ) ++ ++ assert res.context["custom_marker"] == "kept" ++ assert res.context["scheduled_start_time"] == runtime_scheduled_start_time ++ assert res.context["flow_run_version"] == 13 ++ ++ + def test_client_is_always_called_even_during_failures(client): + @prefect.task + def raise_me(x, y): +diff --git a/tests/engine/cloud/test_cloud_flows.py b/tests/engine/cloud/test_cloud_flows.py +index a0789b4fcb..0baf09c3ba 100644 +--- a/tests/engine/cloud/test_cloud_flows.py ++++ b/tests/engine/cloud/test_cloud_flows.py +@@ -102,6 +102,7 @@ class MockedCloudClient(MagicMock): + + return FlowRunInfoResult( + parameters={}, ++ context=None, + version=flow_run.version, + scheduled_start_time=pendulum.parse("2019-01-25T19:15:58.632412+00:00"), + state=flow_run.state, +diff --git 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 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++export PATH="$HOME/.pyenv/bin:$PATH" ++set +u ++eval "$(pyenv init -)" ++pyenv global 3.8.20 ++set -u ++ ++ ++pip install -e . --no-deps -q ++ ++case "${1:-}" in ++ base) ++ python -m pytest \ ++ tests/client/test_client.py::test_client_initializes_from_config \ ++ tests/client/test_client.py::test_get_flow_run_info_raises_informative_error \ ++ tests/engine/cloud/test_cloud_flow_runner.py::test_task_runner_cls_is_cloud_task_runner \ ++ tests/engine/cloud/test_cloud_flows.py::test_scheduled_start_time_is_in_context \ ++ -v ++ ;; ++ new) ++ python -m pytest \ ++ tests/client/test_client.py::test_get_flow_run_info \ ++ tests/client/test_client.py::test_flow_run_info_returns_dynamic_context_field \ ++ tests/engine/cloud/test_cloud_flow_runner.py::test_flow_runner_loads_context_from_cloud \ ++ tests/engine/cloud/test_cloud_flow_runner.py::test_flow_runner_prefers_runtime_metadata_over_cloud_context \ ++ tests/engine/cloud/test_cloud_flow_runner.py::test_cloud_run_context_accepts_unexpected_keys_and_versions \ ++ tests/engine/cloud/test_cloud_flow_runner.py::test_cloud_runtime_metadata_wins_for_arbitrary_conflicts \ ++ -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-000213/tests/test.sh b/tasks/format-code-task-000213/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a1150ecd0538395481e13796c88e59f6df334e73 --- /dev/null +++ b/tasks/format-code-task-000213/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/client/test_client.py +tests/engine/cloud/test_cloud_flow_runner.py +tests/engine/cloud/test_cloud_flows.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-000213/tests/test_command.sh b/tasks/format-code-task-000213/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-000213/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-000214/environment/Dockerfile b/tasks/format-code-task-000214/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cfcdf14d77919c5441ba73c6066ba70f54a3df78 --- /dev/null +++ b/tasks/format-code-task-000214/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:346d40271045ce3b510b28a120f54b39cb70921467c512ec526f8426714bd46a diff --git a/tasks/format-code-task-000214/environment/setup/files/blocklist b/tasks/format-code-task-000214/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000214/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000214/environment/setup/setup.sh b/tasks/format-code-task-000214/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000214/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000214/tests/test.patch b/tasks/format-code-task-000214/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e0a4504d19833711076ce510058f4679f23f43d3 --- /dev/null +++ b/tasks/format-code-task-000214/tests/test.patch @@ -0,0 +1,229 @@ +diff --git a/tests/Unit/Core/Context/EmployeeContextMultiShopAuthorizationTest.php b/tests/Unit/Core/Context/EmployeeContextMultiShopAuthorizationTest.php +new file mode 100644 +index 00000000000..dddbf2a1cf9 +--- /dev/null ++++ b/tests/Unit/Core/Context/EmployeeContextMultiShopAuthorizationTest.php +@@ -0,0 +1,199 @@ ++ ++ * @copyright Since 2007 PrestaShop SA and Contributors ++ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) ++ */ ++ ++declare(strict_types=1); ++ ++namespace Tests\Unit\Core\Context; ++ ++use PHPUnit\Framework\TestCase; ++use PrestaShop\PrestaShop\Core\Context\Employee; ++use PrestaShop\PrestaShop\Core\Context\EmployeeContext; ++use PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject\ShopConstraint; ++ ++class EmployeeContextMultiShopAuthorizationTest extends TestCase ++{ ++ /** ++ * @dataProvider provideAllShopsCases ++ */ ++ public function testHasAuthorizationForAllShops( ++ bool $hasEmployee, ++ bool $isSuperAdmin, ++ array $associatedShopIds, ++ array $allShopIds, ++ bool $expectedAuthorization ++ ): void { ++ $employee = $hasEmployee ? $this->mockEmployee($isSuperAdmin, $associatedShopIds) : null; ++ $employeeContext = new EmployeeContext($employee, $allShopIds); ++ ++ $this->assertSame($expectedAuthorization, $employeeContext->hasAuthorizationForAllShops()); ++ } ++ ++ public function provideAllShopsCases(): iterable ++ { ++ yield 'no employee is never authorized' => [ ++ false, ++ false, ++ [], ++ [1, 2, 3], ++ false, ++ ]; ++ ++ yield 'super admin is authorized for all shops' => [ ++ true, ++ true, ++ [], ++ [1, 2, 3], ++ true, ++ ]; ++ ++ yield 'employee associated with every existing shop is authorized' => [ ++ true, ++ false, ++ [1, 2, 3], ++ [1, 2, 3], ++ true, ++ ]; ++ ++ yield 'employee missing one existing shop is not authorized' => [ ++ true, ++ false, ++ [1, 2], ++ [1, 2, 3], ++ false, ++ ]; ++ ++ yield 'employee associated with a superset of existing shops is authorized' => [ ++ true, ++ false, ++ [1, 2, 3, 4], ++ [1, 2, 3], ++ true, ++ ]; ++ ++ yield 'logged in employee is trivially authorized when no shop exists' => [ ++ true, ++ false, ++ [], ++ [], ++ true, ++ ]; ++ } ++ ++ public function testHasAuthorizationForAllShopsWithEmployeeOnlyConstruction(): void ++ { ++ ++ ++ $employeeContext = new EmployeeContext($this->mockEmployee(false, [])); ++ ++ $this->assertTrue($employeeContext->hasAuthorizationForAllShops()); ++ } ++ ++ public function testHasAuthorizationForAllShopsWithoutEmployeeAndEmployeeOnlyConstruction(): void ++ { ++ $employeeContext = new EmployeeContext(null); ++ ++ $this->assertFalse($employeeContext->hasAuthorizationForAllShops()); ++ } ++ ++ public function testShopConstraintTargetingAuthorizedShop(): void ++ { ++ $employeeContext = new EmployeeContext($this->mockEmployee(false, [5, 7]), [5, 7, 9]); ++ ++ $this->assertTrue($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::shop(5))); ++ } ++ ++ public function testShopConstraintTargetingUnauthorizedShop(): void ++ { ++ $employeeContext = new EmployeeContext($this->mockEmployee(false, [5, 7]), [5, 7, 9]); ++ ++ $this->assertFalse($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::shop(9))); ++ } ++ ++ public function testShopConstraintTargetingAuthorizedShopGroup(): void ++ { ++ $employeeContext = new EmployeeContext($this->mockEmployee(false, [], [2, 4]), [1, 2, 3]); ++ ++ $this->assertTrue($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::shopGroup(2))); ++ } ++ ++ public function testShopConstraintTargetingUnauthorizedShopGroup(): void ++ { ++ $employeeContext = new EmployeeContext($this->mockEmployee(false, [], [2, 4]), [1, 2, 3]); ++ ++ $this->assertFalse($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::shopGroup(3))); ++ } ++ ++ public function testShopConstraintTargetingAllShopsWhenAuthorized(): void ++ { ++ $employeeContext = new EmployeeContext($this->mockEmployee(false, [1, 2, 3]), [1, 2, 3]); ++ ++ $this->assertTrue($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::allShops())); ++ } ++ ++ public function testShopConstraintTargetingAllShopsWhenNotAuthorized(): void ++ { ++ $employeeContext = new EmployeeContext($this->mockEmployee(false, [1, 2]), [1, 2, 3]); ++ ++ $this->assertFalse($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::allShops())); ++ } ++ ++ public function testShopConstraintIsAuthorizedForSuperAdmin(): void ++ { ++ $employeeContext = new EmployeeContext($this->mockEmployee(true, []), [1, 2, 3]); ++ ++ $this->assertTrue($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::shop(9))); ++ $this->assertTrue($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::shopGroup(9))); ++ $this->assertTrue($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::allShops())); ++ } ++ ++ public function testShopConstraintIsNeverAuthorizedWithoutEmployee(): void ++ { ++ $employeeContext = new EmployeeContext(null, [1, 2, 3]); ++ ++ $this->assertFalse($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::shop(1))); ++ $this->assertFalse($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::shopGroup(1))); ++ $this->assertFalse($employeeContext->hasAuthorizationOnShopConstraint(ShopConstraint::allShops())); ++ } ++ ++ private function mockEmployee(bool $isSuperAdmin, array $associatedShopIds, array $associatedShopGroupIds = []): Employee ++ { ++ $employee = $this->createMock(Employee::class); ++ $employee ++ ->method('getProfileId') ++ ->willReturn($isSuperAdmin ? EmployeeContext::SUPER_ADMIN_PROFILE_ID : 42) ++ ; ++ $employee ++ ->method('getAssociatedShopIds') ++ ->willReturn($associatedShopIds) ++ ; ++ $employee ++ ->method('getAssociatedShopGroupIds') ++ ->willReturn($associatedShopGroupIds) ++ ; ++ ++ return $employee; ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++vendor/bin/phpunit -c tests/Unit/phpunit.xml \ ++ tests/Unit/Core/Context/EmployeeContextTest.php \ ++ tests/Unit/Core/Context/EmployeeContextBuilderTest.php ++ ++ ++vendor/bin/phpunit -c tests/Unit/phpunit.xml \ ++ tests/Unit/Core/Context/EmployeeContextMultiShopAuthorizationTest.php diff --git a/tasks/format-code-task-000214/tests/test.sh b/tasks/format-code-task-000214/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bc606dabf81004b2aa4969e07d185e5e8af1006c --- /dev/null +++ b/tasks/format-code-task-000214/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/Core/Context/EmployeeContextMultiShopAuthorizationTest.php +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000214/tests/test_command.sh b/tasks/format-code-task-000214/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000214/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000222/environment/Dockerfile b/tasks/format-code-task-000222/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1fe853141d5d67a6008aa62a5b1a27457e3998d8 --- /dev/null +++ b/tasks/format-code-task-000222/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1c5c12de4f8d1ff9692da1e1d71f4f3f0e8c6cc1c485627767a1a36b3ad914ac diff --git a/tasks/format-code-task-000222/environment/setup/files/blocklist b/tasks/format-code-task-000222/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000222/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000222/environment/setup/setup.sh b/tasks/format-code-task-000222/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000222/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000222/tests/test.patch b/tasks/format-code-task-000222/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a7a801547404a9a5fe60eddfb49eede22f9a2a03 --- /dev/null +++ b/tasks/format-code-task-000222/tests/test.patch @@ -0,0 +1,162 @@ +diff --git a/tests/test_b028_stacklevel_contract.py b/tests/test_b028_stacklevel_contract.py +new file mode 100644 +index 0000000..86b3e3d +--- /dev/null ++++ b/tests/test_b028_stacklevel_contract.py +@@ -0,0 +1,144 @@ ++import ast ++import textwrap ++import unittest ++ ++from bugbear import BugBearChecker ++ ++ ++B028_MESSAGE = "B028 No explicit stacklevel argument found." ++ ++ ++def b028_diagnostics(source): ++ source = textwrap.dedent(source).lstrip("\n") ++ checker = BugBearChecker( ++ tree=ast.parse(source), ++ lines=source.splitlines(keepends=True), ++ filename="b028_contract_sample.py", ++ ) ++ return [ ++ (line, column, message) ++ for line, column, message, _ in checker.run() ++ if message.startswith("B028") ++ ] ++ ++ ++class B028StacklevelContractTests(unittest.TestCase): ++ def test_reports_standard_warn_calls_through_supported_import_forms(self): ++ source = """ ++ import warnings ++ import warnings as warning_tools ++ from warnings import warn ++ from warnings import warn as emit_warning ++ ++ warnings.warn("canonical") ++ warning_tools.warn("module alias") ++ warn("direct import") ++ emit_warning("direct alias") ++ """ ++ self.assertEqual( ++ b028_diagnostics(source), ++ [ ++ (6, 0, B028_MESSAGE), ++ (7, 0, B028_MESSAGE), ++ (8, 0, B028_MESSAGE), ++ (9, 0, B028_MESSAGE), ++ ], ++ ) ++ ++ def test_call_shape_distinguishes_explicit_and_unknown_stacklevel(self): ++ source = """ ++ import warnings ++ ++ warnings.warn("keyword", stacklevel=2) ++ warnings.warn("positional", UserWarning, 2) ++ warnings.warn("expanded", **warning_options) ++ warnings.warn("two positional", UserWarning) ++ warnings.warn(message="message only", category=UserWarning) ++ """ ++ self.assertEqual( ++ b028_diagnostics(source), ++ [ ++ (6, 0, B028_MESSAGE), ++ (7, 0, B028_MESSAGE), ++ ], ++ ) ++ ++ def test_unrelated_warn_symbols_are_not_reported(self): ++ source = """ ++ import logging ++ from another_warnings_package import warn ++ ++ logging.getLogger(__name__).warn("logger") ++ service.warn("method") ++ warn("other import") ++ ++ def warn(message): ++ return message ++ ++ warn("plain function") ++ """ ++ self.assertEqual(b028_diagnostics(source), []) ++ ++ def test_rebinding_and_reimport_change_which_calls_are_standard_warn(self): ++ source = """ ++ import warnings as warning_api ++ from warnings import warn as emit ++ ++ warning_api.warn("before module rebind") ++ emit("before function rebind") ++ ++ warning_api = custom_warning_api ++ emit = custom_emit ++ warning_api.warn("after module rebind") ++ emit("after function rebind") ++ ++ import warnings as warning_api ++ from warnings import warn as emit ++ warning_api.warn("after module reimport") ++ emit("after function reimport") ++ """ ++ self.assertEqual( ++ b028_diagnostics(source), ++ [ ++ (4, 0, B028_MESSAGE), ++ (5, 0, B028_MESSAGE), ++ (14, 0, B028_MESSAGE), ++ (15, 0, B028_MESSAGE), ++ ], ++ ) ++ ++ def test_outer_aliases_are_inherited_but_function_parameters_shadow_them(self): ++ source = """ ++ import warnings ++ from warnings import warn as emit ++ ++ def inherited_aliases(): ++ warnings.warn("module from child") ++ emit("function from child") ++ ++ def shadowed_aliases(warnings, emit): ++ warnings.warn("shadowed module") ++ emit("shadowed function") ++ ++ def locally_imported_aliases(): ++ import warnings as local_warnings ++ from warnings import warn as local_emit ++ local_warnings.warn("local module") ++ local_emit("local function") ++ ++ local_warnings.warn("local import must not leak") ++ local_emit("local direct import must not leak") ++ """ ++ self.assertEqual( ++ b028_diagnostics(source), ++ [ ++ (5, 4, B028_MESSAGE), ++ (6, 4, B028_MESSAGE), ++ (15, 4, B028_MESSAGE), ++ (16, 4, B028_MESSAGE), ++ ], ++ ) ++ ++ ++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,7 @@ ++#!/bin/bash ++set -euo pipefail ++ ++python -m unittest \ ++ tests.test_b028_stacklevel_contract \ ++ tests.test_bugbear.BugbearTestCase.test_b008_extended \ ++ tests.test_bugbear.BugbearTestCase.test_b904 diff --git a/tasks/format-code-task-000222/tests/test.sh b/tasks/format-code-task-000222/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..df16c24433972d5378ff80c29f250297f81ef203 --- /dev/null +++ b/tasks/format-code-task-000222/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_b028_stacklevel_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-000222/tests/test_command.sh b/tasks/format-code-task-000222/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000222/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000225/environment/Dockerfile b/tasks/format-code-task-000225/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..88b31f48d5dcc1322a024148c97985b42846eb63 --- /dev/null +++ b/tasks/format-code-task-000225/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3067c3851dd34101ba5531a933ee697644e4a5a6930c885c75e8ca0d4e76f073 diff --git a/tasks/format-code-task-000225/environment/setup/files/blocklist b/tasks/format-code-task-000225/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000225/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000225/environment/setup/setup.sh b/tasks/format-code-task-000225/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000225/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000225/tests/test.patch b/tasks/format-code-task-000225/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5910293d76a5bbd4e1091a8138d136175a819c0c --- /dev/null +++ b/tasks/format-code-task-000225/tests/test.patch @@ -0,0 +1,145 @@ +diff --git a/test/test_linear_expression.py b/test/test_linear_expression.py +index 06794a2..122d0c4 100644 +--- a/test/test_linear_expression.py ++++ b/test/test_linear_expression.py +@@ -399,6 +399,73 @@ def test_linear_expression_sum_drop_zeros(z): + assert res.nterm == 2 + + ++def test_linear_expression_sum_dim_keyword(x, y, z): ++ """The new `dim` keyword (xarray-aligned) should sum over given dimension.""" ++ expr = 10 * x + y + z ++ res_kwarg = expr.sum(dim="dim_0") ++ res_pos = expr.sum("dim_0") ++ assert_linequal(res_kwarg, res_pos) ++ assert res_kwarg.nterm == expr.nterm * len(expr.data.dim_0) ++ ++ ++def test_linear_expression_sum_dims_keyword_backward_compat(x, y, z): ++ """Old `dims` keyword should still work for backward compatibility.""" ++ import warnings ++ ++ expr = 10 * x + y + z ++ with warnings.catch_warnings(): ++ warnings.simplefilter("ignore", DeprecationWarning) ++ res_old = expr.sum(dims="dim_0") ++ res_new = expr.sum(dim="dim_0") ++ assert_linequal(res_old, res_new) ++ ++ ++def test_linear_expression_sum_dims_keyword_deprecation_warning(x, y, z): ++ """Using `dims` keyword should emit a DeprecationWarning.""" ++ expr = 10 * x + y + z ++ with pytest.warns(DeprecationWarning): ++ expr.sum(dims="dim_0") ++ ++ ++def test_linear_expression_sum_dim_keyword_no_warning(x, y, z): ++ """Using `dim` (the new keyword) should NOT emit a DeprecationWarning.""" ++ import warnings ++ ++ expr = 10 * x + y + z ++ with warnings.catch_warnings(): ++ warnings.simplefilter("error", DeprecationWarning) ++ ++ expr.sum(dim="dim_0") ++ ++ ++def test_linear_expression_sum_dim_xarray_linopy_mix(): ++ """Reproduce the issue's example: dim=... must work in mixed xarray/linopy expressions.""" ++ import linopy as _linopy ++ ++ dimX = xr.DataArray(["x1", "x2", "x3"], dims=["X"]) ++ dimU = xr.DataArray(["u1", "u2", "u3", "u4"], dims=["U"]) ++ A = xr.DataArray( ++ [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]], ++ coords={"X": dimX, "U": dimU}, ++ ) ++ x_tilde = xr.DataArray([10, 20, 30], dims=["X"]) ++ m = _linopy.Model() ++ x_var = m.add_variables(coords=[dimX]) ++ ++ tmp = A * x_var - A * x_tilde ++ result = tmp.sum(dim="X") ++ assert isinstance(result, LinearExpression) ++ ++ assert "X" not in result.coord_dims ++ assert "U" in result.coord_dims ++ assert len(result.data.U) == 4 ++ ++ ++ ++ ++ assert (result.const == -140).all().item() ++ ++ + def test_linear_expression_multiplication(x, y, z): + expr = 10 * x + y + z + mexpr = expr * 10 +diff --git a/test/test_variable.py b/test/test_variable.py +index 6c498f0..521dbe4 100644 +--- a/test/test_variable.py ++++ b/test/test_variable.py +@@ -143,6 +143,40 @@ def test_variable_sum(x): + assert res.nterm == 10 + + ++def test_variable_sum_dim_keyword(x): ++ """The new `dim` keyword (xarray-aligned) should sum over given dimension.""" ++ res_kwarg = x.sum(dim="first") ++ res_pos = x.sum("first") ++ ++ assert res_kwarg.nterm == res_pos.nterm ++ assert res_kwarg.nterm == 10 ++ ++ ++def test_variable_sum_dims_keyword_backward_compat(x): ++ """Old `dims` keyword should still work for backward compatibility.""" ++ import warnings ++ ++ with warnings.catch_warnings(): ++ warnings.simplefilter("ignore", DeprecationWarning) ++ res = x.sum(dims="first") ++ assert res.nterm == 10 ++ ++ ++def test_variable_sum_dims_keyword_deprecation_warning(x): ++ """Using `dims` keyword on Variable.sum should emit a DeprecationWarning.""" ++ with pytest.warns(DeprecationWarning): ++ x.sum(dims="first") ++ ++ ++def test_variable_sum_dim_keyword_no_warning(x): ++ """Using `dim` keyword on Variable.sum should NOT emit a DeprecationWarning.""" ++ import warnings ++ ++ with warnings.catch_warnings(): ++ warnings.simplefilter("error", DeprecationWarning) ++ x.sum(dim="first") ++ ++ + def test_variable_where(x): + x = x.where([True] * 4 + [False] * 6) + assert isinstance(x, linopy.variables.Variable) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..adbfb4f +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest test/test_linear_expression.py test/test_variable.py -k sum"] ++} +diff --git 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/test_linear_expression.py::test_linear_expression_sum_dim_keyword test/test_linear_expression.py::test_linear_expression_sum_dims_keyword_backward_compat test/test_linear_expression.py::test_linear_expression_sum_dims_keyword_deprecation_warning test/test_linear_expression.py::test_linear_expression_sum_dim_keyword_no_warning test/test_linear_expression.py::test_linear_expression_sum_dim_xarray_linopy_mix test/test_variable.py::test_variable_sum_dim_keyword test/test_variable.py::test_variable_sum_dims_keyword_backward_compat test/test_variable.py::test_variable_sum_dims_keyword_deprecation_warning test/test_variable.py::test_variable_sum_dim_keyword_no_warning ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000225/tests/test.sh b/tasks/format-code-task-000225/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9a0c6ef3454be9d0fb2ddb5f4abb2e98b69fee6b --- /dev/null +++ b/tasks/format-code-task-000225/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_linear_expression.py +test/test_variable.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-000225/tests/test_command.sh b/tasks/format-code-task-000225/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000225/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000240/environment/Dockerfile b/tasks/format-code-task-000240/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7c665df271e9db36e2d9be3d5c414824f2906137 --- /dev/null +++ b/tasks/format-code-task-000240/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8165cb98c8ca4f4eec0e42f651bba876ab107bc77a39d785c054386cfde4a00d diff --git a/tasks/format-code-task-000240/environment/setup/files/blocklist b/tasks/format-code-task-000240/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000240/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000240/environment/setup/setup.sh b/tasks/format-code-task-000240/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000240/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000240/tests/test.patch b/tasks/format-code-task-000240/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..86a4ddaf712b8a0f194ca335200534adcf9a42ea --- /dev/null +++ b/tasks/format-code-task-000240/tests/test.patch @@ -0,0 +1,100 @@ +diff --git a/test/lib.tcp.js b/test/lib.tcp.js +index 47b2c1f..e989f8f 100644 +--- a/test/lib.tcp.js ++++ b/test/lib.tcp.js +@@ -48,5 +48,71 @@ describe('Lib', function () { + tcp.connect({}, done).should.equal(socket); + }); + ++ it('should create a secure connection when useTLS is true', function (done) { ++ var secureCalled = false; ++ var plainCalled = false; ++ tcp.createSecureSocket = function tlsConnect(options, cb) { ++ tcp.createSecureSocket = createSecureSocket; ++ secureCalled = true; ++ options.allowHalfOpen.should.equal(false); ++ process.nextTick(cb); ++ return socket; ++ }; ++ var origPlain = tcp.createSocket; ++ tcp.createSocket = function netConnect(options, cb) { ++ plainCalled = true; ++ process.nextTick(cb); ++ return socket; ++ }; ++ var result = tcp.connect({ useTLS: true }, function () { ++ tcp.createSocket = origPlain; ++ secureCalled.should.equal(true); ++ plainCalled.should.equal(false); ++ done(); ++ }); ++ result.should.equal(socket); ++ }); ++ ++ it('should create a plain connection when useTLS is false', function (done) { ++ var secureCalled = false; ++ var plainCalled = false; ++ var origSecure = tcp.createSecureSocket; ++ tcp.createSecureSocket = function tlsConnect(options, cb) { ++ secureCalled = true; ++ process.nextTick(cb); ++ return socket; ++ }; ++ tcp.createSocket = function netConnect(options, cb) { ++ tcp.createSocket = createSocket; ++ plainCalled = true; ++ options.allowHalfOpen.should.equal(false); ++ process.nextTick(cb); ++ return socket; ++ }; ++ var result = tcp.connect({ useTLS: false }, function () { ++ tcp.createSecureSocket = origSecure; ++ secureCalled.should.equal(false); ++ plainCalled.should.equal(true); ++ done(); ++ }); ++ result.should.equal(socket); ++ }); ++ ++ it('should still create a secure connection for cert option (preservation)', function (done) { ++ var secureCalled = false; ++ tcp.createSecureSocket = function tlsConnect(options, cb) { ++ tcp.createSecureSocket = createSecureSocket; ++ secureCalled = true; ++ options.allowHalfOpen.should.equal(false); ++ process.nextTick(cb); ++ return socket; ++ }; ++ var result = tcp.connect({ cert: true }, function () { ++ secureCalled.should.equal(true); ++ done(); ++ }); ++ result.should.equal(socket); ++ }); ++ + }); +-}); +\ No newline at end of file ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..fe7910b +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/mocha -R spec test/lib.tcp.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_modules/.bin/mocha -R spec test/lib.tcp.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000240/tests/test.sh b/tasks/format-code-task-000240/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b9f403c64483c0955511a72dc9d68527944e18c4 --- /dev/null +++ b/tasks/format-code-task-000240/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/lib.tcp.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-000240/tests/test_command.sh b/tasks/format-code-task-000240/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000240/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000241/environment/Dockerfile b/tasks/format-code-task-000241/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ba631e520a8d1c72f25bcd5204f21dcbfdf0942d --- /dev/null +++ b/tasks/format-code-task-000241/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e25a6e6879b755cfc4d32b444f12f690d66c57699754021e08e3d67e2c527765 diff --git a/tasks/format-code-task-000241/environment/setup/files/blocklist b/tasks/format-code-task-000241/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000241/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000241/environment/setup/setup.sh b/tasks/format-code-task-000241/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000241/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000241/tests/test.patch b/tasks/format-code-task-000241/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8fcd7ddb62bc05013d83ec9ad59539aa0089f471 --- /dev/null +++ b/tasks/format-code-task-000241/tests/test.patch @@ -0,0 +1,59 @@ +diff --git a/smt/surrogate_models/tests/test_krg_predictions.py b/smt/surrogate_models/tests/test_krg_predictions.py +index 1f5f5032e..d089e0de4 100644 +--- a/smt/surrogate_models/tests/test_krg_predictions.py ++++ b/smt/surrogate_models/tests/test_krg_predictions.py +@@ -25,8 +25,8 @@ def pb(x): + return y + + xlimits = np.array([[-5, 10], [-5, 10]]) +- sampling = LHS(xlimits=xlimits, random_state=42) +- self.xt = sampling(12) ++ self.sampling = LHS(xlimits=xlimits, random_state=42) ++ self.xt = self.sampling(12) + self.yt = pb(self.xt) + + def test_predictions(self): +@@ -79,6 +79,22 @@ def test_predictions(self): + else: + Test._check_prediction_derivatives(self, sm) + ++ def test_variance_derivatives_vs_gradient(self): ++ ++ ++ sm = KRG(theta0=[0.01], print_global=False) ++ sm.set_training_values(self.xt, self.yt) ++ sm.train() ++ x = np.array([[1, 2]]) ++ deriv0 = sm.predict_variance_derivatives(x, 0) ++ deriv1 = sm.predict_variance_derivatives(x, 1) ++ derivs = np.hstack((deriv0, deriv1)) ++ gradient = sm.predict_variance_gradient(x[0]) ++ self.assertEqual((1, 2), gradient.shape) ++ gradient = sm.predict_variance_gradient(x) ++ self.assertEqual((1, 2), gradient.shape) ++ np.testing.assert_allclose(gradient, derivs) ++ + @staticmethod + def _check_prediction_variances(self, sm): + y_predicted = sm.predict_variances(self.xt) +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+3SXY7CIBQFYJ5dxd2AtDSlXQ5pC9FmBBqgTdz9YCdGY+L4opmMnu8BbvgJkAPv ++5/GglXFLwV6lzFop1z677ddayEqItq1bWbNSiEY0jOTLbnRljqkLRCx4n35b92j+n+KX/JOJSQ3e ++2s5pHvfPO+NR/qJuLvmfxvNAVTEqn3eF+z48/0HTGnxv9OZcFHw5/Yd+dMV0THvvaGspV3mWok1F ++nEPwuy4ZZb02h7ju+2nVV9ipKRg9Dmn0LvLpSNtl89evBAAAAAAAAAAAAAAAAAAAAAB4T99eD6+s ++ACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-000241/tests/test.sh b/tasks/format-code-task-000241/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..023a20cf455ef55f9452f837420d853e7c3bfdc6 --- /dev/null +++ b/tasks/format-code-task-000241/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' +smt/surrogate_models/tests/test_krg_predictions.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-000241/tests/test_command.sh b/tasks/format-code-task-000241/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000241/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000246/environment/Dockerfile b/tasks/format-code-task-000246/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a7035e0ec542e02de26211d09f6ab1b22afc7284 --- /dev/null +++ b/tasks/format-code-task-000246/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d77cdf222d398c0cce7727295d950fed781c8bb13ac9da6b79ce7243a2eff991 diff --git a/tasks/format-code-task-000246/environment/setup/files/blocklist b/tasks/format-code-task-000246/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000246/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000246/environment/setup/setup.sh b/tasks/format-code-task-000246/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000246/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000246/tests/test.patch b/tasks/format-code-task-000246/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9d640617b81c37a33614deda2108f5031fd25e1e --- /dev/null +++ b/tasks/format-code-task-000246/tests/test.patch @@ -0,0 +1,64 @@ +diff --git a/test/requests/code_actions_test.rb b/test/requests/code_actions_test.rb +new file mode 100644 +index 0000000000..d874fe4e29 +--- /dev/null ++++ b/test/requests/code_actions_test.rb +@@ -0,0 +1,37 @@ ++ ++# frozen_string_literal: true ++ ++require "test_helper" ++require "ruby_lsp/requests/support/rubocop_diagnostics_runner" ++ ++class CodeActionsTest < Minitest::Test ++ def test_diagnostic_calls_are_cached ++ document = RubyLsp::Document.new(<<~RUBY) ++ class Foo ++ def bar ++ a = 123 ++ b = a + 321 ++ a ** b ++ end ++ end ++ RUBY ++ ++ uri = "file://#{__FILE__}" ++ @counter = 0 ++ increment_counter = ->(_uri, _document) { ++ @counter += 1 ++ [] ++ } ++ ++ ++ ++ RubyLsp::Requests::Support::RuboCopDiagnosticsRunner.instance.stub(:run, increment_counter) do ++ RubyLsp::Requests::CodeActions.new(uri, document, 1..3).run ++ RubyLsp::Requests::CodeActions.new(uri, document, 2..3).run ++ RubyLsp::Requests::CodeActions.new(uri, document, 2..4).run ++ RubyLsp::Requests::CodeActions.new(uri, document, 3..5).run ++ end ++ ++ assert_equal(1, @counter) ++ end ++end +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SQWuDMBQHcM9+iod42A5VYw1CYYceBt1hbIfdxZhABZusSSzdt1/0sjLYemkZ ++Zf/fIU/yxBfyNxNjP8hG6UMeXUsR1JzPNfhe52fGS1ayii152GeM18uI+NVOdGJ0vrVEkTXG//be ++uf6Nyr7y98r5pjO7Xatl5raXm3Eu/5Kd5F+wkH/F6yqi4nJH+Nk/z7+TNAcvlIzV8d1YT6/rt81D ++km5enh/zzIrp1xC9XqXTfhKrQztQkt7NDep172lBonXb+yQWo5aDInVUHdlRfNDiafo2TUtu1X4M ++1eWdkappO98b7ZqpFYbEf30PAAAAAAAAAAAAAAAAAAAAAAC36BPLrqOmACgAAA== +diff --git 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-000246/tests/test.sh b/tasks/format-code-task-000246/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8ae806564a88f99b081c6e433cce00e73f1793b5 --- /dev/null +++ b/tasks/format-code-task-000246/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/requests/code_actions_test.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-000246/tests/test_command.sh b/tasks/format-code-task-000246/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000246/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000247/environment/Dockerfile b/tasks/format-code-task-000247/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6ebd8aa5e746da7ab6018ff5959c930a997e7446 --- /dev/null +++ b/tasks/format-code-task-000247/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f1ebfd63bea42bb71a2475aa2686d38ca9f84b89041d7390fe52252a505db585 diff --git a/tasks/format-code-task-000247/environment/setup/files/blocklist b/tasks/format-code-task-000247/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000247/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000247/environment/setup/setup.sh b/tasks/format-code-task-000247/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000247/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000247/tests/test.patch b/tasks/format-code-task-000247/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2e7d504e8d121c9f82a4bc3a46f85b571eedb9ca --- /dev/null +++ b/tasks/format-code-task-000247/tests/test.patch @@ -0,0 +1,298 @@ +diff --git a/toxic_api_test.go b/toxic_api_test.go +new file mode 100644 +index 0000000..70dc22b +--- /dev/null ++++ b/toxic_api_test.go +@@ -0,0 +1,258 @@ ++package main ++ ++import ( ++ "bytes" ++ "encoding/json" ++ "io" ++ "net" ++ "net/http" ++ "strings" ++ "testing" ++ "time" ++) ++ ++ ++ ++func createNamedProxy(t *testing.T, addr, name, listen, upstream string) *http.Response { ++ body := `{"Name":"` + name + `","Listen":"` + listen + `","Upstream":"` + upstream + `"}` ++ resp, err := http.Post(addr+"/proxies", "application/json", strings.NewReader(body)) ++ if err != nil { ++ t.Fatal("Failed to create proxy", err) ++ } ++ return resp ++} ++ ++ ++func getToxics(t *testing.T, addr, proxy, direction string) map[string]interface{} { ++ resp, err := http.Get(addr + "/proxies/" + proxy + "/" + direction + "/toxics") ++ if err != nil { ++ t.Fatal("Failed to get toxics", err) ++ } ++ defer resp.Body.Close() ++ if resp.StatusCode != http.StatusOK { ++ t.Fatalf("Expected 200 listing toxics, got %d", resp.StatusCode) ++ } ++ out := make(map[string]interface{}) ++ if err := json.NewDecoder(resp.Body).Decode(&out); err != nil { ++ t.Fatal("Failed to decode toxic list", err) ++ } ++ return out ++} ++ ++ ++ ++func setToxic(t *testing.T, addr, proxy, direction, name, body string) (*http.Response, map[string]interface{}) { ++ resp, err := http.Post(addr+"/proxies/"+proxy+"/"+direction+"/toxics/"+name, "application/json", strings.NewReader(body)) ++ if err != nil { ++ t.Fatal("Failed to set toxic", err) ++ } ++ defer resp.Body.Close() ++ out := make(map[string]interface{}) ++ json.NewDecoder(resp.Body).Decode(&out) ++ return resp, out ++} ++ ++func asObject(t *testing.T, v interface{}) map[string]interface{} { ++ m, ok := v.(map[string]interface{}) ++ if !ok { ++ t.Fatalf("Expected toxic to be a JSON object, got %T", v) ++ } ++ return m ++} ++ ++func TestNewProxyListsDisabledLatencyToxicBothDirections(t *testing.T) { ++ WithServer(t, func(addr string) { ++ if resp := createNamedProxy(t, addr, "mysql_master", "localhost:3310", "localhost:20001"); resp.StatusCode != http.StatusCreated { ++ t.Fatal("Unable to create proxy") ++ } ++ ++ for _, dir := range []string{"upstream", "downstream"} { ++ toxics := getToxics(t, addr, "mysql_master", dir) ++ raw, ok := toxics["latency"] ++ if !ok { ++ t.Fatalf("Expected a latency toxic in %s list", dir) ++ } ++ latency := asObject(t, raw) ++ if latency["enabled"] != false { ++ t.Fatalf("Expected %s latency toxic to start disabled", dir) ++ } ++ if latency["latency"] != 0.0 || latency["jitter"] != 0.0 { ++ t.Fatalf("Expected %s latency toxic to default latency/jitter to 0, got %v", dir, latency) ++ } ++ } ++ }) ++} ++ ++func TestSetToxicPersistsAndEchoesState(t *testing.T) { ++ WithServer(t, func(addr string) { ++ if resp := createNamedProxy(t, addr, "mysql_master", "localhost:3310", "localhost:20001"); resp.StatusCode != http.StatusCreated { ++ t.Fatal("Unable to create proxy") ++ } ++ ++ resp, out := setToxic(t, addr, "mysql_master", "downstream", "latency", `{"enabled":true,"latency":100,"jitter":10}`) ++ if resp.StatusCode != http.StatusOK { ++ t.Fatalf("Expected 200 setting toxic, got %d", resp.StatusCode) ++ } ++ if out["enabled"] != true || out["latency"] != 100.0 || out["jitter"] != 10.0 { ++ t.Fatalf("POST response did not reflect the new state: %v", out) ++ } ++ ++ toxics := getToxics(t, addr, "mysql_master", "downstream") ++ latency := asObject(t, toxics["latency"]) ++ if latency["enabled"] != true || latency["latency"] != 100.0 || latency["jitter"] != 10.0 { ++ t.Fatalf("GET did not reflect the persisted state: %v", latency) ++ } ++ }) ++} ++ ++func TestSetToxicIsPerDirection(t *testing.T) { ++ WithServer(t, func(addr string) { ++ if resp := createNamedProxy(t, addr, "mysql_master", "localhost:3310", "localhost:20001"); resp.StatusCode != http.StatusCreated { ++ t.Fatal("Unable to create proxy") ++ } ++ ++ setToxic(t, addr, "mysql_master", "downstream", "latency", `{"enabled":true,"latency":100,"jitter":10}`) ++ ++ up := asObject(t, getToxics(t, addr, "mysql_master", "upstream")["latency"]) ++ if up["enabled"] != false { ++ t.Fatal("Setting downstream toxic must not enable the upstream toxic") ++ } ++ }) ++} ++ ++func TestSetToxicResetsOmittedFields(t *testing.T) { ++ WithServer(t, func(addr string) { ++ if resp := createNamedProxy(t, addr, "mysql_master", "localhost:3310", "localhost:20001"); resp.StatusCode != http.StatusCreated { ++ t.Fatal("Unable to create proxy") ++ } ++ ++ setToxic(t, addr, "mysql_master", "downstream", "latency", `{"enabled":true,"latency":600,"jitter":40}`) ++ ++ ++ _, out := setToxic(t, addr, "mysql_master", "downstream", "latency", `{"enabled":false}`) ++ if out["enabled"] != false || out["latency"] != 0.0 || out["jitter"] != 0.0 { ++ t.Fatalf("Omitted fields should reset to zero, got %v", out) ++ } ++ ++ latency := asObject(t, getToxics(t, addr, "mysql_master", "downstream")["latency"]) ++ if latency["enabled"] != false || latency["latency"] != 0.0 || latency["jitter"] != 0.0 { ++ t.Fatalf("Reset state did not persist, got %v", latency) ++ } ++ }) ++} ++ ++func TestToxicsForUnknownProxyReturn404(t *testing.T) { ++ WithServer(t, func(addr string) { ++ resp, err := http.Get(addr + "/proxies/does_not_exist/upstream/toxics") ++ if err != nil { ++ t.Fatal(err) ++ } ++ resp.Body.Close() ++ if resp.StatusCode != http.StatusNotFound { ++ t.Fatalf("Expected 404 for unknown proxy, got %d", resp.StatusCode) ++ } ++ ++ resp2, _ := setToxic(t, addr, "does_not_exist", "upstream", "latency", `{"enabled":true}`) ++ if resp2.StatusCode != http.StatusNotFound { ++ t.Fatalf("Expected 404 for unknown proxy on POST, got %d", resp2.StatusCode) ++ } ++ }) ++} ++ ++func TestSetUnknownToxicReturns404(t *testing.T) { ++ WithServer(t, func(addr string) { ++ if resp := createNamedProxy(t, addr, "mysql_master", "localhost:3310", "localhost:20001"); resp.StatusCode != http.StatusCreated { ++ t.Fatal("Unable to create proxy") ++ } ++ resp, _ := setToxic(t, addr, "mysql_master", "upstream", "nonexistent_toxic", `{"enabled":true}`) ++ if resp.StatusCode != http.StatusNotFound { ++ t.Fatalf("Expected 404 for unknown toxic, got %d", resp.StatusCode) ++ } ++ }) ++} ++ ++ ++func echoServer(t *testing.T, listen string) (stop func()) { ++ ln, err := net.Listen("tcp", listen) ++ if err != nil { ++ t.Fatal("Failed to start echo server", err) ++ } ++ done := make(chan struct{}) ++ go func() { ++ for { ++ conn, err := ln.Accept() ++ if err != nil { ++ select { ++ case <-done: ++ default: ++ } ++ return ++ } ++ go io.Copy(conn, conn) ++ } ++ }() ++ return func() { ++ close(done) ++ ln.Close() ++ } ++} ++ ++ ++ ++func roundTrip(t *testing.T, proxyAddr string, msg []byte) time.Duration { ++ conn, err := net.Dial("tcp", proxyAddr) ++ if err != nil { ++ t.Fatal("Failed to dial proxy", err) ++ } ++ defer conn.Close() ++ ++ start := time.Now() ++ if _, err := conn.Write(msg); err != nil { ++ t.Fatal("Failed to write to proxy", err) ++ } ++ buf := make([]byte, len(msg)) ++ if _, err := io.ReadFull(conn, buf); err != nil { ++ t.Fatal("Failed to read echo from proxy", err) ++ } ++ elapsed := time.Since(start) ++ if !bytes.Equal(buf, msg) { ++ t.Fatalf("Echo mismatch: got %q want %q", buf, msg) ++ } ++ return elapsed ++} ++ ++func TestLatencyToxicDelaysTraffic(t *testing.T) { ++ WithServer(t, func(addr string) { ++ stop := echoServer(t, "localhost:20102") ++ defer stop() ++ ++ if resp := createNamedProxy(t, addr, "lat_on", "localhost:20101", "localhost:20102"); resp.StatusCode != http.StatusCreated { ++ t.Fatal("Unable to create proxy") ++ } ++ ++ setToxic(t, addr, "lat_on", "downstream", "latency", `{"enabled":true,"latency":600,"jitter":0}`) ++ ++ msg := []byte("hello world") ++ elapsed := roundTrip(t, "localhost:20101", msg) ++ if elapsed < 450*time.Millisecond { ++ t.Fatalf("Expected enabled latency toxic to delay traffic by ~600ms, took %v", elapsed) ++ } ++ }) ++} ++ ++func TestNoLatencyToxicDoesNotDelayTraffic(t *testing.T) { ++ WithServer(t, func(addr string) { ++ stop := echoServer(t, "localhost:20104") ++ defer stop() ++ ++ if resp := createNamedProxy(t, addr, "lat_off", "localhost:20103", "localhost:20104"); resp.StatusCode != http.StatusCreated { ++ t.Fatal("Unable to create proxy") ++ } ++ ++ msg := []byte("hello world") ++ elapsed := roundTrip(t, "localhost:20103", msg) ++ if elapsed > 300*time.Millisecond { ++ t.Fatalf("Expected no added latency, but round trip took %v", elapsed) ++ } ++ }) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,29 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++export GO111MODULE=off ++export GOPATH="/root/go:/testbed/Godeps/_workspace" ++PKG_DIR="/root/go/src/github.com/Shopify/toxiproxy" ++mkdir -p "$(dirname "$PKG_DIR")" ++ln -sfn /testbed "$PKG_DIR" ++cd "$PKG_DIR" ++ ++ ++ ++ ++ ++TEST_BIN="$(mktemp -d)/toxiproxy.test" ++go test -c -o "$TEST_BIN" ++ ++ ++ ++ ++"$TEST_BIN" diff --git a/tasks/format-code-task-000247/tests/test.sh b/tasks/format-code-task-000247/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..29b10dbfbd1ff6f0f9f517b916b9ea8d65c76bd4 --- /dev/null +++ b/tasks/format-code-task-000247/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' +toxic_api_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000247/tests/test_command.sh b/tasks/format-code-task-000247/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000247/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000278/environment/Dockerfile b/tasks/format-code-task-000278/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2361eb78338897cc288e368acbe4620c2a44898d --- /dev/null +++ b/tasks/format-code-task-000278/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3e4b4ed8ab9f7e5623d7ee3cd3dd50c54ad8661a3493a1c8e9cd7ab474148fc7 diff --git a/tasks/format-code-task-000278/environment/setup/files/blocklist b/tasks/format-code-task-000278/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000278/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000278/environment/setup/setup.sh b/tasks/format-code-task-000278/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000278/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000278/tests/test.patch b/tasks/format-code-task-000278/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1951791bde7a1be1cc7452e27a6ef27706da28c0 --- /dev/null +++ b/tasks/format-code-task-000278/tests/test.patch @@ -0,0 +1,71 @@ +diff --git a/spec/service_spec.rb b/spec/service_spec.rb +index 6cb97be..6039a07 100644 +--- a/spec/service_spec.rb ++++ b/spec/service_spec.rb +@@ -9,9 +9,10 @@ + context "services" do + let(:key) { "toast" } + let(:key_url) { "/v1/catalog/service/#{key}" } +- let(:key_url_with_alloptions) { "/v1/catalog/service/#{key}?wait=5m&index=3" } ++ let(:key_url_with_alloptions) { "/v1/catalog/service/#{key}?wait=5m&index=3&dc=somedc" } + let(:key_url_with_indexoption) { "/v1/catalog/service/#{key}?index=5" } + let(:key_url_with_waitoption) { "/v1/catalog/service/#{key}?wait=6s" } ++ let(:key_url_with_datacenteroption) { "/v1/catalog/service/#{key}?dc=somedc" } + let(:body) { + [ + { +@@ -116,14 +117,26 @@ + expect(s.Node).to eq("foo") + end + +- it "both options" do ++ it "datacenter option" do ++ json = JSON.generate(body) ++ ++ faraday.stub(:get).with(key_url_with_datacenteroption).and_return(OpenStruct.new({ body: json, headers: headers })) ++ ++ service = Diplomat::Service.new(faraday) ++ ++ options = { :dc => "somedc" } ++ s = service.get("toast", :first, options) ++ expect(s.Node).to eq("foo") ++ end ++ ++ it "all options" do + json = JSON.generate(body) + + faraday.stub(:get).with(key_url_with_alloptions).and_return(OpenStruct.new({ body: json, headers: headers })) + + service = Diplomat::Service.new(faraday) + +- options = { :wait => "5m", :index => "3" } ++ options = { :wait => "5m", :index => "3", :dc => 'somedc' } + s = service.get("toast", :first, options) + expect(s.Node).to eq("foo") + end +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,10 @@ ++H4sIAAAAAAAAA+2WXYvTQBSGe91fcWiFtmDT5quBiIL1asGrrl6ISMnHqR12MhNnJt32xt/uJFtN ++WXXrQjcingeSycyZL3jnnRMnrRjP1yh2s95TMbdEYdiUlvtl8+2GnuvNg8if+72564bRogfhk+3o ++hEqbRAH0lJTmoX7n4v8oTqt/Womco7r8OXiM/p7rWv19z4tI/y74hf4aTVU6Kr3YGrXAiyD4rf6B ++H9zTP4jcsAfzi+3gAf5z/YdwvWUFGAnpoUy0huMpgB0qzaSATIoNZ5nR/SG82yJ8xkKXmIHCLxVT ++2A74+gpcx7dVA6sqPYDveJAqTG7aLq6zh3ElTMKEsRMUcof5xM77mvNmXkgUAhNWEc4xB33QBovp ++LcvxOWgJtwj6hpU/pkNh7A74wekXMq84wvIu0AfIcQMa+cZpDrNtABiCkFNZxu1KyS5hPEntwJOV ++bF8Ueb9+/rY2XfCz/y/p/DvO+d8PW/+7UZ3//XBB/u+Erv3/R24nP3fGif8NarPOZFEkInf09nJr ++nPv/8/yozf/Bos7/C88j/3dBlkMjfIrWI/tSKuve98sPb6+WLwffA7P2kMTPjtFBX9Umn15xltp3 ++cyVMEQbHawFGqm6aZVLh6AXgnpnx6tq2xPEb2xTHq0qIOtdUYvxx1HTVqHYsw3VdsTlo9GkyGZBl ++CYIgCIIgCIIgCIIgCIIgCIIgHss379SrjAAoAAA= +diff --git 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-000278/tests/test.sh b/tasks/format-code-task-000278/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..50b1bdca405aecb90f220111134771d2b6ae020b --- /dev/null +++ b/tasks/format-code-task-000278/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' +spec/service_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-000278/tests/test_command.sh b/tasks/format-code-task-000278/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000278/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000279/environment/Dockerfile b/tasks/format-code-task-000279/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c08eb281493127a1589fd5ed028bc2fde0f5e480 --- /dev/null +++ b/tasks/format-code-task-000279/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0279ddd1464cf015aea71c8816f11cb09c30e8999f7d231f4ad17e3b83fac48d diff --git a/tasks/format-code-task-000279/environment/setup/files/blocklist b/tasks/format-code-task-000279/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000279/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000279/environment/setup/setup.sh b/tasks/format-code-task-000279/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000279/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000279/tests/test.patch b/tasks/format-code-task-000279/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..79a1da6ae4bd2094cf64853a8c8dbbc50822517a --- /dev/null +++ b/tasks/format-code-task-000279/tests/test.patch @@ -0,0 +1,209 @@ +diff --git a/weblate/trans/tests/test_source_review.py b/weblate/trans/tests/test_source_review.py +new file mode 100644 +index 0000000000..d40b21fce0 +--- /dev/null ++++ b/weblate/trans/tests/test_source_review.py +@@ -0,0 +1,118 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++from weblate.auth.models import Group ++from weblate.trans.models import Project ++from weblate.trans.tests.test_views import ViewTestCase ++from weblate.utils.state import STATE_APPROVED ++ ++ ++class SourceReviewTest(ViewTestCase): ++ def set_review(self, source_review=False, translation_review=False): ++ self.project.source_review = source_review ++ self.project.translation_review = translation_review ++ self.project.save() ++ ++ def test_defaults(self): ++ ++ project = Project.objects.create(name="Defaults", slug="defaults") ++ self.assertFalse(project.source_review) ++ self.assertFalse(project.translation_review) ++ ++ def test_translation_enable_review_disabled(self): ++ self.set_review(source_review=False, translation_review=False) ++ self.assertFalse(self.get_translation("cs").enable_review) ++ self.assertFalse(self.get_translation("en").enable_review) ++ ++ def test_translation_enable_review_translation(self): ++ self.set_review(source_review=False, translation_review=True) ++ ++ self.assertTrue(self.get_translation("cs").enable_review) ++ ++ self.assertFalse(self.get_translation("en").enable_review) ++ ++ def test_translation_enable_review_source(self): ++ self.set_review(source_review=True, translation_review=False) ++ ++ self.assertTrue(self.get_translation("en").enable_review) ++ ++ self.assertFalse(self.get_translation("cs").enable_review) ++ ++ def test_review_permission_disabled(self): ++ self.make_manager() ++ self.set_review(source_review=False, translation_review=False) ++ self.assertFalse(self.user.has_perm("unit.review", self.get_translation("cs"))) ++ self.assertFalse(self.user.has_perm("unit.review", self.component)) ++ self.assertFalse(self.user.has_perm("unit.review", self.project)) ++ ++ def test_review_permission_translation(self): ++ self.make_manager() ++ self.set_review(source_review=False, translation_review=True) ++ ++ self.assertTrue(self.user.has_perm("unit.review", self.get_translation("cs"))) ++ ++ self.assertTrue(self.user.has_perm("unit.review", self.component)) ++ self.assertTrue(self.user.has_perm("unit.review", self.project)) ++ ++ def test_review_permission_source_only(self): ++ self.make_manager() ++ self.set_review(source_review=True, translation_review=False) ++ ++ self.assertFalse(self.user.has_perm("unit.review", self.get_translation("cs"))) ++ ++ self.assertTrue(self.user.has_perm("unit.review", self.component)) ++ self.assertTrue(self.user.has_perm("unit.review", self.project)) ++ ++ def test_approve_with_translation_review(self): ++ self.make_manager() ++ self.set_review(source_review=False, translation_review=True) ++ self.edit_unit( ++ "Hello, world!\n", "Nazdar svete!\n", review=str(STATE_APPROVED) ++ ) ++ unit = self.get_unit() ++ self.assertTrue(unit.approved) ++ ++ def test_approve_without_translation_review(self): ++ self.make_manager() ++ self.set_review(source_review=False, translation_review=False) ++ self.edit_unit( ++ "Hello, world!\n", "Nazdar svete!\n", review=str(STATE_APPROVED) ++ ) ++ unit = self.get_unit() ++ self.assertFalse(unit.approved) ++ ++ def review_group(self): ++ return Group.objects.filter(name="{}@Review".format(self.project.name)) ++ ++ def test_review_group_disabled(self): ++ self.project.access_control = Project.ACCESS_PUBLIC ++ self.set_review(source_review=False, translation_review=False) ++ self.assertFalse(self.review_group().exists()) ++ ++ def test_review_group_translation(self): ++ self.project.access_control = Project.ACCESS_PUBLIC ++ self.set_review(source_review=False, translation_review=True) ++ self.assertTrue(self.review_group().exists()) ++ ++ def test_review_group_source(self): ++ self.project.access_control = Project.ACCESS_PUBLIC ++ self.set_review(source_review=True, translation_review=False) ++ self.assertTrue(self.review_group().exists()) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,80 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++pg_ctlcluster 16 main start >/dev/null 2>&1 || true ++for _ in $(seq 1 30); do ++ pg_isready -h /var/run/postgresql >/dev/null 2>&1 && break ++ sleep 1 ++done ++sudo -u postgres psql -tc "SELECT 1 FROM pg_roles WHERE rolname='weblate'" \ ++ | grep -q 1 || sudo -u postgres psql -c \ ++ "CREATE USER weblate WITH PASSWORD 'weblate' CREATEDB SUPERUSER;" ++sudo -u postgres psql -c "ALTER ROLE weblate SET timezone TO 'UTC';" >/dev/null ++ ++ ++ ++python3 - <<'PY' ++import django.db.backends.postgresql.utils as m ++import pathlib ++p = pathlib.Path(m.__file__) ++text = p.read_text() ++if "timedelta" not in text: ++ p.write_text( ++ "from datetime import timedelta\n\n" ++ "from django.utils.timezone import utc\n\n\n" ++ "def utc_tzinfo_factory(offset):\n" ++ " if offset not in (0, timedelta(0)):\n" ++ " raise AssertionError(\"database connection isn't set to UTC\")\n" ++ " return utc\n" ++ ) ++PY ++ ++ ++ ++python3 - <<'PY' ++import pathlib ++p = pathlib.Path("/testbed/weblate/utils/django_hacks.py") ++text = p.read_text() ++fixed = text.replace( ++ "cls.on_commit_mgr.__exit__()", ++ "cls.on_commit_mgr.__exit__(None, None, None)", ++) ++if fixed != text: ++ p.write_text(fixed) ++PY ++ ++export DJANGO_SETTINGS_MODULE=weblate.settings_test ++export CI_DATABASE=postgresql ++export CI_DB_USER=weblate ++export CI_DB_PASSWORD=weblate ++export CI_DB_HOST=localhost ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++./manage.py test \ ++ weblate.auth.tests.test_permissions \ ++ weblate.trans.tests.test_models \ ++ weblate.trans.tests.test_source_review \ ++ --noinput diff --git a/tasks/format-code-task-000279/tests/test.sh b/tasks/format-code-task-000279/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a5eb0fc551e0de103f5a2a4a622b1847d3917de3 --- /dev/null +++ b/tasks/format-code-task-000279/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' +weblate/trans/tests/test_source_review.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-000279/tests/test_command.sh b/tasks/format-code-task-000279/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000279/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000410/environment/Dockerfile b/tasks/format-code-task-000410/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a9f33aa0b75474b4bf8eb26ae70b474aea508753 --- /dev/null +++ b/tasks/format-code-task-000410/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:deacb9c852ceee25d491d3e50a2514ace8b5c90035dd7615f89fd0e668f134dd diff --git a/tasks/format-code-task-000410/environment/setup/files/blocklist b/tasks/format-code-task-000410/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000410/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000410/environment/setup/setup.sh b/tasks/format-code-task-000410/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000410/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000410/tests/test.patch b/tasks/format-code-task-000410/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b7bbb2cd524f9ebf2e9c33d14a1ea47b9eb8aeb7 --- /dev/null +++ b/tasks/format-code-task-000410/tests/test.patch @@ -0,0 +1,95 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..d6003cb3fc +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/providers/google/cloud/transfers/test_bigquery_to_gcs.py::TestBigQueryToGCSOperatorNowait -v"] ++} +diff --git a/tests/providers/google/cloud/transfers/test_bigquery_to_gcs.py b/tests/providers/google/cloud/transfers/test_bigquery_to_gcs.py +index 3360084642..46313d2210 100644 +--- a/tests/providers/google/cloud/transfers/test_bigquery_to_gcs.py ++++ b/tests/providers/google/cloud/transfers/test_bigquery_to_gcs.py +@@ -152,3 +152,68 @@ class TestBigQueryToGCSOperator: + retry=DEFAULT_RETRY, + nowait=True, + ) ++ ++ ++class TestBigQueryToGCSOperatorNowait: ++ """Tests for the fix that BigQueryToGCSOperator must wait for completion in non-deferrable mode.""" ++ ++ @mock.patch("airflow.providers.google.cloud.transfers.bigquery_to_gcs.BigQueryHook") ++ def test_execute_non_deferrable_passes_nowait_false(self, mock_hook): ++ """In default (non-deferrable) mode, insert_job must be called with nowait=False ++ so the operator waits for completion. Regression for issue where nowait=True ++ caused BigQueryToGCSOperator to return before CSVs were written.""" ++ source_project_dataset_table = f"{PROJECT_ID}:{TEST_DATASET}.{TEST_TABLE_ID}" ++ destination_cloud_storage_uris = ["gs://some-bucket/some-file.txt"] ++ job_id = "123456" ++ hash_ = "hash" ++ real_job_id = f"{job_id}_{hash_}" ++ ++ mock_hook.return_value.split_tablename.return_value = (PROJECT_ID, TEST_DATASET, TEST_TABLE_ID) ++ mock_hook.return_value.generate_job_id.return_value = real_job_id ++ mock_hook.return_value.insert_job.return_value = MagicMock(job_id="real_job_id", error_result=False) ++ mock_hook.return_value.project_id = PROJECT_ID ++ ++ operator = BigQueryToGCSOperator( ++ task_id=TASK_ID, ++ source_project_dataset_table=source_project_dataset_table, ++ destination_cloud_storage_uris=destination_cloud_storage_uris, ++ ) ++ operator.execute(context=mock.MagicMock()) ++ ++ ++ _, kwargs = mock_hook.return_value.insert_job.call_args ++ assert kwargs["nowait"] is False, ( ++ f"In non-deferrable mode, insert_job must be called with nowait=False so the " ++ f"operator waits for completion; got nowait={kwargs.get('nowait')!r}." ++ ) ++ ++ @mock.patch("airflow.providers.google.cloud.transfers.bigquery_to_gcs.BigQueryHook") ++ def test_execute_deferrable_passes_nowait_true(self, mock_hook): ++ """In deferrable mode, insert_job must be called with nowait=True so the ++ operator submits the job and defers immediately to the trigger.""" ++ source_project_dataset_table = f"{PROJECT_ID}:{TEST_DATASET}.{TEST_TABLE_ID}" ++ destination_cloud_storage_uris = ["gs://some-bucket/some-file.txt"] ++ job_id = "123456" ++ hash_ = "hash" ++ real_job_id = f"{job_id}_{hash_}" ++ ++ mock_hook.return_value.split_tablename.return_value = (PROJECT_ID, TEST_DATASET, TEST_TABLE_ID) ++ mock_hook.return_value.generate_job_id.return_value = real_job_id ++ mock_hook.return_value.insert_job.return_value = MagicMock(job_id="real_job_id", error_result=False) ++ mock_hook.return_value.project_id = PROJECT_ID ++ ++ operator = BigQueryToGCSOperator( ++ project_id=PROJECT_ID, ++ task_id=TASK_ID, ++ source_project_dataset_table=source_project_dataset_table, ++ destination_cloud_storage_uris=destination_cloud_storage_uris, ++ deferrable=True, ++ ) ++ with pytest.raises(TaskDeferred): ++ operator.execute(context=mock.MagicMock()) ++ ++ _, kwargs = mock_hook.return_value.insert_job.call_args ++ assert kwargs["nowait"] is True, ( ++ f"In deferrable mode, insert_job must be called with nowait=True; " ++ f"got nowait={kwargs.get('nowait')!r}." ++ ) +diff --git 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/providers/google/cloud/transfers/test_bigquery_to_gcs.py::TestBigQueryToGCSOperatorNowait -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000410/tests/test.sh b/tasks/format-code-task-000410/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7af52210bd0628c26f0f8e902cf63b25f9f206fb --- /dev/null +++ b/tasks/format-code-task-000410/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/providers/google/cloud/transfers/test_bigquery_to_gcs.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-000410/tests/test_command.sh b/tasks/format-code-task-000410/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000410/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000411/environment/Dockerfile b/tasks/format-code-task-000411/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f2e7bc46523c0e8cd0018304143b74798d4f0aac --- /dev/null +++ b/tasks/format-code-task-000411/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e884ac54c8364445483cfd8d1ad1ec5fbda03286a160d235449dc82beeaf68af diff --git a/tasks/format-code-task-000411/environment/setup/files/blocklist b/tasks/format-code-task-000411/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000411/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000411/environment/setup/setup.sh b/tasks/format-code-task-000411/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000411/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000411/tests/test.patch b/tasks/format-code-task-000411/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d06f198067830edd1eb4b759d7322cff5a976c29 --- /dev/null +++ b/tasks/format-code-task-000411/tests/test.patch @@ -0,0 +1,88 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..bf1c8d7df9 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/core/test_configuration.py::TestWebserverConfigPath -v"] ++} +diff --git a/tests/core/test_configuration.py b/tests/core/test_configuration.py +index 961bc3c7cc..f908f17b69 100644 +--- a/tests/core/test_configuration.py ++++ b/tests/core/test_configuration.py +@@ -1430,3 +1430,61 @@ sql_alchemy_conn=sqlite://test + w = captured.pop() + assert "your `conf.get*` call to use the new name" in str(w.message) + assert w.category == FutureWarning ++ ++ ++class TestWebserverConfigPath: ++ """Tests for customizing the webserver_config.py location.""" ++ ++ def test_default_config_template_has_webserver_config_file_option(self): ++ """The default config template must expose [webserver] config_file option.""" ++ from airflow.configuration import ( ++ AirflowConfigParser, ++ _parameterized_config_from_template, ++ ) ++ ++ with mock.patch.dict("os.environ"): ++ os.environ.pop("AIRFLOW__WEBSERVER__CONFIG_FILE", None) ++ default_config = _parameterized_config_from_template("default_airflow.cfg") ++ parser = AirflowConfigParser(default_config=default_config) ++ value = parser.get("webserver", "config_file") ++ assert value.endswith("/webserver_config.py") ++ ++ def test_webserver_config_overridden_via_env_var(self): ++ """Setting AIRFLOW__WEBSERVER__CONFIG_FILE updates WEBSERVER_CONFIG.""" ++ from airflow import configuration as airflow_configuration ++ ++ original_webserver_config = airflow_configuration.WEBSERVER_CONFIG ++ original_conf = airflow_configuration.conf ++ tmp_dir = tempfile.mkdtemp() ++ custom_path = os.path.join(tmp_dir, "my_custom_webserver_config.py") ++ try: ++ with mock.patch.dict( ++ "os.environ", ++ {"AIRFLOW__WEBSERVER__CONFIG_FILE": custom_path}, ++ ): ++ airflow_configuration.initialize_config() ++ assert airflow_configuration.WEBSERVER_CONFIG == custom_path ++ finally: ++ airflow_configuration.WEBSERVER_CONFIG = original_webserver_config ++ airflow_configuration.conf = original_conf ++ import shutil as _shutil ++ ++ _shutil.rmtree(tmp_dir, ignore_errors=True) ++ ++ def test_webserver_config_default_path_uses_airflow_home(self): ++ """Default WEBSERVER_CONFIG resolves to {AIRFLOW_HOME}/webserver_config.py.""" ++ from airflow import configuration as airflow_configuration ++ ++ original_webserver_config = airflow_configuration.WEBSERVER_CONFIG ++ original_conf = airflow_configuration.conf ++ try: ++ with mock.patch.dict("os.environ"): ++ os.environ.pop("AIRFLOW__WEBSERVER__CONFIG_FILE", None) ++ airflow_configuration.initialize_config() ++ expected = os.path.join( ++ airflow_configuration.AIRFLOW_HOME, "webserver_config.py" ++ ) ++ assert airflow_configuration.WEBSERVER_CONFIG == expected ++ finally: ++ airflow_configuration.WEBSERVER_CONFIG = original_webserver_config ++ airflow_configuration.conf = original_conf +diff --git 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_configuration.py::TestWebserverConfigPath -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000411/tests/test.sh b/tasks/format-code-task-000411/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a54c828df9d7c05f62445f7b42a68169db223359 --- /dev/null +++ b/tasks/format-code-task-000411/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_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-000411/tests/test_command.sh b/tasks/format-code-task-000411/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000411/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000416/environment/Dockerfile b/tasks/format-code-task-000416/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b5c52a3f842663205258f9e6112b6f98dc92f2b3 --- /dev/null +++ b/tasks/format-code-task-000416/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6079a16e2fc5b25d3dcedd6ca78b0ce510a9642e7b65bebfb66c415bdda45fbe diff --git a/tasks/format-code-task-000416/environment/setup/files/blocklist b/tasks/format-code-task-000416/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000416/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000416/environment/setup/setup.sh b/tasks/format-code-task-000416/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000416/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000416/tests/test.patch b/tasks/format-code-task-000416/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..53d64af1fd7a9b2155968505287586605d5e8e83 --- /dev/null +++ b/tasks/format-code-task-000416/tests/test.patch @@ -0,0 +1,84 @@ +diff --git a/tests/providers/common/sql/hooks/test_dbapi.py b/tests/providers/common/sql/hooks/test_dbapi.py +index 090ec80e682b1..10e4756307e69 100644 +--- a/tests/providers/common/sql/hooks/test_dbapi.py ++++ b/tests/providers/common/sql/hooks/test_dbapi.py +@@ -476,7 +476,7 @@ def test_placeholder_with_invalid_placeholder_in_extra(self, caplog): + ) + + assert self.db_hook.placeholder == "%s" +- assert any( ++ assert ( + "Placeholder defined in Connection 'test_conn_id' is not listed in 'DEFAULT_SQL_PLACEHOLDERS' " + "and got ignored. Falling back to the default placeholder '%s'." in message + for message in caplog.messages +diff --git a/tests/providers/common/sql/hooks/test_sql.py b/tests/providers/common/sql/hooks/test_sql.py +index 5d3f4acfb16f0..866a6f55287d6 100644 +--- a/tests/providers/common/sql/hooks/test_sql.py ++++ b/tests/providers/common/sql/hooks/test_sql.py +@@ -18,6 +18,7 @@ + # + from __future__ import annotations + ++import logging + import warnings + from unittest.mock import MagicMock + +@@ -256,3 +257,21 @@ def test_make_common_data_structure_no_deprecated_method(self): + def test_placeholder_config_from_extra(self): + dbapi_hook = mock_hook(DbApiHook, conn_params={"extra": {"placeholder": "?"}}) + assert dbapi_hook.placeholder == "?" ++ ++ @pytest.mark.db_test ++ def test_placeholder_config_from_extra_when_not_in_default_sql_placeholders(self, caplog): ++ with caplog.at_level(logging.WARNING, logger="airflow.providers.common.sql.hooks.test_sql"): ++ dbapi_hook = mock_hook(DbApiHook, conn_params={"extra": {"placeholder": "!"}}) ++ assert dbapi_hook.placeholder == "%s" ++ assert ( ++ "Placeholder '!' defined in Connection 'default_conn_id' is not listed in 'DEFAULT_SQL_PLACEHOLDERS' " ++ f"and got ignored. Falling back to the default placeholder '{DbApiHook._placeholder}'." ++ in caplog.text ++ ) ++ ++ @pytest.mark.db_test ++ def test_placeholder_multiple_times_and_make_sure_connection_is_only_invoked_once(self): ++ dbapi_hook = mock_hook(DbApiHook) ++ for _ in range(10): ++ assert dbapi_hook.placeholder == "%s" ++ assert dbapi_hook.connection_invocations == 1 +diff --git a/tests/providers/common/sql/test_utils.py b/tests/providers/common/sql/test_utils.py +index 3f5255f8bdb16..7c76f3a7fa507 100644 +--- a/tests/providers/common/sql/test_utils.py ++++ b/tests/providers/common/sql/test_utils.py +@@ -52,9 +52,11 @@ def mock_hook(hook_class: type[BaseHook], hook_params=None, conn_params=None): + + class MockedHook(hook_class): # type: ignore[misc, valid-type] + conn_name_attr = "test_conn_id" ++ connection_invocations = 0 + + @classmethod + def get_connection(cls, conn_id: str): ++ cls.connection_invocations += 1 + return connection + + def get_conn(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,5 @@ ++H4sIAAAAAAAAA+3S3WqDMBwFcK99ioxdaz5a9XFKNAHD1LgkSvv2Sxx0Y7C5i3Zj7PwuTIIHDJ5/ ++2S5mUCc9rTS7FxY1VbWt0cd12/NKcCEOrGnqjHFeszoj1d1u9M7ig3SEZM7a8FVu7/0fVb71H7QP ++p86Oo5xU6fvbfWOv/4Norv0fhYj9H2vOMsJud4XP/fP+Hx9oaybaSt/nnSLbELRa5d4urtPXMy3X ++NCIpKrtgVhl0Pl9CbydSjCTuYoykh6ezs6tR2nmaZslO1D8PtLf2yb9OmGrlbMr58s14PO6Et9gS ++zOBTsDiTYs1/+7cCAAAAAAAAAAAAAAAAAAAAAPyIF1iPyHkAKAAA +diff --git 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-000416/tests/test.sh b/tasks/format-code-task-000416/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d72a0a373c7c0fa6432eee51a68a6bda83c30a09 --- /dev/null +++ b/tasks/format-code-task-000416/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/providers/common/sql/hooks/test_dbapi.py +tests/providers/common/sql/hooks/test_sql.py +tests/providers/common/sql/test_utils.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-000416/tests/test_command.sh b/tasks/format-code-task-000416/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000416/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000428/environment/Dockerfile b/tasks/format-code-task-000428/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d71e9fd068a3bb37a22b05090cb7ab91118ae2ef --- /dev/null +++ b/tasks/format-code-task-000428/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c32a5965bbace00a6bae9a1f85a92c4f3aec47ba6a3ea3cd213e5cc4672fd43f diff --git a/tasks/format-code-task-000428/environment/setup/files/blocklist b/tasks/format-code-task-000428/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000428/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000428/environment/setup/setup.sh b/tasks/format-code-task-000428/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000428/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000428/tests/test.patch b/tasks/format-code-task-000428/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b5d441cde5b1b1b1cb2b199bdc409e0c568bb44a --- /dev/null +++ b/tasks/format-code-task-000428/tests/test.patch @@ -0,0 +1,180 @@ +diff --git a/test/singa/test_optimizer_factory.cc b/test/singa/test_optimizer_factory.cc +new file mode 100644 +index 00000000..82660c77 +--- /dev/null ++++ b/test/singa/test_optimizer_factory.cc +@@ -0,0 +1,131 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++#include "gtest/gtest.h" ++#include "singa/model/optimizer.h" ++#include "singa/singa_config.h" ++#include ++#include ++ ++ ++TEST(OptimizerFactory, ReturnsBaseHandle) { ++ std::shared_ptr sgd = singa::CreateOptimizer("SGD"); ++ std::shared_ptr nesterov = ++ singa::CreateOptimizer("Nesterov"); ++ std::shared_ptr adagrad = ++ singa::CreateOptimizer("Adagrad"); ++ std::shared_ptr rmsprop = ++ singa::CreateOptimizer("RMSProp"); ++ EXPECT_NE(sgd, nullptr); ++ EXPECT_NE(nesterov, nullptr); ++ EXPECT_NE(adagrad, nullptr); ++ EXPECT_NE(rmsprop, nullptr); ++} ++ ++TEST(OptimizerFactory, SGDApply) { ++ auto opt = singa::CreateOptimizer("SGD"); ++ const float v[4] = {0.1, 0.2, 0.3, 0.4}; ++ const float g[4] = {0.1, 0.1, 0.1, 0.1}; ++ ++ singa::Tensor value(singa::Shape{4}), grad(singa::Shape{4}); ++ value.CopyDataFromHostPtr(v, 4); ++ grad.CopyDataFromHostPtr(g, 4); ++ ++ float lr = 0.1f; ++ opt->Apply(0, lr, "xx", grad, &value); ++ ++ singa::Tensor v1 = value.Clone(); ++ const float* newv1 = v1.data(); ++ for (int i = 0; i < 4; i++) EXPECT_FLOAT_EQ(newv1[i], v[i] - g[i] * lr); ++} ++ ++TEST(OptimizerFactory, AdagradApply) { ++ auto opt = singa::CreateOptimizer("Adagrad"); ++ float lr = 0.1f; ++ const float v[4] = {0.1, 0.2, 0.3, 0.4}; ++ const float g[4] = {0.01, 0.02, 0.03, 0.04}; ++ ++ singa::Tensor value(singa::Shape{4}), grad(singa::Shape{4}); ++ value.CopyDataFromHostPtr(v, 4); ++ grad.CopyDataFromHostPtr(g, 4); ++ ++ singa::OptimizerConf conf; ++ opt->Setup(conf); ++ opt->Apply(0, lr, "xx", grad, &value); ++ ++ singa::Tensor v1 = value.Clone(); ++ const float* newv1 = v1.data(); ++ float history[4]; ++ for (int i = 0; i < 4; ++i) history[i] = g[i] * g[i]; ++ for (int i = 0; i < 4; ++i) ++ EXPECT_NEAR(newv1[i], v[i] - lr * g[i] / sqrt(history[i] + conf.delta()), ++ 1e-5); ++} ++ ++TEST(OptimizerFactory, NesterovApply) { ++ auto opt = singa::CreateOptimizer("Nesterov"); ++ float lr = 0.1f; ++ const float v[4] = {0.1, 0.2, 0.3, 0.4}; ++ const float g[4] = {0.01, 0.02, 0.03, 0.04}; ++ ++ singa::Tensor value(singa::Shape{4}), grad(singa::Shape{4}); ++ value.CopyDataFromHostPtr(v, 4); ++ grad.CopyDataFromHostPtr(g, 4); ++ ++ singa::OptimizerConf conf; ++ opt->Setup(conf); ++ float mom = conf.momentum(); ++ opt->Apply(0, lr, "xx", grad, &value); ++ ++ singa::Tensor v1 = value.Clone(); ++ const float* newv1 = v1.data(); ++ for (int i = 0; i < 4; ++i) ++ EXPECT_NEAR(newv1[i], v[i] - (1 + mom) * g[i] * lr, 1e-5); ++} ++ ++TEST(OptimizerFactory, RMSPropApply) { ++ auto opt = singa::CreateOptimizer("RMSProp"); ++ float lr = 0.1f; ++ const float v[4] = {0.1, 0.2, 0.3, 0.4}; ++ const float g[4] = {0.01, 0.02, 0.03, 0.04}; ++ ++ singa::Tensor value(singa::Shape{4}), grad(singa::Shape{4}); ++ value.CopyDataFromHostPtr(v, 4); ++ grad.CopyDataFromHostPtr(g, 4); ++ ++ singa::OptimizerConf conf; ++ opt->Setup(conf); ++ float rho = conf.rho(); ++ float delta = conf.delta(); ++ opt->Apply(0, lr, "xx", grad, &value); ++ ++ singa::Tensor v1 = value.Clone(); ++ const float* newv1 = v1.data(); ++ for (int i = 0; i < 4; ++i) { ++ float history = (1 - rho) * g[i] * g[i]; ++ EXPECT_NEAR(newv1[i], v[i] - lr * g[i] / sqrt(history + delta), 1e-5); ++ } ++} ++ ++TEST(OptimizerFactoryDeathTest, UnknownType) { ++ ::testing::FLAGS_gtest_death_test_style = "threadsafe"; ++ ASSERT_DEATH({ auto opt = singa::CreateOptimizer("NoSuchOptimizer"); }, ""); ++} +diff --git 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 ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++export LD_LIBRARY_PATH="/testbed/build/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" ++ ++CXX=${CXX:-g++} ++COMMON_FLAGS="-std=c++11 -fpermissive -include cstdint" ++INCLUDES="-I include -I build/include -I src -I test" ++SRCS="src/model/optimizer/optimizer.cc test/gtest/gtest_main.cc" ++LIBS="build/lib/libgtest.a -L build/lib -lsinga_model -lsinga_core -lsinga_io -lsinga_utils -lprotobuf -lopenblas -lglog -llmdb -lpthread" ++ ++build_and_run() { ++ local out="$1"; shift ++ $CXX $COMMON_FLAGS $INCLUDES "$@" $SRCS $LIBS -o "$out" ++ "$out" ++} ++ ++ ++build_and_run /tmp/regression_tests \ ++ test/singa/test_sgd.cc \ ++ test/singa/test_adagrad.cc \ ++ test/singa/test_nesterov.cc \ ++ test/singa/test_rmsprop.cc ++ ++ ++build_and_run /tmp/factory_tests \ ++ test/singa/test_optimizer_factory.cc diff --git a/tasks/format-code-task-000428/tests/test.sh b/tasks/format-code-task-000428/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4bc5408ccc62fc682b206d1fc1820becfcf15206 --- /dev/null +++ b/tasks/format-code-task-000428/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/singa/test_optimizer_factory.cc +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000442/environment/Dockerfile b/tasks/format-code-task-000442/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b9afc55a62922bfb4610b7a9823b0698a0361806 --- /dev/null +++ b/tasks/format-code-task-000442/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:68c509f7bfd2de77acefbcef47e56cfa2b5bb71920f0f9df68532f4432f1f0b0 diff --git a/tasks/format-code-task-000442/environment/setup/files/blocklist b/tasks/format-code-task-000442/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000442/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000442/environment/setup/setup.sh b/tasks/format-code-task-000442/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000442/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000442/tests/test.patch b/tasks/format-code-task-000442/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2fd732a6c2a1f84ccd53c65625a2612636e39440 --- /dev/null +++ b/tasks/format-code-task-000442/tests/test.patch @@ -0,0 +1,448 @@ +diff --git a/usercase-test-coderl/eval_acceptance_test.go b/usercase-test-coderl/eval_acceptance_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/eval_acceptance_test.go +@@ -0,0 +1,416 @@ ++package usercase_test_coderl ++ ++import ( ++ "fmt" ++ "os" ++ "reflect" ++ "sort" ++ "strings" ++ "testing" ++ ++ "github.com/araddon/qlbridge/datasource" ++ "github.com/araddon/qlbridge/expr" ++ "github.com/araddon/qlbridge/expr/builtins" ++ "github.com/araddon/qlbridge/value" ++ "github.com/araddon/qlbridge/vm" ++) ++ ++ ++ ++ ++ ++ ++func init() { ++ builtins.LoadAllBuiltins() ++} ++ ++func TestEvalAddsParsedIdentityAndLiteral(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "int5 + 5") ++ assertIntValue(t, got, ok, 10) ++} ++ ++func TestEvalCallsRegisteredBuiltinWithEvaluatedArguments(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "toint(str5) + 6") ++ assertIntValue(t, got, ok, 11) ++} ++ ++func TestEvalBooleanEqualityTrue(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `email == "bob@bob.com"`) ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalBooleanInequalityFalse(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `email != "bob@bob.com"`) ++ assertBoolValue(t, got, ok, false) ++} ++ ++func TestEvalArithmeticSubtraction(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "int7 - 2") ++ assertIntValue(t, got, ok, 5) ++} ++ ++func TestEvalArithmeticMultiplication(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "int5 * 3") ++ assertIntValue(t, got, ok, 15) ++} ++ ++func TestEvalArithmeticDivision(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "int5 / int5") ++ ++ assertNumericValue(t, got, ok, 1) ++} ++ ++func TestEvalArithmeticModulus(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "int7 % 3") ++ assertIntValue(t, got, ok, 1) ++} ++ ++func TestEvalComparisonSingleEquals(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "int5 = 5") ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalComparisonGreaterThan(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "int5 > 4") ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalComparisonGreaterThanOrEqual(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "int5 >= 5") ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalComparisonLessThan(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "int5 < 6") ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalComparisonLessThanOrEqual(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "int5 <= 5") ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalBooleanAndKeyword(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `int5 > 1 AND email == "bob@bob.com"`) ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalBooleanOrKeyword(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `int5 > 8 OR email == "bob@bob.com"`) ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalBooleanAndSymbols(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `int5 > 1 && email == "bob@bob.com"`) ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalBooleanOrSymbols(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `int5 > 8 || email == "bob@bob.com"`) ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalBooleanNot(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `!(email == "bob@bob.com")`) ++ assertBoolValue(t, got, ok, false) ++} ++ ++func TestEvalLikeStarPattern(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `email LIKE "bob*"`) ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalLikePercentPattern(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `email LIKE "bob%@bob.com"`) ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalContainsArrayValue(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "[1,2,3,5] contains int5") ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalStringInMapKeys(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `"google.com" IN hits`) ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalArrayIntersectsContextSlice(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `["abc","zzz"] INTERSECTS urls`) ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalBetweenStrictlyInsideBounds(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "int5 BETWEEN 1 AND 9") ++ assertBoolValue(t, got, ok, true) ++} ++ ++func TestEvalMissingFieldReturnsFalseWithoutPanic(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), "missing > 21") ++ assertBoolValue(t, got, ok, false) ++} ++ ++func TestEvalUnsupportedTypeCombinationReportsFailure(t *testing.T) { ++ ++ ++ got, ok := eval(t, baseContext(), `"hello" == split("hell-no", ",")`) ++ if ok != false { ++ t.Fatalf("ok = %v, want false", ok) ++ } ++ ++ _ = got ++ again, againOK := eval(t, baseContext(), "int5 + 5") ++ assertIntValue(t, again, againOK, 10) ++} ++ ++func TestEvalMissingFieldComparisonDoesNotPanic(t *testing.T) { ++ defer func() { ++ ++ if recovered := recover(); recovered != nil { ++ t.Fatalf("panic = %#v, want no panic", recovered) ++ } ++ }() ++ ++ got, ok := vm.Eval(baseContext(), expr.MustParse("missing > 21")) ++ assertBoolValue(t, got, ok, false) ++} ++ ++func TestEvalIsReferentiallyTransparentForSameInput(t *testing.T) { ++ ctx := baseContext() ++ node := expr.MustParse("int5 + 5") ++ ++ first, firstOK := vm.Eval(ctx, node) ++ second, secondOK := vm.Eval(ctx, node) ++ ++ assertIntValue(t, first, firstOK, 10) ++ assertIntValue(t, second, secondOK, 10) ++} ++ ++func TestEvalDoesNotMutateCallerContextOrParsedNode(t *testing.T) { ++ ctx := baseContext() ++ node := expr.MustParse("[1,2,3,5] contains int5") ++ beforeContext := snapshotContext(t, ctx) ++ wantContext := map[string]string{ ++ "email": "string:bob@bob.com", ++ "hits": "map[string]int:google.com=5", ++ "int5": "int:5", ++ "int7": "int:7", ++ "str5": "string:5", ++ "urls": "[]string:abc,123", ++ } ++ ++ got, ok := vm.Eval(ctx, node) ++ ++ assertBoolValue(t, got, ok, true) ++ if !reflect.DeepEqual(beforeContext, wantContext) { ++ t.Fatalf("initial context snapshot = %#v, want %#v", beforeContext, wantContext) ++ } ++ if after := snapshotContext(t, ctx); !reflect.DeepEqual(after, beforeContext) { ++ t.Fatalf("context after Eval = %#v, want unchanged %#v", after, beforeContext) ++ } ++ ++ again, againOK := vm.Eval(ctx, node) ++ assertBoolValue(t, again, againOK, true) ++} ++ ++func TestEvalNoGlobalStateWithInProcessNoise(t *testing.T) { ++ ctx := baseContext() ++ ++ first, firstOK := eval(t, ctx, "int5 + 5") ++ noiseInt, noiseIntOK := eval(t, ctx, "toint(str5) + 6") ++ noiseBool, noiseBoolOK := eval(t, ctx, "missing > 21") ++ again, againOK := eval(t, ctx, "int5 + 5") ++ ++ assertIntValue(t, first, firstOK, 10) ++ assertIntValue(t, noiseInt, noiseIntOK, 11) ++ assertBoolValue(t, noiseBool, noiseBoolOK, false) ++ assertIntValue(t, again, againOK, 10) ++} ++ ++func TestEvalDoesNotCreateRelativeFilesystemSideEffects(t *testing.T) { ++ oldwd, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("Getwd failed: %v", err) ++ } ++ tmp := t.TempDir() ++ if err := os.Chdir(tmp); err != nil { ++ t.Fatalf("Chdir(%q) failed: %v", tmp, err) ++ } ++ defer func() { ++ if err := os.Chdir(oldwd); err != nil { ++ t.Fatalf("restore cwd failed: %v", err) ++ } ++ }() ++ ++ if before := dirEntries(t, tmp); !reflect.DeepEqual(before, []string{}) { ++ t.Fatalf("tmp dir entries before Eval = %#v, want []", before) ++ } ++ got, ok := eval(t, baseContext(), `email LIKE "bob*"`) ++ assertBoolValue(t, got, ok, true) ++ if after := dirEntries(t, tmp); !reflect.DeepEqual(after, []string{}) { ++ t.Fatalf("tmp dir entries after Eval = %#v, want []", after) ++ } ++} ++ ++func eval(t *testing.T, ctx expr.EvalContext, expression string) (value.Value, bool) { ++ t.Helper() ++ return vm.Eval(ctx, expr.MustParse(expression)) ++} ++ ++func baseContext() *datasource.ContextSimple { ++ return datasource.NewContextSimpleNative(map[string]interface{}{ ++ "int5": int64(5), ++ "int7": int64(7), ++ "str5": "5", ++ "email": "bob@bob.com", ++ "urls": []string{"abc", "123"}, ++ "hits": map[string]int64{"google.com": 5}, ++ }) ++} ++ ++func assertIntValue(t *testing.T, got value.Value, ok bool, want int64) { ++ t.Helper() ++ if ok != true { ++ t.Fatalf("ok = %v, want true", ok) ++ } ++ iv, isInt := got.(value.IntValue) ++ if !isInt { ++ t.Fatalf("value type = %T, want value.IntValue", got) ++ } ++ if iv.Val() != want { ++ t.Fatalf("IntValue.Val() = %d, want %d", iv.Val(), want) ++ } ++} ++ ++func assertNumericValue(t *testing.T, got value.Value, ok bool, want float64) { ++ t.Helper() ++ if ok != true { ++ t.Fatalf("ok = %v, want true", ok) ++ } ++ switch tv := got.(type) { ++ case value.IntValue: ++ if float64(tv.Val()) != want { ++ t.Fatalf("IntValue.Val() = %d, want numeric %v", tv.Val(), want) ++ } ++ case value.NumberValue: ++ if tv.Val() != want { ++ t.Fatalf("NumberValue.Val() = %v, want %v", tv.Val(), want) ++ } ++ default: ++ t.Fatalf("value type = %T, want numeric value", got) ++ } ++} ++ ++func assertBoolValue(t *testing.T, got value.Value, ok bool, want bool) { ++ t.Helper() ++ if ok != true { ++ t.Fatalf("ok = %v, want true", ok) ++ } ++ bv, isBool := got.(value.BoolValue) ++ if !isBool { ++ t.Fatalf("value type = %T, want value.BoolValue", got) ++ } ++ if bv.Val() != want { ++ t.Fatalf("BoolValue.Val() = %v, want %v", bv.Val(), want) ++ } ++} ++ ++func snapshotContext(t *testing.T, ctx expr.ContextReader) map[string]string { ++ t.Helper() ++ row := ctx.Row() ++ out := make(map[string]string, len(row)) ++ for key, val := range row { ++ out[key] = snapshotValue(t, val) ++ } ++ return out ++} ++ ++func snapshotValue(t *testing.T, val value.Value) string { ++ t.Helper() ++ switch tv := val.(type) { ++ case value.IntValue: ++ return fmt.Sprintf("%s:%d", tv.Type().String(), tv.Val()) ++ case value.StringValue: ++ return fmt.Sprintf("%s:%s", tv.Type().String(), tv.Val()) ++ case value.StringsValue: ++ return fmt.Sprintf("%s:%s", tv.Type().String(), strings.Join(tv.Val(), ",")) ++ case value.MapIntValue: ++ keys := make([]string, 0, len(tv.Val())) ++ for key := range tv.Val() { ++ keys = append(keys, key) ++ } ++ sort.Strings(keys) ++ parts := make([]string, 0, len(keys)) ++ for _, key := range keys { ++ parts = append(parts, fmt.Sprintf("%s=%d", key, tv.Val()[key])) ++ } ++ return fmt.Sprintf("%s:%s", tv.Type().String(), strings.Join(parts, ",")) ++ default: ++ t.Fatalf("unhandled snapshot value type %T", val) ++ return "" ++ } ++} ++ ++func dirEntries(t *testing.T, path string) []string { ++ t.Helper() ++ entries, err := os.ReadDir(path) ++ if err != nil { ++ t.Fatalf("ReadDir(%q) failed: %v", path, err) ++ } ++ names := make([]string, len(entries)) ++ for i, entry := range entries { ++ names[i] = entry.Name() ++ } ++ sort.Strings(names) ++ return names ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,22 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export GOPATH="${GOPATH:-/go}" ++export GOMODCACHE="${GOMODCACHE:-$GOPATH/pkg/mod}" ++export GOPROXY=off ++export GOSUMDB=off ++export GONOSUMDB=* ++export GOVCS=*:off ++export GOTOOLCHAIN=local ++export GOCACHE=/workspace/repo/.gocache-coderl ++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-000442/tests/test.sh b/tasks/format-code-task-000442/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5b6dd69f9ea5bbc22e6c88011c7d3663af719814 --- /dev/null +++ b/tasks/format-code-task-000442/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/eval_acceptance_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-000442/tests/test_command.sh b/tasks/format-code-task-000442/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000442/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-000445/environment/Dockerfile b/tasks/format-code-task-000445/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1ebb83d6891ec3b9824b003bff14de69d4c7c553 --- /dev/null +++ b/tasks/format-code-task-000445/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7c8c9f1374985175ecfb5cbafdadc0b9a47389fc84a51aa916f5d08e37b5b9a5 diff --git a/tasks/format-code-task-000445/environment/setup/files/blocklist b/tasks/format-code-task-000445/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000445/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000445/environment/setup/setup.sh b/tasks/format-code-task-000445/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000445/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000445/tests/test.patch b/tasks/format-code-task-000445/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..079768f896ddf7de5821b0f08747cbccb0da98db --- /dev/null +++ b/tasks/format-code-task-000445/tests/test.patch @@ -0,0 +1,38 @@ +diff --git a/topics/web/sockets/example1/main_test.go b/topics/web/sockets/example1/main_test.go +index 1d10e0389..ac33e7c91 100644 +--- a/topics/web/sockets/example1/main_test.go ++++ b/topics/web/sockets/example1/main_test.go +@@ -31,7 +31,7 @@ func TestApp(t *testing.T) { + } + + // Send this string across the websocket connection. +- if _, err = ws.Write([]byte("hello, world!")); err != nil { ++ if _, err = ws.Write([]byte(`"hello, world!"`)); 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+3TQWvbMBQHcJ/9Kd7YcViyvLoZjMEGK91hI6NspzGKLMmOiC0ZSU69bz/ZlDQU ++UjfQMra938XGkv56kV5INehWXiuzo8lzyaNVWc7P6P5zfmdlwdh5sTpbFUke31ieQPlsFR0YfOAO ++IHHWhofmLY3/pcjd/Qflw7WwXceNJH7zdHss3D8r49j+/ov4nZ2dF68TyJ+uhOP+8/sXEuaLr5RM ++05dwYfzgFFyuv3749gn8r67VZgtq1D74tNtK7SDrgU6HQRtLvRO00WEzVCQ2DuVOctPyyqetgczX ++Zp+9vCSOBce10aY5KESqXhmpjNDKA48ftNkX50Sqa/gBLyA7nt9Yp9uW054H+PkWwkaZFGDxl9wu ++uzduW24aYl1Dxxgiesjc3Yx+29DOyiObv98xkpPiMXWeFC2sCWqc49kj4m+nn7RFN4xT/BvCFuPj ++1AeiD46PGhVrzklZkvz4IU+zprxNXA7ZFQyvbhZLWEir9dRdV4OZWgGm7kzFid15uWaMfVl//P75 ++4p2ta2jsnAPZDggNttfC0xtVUW/FVgVP1ci7vlWMpn/6z44QQgghhBBCCCGEEEIIIYQQQgihf9Jv ++qkIgPgAoAAA= +diff --git 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-000445/tests/test.sh b/tasks/format-code-task-000445/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fa352bbd4f52b138e2b0f25f7680707a9b794199 --- /dev/null +++ b/tasks/format-code-task-000445/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' +topics/web/sockets/example1/main_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-000445/tests/test_command.sh b/tasks/format-code-task-000445/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000445/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000474/environment/Dockerfile b/tasks/format-code-task-000474/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bcc6fc7b0871764d3eb4f5b6a6feba1b5ebf35fa --- /dev/null +++ b/tasks/format-code-task-000474/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c356f8a411726d01a9ebacf81321ac6df672c31cfb513e94714e03a6439bdcb2 diff --git a/tasks/format-code-task-000474/environment/setup/files/blocklist b/tasks/format-code-task-000474/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000474/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000474/environment/setup/setup.sh b/tasks/format-code-task-000474/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000474/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000474/tests/test.patch b/tasks/format-code-task-000474/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9b9973644f8eb8d1e6a79810537cb830ab9cd559 --- /dev/null +++ b/tasks/format-code-task-000474/tests/test.patch @@ -0,0 +1,345 @@ +diff --git a/usercase-test-coderl/test_palace_graph_analyzer.py b/usercase-test-coderl/test_palace_graph_analyzer.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_palace_graph_analyzer.py +@@ -0,0 +1,316 @@ ++ ++ ++from __future__ import annotations ++ ++import gc ++import tempfile ++ ++import pytest ++ ++from memory_palace.graph_analyzer import PalaceGraphAnalyzer ++from memory_palace.knowledge_graph import KnowledgeGraph ++ ++ ++def _sample_graph() -> KnowledgeGraph: ++ graph = KnowledgeGraph(":memory:") ++ for entity_id in ("a", "b", "c", "d", "e"): ++ graph.upsert_entity(entity_id, "concept", f"Entity {entity_id.upper()}") ++ ++ graph.create_synapse("a", "b", strength=0.8) ++ graph.create_synapse("b", "c", strength=0.6) ++ graph.create_synapse("c", "d", strength=0.4) ++ graph.create_synapse("a", "c", strength=0.3) ++ graph.create_synapse("d", "e", strength=0.2) ++ return graph ++ ++ ++def _normalized_link_predictions( ++ predictions: list[tuple[str, str, float]], ++) -> list[tuple[tuple[str, str], float]]: ++ return [ ++ (tuple(sorted((source, target))), score) ++ for source, target, score in predictions ++ ] ++ ++ ++def _component_set(components: list[set[str]]) -> set[frozenset[str]]: ++ return {frozenset(component) for component in components} ++ ++ ++def test_build_graph_loads_sample_entities_synapses_and_weights() -> None: ++ ++ ++ ++ graph = _sample_graph() ++ try: ++ nx_graph = PalaceGraphAnalyzer(graph).build_graph() ++ ++ assert type(nx_graph).__name__ == "DiGraph" ++ assert len(nx_graph.nodes) == 5 ++ assert len(nx_graph.edges) == 5 ++ ++ assert set(nx_graph.nodes) == {"a", "b", "c", "d", "e"} ++ assert set(nx_graph.edges) == { ++ ("a", "b"), ++ ("a", "c"), ++ ("b", "c"), ++ ("c", "d"), ++ ("d", "e"), ++ } ++ assert nx_graph["a"]["b"]["weight"] == 0.8 ++ finally: ++ graph.close() ++ ++ ++def test_sample_rank_and_centrality_scores_are_state_derived() -> None: ++ ++ ++ ++ graph = _sample_graph() ++ try: ++ analyzer = PalaceGraphAnalyzer(graph) ++ ++ page_rank = analyzer.pagerank() ++ assert set(page_rank) == {"a", "b", "c", "d", "e"} ++ assert all(0.0 <= score <= 1.0 for score in page_rank.values()) ++ assert page_rank["a"] < page_rank["d"] ++ ++ centrality = analyzer.betweenness_centrality() ++ assert set(centrality) == {"a", "b", "c", "d", "e"} ++ ++ assert centrality["b"] > centrality["e"] or centrality["c"] > centrality["e"] ++ finally: ++ graph.close() ++ ++ ++def test_sample_undirected_structure_outputs_are_exact() -> None: ++ ++ ++ ++ graph = _sample_graph() ++ try: ++ analyzer = PalaceGraphAnalyzer(graph) ++ ++ communities = analyzer.detect_communities() ++ assert all(isinstance(community_id, int) for community_id in communities) ++ assert all( ++ isinstance(members, set) and members for members in communities.values() ++ ) ++ assert set().union(*communities.values()) == {"a", "b", "c", "d", "e"} ++ assert sum(len(members) for members in communities.values()) == 5 ++ ++ ++ assert {tuple(sorted(edge)) for edge in analyzer.find_bridges()} == { ++ ("c", "d"), ++ ("d", "e"), ++ } ++ ++ assert set(analyzer.find_keystones()) == {"c", "d"} ++ assert analyzer.connected_components() == [{"a", "b", "c", "d", "e"}] ++ finally: ++ graph.close() ++ ++ ++def test_shortest_path_prefers_stronger_synapses_and_missing_endpoints_return_none() -> None: ++ ++ ++ ++ graph = _sample_graph() ++ try: ++ analyzer = PalaceGraphAnalyzer(graph) ++ ++ assert analyzer.shortest_path("a", "e") == ["a", "b", "c", "d", "e"] ++ assert analyzer.shortest_path("missing", "e") is None ++ assert analyzer.shortest_path("a", "missing") is None ++ finally: ++ graph.close() ++ ++ ++def test_disconnected_graph_components_and_no_path_are_exact() -> None: ++ ++ ++ ++ graph = KnowledgeGraph(":memory:") ++ try: ++ for entity_id in ("a", "b", "z"): ++ graph.upsert_entity(entity_id, "concept", entity_id) ++ graph.create_synapse("a", "b", strength=0.5) ++ ++ analyzer = PalaceGraphAnalyzer(graph) ++ ++ ++ assert _component_set(analyzer.connected_components()) == { ++ frozenset({"a", "b"}), ++ frozenset({"z"}), ++ } ++ assert analyzer.shortest_path("a", "z") is None ++ assert analyzer.predict_links() == [] ++ finally: ++ graph.close() ++ ++ ++def test_empty_graph_algorithm_results_are_empty_literals() -> None: ++ ++ ++ ++ graph = KnowledgeGraph(":memory:") ++ try: ++ analyzer = PalaceGraphAnalyzer(graph) ++ nx_graph = analyzer.build_graph() ++ ++ assert len(nx_graph.nodes) == 0 ++ assert len(nx_graph.edges) == 0 ++ assert analyzer.pagerank() == {} ++ assert analyzer.betweenness_centrality() == {} ++ assert analyzer.detect_communities() == {} ++ assert analyzer.find_bridges() == [] ++ assert analyzer.find_keystones() == [] ++ assert analyzer.connected_components() == [] ++ assert analyzer.predict_links() == [] ++ finally: ++ graph.close() ++ ++ ++def test_predict_links_uses_adamic_adar_ordering_and_top_n() -> None: ++ ++ ++ ++ graph = _sample_graph() ++ try: ++ analyzer = PalaceGraphAnalyzer(graph) ++ ++ top_ten = _normalized_link_predictions(analyzer.predict_links(top_n=10)) ++ assert top_ten[0][0] == ("c", "e") ++ assert set(pair for pair, _score in top_ten[1:]) == {("a", "d"), ("b", "d")} ++ ++ assert all(score > 0.0 for _pair, score in top_ten) ++ assert [score for _pair, score in top_ten] == sorted( ++ (score for _pair, score in top_ten), reverse=True ++ ) ++ assert top_ten[0][1] > top_ten[1][1] ++ assert top_ten[1][1] == pytest.approx(top_ten[2][1]) ++ ++ top_two = _normalized_link_predictions(analyzer.predict_links(top_n=2)) ++ assert len(top_two) == 2 ++ assert top_two[0][0] == ("c", "e") ++ assert top_two[1][0] in {("a", "d"), ("b", "d")} ++ assert top_two[0][1] > top_two[1][1] > 0.0 ++ assert analyzer.predict_links(top_n=0) == [] ++ finally: ++ graph.close() ++ ++ ++def test_predict_links_empty_for_too_few_nodes_and_complete_two_node_graph() -> None: ++ ++ ++ ++ one_node = KnowledgeGraph(":memory:") ++ two_node_complete = KnowledgeGraph(":memory:") ++ try: ++ one_node.upsert_entity("solo", "concept", "Solo") ++ assert PalaceGraphAnalyzer(one_node).predict_links() == [] ++ ++ two_node_complete.upsert_entity("x", "concept", "X") ++ two_node_complete.upsert_entity("y", "concept", "Y") ++ two_node_complete.create_synapse("x", "y", strength=0.9) ++ assert PalaceGraphAnalyzer(two_node_complete).predict_links() == [] ++ finally: ++ one_node.close() ++ two_node_complete.close() ++ ++ ++def test_analyzer_reads_entities_and_synapses_from_live_knowledge_graph() -> None: ++ ++ ++ ++ graph = _sample_graph() ++ try: ++ analyzer = PalaceGraphAnalyzer(graph) ++ ++ nx_graph = analyzer.build_graph() ++ assert set(nx_graph.nodes) == {"a", "b", "c", "d", "e"} ++ ++ assert set(analyzer.pagerank()) == {"a", "b", "c", "d", "e"} ++ finally: ++ graph.close() ++ ++ ++def test_analyzer_build_graph_is_repeatable_before_cleanup() -> None: ++ ++ ++ ++ graph = _sample_graph() ++ try: ++ analyzer = PalaceGraphAnalyzer(graph) ++ nx_graph = analyzer.build_graph() ++ ++ ++ assert set(nx_graph.nodes) == {"a", "b", "c", "d", "e"} ++ assert len(nx_graph.edges) == 5 ++ finally: ++ graph.close() ++ ++ ++def test_two_analyzers_reflect_independent_knowledge_graph_state() -> None: ++ ++ ++ ++ graph_a = KnowledgeGraph(":memory:") ++ graph_b = KnowledgeGraph(":memory:") ++ try: ++ for entity_id in ("a", "b", "c"): ++ graph_a.upsert_entity(entity_id, "concept", entity_id) ++ graph_a.create_synapse("a", "b", strength=0.8) ++ graph_a.create_synapse("b", "c", strength=0.6) ++ ++ for entity_id in ("x", "y"): ++ graph_b.upsert_entity(entity_id, "concept", entity_id) ++ graph_b.create_synapse("x", "y", strength=0.9) ++ ++ nx_a = PalaceGraphAnalyzer(graph_a).build_graph() ++ nx_b = PalaceGraphAnalyzer(graph_b).build_graph() ++ ++ assert sorted(nx_a.nodes) == ["a", "b", "c"] ++ assert sorted(nx_a.edges) == [("a", "b"), ("b", "c")] ++ assert sorted(nx_b.nodes) == ["x", "y"] ++ assert sorted(nx_b.edges) == [("x", "y")] ++ ++ assert set(PalaceGraphAnalyzer(graph_a).pagerank()) == {"a", "b", "c"} ++ assert set(PalaceGraphAnalyzer(graph_b).pagerank()) == {"x", "y"} ++ finally: ++ graph_a.close() ++ graph_b.close() ++ ++ ++def test_repeated_construct_use_cycles_load_weighted_graphs() -> None: ++ ++ ++ ++ gc.collect() ++ retained_sessions: list[tuple[KnowledgeGraph, PalaceGraphAnalyzer]] = [] ++ snapshots: list[tuple[int, int, float]] = [] ++ ++ with tempfile.TemporaryDirectory() as temp_dir: ++ for index in range(120): ++ graph = KnowledgeGraph(f"{temp_dir}/graph_{index}.sqlite") ++ graph.upsert_entity("a", "concept", "Entity A") ++ graph.upsert_entity("b", "concept", "Entity B") ++ graph.create_synapse("a", "b", strength=0.8) ++ analyzer = PalaceGraphAnalyzer(graph) ++ ++ nx_graph = analyzer.build_graph() ++ assert len(nx_graph.nodes) == 2 ++ assert len(nx_graph.edges) == 1 ++ assert nx_graph["a"]["b"]["weight"] == 0.8 ++ snapshots.append( ++ (len(nx_graph.nodes), len(nx_graph.edges), nx_graph["a"]["b"]["weight"]) ++ ) ++ ++ graph.close() ++ retained_sessions.append((graph, analyzer)) ++ ++ gc.collect() ++ ++ ++ assert len(retained_sessions) == 120 ++ assert snapshots == [(2, 1, 0.8)] * 120 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTHONPATH="/workspace/repo/plugins/memory-palace/src:/workspace/repo/plugins/leyline/src:${PYTHONPATH:-}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_palace_graph_analyzer.py -v diff --git a/tasks/format-code-task-000474/tests/test.sh b/tasks/format-code-task-000474/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..16a18f954e81c53cee54ff6815c804f8ba574044 --- /dev/null +++ b/tasks/format-code-task-000474/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_palace_graph_analyzer.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-000474/tests/test_command.sh b/tasks/format-code-task-000474/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000474/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-000480/environment/Dockerfile b/tasks/format-code-task-000480/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e68f56e4d1e1a5fe246220893e128a03f4364fc3 --- /dev/null +++ b/tasks/format-code-task-000480/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:694a39cb53997d9662d52de6132423ecdee75b71e946975f0f5376c2ab2cd054 diff --git a/tasks/format-code-task-000480/environment/setup/files/blocklist b/tasks/format-code-task-000480/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000480/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000480/environment/setup/setup.sh b/tasks/format-code-task-000480/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000480/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000480/tests/test.patch b/tasks/format-code-task-000480/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1e9fece771a64dbfa5566e05f333daecfd49a8f9 --- /dev/null +++ b/tasks/format-code-task-000480/tests/test.patch @@ -0,0 +1,75 @@ +diff --git a/internal/handlers/handler_authz_test.go b/internal/handlers/handler_authz_test.go +index dbba67e462844..63f22b0bdfbe7 100644 +--- a/internal/handlers/handler_authz_test.go ++++ b/internal/handlers/handler_authz_test.go +@@ -244,7 +244,7 @@ func (s *AuthzSuite) TestShouldVerifyFailureToGetDetailsUsingBasicScheme() { + + s.ConfigureMockSessionProviderWithAutomaticAutheliaURLs(mock) + +- targetURI := s.RequireParseRequestURI("https://bypass.example.com") ++ targetURI := s.RequireParseRequestURI("https://onefactor.example.com") + + s.setRequest(mock.Ctx, fasthttp.MethodGet, targetURI, true, false) + +@@ -274,6 +274,40 @@ func (s *AuthzSuite) TestShouldVerifyFailureToGetDetailsUsingBasicScheme() { + } + } + ++func (s *AuthzSuite) TestShouldVerifyBypassWithErrorToGetDetailsUsingBasicScheme() { ++ if s.setRequest == nil { ++ s.T().Skip() ++ } ++ ++ authz := s.Builder().Build() ++ ++ mock := mocks.NewMockAutheliaCtx(s.T()) ++ ++ defer mock.Close() ++ ++ s.ConfigureMockSessionProviderWithAutomaticAutheliaURLs(mock) ++ ++ targetURI := s.RequireParseRequestURI("https://bypass.example.com") ++ ++ s.setRequest(mock.Ctx, fasthttp.MethodGet, targetURI, true, false) ++ ++ mock.Ctx.Request.Header.Set(fasthttp.HeaderProxyAuthorization, "Basic am9objpwYXNzd29yZA==") ++ ++ gomock.InOrder( ++ mock.UserProviderMock.EXPECT(). ++ CheckUserPassword(gomock.Eq("john"), gomock.Eq("password")). ++ Return(true, nil), ++ ++ mock.UserProviderMock.EXPECT(). ++ GetDetails(gomock.Eq("john")). ++ Return(nil, fmt.Errorf("generic failure")), ++ ) ++ ++ authz.Handler(mock.Ctx) ++ ++ s.Equal(fasthttp.StatusOK, mock.Ctx.Response.StatusCode()) ++} ++ + func (s *AuthzSuite) TestShouldNotFailOnMissingEmail() { + if s.setRequest == nil { + s.T().Skip() +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+3STUvDMBgH8J77KR4neGvTdGt7UvCgJ0/T+0jbsBa6BNNkvuCHN61CxaG7bKj4 ++/0HIy/NAQ/+JS9d29UqqLQuOJfGKLBtn7/M8rnmW8pTPF3lRBAnnOecBZUe70Qeut8IQBUZr+13f ++vvofFU/5W9nbVaU3G6HquG8O9419+acFn/KfL3z+i5znASWHu8LX/nn+pyesbBUrRd+EVU3jIyhl ++Ha41DUuKthRV2il7zilmrbLSKNGxxr+RTpqeUWScotmd7106da3NgzD1pbPNMJ5vXWvly3txOFnK ++e+d3u8UbuRbV0+751eNb81SZUXpxxsOf/nEAAAAAAAAAAAAAAAAAAAAAAL/AK748o5QAKAAA +diff --git 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-000480/tests/test.sh b/tasks/format-code-task-000480/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7aee6b59343f48e5788e7bd958bb7575db5b7070 --- /dev/null +++ b/tasks/format-code-task-000480/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/handlers/handler_authz_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-000480/tests/test_command.sh b/tasks/format-code-task-000480/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000480/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000487/environment/Dockerfile b/tasks/format-code-task-000487/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2225575be736c00a881d93bdd3b72c4834ea5334 --- /dev/null +++ b/tasks/format-code-task-000487/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:679370c28f3b07cf3943f177574f2511d87355c3deed9ff342b3154444e8acb5 diff --git a/tasks/format-code-task-000487/environment/setup/files/blocklist b/tasks/format-code-task-000487/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000487/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000487/environment/setup/setup.sh b/tasks/format-code-task-000487/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000487/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000487/tests/test.patch b/tasks/format-code-task-000487/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..46ad8ed789619901004f50ed1a9a39b4105a75ec --- /dev/null +++ b/tasks/format-code-task-000487/tests/test.patch @@ -0,0 +1,177 @@ +diff --git a/utils/ip_test.go b/utils/ip_test.go +new file mode 100644 +index 000000000000..179014f4b8d1 +--- /dev/null ++++ b/utils/ip_test.go +@@ -0,0 +1,151 @@ ++ ++ ++ ++package utils ++ ++import ( ++ "fmt" ++ "net" ++ "testing" ++) ++ ++func TestIPDescEqual(t *testing.T) { ++ tests := []struct { ++ ipDesc1 IPDesc ++ ipDesc2 IPDesc ++ result bool ++ }{ ++ ++ { ++ IPDesc{net.ParseIP("127.0.0.1"), 0}, ++ IPDesc{net.ParseIP("127.0.0.1"), 0}, ++ true, ++ }, { ++ IPDesc{net.ParseIP("::1"), 0}, ++ IPDesc{net.ParseIP("::1"), 0}, ++ true, ++ }, { ++ IPDesc{net.ParseIP("127.0.0.1"), 0}, ++ IPDesc{net.ParseIP("::ffff:127.0.0.1"), 0}, ++ true, ++ }, ++ ++ ++ { ++ IPDesc{net.ParseIP("127.0.0.1"), 0}, ++ IPDesc{net.ParseIP("1.2.3.4"), 0}, ++ false, ++ }, { ++ IPDesc{net.ParseIP("::1"), 0}, ++ IPDesc{net.ParseIP("2001::1"), 0}, ++ false, ++ }, { ++ IPDesc{net.ParseIP("127.0.0.1"), 0}, ++ IPDesc{net.ParseIP("127.0.0.1"), 1}, ++ false, ++ }, ++ } ++ for i, tt := range tests { ++ t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { ++ if tt.ipDesc1.IP == nil { ++ t.Error("ipDesc1 nil") ++ } else if tt.ipDesc2.IP == nil { ++ t.Error("ipDesc2 nil") ++ } ++ result := tt.ipDesc1.Equal(tt.ipDesc2) ++ if result && result != tt.result { ++ t.Error("Expected IPDesc to be equal, but they were not") ++ } ++ if !result && result != tt.result { ++ t.Error("Expected IPDesc to be unequal, but they were equal") ++ } ++ }) ++ } ++} ++ ++func TestIPDescPortString(t *testing.T) { ++ tests := []struct { ++ ipDesc IPDesc ++ result string ++ }{ ++ {IPDesc{net.ParseIP("127.0.0.1"), 0}, ":0"}, ++ {IPDesc{net.ParseIP("::1"), 42}, ":42"}, ++ {IPDesc{net.ParseIP("::ffff:127.0.0.1"), 65535}, ":65535"}, ++ {IPDesc{net.IP{}, 1234}, ":1234"}, ++ } ++ for _, tt := range tests { ++ t.Run(tt.result, func(t *testing.T) { ++ if result := tt.ipDesc.PortString(); result != tt.result { ++ t.Errorf("Expected %q, got %q", tt.result, result) ++ } ++ }) ++ } ++} ++ ++func TestIPDescString(t *testing.T) { ++ tests := []struct { ++ ipDesc IPDesc ++ result string ++ }{ ++ {IPDesc{net.ParseIP("127.0.0.1"), 0}, "127.0.0.1:0"}, ++ {IPDesc{net.ParseIP("::1"), 42}, "[::1]:42"}, ++ {IPDesc{net.ParseIP("::ffff:127.0.0.1"), 65535}, "127.0.0.1:65535"}, ++ {IPDesc{net.IP{}, 1234}, ":1234"}, ++ } ++ for _, tt := range tests { ++ t.Run(tt.result, func(t *testing.T) { ++ if result := tt.ipDesc.String(); result != tt.result { ++ t.Errorf("Expected %q, got %q", tt.result, result) ++ } ++ }) ++ } ++} ++ ++func TestToIPDescError(t *testing.T) { ++ tests := []struct { ++ in string ++ out IPDesc ++ }{ ++ {"", IPDesc{}}, ++ {":", IPDesc{}}, ++ {"abc:", IPDesc{}}, ++ {":abc", IPDesc{}}, ++ {"abc:abc", IPDesc{}}, ++ {"127.0.0.1:", IPDesc{}}, ++ {":1", IPDesc{}}, ++ {"::1", IPDesc{}}, ++ {"::1:42", IPDesc{}}, ++ } ++ for _, tt := range tests { ++ t.Run(tt.in, func(t *testing.T) { ++ result, err := ToIPDesc(tt.in) ++ if err == nil { ++ t.Errorf("Unexpected success") ++ } ++ if !tt.out.Equal(result) { ++ t.Errorf("Expected %v, got %v", tt.out, result) ++ } ++ }) ++ } ++} ++ ++func TestToIPDesc(t *testing.T) { ++ tests := []struct { ++ in string ++ out IPDesc ++ }{ ++ {"127.0.0.1:42", IPDesc{net.ParseIP("127.0.0.1"), 42}}, ++ {"[::1]:42", IPDesc{net.ParseIP("::1"), 42}}, ++ } ++ for _, tt := range tests { ++ t.Run(tt.in, func(t *testing.T) { ++ result, err := ToIPDesc(tt.in) ++ if err != nil { ++ t.Errorf("Unexpected error %v", err) ++ } ++ if !tt.out.Equal(result) { ++ t.Errorf("Expected %#v, got %#v", tt.out, result) ++ } ++ }) ++ } ++} +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+3RvQrCMBRA4c4+RV7ANreaOLkpLoqTs2h/tKAGbNrnt3apCOqiiHi+JYEbyIUT ++bqvikK6zUx0Fn6IbI2Pas3F/tncxsY6tGYi2gRaxWgJlPrbRjar0m7NSwdk5/+zdq/mPCrv+Piv9 ++OnHH4+aUhuX+fX+87G+7/tpK039opemv37fCY3/eP0lVG36bpb3ZUkQWy8lqPh27PFc7p64j1a9V ++GFW+OJRR79v7AgAAAAAAAAAAAAAAAOhcAJCE5MEAKAAA +diff --git 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-000487/tests/test.sh b/tasks/format-code-task-000487/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0fa7c942b1a6e230ce8a599b035dc6cc49a01ef4 --- /dev/null +++ b/tasks/format-code-task-000487/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' +utils/ip_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-000487/tests/test_command.sh b/tasks/format-code-task-000487/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000487/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000489/environment/Dockerfile b/tasks/format-code-task-000489/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..241e26ba8bd507eb4e056d61d1bf58c1e14697f7 --- /dev/null +++ b/tasks/format-code-task-000489/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6f101c26c643663eb22bf07e5110ad2fd97a0930d853796d5908a2a27580d87a diff --git a/tasks/format-code-task-000489/environment/setup/files/blocklist b/tasks/format-code-task-000489/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000489/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000489/environment/setup/setup.sh b/tasks/format-code-task-000489/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000489/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000489/tests/test.patch b/tasks/format-code-task-000489/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fa45aec866db279051f722c89db0433cbd12c05e --- /dev/null +++ b/tasks/format-code-task-000489/tests/test.patch @@ -0,0 +1,425 @@ +diff --git a/usercase-test-coderl/fixtures/base.toml b/usercase-test-coderl/fixtures/base.toml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/base.toml +@@ -0,0 +1,4 @@ ++[TAIPY] ++custom_property_not_overwritten = true ++custom_property_overwritten = 10 ++base_only = "base" +diff --git a/usercase-test-coderl/fixtures/env_overlay.toml b/usercase-test-coderl/fixtures/env_overlay.toml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/env_overlay.toml +@@ -0,0 +1,4 @@ ++[TAIPY] ++custom_property_overwritten = 11 ++foo = 2 ++backup_marker = "env" +diff --git a/usercase-test-coderl/fixtures/env_overlay_alt.toml b/usercase-test-coderl/fixtures/env_overlay_alt.toml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/env_overlay_alt.toml +@@ -0,0 +1,3 @@ ++[TAIPY] ++custom_property_overwritten = 101 ++session_marker = "a-env" +diff --git a/usercase-test-coderl/fixtures/override.toml b/usercase-test-coderl/fixtures/override.toml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/override.toml +@@ -0,0 +1,4 @@ ++[TAIPY] ++custom_property_overwritten = 12 ++foo = 3 ++override_only = "override" +diff --git a/usercase-test-coderl/fixtures/session_b_base.toml b/usercase-test-coderl/fixtures/session_b_base.toml +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/session_b_base.toml +@@ -0,0 +1,3 @@ ++[TAIPY] ++custom_property_overwritten = 20 ++session_marker = "b-base" +diff --git a/usercase-test-coderl/test_taipy_env_config_path.py b/usercase-test-coderl/test_taipy_env_config_path.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_taipy_env_config_path.py +@@ -0,0 +1,354 @@ ++ ++ ++ ++ ++ ++ ++ ++from __future__ import annotations ++ ++import json ++import os ++import subprocess ++import sys ++import textwrap ++ ++import pytest ++ ++ ++FIXTURES = "/workspace/repo/usercase-test-coderl/fixtures" ++RESULT_PREFIX = "USERCASE_RESULT=" ++MISSING_ENV_FILE = "/workspace/repo/usercase-test-coderl/fixtures/missing_taipy_env_config.toml" ++ ++ ++def normalize_backup_value(value): ++ if value == "True:bool": ++ return True ++ if value == "False:bool": ++ return False ++ if isinstance(value, str) and value.endswith(":int"): ++ return int(value.removesuffix(":int")) ++ return value ++ ++ ++def run_config_session(code: str) -> tuple[dict, str]: ++ env = os.environ.copy() ++ env.pop("TAIPY_CONFIG_PATH", None) ++ env["PYTHONPATH"] = "/workspace/repo" + os.pathsep + env.get("PYTHONPATH", "") ++ completed = subprocess.run( ++ [sys.executable, "-c", textwrap.dedent(code)], ++ cwd="/workspace/repo", ++ env=env, ++ text=True, ++ capture_output=True, ++ ) ++ output = completed.stdout + completed.stderr ++ if completed.returncode != 0: ++ pytest.fail(output) ++ ++ for line in reversed(output.splitlines()): ++ if line.startswith(RESULT_PREFIX): ++ return json.loads(line.removeprefix(RESULT_PREFIX)), output ++ pytest.fail(f"missing {RESULT_PREFIX!r} line in subprocess output:\n{output}") ++ ++ ++def test_env_file_has_highest_precedence_after_load(): ++ ++ ++ ++ result, _ = run_config_session( ++ f""" ++ import json ++ import os ++ from taipy.common.config import Config ++ ++ os.environ["TAIPY_CONFIG_PATH"] = "{FIXTURES}/env_overlay.toml" ++ Config.load("{FIXTURES}/base.toml") ++ result = {{ ++ "after_load": {{ ++ "custom_property_not_overwritten": Config.global_config.custom_property_not_overwritten, ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ "foo": Config.global_config.foo, ++ }} ++ }} ++ print("{RESULT_PREFIX}" + json.dumps(result, sort_keys=True)) ++ """ ++ ) ++ ++ ++ assert result["after_load"]["custom_property_not_overwritten"] is True ++ assert result["after_load"]["custom_property_overwritten"] == 11 ++ assert result["after_load"]["foo"] == 2 ++ ++ ++def test_env_file_overlays_python_configuration(): ++ ++ ++ ++ result, _ = run_config_session( ++ f""" ++ import json ++ import os ++ from taipy.common.config import Config ++ ++ os.environ["TAIPY_CONFIG_PATH"] = "{FIXTURES}/env_overlay.toml" ++ Config.configure_global_app(foo=1) ++ result = {{ ++ "global": {{ ++ "foo": Config.global_config.foo, ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ }}, ++ }} ++ print("{RESULT_PREFIX}" + json.dumps(result, sort_keys=True)) ++ """ ++ ) ++ ++ ++ assert result["global"]["foo"] == 2 ++ assert result["global"]["custom_property_overwritten"] == 11 ++ ++ ++def test_env_file_has_highest_precedence_after_override(): ++ ++ ++ ++ result, _ = run_config_session( ++ f""" ++ import json ++ import os ++ from taipy.common.config import Config ++ ++ os.environ["TAIPY_CONFIG_PATH"] = "{FIXTURES}/env_overlay.toml" ++ Config.configure_global_app(foo=1) ++ result = {{ ++ "after_python": {{ ++ "foo": Config.global_config.foo, ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ }} ++ }} ++ Config.override("{FIXTURES}/override.toml") ++ result["after_override"] = {{ ++ "foo": Config.global_config.foo, ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ "override_only": Config.global_config.override_only, ++ }} ++ print("{RESULT_PREFIX}" + json.dumps(result, sort_keys=True)) ++ """ ++ ) ++ ++ ++ assert result["after_python"]["foo"] == 2 ++ assert result["after_python"]["custom_property_overwritten"] == 11 ++ assert result["after_override"]["foo"] == 2 ++ assert result["after_override"]["custom_property_overwritten"] == 11 ++ assert result["after_override"]["override_only"] == "override" ++ ++ ++def test_missing_environment_file_logs_and_uses_normal_layers(): ++ ++ ++ ++ result, output = run_config_session( ++ f""" ++ import json ++ import os ++ from taipy.common.config import Config ++ ++ os.environ["TAIPY_CONFIG_PATH"] = "{MISSING_ENV_FILE}" ++ Config.configure_global_app(foo=1) ++ result = {{ ++ "after_python_missing_env": {{ ++ "foo": Config.global_config.foo, ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ }} ++ }} ++ Config.load("{FIXTURES}/base.toml") ++ result["after_load_missing_env"] = {{ ++ "custom_property_not_overwritten": Config.global_config.custom_property_not_overwritten, ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ "foo": Config.global_config.foo, ++ }} ++ print("{RESULT_PREFIX}" + json.dumps(result, sort_keys=True)) ++ """ ++ ) ++ ++ ++ assert result["after_python_missing_env"]["foo"] == 1 ++ assert result["after_python_missing_env"]["custom_property_overwritten"] is None ++ assert result["after_load_missing_env"]["custom_property_not_overwritten"] is True ++ assert result["after_load_missing_env"]["custom_property_overwritten"] == 10 ++ assert result["after_load_missing_env"]["foo"] is None ++ ++ assert MISSING_ENV_FILE in output ++ assert "TAIPY_CONFIG_PATH" in output ++ assert any(phrase in output.lower() for phrase in ("does not exist", "not found", "missing")) ++ ++ ++def test_backup_writes_applied_environment_overlay(): ++ ++ ++ ++ result, _ = run_config_session( ++ f""" ++ import json ++ import os ++ import tempfile ++ import toml ++ from pathlib import Path ++ from taipy.common.config import Config ++ ++ os.environ["TAIPY_CONFIG_PATH"] = "{FIXTURES}/env_overlay.toml" ++ with tempfile.TemporaryDirectory() as directory: ++ backup = Path(directory) / "backup.toml" ++ Config.load("{FIXTURES}/base.toml") ++ Config.configure_global_app(foo=1) ++ Config.backup(str(backup)) ++ backed_up = toml.load(str(backup))["TAIPY"] ++ print("{RESULT_PREFIX}" + json.dumps({{"taipy": backed_up}}, sort_keys=True)) ++ """ ++ ) ++ ++ backed_up = {key: normalize_backup_value(value) for key, value in result["taipy"].items()} ++ ++ assert backed_up["custom_property_not_overwritten"] is True ++ assert backed_up["custom_property_overwritten"] == 11 ++ assert backed_up["foo"] == 2 ++ ++ ++def test_environment_path_is_applied_on_later_compilation(): ++ ++ ++ ++ result, _ = run_config_session( ++ f""" ++ import json ++ import os ++ from taipy.common.config import Config ++ ++ Config.load("{FIXTURES}/base.toml") ++ before = {{ ++ "custom_property_not_overwritten": Config.global_config.custom_property_not_overwritten, ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ }} ++ os.environ["TAIPY_CONFIG_PATH"] = "{FIXTURES}/env_overlay.toml" ++ Config.load("{FIXTURES}/base.toml") ++ after = {{ ++ "custom_property_not_overwritten": Config.global_config.custom_property_not_overwritten, ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ }} ++ print("{RESULT_PREFIX}" + json.dumps({{"before": before, "after": after}}, sort_keys=True)) ++ """ ++ ) ++ ++ ++ assert result["before"] == {"custom_property_not_overwritten": True, "custom_property_overwritten": 10} ++ assert result["after"] == {"custom_property_not_overwritten": True, "custom_property_overwritten": 11} ++ ++ ++def test_environment_path_set_before_compilation_overlays_load(): ++ ++ ++ ++ result, _ = run_config_session( ++ f""" ++ import json ++ import os ++ from taipy.common.config import Config ++ ++ os.environ["TAIPY_CONFIG_PATH"] = "{FIXTURES}/env_overlay.toml" ++ Config.load("{FIXTURES}/base.toml") ++ result = {{ ++ "custom_property_not_overwritten": Config.global_config.custom_property_not_overwritten, ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ "foo": Config.global_config.foo, ++ }} ++ print("{RESULT_PREFIX}" + json.dumps(result, sort_keys=True)) ++ """ ++ ) ++ ++ ++ assert result["custom_property_not_overwritten"] is True ++ assert result["custom_property_overwritten"] == 11 ++ assert result["foo"] == 2 ++ ++ ++def test_independent_process_wide_config_sessions_do_not_share_state(): ++ ++ ++ ++ session_a, _ = run_config_session( ++ f""" ++ import json ++ import os ++ from taipy.common.config import Config ++ ++ os.environ["TAIPY_CONFIG_PATH"] = "{FIXTURES}/env_overlay_alt.toml" ++ Config.load("{FIXTURES}/base.toml") ++ result = {{ ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ "session_marker": Config.global_config.session_marker, ++ }} ++ print("{RESULT_PREFIX}" + json.dumps(result, sort_keys=True)) ++ """ ++ ) ++ session_b, _ = run_config_session( ++ f""" ++ import json ++ from taipy.common.config import Config ++ ++ Config.load("{FIXTURES}/session_b_base.toml") ++ result = {{ ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ "session_marker": Config.global_config.session_marker, ++ }} ++ print("{RESULT_PREFIX}" + json.dumps(result, sort_keys=True)) ++ """ ++ ) ++ ++ ++ assert session_a == {"custom_property_overwritten": 101, "session_marker": "a-env"} ++ assert session_b == {"custom_property_overwritten": 20, "session_marker": "b-base"} ++ ++ ++def test_repeated_environment_compile_and_backup_cycles_keep_overlay_applied(): ++ ++ ++ ++ result, _ = run_config_session( ++ f""" ++ import json ++ import logging ++ import os ++ import tempfile ++ import toml ++ from pathlib import Path ++ from taipy.common.config import Config ++ ++ logging.getLogger("Taipy").disabled = True ++ os.environ["TAIPY_CONFIG_PATH"] = "{FIXTURES}/env_overlay.toml" ++ with tempfile.TemporaryDirectory() as directory: ++ backup = Path(directory) / "backup.toml" ++ for i in range(5): ++ Config.load("{FIXTURES}/base.toml") ++ Config.configure_global_app(iteration=i) ++ Config.backup(str(backup)) ++ backed_up = toml.load(str(backup))["TAIPY"] ++ result = {{ ++ "cycles": 5, ++ "custom_property_overwritten": Config.global_config.custom_property_overwritten, ++ "foo": Config.global_config.foo, ++ "backup_exists": backup.exists(), ++ "backed_up": backed_up, ++ }} ++ print("{RESULT_PREFIX}" + json.dumps(result, sort_keys=True)) ++ """ ++ ) ++ ++ backed_up = {key: normalize_backup_value(value) for key, value in result["backed_up"].items()} ++ ++ assert result["cycles"] == 5 ++ assert result["custom_property_overwritten"] == 11 ++ assert result["foo"] == 2 ++ assert result["backup_exists"] is True ++ assert backed_up["custom_property_overwritten"] == 11 ++ assert backed_up["foo"] == 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,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 PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_taipy_env_config_path.py -v diff --git a/tasks/format-code-task-000489/tests/test.sh b/tasks/format-code-task-000489/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1c7952bd0c59d43e9003e5205bcb07a36dc369d7 --- /dev/null +++ b/tasks/format-code-task-000489/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/base.toml +usercase-test-coderl/fixtures/env_overlay.toml +usercase-test-coderl/fixtures/env_overlay_alt.toml +usercase-test-coderl/fixtures/override.toml +usercase-test-coderl/fixtures/session_b_base.toml +usercase-test-coderl/test_taipy_env_config_path.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-000489/tests/test_command.sh b/tasks/format-code-task-000489/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000489/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-000622/environment/Dockerfile b/tasks/format-code-task-000622/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..72b649427339f56b2ff905ef55221ea236bcbd32 --- /dev/null +++ b/tasks/format-code-task-000622/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:41c0de22a34d8c5e1496970845916f87a5dc5799b72803796c144e570424e38d diff --git a/tasks/format-code-task-000622/environment/setup/files/blocklist b/tasks/format-code-task-000622/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000622/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000622/environment/setup/setup.sh b/tasks/format-code-task-000622/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000622/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000622/tests/test.patch b/tasks/format-code-task-000622/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5cf5ad484eedd208f58f8dc5cf77c468bbf74da7 --- /dev/null +++ b/tasks/format-code-task-000622/tests/test.patch @@ -0,0 +1,269 @@ +diff --git a/cmd/snap/cmd_buy_test.go b/cmd/snap/cmd_buy_test.go +index bc62fdba5f9..36fa6334e4a 100644 +--- a/cmd/snap/cmd_buy_test.go ++++ b/cmd/snap/cmd_buy_test.go +@@ -26,7 +26,6 @@ import ( + + "gopkg.in/check.v1" + +- "github.com/snapcore/snapd/arch" + snap "github.com/snapcore/snapd/cmd/snap" + ) + +@@ -257,18 +256,7 @@ const loginJson = ` + } + ` + +-func archWithBrokenDevPtmx() error { +- if ubuArch := arch.UbuntuArchitecture(); ubuArch == "ppc64el" || ubuArch == "powerpc" { +- return fmt.Errorf("/dev/ptmx ioctl not working on %s", ubuArch) +- } +- return nil +-} +- + func (s *BuySnapSuite) TestBuySnapSuccess(c *check.C) { +- if err := archWithBrokenDevPtmx(); err != nil { +- c.Skip(err.Error()) +- } +- + mockServer := &buyTestMockSnapServer{ + ExpectedMethods: expectedMethods{ + "GET": &expectedMethod{ +@@ -304,7 +292,7 @@ func (s *BuySnapSuite) TestBuySnapSuccess(c *check.C) { + s.RedirectClientToTestServer(mockServer.serveHttp) + + // Confirm the purchase. +- fmt.Fprint(s.term, "the password\n") ++ s.password = "the password" + + rest, err := snap.Parser().ParseArgs([]string{"buy", "hello"}) + c.Check(err, check.IsNil) +@@ -330,10 +318,6 @@ const buySnapPaymentDeclinedJson = ` + ` + + func (s *BuySnapSuite) TestBuySnapPaymentDeclined(c *check.C) { +- if err := archWithBrokenDevPtmx(); err != nil { +- c.Skip(err.Error()) +- } +- + mockServer := &buyTestMockSnapServer{ + ExpectedMethods: expectedMethods{ + "GET": &expectedMethod{ +@@ -369,7 +353,7 @@ func (s *BuySnapSuite) TestBuySnapPaymentDeclined(c *check.C) { + s.RedirectClientToTestServer(mockServer.serveHttp) + + // Confirm the purchase. +- fmt.Fprint(s.term, "the password\n") ++ s.password = "the password" + + rest, err := snap.Parser().ParseArgs([]string{"buy", "hello"}) + c.Assert(err, check.NotNil) +diff --git a/cmd/snap/cmd_login_test.go b/cmd/snap/cmd_login_test.go +index cce666c287b..c9b43894c60 100644 +--- a/cmd/snap/cmd_login_test.go ++++ b/cmd/snap/cmd_login_test.go +@@ -49,15 +49,11 @@ func makeLoginTestServer(c *C, n *int) func(w http.ResponseWriter, r *http.Reque + } + + func (s *SnapSuite) TestLoginSimple(c *C) { +- if err := archWithBrokenDevPtmx(); err != nil { +- c.Skip(err.Error()) +- } +- + n := 0 + s.RedirectClientToTestServer(makeLoginTestServer(c, &n)) + + // send the password +- fmt.Fprint(s.term, "some-password\n") ++ s.password = "some-password\n" + rest, err := snap.Parser().ParseArgs([]string{"login", "foo@example.com"}) + c.Assert(err, IsNil) + c.Assert(rest, DeepEquals, []string{}) +@@ -69,17 +65,13 @@ Login successful + } + + func (s *SnapSuite) TestLoginAskEmail(c *C) { +- if err := archWithBrokenDevPtmx(); err != nil { +- c.Skip(err.Error()) +- } +- + n := 0 + s.RedirectClientToTestServer(makeLoginTestServer(c, &n)) + + // send the email + fmt.Fprint(s.stdin, "foo@example.com\n") + // send the password +- fmt.Fprint(s.term, "some-password\n") ++ s.password = "some-password" + + rest, err := snap.Parser().ParseArgs([]string{"login"}) + c.Assert(err, IsNil) +diff --git a/cmd/snap/main_test.go b/cmd/snap/main_test.go +index 65db4605e32..888c36b4efa 100644 +--- a/cmd/snap/main_test.go ++++ b/cmd/snap/main_test.go +@@ -31,6 +31,8 @@ import ( + + . "gopkg.in/check.v1" + ++ "golang.org/x/crypto/ssh/terminal" ++ + "github.com/snapcore/snapd/cmd" + "github.com/snapcore/snapd/dirs" + "github.com/snapcore/snapd/osutil" +@@ -42,34 +44,31 @@ import ( + // Hook up check.v1 into the "go test" runner + func Test(t *testing.T) { TestingT(t) } + +-func openPty() (*os.File, error) { +- return os.OpenFile("/dev/ptmx", os.O_RDWR, 0) +-} +- + type BaseSnapSuite struct { + testutil.BaseTest +- stdin *bytes.Buffer +- stdout *bytes.Buffer +- stderr *bytes.Buffer +- term *os.File ++ stdin *bytes.Buffer ++ stdout *bytes.Buffer ++ stderr *bytes.Buffer ++ password string + + AuthFile string + } + ++func (s *BaseSnapSuite) readPassword(fd int) ([]byte, error) { ++ return []byte(s.password), nil ++} ++ + func (s *BaseSnapSuite) SetUpTest(c *C) { + s.BaseTest.SetUpTest(c) + s.stdin = bytes.NewBuffer(nil) + s.stdout = bytes.NewBuffer(nil) + s.stderr = bytes.NewBuffer(nil) +- +- pty, err := openPty() +- c.Assert(err, IsNil) +- s.term = pty ++ s.password = "" + + snap.Stdin = s.stdin + snap.Stdout = s.stdout + snap.Stderr = s.stderr +- snap.Terminal = int(s.term.Fd()) ++ snap.ReadPassword = s.readPassword + s.AuthFile = filepath.Join(c.MkDir(), "json") + os.Setenv(TestAuthFileEnvKey, s.AuthFile) + } +@@ -78,9 +77,7 @@ func (s *BaseSnapSuite) TearDownTest(c *C) { + snap.Stdin = os.Stdin + snap.Stdout = os.Stdout + snap.Stderr = os.Stderr +- snap.Terminal = 0 +- +- s.term.Close() ++ snap.ReadPassword = terminal.ReadPassword + + c.Assert(s.AuthFile == "", Equals, false) + err := os.Unsetenv(TestAuthFileEnvKey) +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,84 @@ ++H4sIAAAAAAAAA+xZWZOjSJLu161fkY8zJsvkCM41mwdAiEMSCEmA0MsaNwjEfQh+/aKsmmqUWZld ++0z21Zmu78ZCSMiK+zz3cw90j4sVp49T7Lz/roN9+VYOnRuL46+fU3n6+fkdwFIYJEsPw6f8IQsDY ++b0/4L5No1tq6saunp9+qPG8+G/dH/f9L28vv9g/zl2vu/QKOu4EJDPvI/giJ4d/tj8LoZH+URCb7 ++w79Alnft/7j9J4u3qf8Uxk3UOi9ufoXqzC7cvPJfv3hfvoT5E/KC4i/wly+VX7Zx5T/97ct/zCa4 ++kR+Gtm1DhfPUIS/wC0o/9k9geT2513M91I1/9Z46eBoFP6MwQiMIjME0mHb8swdcD/M9xHPc4AEg ++zKs4TW3o2t7uBNQL8sPu3nfq3E385j4IfwFvBtX+bYBCv2n8WzOTgIApAKMojAHkeQo/BGHDNuxi ++9sPsi1/XfucldyWC1A7rOwXxRo5rl+PTADfPgjgs7Kr2q995UIBMXAiC4hj5DOOOR1FkAOP+DyBa ++Z3K152nZfxeShPG7oDACiGcUJ2iSsDGUhIlpcp7aWfiSVyF0g9xqKJrXefhkhzedmf+qNo597SmS ++8CXO7sZzk5cO+Wq5V0mn8AsmJgzD0GcEdh2aQgnSJdzZrKvt2tOGyH6fOOus/KYavveAWU+TX52X ++Dn3q0O+rj6AwhUzKIfSzh3uIg1MoTAByPmlI/cqBwsp2/aBNvwGjLwg+GzTY1/Qb8l2/v3/kq0kF ++FZN8zXBfignjCYKe4sybBrrN24H/dJRJiw+HXe2mye5eUbWZ38deE321GvbhjLqZ+N3oDl83cTDc ++lUGQd5LMLTdtmzsqhr0TZD6q8avr6zDwZtjfv3yy/x/jf91ef0GM+Tz+IzhOkO/i/1QG/H/8/x9o ++n8fxpwj5z5Wb6AqehXyCboquFeCgRwR+dSM2zWChhSlBZ1QLuYy38n98+RzuW4lxRzUxGABsQ662 ++HC6vzdSrj6bjCZdNDu9v+npNgvXi2O5uJwA/ov6JZHLni02sOk+BrG4XRWn3CN1GxYEbowuGlTnA ++CyVcr4RyXK4T/S/zzdRc4ZF9IruLYQhw4iIgkEy/1I1Y2Q28fOsg9dplbA5bVx97oPXsznfD6JW3 ++8PvXIDHFiAmxu9AXqEWcMus4PpDVXo+aVGX2ZQ0WVSJaFgIulnnUadL9CcSZqDJpUZZrokoc1eHV ++yKdkBFKmT6E6URUs3oiXQy0tXFwE1ANwYDdxNK1Tmld3UHqKPhMadduJKQaViDGUgrSLA2S1QAxg ++gfRwrUoY4W1HNwGXm3j9B2gzEX3N5ZGy0W61a+B7+9wVp6pyqGWVuABaetqi1S1OuWwW46MRg8rO ++EsfOoCkluMk98H5NIegd9BZc1SjKRTwQdqHDM2m0KWSRLuARgrV4jHM6rycr0ZJu/RzoTGAtgsw8 ++OK38mFlJEmLzbIujNNPIOXEOUUOs3YyvHTaT0UcvD/M8TP27rdxr8S1VPU9/J5+DwZQyATql/2ci ++IEmaJoKpXHnVpARFtsLlFavsR6reLxfS/kJaxHI7WMJRKbMzbd+OziHIFekvss1UpLTSXYZjpZep ++7kACutOOZtz6Qj62e4SisNDztkOfEPFGf0P6tqi7ox1bdoPRzakPq5VlRmWlhJWu8BaNthRy2EUt ++WR+9UeNj0/oDtJmIzDqgJYzhy93xuh0ad+vC60TJW44gDMA2Z6xc4sHVPMRb7YegbwvLO2ZtL5sz ++sXNuENwunNDSQEkTxTnkxiBan4Rd2ZDJmURtRQl/CnMmrrWnUpyCs6HxtY6RjiEanemTEWEOji94 ++HbI95hIgwVaM+DfQ/2KJeydTUAe9OpiQxMghXQGzjfb0DrFEtUjJfICcxe12whgQb9G/SDZTUOJl ++28AgQoaNItcASFacru+I9rq/VC5r8I7a2cSJax3o0R4fVeF3TK5rcZ3ShWpjD0h1Djpo3JHxpjiI ++gn6G1JagjnB8Qhx2jf0U5kzcbUIdkUhizEKN5Vi06UpmDss1qgvmJYb5diewmbLZ5vnwGHEfak3k ++IZB5zABSj0zpAI6dpaJqqihuLUuSnChwxMMVcNi5zmV1r+QfQ6JfNV9dQwAa3S4xiBqu9FFWkBtZ ++b+RMNPpoBwCnJIVlQGTVS59izcSLixKy0YzcrW9AFesRW8uShPudf2p2Klb2/EnwjMAcg+w9ZDO8 ++Ty3FSrMygjDFSi12lpJeenVb5gh8TKwICQbgWnGOpsDhau0t3rwIn5AwvOb2+L5JV+J2j+m9SNee ++hh85qoPLpcaJ2alZJPb6cDT4T5BmomGy0y2Wsgn0I7SJ1V72Lc1H/KBs9BsUG5F9hbAu8JjqTcz8 ++Xvi/pirbmc7Qr9jYa3DInN2GpQIj0Om4d5wcwMdd42z2Y2+2hC0fiFOE+bbdxczPgc4E1uGiuBAG ++Xh4QcJKJPKAEi6lR3DJQf4/xhhvsy5UU5WzD/xg7ru1vRodfqPmuLDHchU4MBrqIoKELiMumGXen ++DHai0yBctrDo3dy6ct9k7B8CI19d87ZTjyulFJJ2qQsxEKEy0R1Nxc4xa6NOtS7xCk6po+BvfwZy ++JuwuyloliCM8HVWchAKQLXLPcraY3LTFRr1pKlPeNK5FzQ9W4d15bQJF2S5YX8fcIdirh1n1Bh6H ++UC0Db5WtSWGPaRuYWOYYVJDWz4HOBN70V5Hy6hu5MCn9NgJJlC0R1w59GEp1yY5FO+IiBOnI6jFN ++/rlLhdfFX+nHs2NZTEWucs87jBtyn+3hNDyhqooM9HUBljFvUGyr/RsY59Eju13WYys4xXZ59XKJ ++TPKw9UvW2HsBEewYAfeYWgdhS8Dvif+Fy487F2GizXmI7V1gjOKp4EZhSKmCSBm1WjJSftqdRyZc ++72gHsf4S10y9RbeQGqNA7XLESaflAMQtzxpbcES7O0fqBWVrdntexuf1Yzoorv5oV97dT7w4CNL4 ++27Hoa1xbsv2ShxVh0HJWdDaatesP+i7ntuYeZ/lRSqAASc8Oo21/DnRuj7VITjZYRdbtuEYKd58l ++66QMjnlYOyEZnhXDwqZq0TpDj6mxysPCLwofctOpUpmfe6ZFwhAapycfQCmaoFHSBjD5Wk8ATSSN ++QbXtWBeViqEPPmZp0j5ZHrke4eW0pm9HnbM5f7/9a2TzGF7h2lBGF8nk3DW1VLH11k1dXEqyEi8N ++lkmnXTAyjn5wHz39w6uYCZOs0ViYtiXO93sSsqVzRdk5vvAqG/SxNqwvl1Xbhca6JfWfwpyJ25/7 ++wAS1uwn36wUKQpXAtbMfrIu1ts+CkaiXNIUoV4wl7tA/vt/7vjgAplAUIRHq2UUpDPgw4tH2vD73 ++Lkro8hUCcTDOcEmIxJsglnWcLwhE0xPBpMrCq2sJXvR/zDbtfITCMAx+xl0MxgnSRtFgnkSGOFzp ++dFeKoxXzlH7t1r5rJ7x88TLzAi4XjKbTbOUmASd9yIZ/y/USuzv1u2B9s0jX1M6AOnPSfifhsLXx ++/W65STfZwOH9Xjh+jjU/rDBenziVLSgM26OJeiKs1a4G5hZFT6WE8Sfeo8LFjVRd6g3kt9vT7yuB ++wRgKpmiIP/sO7rgOjgSoPa/iG1oUmoASVeWG+0e0ajKyJPxjKXFWqRvZugZNJOdAK9Lwx1T3i9rX ++rDTK0pm5MaIBqSI37SNVZCw/0sZNcDi1AYQf8g207IgeemvAGdBMsMMFyy/UZU2crmLBnnVoNMUe ++sAaY6g1s3cULvSFdzbUWr7vlB/eQ39cARaatidIY/ezBDoI4nm271HxjHo47atktBxfyJNyhjnhU ++R01yOSx4DD1mQ61w+s67uLEQWX9ENZ0oSJREiGeb9sDEBCbPA7+ECkOmDTWlOfBMkyRASQBgmvZm ++VBGiXEzXp0/7jaDxtUn2xVrhLgK9bJSUS412teHP3lJx+PpzKgRGCZiEAaCeAcAx2EYCAgbkv5MK ++++ZEceqdUyBj7eivdzBZoavFQi1InmZRWt7rw8JGST52Gvb4gdGxRyfChA3C45IeLaJmreq8ak/Z ++J6oYvxzqwBDiYjlFXLbMuOtbp3y4pr4bDttvdLRmAaJCCpcuxpVCM1VLMxBXTjl2XRzPMsEulv0R +++wRpJlpaRamoeJosqgukNKxYDFZrozXiXJYin3FBwB62K4uX6uQd4NcTwiOeUm4pXld1BMsuiQyC ++cmsuCpfYeFkfxZB0KXqxIYeh7dW3S/cdj/yqKlde4t6j/UNI+bDGJANna0dFXEnSaDaxt7Ojlbmn ++QHWs3E+QZqLZeH25nYSajuoMYmSjb/m045ic7ijN2oyd3an4iO7i7euV3fsnH/jxGYZCAIpPPz0U ++91FqCnH4jIvLidgxZGbMGFtKyoKK2mOfyhp3nqZf8gByHQUzTNwa4R9y/fN5CaFgAqUQctph1DNJ ++UYFHUtj9xv8XcH34lHUnEf0Ywphl4JmlnCDn7U1XijJrlN423Tas2AsTi2lZ7mMj+XMk87tVMdlJ ++ThUUHokeBIg3POLa8sFSu7iSouR7mKMuaAXKM6bNuN6/st2x2Kt/kw6UNlgwGsNt7p/6qklFquMO ++0P56K+l2VAes1LqE+hRrJt7aF0Cc0bJDnsFeYaDdKguvi6t0YHNYg1V6rfkrGqfGNp+L9+ad79Uh ++aY6pLHdkjI7QasIQ8s02zmla4GsysWh9PKzoxWa5iIX6Y6D59bmcnK5mvLWZnLyxi1vULVc4PUbB ++ZWkO43VgbvER81iCosIZ3s8/M34tWcxF1nmiQ2+M8iBq7Ck4c7FfGlgwWpHClilJjhY8JGX9pzhm ++6rBiXRYtlNXtmBxxtohFhN+ed5uhPGy3lOxIdjesGC5fKXOX+/gB9I6JyFd1iNYlM5wAGx5PW4nC ++Nv2RWKky1uxQhfbRpD9yWzjTfgpzXsyxkZ+Y3R6FGe5kqM7h4C1BSxzopX8Ypui0QXeMw3BQK889 ++7fEp9o6zpG5hz3MWyVndbWGhGVazIw3kyeP23c2LhyGnuGPQrm3rQ5yZWPtlkjoJSTOCee2jrGug ++Czs2dsGrwlK9EWfnVF52hFsLDxr/d7tW29M2EoT72b9imla0lDhuCiLqVUEKqQtcKVASSnuqhBx7 ++nVixd82u1xCO/vfO2GniQLhLT6erTtpHSuTdnTfPzL55txS3CfkmfUsgOeH1p8TZu+ncuOeXh/s6 ++97OD1833vdej0VGSnB+Lc/3yc//L771Wt/OgnGon2tKTceumtdt1Ty71trvR3d76EuZN/2NrfNOS ++B3/k0VlytOEOXdz5/Opjvxkq57+0Y7nAPUzi8aChRv+ejr+5/7W5/ao5O//dbG49etncoipz/vsf ++4MljZ4BZPfDUyFK4X7CZtiw/gCIbBiywLHadCpnBSae/3645Wkknjgb0wQHHiyYx//aU2mqW9QRc ++HNokg73iylATIgVe7kUxfcm0ohAewzS9wM5hKGBtxwlY7nAdx28gGzFuAcJLM3uIpug08DIG9uUl ++rK3NaiOOAYtjsCdFS7lMKmyBuTR4tbPWtMKIbDrFFxFo1LSnkvbypgOEUiSgvJwFaFcaMQXPJUsF ++SEaeuIpSrEGrknXLT2cOce7dmJs3leW/oCatVWosk4knItUxvWvOeCAklBc3hJyUJk7vaPkeLj6s ++veOj497Zh+6+233ffgHT4tvd4rkIkkOpitLJw2ReKZT0dCUjLVxwm2hA07e9EBUWp5fsmvk6iwSH ++530sd3yfKfWW8YgF+xHPoFj6KJCa84gPS2aMMEdBJG29jHAUFNKK1uXxpSYvwBxIZpTTUO1JD/Wg ++kRimQjvQLr70CcVNCS19Zvkjei37FLwN+Xnuz5LQwdjP8+D2FjKpH2RZSks5ozlQkhGdKoOA5uNP ++Mvz3JCVi4bMwijFJPLXo0waKOFPYYKPW9vQFlKB+oala8HhSCCybMP8ClmL2cQG4Z78ScrxOIvqk ++stAivYRRNfn73lL0DdjlY0jm4K5IlVwcmRTJAfCToLjO5+DDxUBPLoiggflBsHdgV0962NzTUcYa ++L+6zxGIY8QoTsszpKVkOiaAXJWnM6suaOmrsJjgSLIrGGr5gyjLRf7pSCom9WMdZ/W5S1t3rTHod ++OVT1T/jimLzHvBt7SkX+vKITxySyfsbHXFzxbjkG1VGkiHPWSdNvVt/t9S/eHRz23dN2reqN2mLT ++00rp9kEX/CTTD+eszlZxyepMd333E+p+OHl1lrvR+Aec07CtzrkY39X55omAk5jS2J2gVp31lk56 ++X4tZj2YmzN2iv1U7O85vds6ytghDaDizhJ/31GdVe57V5iPhr14QGBgYGBgYGBgYGBgYGBgYGBgY ++GBgYGBgYGBgYGBgYGPzv8B1PCqJaAFAAAA== +diff --git 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-000622/tests/test.sh b/tasks/format-code-task-000622/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..73f9dbb01014cd5ad5d9065e9a629cfcd2b56f12 --- /dev/null +++ b/tasks/format-code-task-000622/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' +cmd/snap/cmd_buy_test.go +cmd/snap/cmd_login_test.go +cmd/snap/main_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-000622/tests/test_command.sh b/tasks/format-code-task-000622/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000622/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000624/environment/Dockerfile b/tasks/format-code-task-000624/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..94bdb85719c5456c6f9f9e22f7552b0ae2808687 --- /dev/null +++ b/tasks/format-code-task-000624/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:dcfd71de34a59fbc329fce8763f8555b0fde809924fc22506b68164103f91c17 diff --git a/tasks/format-code-task-000624/environment/setup/files/blocklist b/tasks/format-code-task-000624/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000624/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000624/environment/setup/setup.sh b/tasks/format-code-task-000624/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000624/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000624/tests/test.patch b/tasks/format-code-task-000624/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d1031cee5b3edd15108510ccd25e9179b78edeaa --- /dev/null +++ b/tasks/format-code-task-000624/tests/test.patch @@ -0,0 +1,529 @@ +diff --git a/usercase-test-coderl/test_data_labeler_predict_pipeline.py b/usercase-test-coderl/test_data_labeler_predict_pipeline.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_data_labeler_predict_pipeline.py +@@ -0,0 +1,499 @@ ++import warnings ++ ++import numpy as np ++import pandas as pd ++import pytest ++ ++import dataprofiler as dp ++from dataprofiler.labelers import BaseDataLabeler ++from dataprofiler.labelers.base_model import BaseModel ++from dataprofiler.labelers.data_processing import ( ++ BaseDataPostprocessor, ++ BaseDataPreprocessor, ++) ++ ++ ++class RecordingPreprocessor(BaseDataPreprocessor): ++ def __init__(self, **parameters): ++ self.calls = [] ++ super().__init__(**parameters) ++ ++ def _validate_parameters(self, parameters): ++ unknown = set(parameters) - {"shared", "stage"} ++ if unknown: ++ raise ValueError(f"bad params {unknown}") ++ ++ @classmethod ++ def help(cls): ++ print("RecordingPreprocessor") ++ ++ def process(self, data, labels=None, label_mapping=None, batch_size=32): ++ values = tuple(str(x) for x in np.reshape(data, -1).tolist()) ++ self.calls.append({"data": values, "batch_size": batch_size}) ++ return [ ++ { ++ "values": values, ++ "batch_size": batch_size, ++ "call_index": len(self.calls), ++ } ++ ] ++ ++ ++class RecordingModel(BaseModel): ++ def __init__(self, label_mapping=None, parameters=None): ++ self.calls = [] ++ super().__init__(label_mapping or {"A": 1, "B": 2}, parameters or {}) ++ ++ def _need_to_reconstruct_model(self): ++ return False ++ ++ def _validate_parameters(self, parameters): ++ unknown = set(parameters) - {"shared", "stage"} ++ if unknown: ++ raise ValueError(f"bad params {unknown}") ++ ++ def _construct_model(self): ++ return None ++ ++ def _reconstruct_model(self): ++ return None ++ ++ def reset_weights(self): ++ return None ++ ++ def predict(self, data, batch_size, show_confidences, verbose): ++ samples = list(data) ++ self.calls.append( ++ { ++ "samples": samples, ++ "batch_size": batch_size, ++ "show_confidences": show_confidences, ++ "verbose": verbose, ++ } ++ ) ++ if show_confidences: ++ return { ++ "pred": [2, 1], ++ "conf": [0.25, 0.75], ++ "model_call_index": len(self.calls), ++ "verbose": verbose, ++ "batch_size": batch_size, ++ } ++ return { ++ "pred": [1, 2], ++ "model_call_index": len(self.calls), ++ "verbose": verbose, ++ "batch_size": batch_size, ++ } ++ ++ @classmethod ++ def load_from_disk(cls, dirpath): ++ return cls() ++ ++ def save_to_disk(self, dirpath): ++ return None ++ ++ ++class RecordingPostprocessor(BaseDataPostprocessor): ++ def __init__(self, **parameters): ++ self.calls = [] ++ super().__init__(**parameters) ++ ++ def _validate_parameters(self, parameters): ++ unknown = set(parameters) - {"shared", "stage"} ++ if unknown: ++ raise ValueError(f"bad params {unknown}") ++ ++ @classmethod ++ def help(cls): ++ print("RecordingPostprocessor") ++ ++ def process(self, data, results, label_mapping): ++ values = tuple(str(x) for x in np.reshape(data, -1).tolist()) ++ reverse = {v: k for k, v in label_mapping.items()} ++ output = { ++ "pred": [reverse[x] for x in results["pred"]], ++ "postprocess_call_index": len(self.calls) + 1, ++ "data_seen": list(values), ++ "model_call_index": results["model_call_index"], ++ "model_verbose": results["verbose"], ++ "model_batch_size": results["batch_size"], ++ } ++ if "conf" in results: ++ output["conf"] = results["conf"] ++ self.calls.append( ++ { ++ "data": values, ++ "results": results, ++ "label_mapping": dict(label_mapping), ++ "output": dict(output), ++ } ++ ) ++ return output ++ ++ ++def make_labeler(preprocessor=None, model=None, postprocessor=None): ++ return dp.DataLabeler.load_with_components( ++ preprocessor or RecordingPreprocessor(), ++ model or RecordingModel(), ++ postprocessor or RecordingPostprocessor(), ++ ) ++ ++ ++def test_predict_runs_pipeline_and_returns_postprocessor_dictionary(): ++ ++ ++ ++ ++ labeler = make_labeler() ++ ++ assert labeler.preprocessor.calls == [] ++ assert labeler.model.calls == [] ++ assert labeler.postprocessor.calls == [] ++ ++ first_result = labeler.predict(["abc", "def"]) ++ assert first_result == { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["abc", "def"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ } ++ assert labeler.preprocessor.calls == [ ++ {"data": ("abc", "def"), "batch_size": 32} ++ ] ++ assert labeler.model.calls == [ ++ { ++ "samples": [ ++ { ++ "values": ("abc", "def"), ++ "batch_size": 32, ++ "call_index": 1, ++ } ++ ], ++ "batch_size": 32, ++ "show_confidences": False, ++ "verbose": True, ++ } ++ ] ++ assert labeler.postprocessor.calls == [ ++ { ++ "data": ("abc", "def"), ++ "results": { ++ "pred": [1, 2], ++ "model_call_index": 1, ++ "verbose": True, ++ "batch_size": 32, ++ }, ++ "label_mapping": {"A": 1, "B": 2}, ++ "output": { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["abc", "def"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ }, ++ } ++ ] ++ ++ ++def test_predict_threads_batch_options_and_evolves_component_state(): ++ ++ ++ ++ ++ labeler = make_labeler() ++ ++ first_result = labeler.predict(["abc", "def"]) ++ second_result = labeler.predict( ++ ["abc"], ++ batch_size=8, ++ predict_options={"show_confidences": True}, ++ verbose=False, ++ ) ++ ++ assert first_result == { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["abc", "def"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ } ++ assert second_result == { ++ "pred": ["B", "A"], ++ "postprocess_call_index": 2, ++ "data_seen": ["abc"], ++ "model_call_index": 2, ++ "model_verbose": False, ++ "model_batch_size": 8, ++ "conf": [0.25, 0.75], ++ } ++ assert labeler.preprocessor.calls == [ ++ {"data": ("abc", "def"), "batch_size": 32}, ++ {"data": ("abc",), "batch_size": 8}, ++ ] ++ assert labeler.model.calls == [ ++ { ++ "samples": [ ++ { ++ "values": ("abc", "def"), ++ "batch_size": 32, ++ "call_index": 1, ++ } ++ ], ++ "batch_size": 32, ++ "show_confidences": False, ++ "verbose": True, ++ }, ++ { ++ "samples": [ ++ {"values": ("abc",), "batch_size": 8, "call_index": 2} ++ ], ++ "batch_size": 8, ++ "show_confidences": True, ++ "verbose": False, ++ }, ++ ] ++ ++ ++@pytest.mark.parametrize( ++ ("data", "expected"), ++ [ ++ ( ++ ["abc", "def"], ++ { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["abc", "def"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ }, ++ ), ++ ( ++ np.array(["ghi", "jkl"], dtype=object), ++ { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["ghi", "jkl"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ }, ++ ), ++ ( ++ pd.Series(["mno", "pqr"], dtype=object), ++ { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["mno", "pqr"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ }, ++ ), ++ ( ++ pd.DataFrame({"col": ["stu", "vwx"]}), ++ { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["stu", "vwx"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ }, ++ ), ++ ( ++ dp.Data(data=pd.DataFrame({"col": ["yz", "12"]}), data_type="csv"), ++ { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["yz", "12"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ }, ++ ), ++ ], ++) ++def test_predict_accepts_all_query_input_shapes(data, expected): ++ ++ ++ ++ ++ labeler = make_labeler() ++ ++ assert labeler.predict(data) == expected ++ ++ ++def test_predict_rejects_plain_string_input_with_type_error(): ++ ++ ++ ++ ++ labeler = make_labeler() ++ ++ ++ with pytest.raises(TypeError): ++ labeler.predict("abc") ++ ++ assert labeler.preprocessor.calls == [] ++ assert labeler.model.calls == [] ++ assert labeler.postprocessor.calls == [] ++ ++ ++def test_base_data_labeler_load_with_components_predicts_when_configured(): ++ ++ ++ ++ ++ labeler = BaseDataLabeler.load_with_components( ++ RecordingPreprocessor(), ++ RecordingModel(), ++ RecordingPostprocessor(), ++ ) ++ ++ ++ assert labeler.predict(["abc", "def"]) == { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["abc", "def"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ } ++ ++ ++def test_pipeline_mismatch_warns_and_continues_by_default(): ++ ++ ++ ++ ++ labeler = make_labeler( ++ RecordingPreprocessor(shared="pre"), ++ RecordingModel(parameters={"shared": "model"}), ++ RecordingPostprocessor(shared="post"), ++ ) ++ ++ with warnings.catch_warnings(record=True) as caught: ++ warnings.simplefilter("always") ++ result = labeler.predict(["abc", "def"]) ++ ++ assert result == { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["abc", "def"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ } ++ ++ assert any(isinstance(w.message, RuntimeWarning) for w in caught) ++ ++ ++def test_pipeline_mismatch_raises_runtime_error_when_requested(): ++ ++ ++ ++ ++ labeler = make_labeler( ++ RecordingPreprocessor(shared="pre"), ++ RecordingModel(parameters={"shared": "model"}), ++ RecordingPostprocessor(shared="post"), ++ ) ++ ++ ++ with pytest.raises(RuntimeError): ++ labeler.predict(["abc", "def"], error_on_mismatch=True) ++ ++ ++ assert labeler.model.calls == [] ++ assert labeler.postprocessor.calls == [] ++ ++ ++def test_two_labeler_instances_keep_independent_component_state(): ++ ++ ++ ++ ++ a = make_labeler() ++ b = make_labeler() ++ ++ assert a.predict(["left", "right"]) == { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["left", "right"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ } ++ assert a.predict( ++ ["left"], ++ batch_size=8, ++ predict_options={"show_confidences": True}, ++ verbose=False, ++ ) == { ++ "pred": ["B", "A"], ++ "postprocess_call_index": 2, ++ "data_seen": ["left"], ++ "model_call_index": 2, ++ "model_verbose": False, ++ "model_batch_size": 8, ++ "conf": [0.25, 0.75], ++ } ++ assert b.predict(["solo", "other"]) == { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["solo", "other"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ } ++ ++ assert a.preprocessor.calls == [ ++ {"data": ("left", "right"), "batch_size": 32}, ++ {"data": ("left",), "batch_size": 8}, ++ ] ++ assert b.preprocessor.calls == [ ++ {"data": ("solo", "other"), "batch_size": 32} ++ ] ++ assert a.postprocessor.calls[1]["output"] == { ++ "pred": ["B", "A"], ++ "postprocess_call_index": 2, ++ "data_seen": ["left"], ++ "model_call_index": 2, ++ "model_verbose": False, ++ "model_batch_size": 8, ++ "conf": [0.25, 0.75], ++ } ++ assert b.postprocessor.calls[0]["output"] == { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["solo", "other"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ } ++ ++ ++def test_construct_predict_discard_cycles_return_postprocessor_output(): ++ ++ ++ ++ ++ ++ ++ for _ in range(10): ++ labeler = make_labeler() ++ assert labeler.predict(["abc", "def"]) == { ++ "pred": ["A", "B"], ++ "postprocess_call_index": 1, ++ "data_seen": ["abc", "def"], ++ "model_call_index": 1, ++ "model_verbose": True, ++ "model_batch_size": 32, ++ } ++ del labeler +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++ ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export AWS_EC2_METADATA_DISABLED=true ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_data_labeler_predict_pipeline.py -v diff --git a/tasks/format-code-task-000624/tests/test.sh b/tasks/format-code-task-000624/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..82b1a50fe24c4225fb7f5d05dd74c432537291d1 --- /dev/null +++ b/tasks/format-code-task-000624/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_data_labeler_predict_pipeline.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-000624/tests/test_command.sh b/tasks/format-code-task-000624/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000624/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-000641/environment/Dockerfile b/tasks/format-code-task-000641/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..faa24fc4ada2121b93f3d2c829f809c383661e7d --- /dev/null +++ b/tasks/format-code-task-000641/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e916c0668386c7f393f665e9f01f2fdd714debdb61801b590f10dbfba372eea4 diff --git a/tasks/format-code-task-000641/environment/setup/files/blocklist b/tasks/format-code-task-000641/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000641/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000641/environment/setup/setup.sh b/tasks/format-code-task-000641/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000641/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000641/tests/test.patch b/tasks/format-code-task-000641/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1bb949553ffe67075acc7ac47e81eee8de17da05 --- /dev/null +++ b/tasks/format-code-task-000641/tests/test.patch @@ -0,0 +1,206 @@ +diff --git a/libcentrifugo/engineredis_concurrency_test.go b/libcentrifugo/engineredis_concurrency_test.go +new file mode 100644 +index 00000000..68ba90e2 +--- /dev/null ++++ b/libcentrifugo/engineredis_concurrency_test.go +@@ -0,0 +1,161 @@ ++package libcentrifugo ++ ++import ( ++ "fmt" ++ "sync" ++ "testing" ++ ++ "github.com/centrifugal/centrifugo/Godeps/_workspace/src/github.com/stretchr/testify/assert" ++) ++ ++ ++func startConcurrencyEngine(t *testing.T) *RedisEngine { ++ app := testApp() ++ e := testRedisEngine(app) ++ assert.Equal(t, nil, e.run()) ++ app.SetEngine(e) ++ return e ++} ++ ++ ++ ++ ++func TestRedisEngineConcurrentSubscribe(t *testing.T) { ++ c := dial() ++ defer c.close() ++ e := startConcurrencyEngine(t) ++ ++ const n = 100 ++ chans := make([]ChannelID, n) ++ for i := 0; i < n; i++ { ++ chans[i] = ChannelID(fmt.Sprintf("concurrent-sub-%d", i)) ++ } ++ ++ subErrs := make([]error, n) ++ var wg sync.WaitGroup ++ for i := 0; i < n; i++ { ++ wg.Add(1) ++ go func(i int) { ++ defer wg.Done() ++ subErrs[i] = e.subscribe(chans[i]) ++ }(i) ++ } ++ wg.Wait() ++ ++ for i := 0; i < n; i++ { ++ assert.Nil(t, subErrs[i], "subscribe should not error") ++ } ++ ++ ++ for i := 0; i < n; i++ { ++ hasSubscribers, err := e.publish(chans[i], []byte("{}")) ++ assert.Equal(t, nil, err) ++ assert.True(t, hasSubscribers, "channel must have active subscriber after subscribe") ++ } ++ ++ ++ unsubErrs := make([]error, n) ++ for i := 0; i < n; i++ { ++ wg.Add(1) ++ go func(i int) { ++ defer wg.Done() ++ unsubErrs[i] = e.unsubscribe(chans[i]) ++ }(i) ++ } ++ wg.Wait() ++ ++ for i := 0; i < n; i++ { ++ assert.Nil(t, unsubErrs[i], "unsubscribe should not error") ++ } ++ ++ for i := 0; i < n; i++ { ++ hasSubscribers, err := e.publish(chans[i], []byte("{}")) ++ assert.Equal(t, nil, err) ++ assert.False(t, hasSubscribers, "channel must have no subscribers after unsubscribe") ++ } ++} ++ ++ ++ ++ ++func TestRedisEngineConcurrentMixed(t *testing.T) { ++ c := dial() ++ defer c.close() ++ e := startConcurrencyEngine(t) ++ ++ const n = 60 ++ chans := make([]ChannelID, n) ++ for i := 0; i < n; i++ { ++ chans[i] = ChannelID(fmt.Sprintf("concurrent-mixed-%d", i)) ++ } ++ ++ var wg sync.WaitGroup ++ errs := make([]error, n) ++ for i := 0; i < n; i++ { ++ wg.Add(1) ++ ++ go func(i int) { ++ defer wg.Done() ++ if err := e.subscribe(chans[i]); err != nil { ++ errs[i] = err ++ return ++ } ++ if i%2 == 1 { ++ errs[i] = e.unsubscribe(chans[i]) ++ } ++ }(i) ++ } ++ wg.Wait() ++ ++ for i := 0; i < n; i++ { ++ assert.Nil(t, errs[i]) ++ } ++ ++ for i := 0; i < n; i++ { ++ hasSubscribers, err := e.publish(chans[i], []byte("{}")) ++ assert.Equal(t, nil, err) ++ if i%2 == 0 { ++ assert.True(t, hasSubscribers, "even channels remain subscribed") ++ } else { ++ assert.False(t, hasSubscribers, "odd channels were unsubscribed") ++ } ++ } ++} ++ ++ ++ ++ ++func TestRedisEngineConcurrentSameChannel(t *testing.T) { ++ c := dial() ++ defer c.close() ++ e := startConcurrencyEngine(t) ++ ++ chID := ChannelID("concurrent-same-channel") ++ ++ const n = 50 ++ errs := make([]error, n) ++ var wg sync.WaitGroup ++ for i := 0; i < n; i++ { ++ wg.Add(1) ++ go func(i int) { ++ defer wg.Done() ++ errs[i] = e.subscribe(chID) ++ }(i) ++ } ++ wg.Wait() ++ ++ for i := 0; i < n; i++ { ++ assert.Nil(t, errs[i]) ++ } ++ ++ hasSubscribers, err := e.publish(chID, []byte("{}")) ++ assert.Equal(t, nil, err) ++ assert.True(t, hasSubscribers) ++ ++ ++ assert.Nil(t, e.unsubscribe(chID)) ++ ++ hasSubscribers, err = e.publish(chID, []byte("{}")) ++ assert.Equal(t, nil, err) ++ assert.False(t, hasSubscribers) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,34 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++export GO111MODULE=off ++PKG_DIR="/root/go/src/github.com/centrifugal/centrifugo/libcentrifugo" ++ ++ ++if ! redis-cli ping >/dev/null 2>&1; then ++ redis-server --daemonize yes --save "" --appendonly no >/tmp/redis-grading.log 2>&1 ++ for _ in $(seq 1 30); do ++ redis-cli ping >/dev/null 2>&1 && break ++ sleep 0.2 ++ done ++fi ++redis-cli -n 9 flushdb >/dev/null 2>&1 || true ++ ++cd "$PKG_DIR" ++ ++ ++go test -run 'TestRedisEngine$' -count=1 -v ++ ++redis-cli -n 9 flushdb >/dev/null 2>&1 || true ++ ++ ++go test -run 'TestRedisEngineConcurrent' -count=1 -v diff --git a/tasks/format-code-task-000641/tests/test.sh b/tasks/format-code-task-000641/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..822f074a0b6d500bdc8577d84d2c783d5ecc0726 --- /dev/null +++ b/tasks/format-code-task-000641/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' +libcentrifugo/engineredis_concurrency_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-000641/tests/test_command.sh b/tasks/format-code-task-000641/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000641/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000646/environment/Dockerfile b/tasks/format-code-task-000646/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f412d43bce75c6594885bbff5993f16300d42d67 --- /dev/null +++ b/tasks/format-code-task-000646/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:98bfeb663013bef6113ff5e6e7d8dc537d0bb1c49a9b1b8819365effec436102 diff --git a/tasks/format-code-task-000646/environment/setup/files/blocklist b/tasks/format-code-task-000646/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000646/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000646/environment/setup/setup.sh b/tasks/format-code-task-000646/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000646/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000646/tests/test.patch b/tasks/format-code-task-000646/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..88a9cc869edc9a21186f8c68c50c0bde3e72cf00 --- /dev/null +++ b/tasks/format-code-task-000646/tests/test.patch @@ -0,0 +1,34 @@ +diff --git a/test/unit_tests/apps/regulations3k/js/permalinks-utils-spec.js b/test/unit_tests/apps/regulations3k/js/permalinks-utils-spec.js +index 02a159453b1..f893ecf208a 100644 +--- a/test/unit_tests/apps/regulations3k/js/permalinks-utils-spec.js ++++ b/test/unit_tests/apps/regulations3k/js/permalinks-utils-spec.js +@@ -203,6 +203,7 @@ describe( 'The Regs3K permalinks utils', () => { + expect( utils.getCommentMarker( '17-a-1-Interp-1' ) ).toEqual( '17(a)(1)-1' ); + expect( utils.getCommentMarker( '3-d-Interp-1' ) ).toEqual( '3(d)-1' ); + expect( utils.getCommentMarker( '3-c-2-Interp-1' ) ).toEqual( '3(c)(2)-1' ); ++ expect( utils.getCommentMarker( '1' ) ).toEqual(''); + } ); + + } ); +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+3R0WrCMBQG4F77FCHIvNhaG7UWCtteYFfC7mSStrHGpUlpogjOd1/sBhuDzRtl ++jP3fzSk9p+khf5RvpCoXQm+HwaXEXpokXfW+1u6ZJSM2iqfpJB0HMWNTFgckudhGn2ys4y0hQWuM +++2nuVP+Pij7yd8K6RWHqmusysqvz/eNU/uPJ5CN/dsx/MmVpQOLzrfC9f55/UZIu+FyUPd3URGp/ ++H0qRMJSVNq0IbdHKxlkyurti5IU4Ln0z8bM7svbfkXmP+OHC6KWsbgd7uhVtbqyg2ZIrK26oa7m2 ++S9PWNNvTp+h6Po/WdnffpxnNeS5UeDyFHvygr4+zB/9+5VyTDYfKFFytjO++NWeiEjvfbkRbcyX1 ++sw03Tiob2kYU3bF9ehi8L6SN38nvwivR++07BgAAAAAAAAAAAAAAAAAAAAC4lFcDmr9rACgAAA== +diff --git 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-000646/tests/test.sh b/tasks/format-code-task-000646/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f46e0f194fc76cf528f4909db4d0bd16bd57eb7 --- /dev/null +++ b/tasks/format-code-task-000646/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/unit_tests/apps/regulations3k/js/permalinks-utils-spec.js +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000646/tests/test_command.sh b/tasks/format-code-task-000646/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000646/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000670/environment/Dockerfile b/tasks/format-code-task-000670/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5ad0992e8a8fbd8aa7bee3bb9f1a5e8c96a9c0dd --- /dev/null +++ b/tasks/format-code-task-000670/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f1359b4b1e5a0c5961538151881bc38a9834cbff404ea3239e95a490bc76ed0e diff --git a/tasks/format-code-task-000670/environment/setup/files/blocklist b/tasks/format-code-task-000670/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000670/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000670/environment/setup/setup.sh b/tasks/format-code-task-000670/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000670/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000670/tests/test.patch b/tasks/format-code-task-000670/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d40a37ea3f93c4a359ff2a74c9146f94b0679b3f --- /dev/null +++ b/tasks/format-code-task-000670/tests/test.patch @@ -0,0 +1,321 @@ +diff --git a/usercase-test-coderl/test_guess_notes.py b/usercase-test-coderl/test_guess_notes.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_guess_notes.py +@@ -0,0 +1,293 @@ ++import pathlib ++ ++from pympress.document import Document, PdfPage ++ ++ ++def _pdf_string(text): ++ escaped = text.replace("\\", "\\\\").replace("(", "\\(").replace(")", "\\)") ++ return f"({escaped})" ++ ++ ++def _write_pdf(path, pages, labels=None): ++ ++ objects = [None, None] ++ page_object_ids = [] ++ ++ for width, height in pages: ++ content = b"q\n1 1 1 rg\n0 0 10 10 re f\nQ\n" ++ content_id = len(objects) + 1 ++ objects.append( ++ f"<< /Length {len(content)} >>\nstream\n".encode("ascii") ++ + content ++ + b"endstream" ++ ) ++ ++ page_id = len(objects) + 1 ++ objects.append( ++ f"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 {width:g} {height:g}] " ++ f"/Contents {content_id} 0 R /Resources << >> >>" ++ ) ++ page_object_ids.append(page_id) ++ ++ label_id = None ++ if labels: ++ label_id = len(objects) + 1 ++ nums = " ".join( ++ f"{page_index} << /P {_pdf_string(label)} >>" ++ for page_index, label in labels.items() ++ ) ++ objects.append(f"<< /Nums [ {nums} ] >>") ++ ++ objects[1] = ( ++ f"<< /Type /Pages /Count {len(page_object_ids)} /Kids [" ++ + " ".join(f"{page_id} 0 R" for page_id in page_object_ids) ++ + "] >>" ++ ) ++ objects[0] = ( ++ "<< /Type /Catalog /Pages 2 0 R" ++ + (f" /PageLabels {label_id} 0 R" if label_id else "") ++ + " >>" ++ ) ++ ++ pdf = bytearray(b"%PDF-1.4\n%\xe2\xe3\xcf\xd3\n") ++ offsets = [] ++ for object_id, obj in enumerate(objects, start=1): ++ offsets.append(len(pdf)) ++ if isinstance(obj, str): ++ obj = obj.encode("utf-8") ++ pdf += f"{object_id} 0 obj\n".encode("ascii") + obj + b"\nendobj\n" ++ ++ xref_offset = len(pdf) ++ pdf += f"xref\n0 {len(objects) + 1}\n0000000000 65535 f \n".encode("ascii") ++ for offset in offsets: ++ pdf += f"{offset:010d} 00000 n \n".encode("ascii") ++ pdf += ( ++ f"trailer\n<< /Size {len(objects) + 1} /Root 1 0 R >>\n" ++ f"startxref\n{xref_offset}\n%%EOF\n" ++ ).encode("ascii") ++ ++ pathlib.Path(path).write_bytes(pdf) ++ ++ ++def _document(tmp_path, filename, pages, labels=None): ++ path = tmp_path / filename ++ _write_pdf(path, pages, labels) ++ return Document.create(None, path.as_uri()) ++ ++ ++def _notes_mapping_snapshot(doc): ++ if doc.notes_mapping is None: ++ return None ++ return list(doc.notes_mapping) ++ ++ ++def test_notes_prefix_label_selects_mapping_mode_without_mutating_state(tmp_path): ++ ++ ++ ++ doc = _document( ++ tmp_path, ++ "labels-map.pdf", ++ [(100, 100), (100, 100)], ++ labels={0: "slide", 1: "notes:"}, ++ ) ++ ++ assert doc.nb_pages == 2 ++ assert doc.pages_number() == 2 ++ assert doc.page_labels == ["slide", "notes:"] ++ assert doc.notes_mapping is None ++ ++ before_mapping = _notes_mapping_snapshot(doc) ++ assert doc.guess_notes("left", "top", 0) is PdfPage.MAP ++ ++ assert _notes_mapping_snapshot(doc) == before_mapping ++ ++ ++def test_unrenderable_or_unresolved_current_page_returns_none(tmp_path): ++ ++ ++ ++ empty_doc = Document.create(None, None) ++ assert empty_doc.pages_number() == 0 ++ assert empty_doc.page_labels == [] ++ assert empty_doc.notes_mapping is None ++ empty_mapping = _notes_mapping_snapshot(empty_doc) ++ assert empty_doc.guess_notes("left", "top", 0) is PdfPage.NONE ++ ++ assert _notes_mapping_snapshot(empty_doc) == empty_mapping ++ ++ doc = _document(tmp_path, "ordinary-one-page.pdf", [(160, 90)]) ++ assert doc.nb_pages == 1 ++ assert doc.pages_number() == 1 ++ assert doc.page_labels == ["1"] ++ assert doc.notes_mapping is None ++ before_mapping = _notes_mapping_snapshot(doc) ++ assert doc.guess_notes("left", "top", 99) is PdfPage.NONE ++ ++ assert _notes_mapping_snapshot(doc) == before_mapping ++ ++ ++def test_even_document_with_two_uniform_aspect_ratio_halves_selects_after(tmp_path): ++ ++ ++ ++ doc = _document( ++ tmp_path, ++ "libreoffice-after.pdf", ++ [(160, 90), (160, 90), (100, 100), (100, 100)], ++ ) ++ ++ assert doc.nb_pages == 4 ++ assert doc.pages_number() == 4 ++ assert doc.page_labels == ["1", "2", "3", "4"] ++ assert doc.notes_mapping is None ++ assert round(doc.page(0).get_aspect_ratio(), 12) == 1.777777777778 ++ assert round(doc.page(2).get_aspect_ratio(), 12) == 1.0 ++ ++ before_mapping = _notes_mapping_snapshot(doc) ++ assert doc.guess_notes("left", "top", 0) is PdfPage.AFTER ++ ++ assert _notes_mapping_snapshot(doc) == before_mapping ++ ++ ++def test_wide_current_page_uses_horizontal_preference_and_right_fallback(tmp_path): ++ ++ ++ ++ doc = _document(tmp_path, "wide-side-notes.pdf", [(200, 100)]) ++ ++ assert doc.nb_pages == 1 ++ assert doc.pages_number() == 1 ++ assert doc.page_labels == ["1"] ++ assert doc.notes_mapping is None ++ assert doc.page(0).get_aspect_ratio() == 2.0 ++ ++ before_mapping = _notes_mapping_snapshot(doc) ++ assert doc.guess_notes("LeFt", "top", 0) is PdfPage.LEFT ++ ++ assert _notes_mapping_snapshot(doc) == before_mapping ++ ++ assert doc.guess_notes("sideways", "top", 0) is PdfPage.RIGHT ++ ++ assert _notes_mapping_snapshot(doc) == before_mapping ++ ++ ++def test_paper_ratios_are_not_detected_as_vertical_notes(tmp_path): ++ ++ ++ ++ letter = _document(tmp_path, "letter.pdf", [(85, 110)]) ++ iso = _document(tmp_path, "iso.pdf", [(100, 141.4213562373095)]) ++ ++ assert letter.nb_pages == 1 ++ assert letter.page_labels == ["1"] ++ assert letter.notes_mapping is None ++ letter_mapping = _notes_mapping_snapshot(letter) ++ assert letter.guess_notes("left", "top", 0) is PdfPage.NONE ++ ++ assert _notes_mapping_snapshot(letter) == letter_mapping ++ ++ assert iso.nb_pages == 1 ++ assert iso.page_labels == ["1"] ++ assert iso.notes_mapping is None ++ iso_mapping = _notes_mapping_snapshot(iso) ++ assert iso.guess_notes("left", "top", 0) is PdfPage.NONE ++ ++ assert _notes_mapping_snapshot(iso) == iso_mapping ++ ++ ++def test_tall_current_page_uses_vertical_preference_and_bottom_fallback(tmp_path): ++ ++ ++ ++ doc = _document(tmp_path, "tall-bottom-notes.pdf", [(70, 100)]) ++ ++ assert doc.nb_pages == 1 ++ assert doc.pages_number() == 1 ++ assert doc.page_labels == ["1"] ++ assert doc.notes_mapping is None ++ assert doc.page(0).get_aspect_ratio() == 0.7 ++ ++ before_mapping = _notes_mapping_snapshot(doc) ++ assert doc.guess_notes("left", "tOp", 0) is PdfPage.TOP ++ ++ assert _notes_mapping_snapshot(doc) == before_mapping ++ ++ assert doc.guess_notes("left", "upward", 0) is PdfPage.BOTTOM ++ ++ assert _notes_mapping_snapshot(doc) == before_mapping ++ ++ ++def test_ordinary_slide_ratio_returns_none(tmp_path): ++ ++ ++ ++ doc = _document(tmp_path, "ordinary-slide.pdf", [(160, 90)]) ++ ++ assert doc.nb_pages == 1 ++ assert doc.pages_number() == 1 ++ assert doc.page_labels == ["1"] ++ assert doc.notes_mapping is None ++ assert round(doc.page(0).get_aspect_ratio(), 12) == 1.777777777778 ++ ++ before_mapping = _notes_mapping_snapshot(doc) ++ assert doc.guess_notes("left", "top", 0) is PdfPage.NONE ++ ++ assert _notes_mapping_snapshot(doc) == before_mapping ++ ++ ++def test_existing_notes_mapping_is_preserved(tmp_path): ++ ++ ++ ++ doc = _document(tmp_path, "mapped-odd-document.pdf", [(160, 90), (160, 90), (160, 90)]) ++ ++ before_mapping = _notes_mapping_snapshot(doc) ++ assert doc.guess_notes("left", "top", 0) is PdfPage.NONE ++ ++ assert _notes_mapping_snapshot(doc) == before_mapping ++ ++ doc.set_notes_pos(PdfPage.ODD.direction()) ++ existing_mapping = _notes_mapping_snapshot(doc) ++ ++ assert existing_mapping ++ ++ assert doc.guess_notes("left", "top", 0) is PdfPage.NONE ++ ++ assert _notes_mapping_snapshot(doc) == existing_mapping ++ ++ ++def test_guess_notes_state_is_independent_between_document_instances(tmp_path): ++ ++ ++ ++ mapped = _document(tmp_path, "first.pdf", [(160, 90), (160, 90), (160, 90)]) ++ tall = _document(tmp_path, "second.pdf", [(70, 100)]) ++ ++ mapped.set_notes_pos(PdfPage.ODD.direction()) ++ mapped_mapping = _notes_mapping_snapshot(mapped) ++ assert mapped.guess_notes("left", "top", 0) is PdfPage.NONE ++ ++ assert _notes_mapping_snapshot(mapped) == mapped_mapping ++ ++ tall_mapping = _notes_mapping_snapshot(tall) ++ assert tall.guess_notes("left", "top", 0) is PdfPage.TOP ++ ++ assert _notes_mapping_snapshot(tall) == tall_mapping ++ ++ ++def test_repeated_public_document_sessions_keep_guessing_wide_pages(tmp_path): ++ ++ ++ ++ pdf_path = tmp_path / "fd-floor.pdf" ++ _write_pdf(pdf_path, [(200, 100)]) ++ uri = pdf_path.as_uri() ++ ++ for _ in range(120): ++ doc = Document.create(None, uri) ++ assert doc.nb_pages == 1 ++ before_mapping = _notes_mapping_snapshot(doc) ++ assert doc.guess_notes("left", "top", 0) is PdfPage.LEFT ++ ++ assert _notes_mapping_snapshot(doc) == before_mapping +diff --git 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 python3 -m pytest /workspace/repo/usercase-test-coderl/test_guess_notes.py -v diff --git a/tasks/format-code-task-000670/tests/test.sh b/tasks/format-code-task-000670/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3db3a1113412999be733c8a3a207ba6cbd49ff85 --- /dev/null +++ b/tasks/format-code-task-000670/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_guess_notes.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-000670/tests/test_command.sh b/tasks/format-code-task-000670/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000670/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-000677/environment/Dockerfile b/tasks/format-code-task-000677/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e2476f94facb733219291a21fa5aae0e675da013 --- /dev/null +++ b/tasks/format-code-task-000677/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2f21ea0c74e39623a76fd9afb9cd8fab1149fbc1ef770a96e2c98e78af7c70ef diff --git a/tasks/format-code-task-000677/environment/setup/files/blocklist b/tasks/format-code-task-000677/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000677/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000677/environment/setup/setup.sh b/tasks/format-code-task-000677/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000677/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000677/tests/test.patch b/tasks/format-code-task-000677/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4b072be5952d9992da237eb1731801708fdcb2ac --- /dev/null +++ b/tasks/format-code-task-000677/tests/test.patch @@ -0,0 +1,203 @@ +diff --git a/usercase-test-coderl/locale-routes.test.js b/usercase-test-coderl/locale-routes.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/locale-routes.test.js +@@ -0,0 +1,166 @@ ++import { execFileSync } from "node:child_process"; ++import fs from "node:fs"; ++import http from "node:http"; ++import https from "node:https"; ++import net from "node:net"; ++import os from "node:os"; ++import path from "node:path"; ++import { afterEach, describe, expect, test, vi } from "vitest"; ++import { getRoutesForLang } from "../website/src/_utils/localeLinks.js"; ++ ++ ++ ++ ++const modulePath = "/workspace/repo/website/src/_utils/localeLinks.js"; ++ ++afterEach(() => { ++ vi.restoreAllMocks(); ++}); ++ ++function expectRoutesUnordered(actual, expected) { ++ ++ expect(actual).toHaveLength(expected.length); ++ expect(actual).toEqual(expect.arrayContaining(expected)); ++} ++ ++function snapshotDirectory(root) { ++ const entries = []; ++ const walk = (dir) => { ++ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { ++ const absolute = path.join(dir, entry.name); ++ const relative = path.relative(root, absolute); ++ entries.push(`${relative}${entry.isDirectory() ? "/" : ""}`); ++ if (entry.isDirectory()) { ++ walk(absolute); ++ } ++ } ++ }; ++ walk(root); ++ return entries.sort(); ++} ++ ++describe("getRoutesForLang acceptance", () => { ++ test("english why page links to Spanish and Chinese equivalents", () => { ++ ++ ++ expect(getRoutesForLang("en", "why", false)).toEqual([ ++ { label: "en español", lang: "es", path: "/es/why.html" }, ++ { label: "中文", lang: "zh", path: "/zh/why.html" }, ++ ]); ++ }); ++ ++ test("spanish resources page links to English root and Chinese subdirectory", () => { ++ ++ ++ expect(getRoutesForLang("es", "resources", false)).toEqual([ ++ { label: "in english", lang: "en", path: "/resources.html" }, ++ { label: "中文", lang: "zh", path: "/zh/resources.html" }, ++ ]); ++ }); ++ ++ test("chinese how page links to English root and Spanish subdirectory", () => { ++ ++ ++ ++ expectRoutesUnordered(getRoutesForLang("zh", "how", false), [ ++ { label: "in english", lang: "en", path: "/how.html" }, ++ { label: "en español", lang: "es", path: "/es/how.html" }, ++ ]); ++ }); ++ ++ test("default isHomepage false preserves the requested page slug", () => { ++ ++ ++ ++ expectRoutesUnordered(getRoutesForLang("es", "why"), [ ++ { label: "in english", lang: "en", path: "/why.html" }, ++ { label: "中文", lang: "zh", path: "/zh/why.html" }, ++ ]); ++ }); ++ ++ test("homepage coercion treats an empty page as index for Chinese current page", () => { ++ ++ ++ ++ expectRoutesUnordered(getRoutesForLang("zh", "", true), [ ++ { label: "in english", lang: "en", path: "/index.html" }, ++ { label: "en español", lang: "es", path: "/es/index.html" }, ++ ]); ++ }); ++ ++ test("homepage coercion ignores a non-index slug when isHomepage is true", () => { ++ ++ ++ ++ expectRoutesUnordered(getRoutesForLang("en", "resources", true), [ ++ { label: "en español", lang: "es", path: "/es/index.html" }, ++ { label: "中文", lang: "zh", path: "/zh/index.html" }, ++ ]); ++ }); ++ ++ test("referential transparency returns the same value for the same inputs", () => { ++ expect(getRoutesForLang("en", "why", false)).toEqual( ++ getRoutesForLang("en", "why", false), ++ ); ++ }); ++ ++ test("does not mutate caller-provided argument values", () => { ++ const args = ["zh", "", true]; ++ const before = structuredClone(args); ++ getRoutesForLang(...args); ++ expect(args).toEqual(before); ++ }); ++ ++ test("fresh Node process returns the same value for identical inputs", () => { ++ const inProcess = getRoutesForLang("es", "resources", false); ++ const script = ` ++ import { getRoutesForLang } from ${JSON.stringify(modulePath)}; ++ process.stdout.write(JSON.stringify(getRoutesForLang("es", "resources", false))); ++ `; ++ const freshProcess = JSON.parse( ++ execFileSync(process.execPath, ["--input-type=module", "-e", script], { ++ encoding: "utf8", ++ }), ++ ); ++ expect(freshProcess).toEqual(inProcess); ++ }); ++ ++ test("does not write files in cwd or use common network APIs", () => { ++ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "locale-routes-")); ++ const previousCwd = process.cwd(); ++ const networkError = () => { ++ throw new Error("network side effect"); ++ }; ++ const writeError = () => { ++ throw new Error("filesystem write side effect"); ++ }; ++ const originalOpenSync = fs.openSync; ++ ++ vi.spyOn(fs, "writeFileSync").mockImplementation(writeError); ++ vi.spyOn(fs, "appendFileSync").mockImplementation(writeError); ++ vi.spyOn(fs, "createWriteStream").mockImplementation(writeError); ++ vi.spyOn(fs, "openSync").mockImplementation((target, flags, mode) => { ++ if (String(flags).match(/[wa+]/)) { ++ writeError(); ++ } ++ return originalOpenSync(target, flags, mode); ++ }); ++ vi.spyOn(net.Socket.prototype, "connect").mockImplementation(networkError); ++ vi.spyOn(http, "request").mockImplementation(networkError); ++ vi.spyOn(https, "request").mockImplementation(networkError); ++ vi.spyOn(globalThis, "fetch").mockImplementation(networkError); ++ ++ try { ++ process.chdir(tempDir); ++ const before = snapshotDirectory(tempDir); ++ expect(getRoutesForLang("en", "why", false)).toEqual([ ++ { label: "en español", lang: "es", path: "/es/why.html" }, ++ { label: "中文", lang: "zh", path: "/zh/why.html" }, ++ ]); ++ expect(snapshotDirectory(tempDir)).toEqual(before); ++ } finally { ++ process.chdir(previousCwd); ++ 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,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 ++ ++export COREPACK_ENABLE_DOWNLOAD_PROMPT=0 ++export YARN_ENABLE_NETWORK=0 ++export npm_config_audit=false ++export npm_config_fund=false ++export npm_config_offline=true ++ ++VITEST_BIN=/workspace/repo/website/node_modules/.bin/vitest ++ ++if [ ! -x "$VITEST_BIN" ] || [ ! -f /workspace/repo/website/node_modules/vitest/dist/cli.js ]; then ++ echo "Offline test dependencies are missing; website/node_modules must be preinstalled before this script runs." >&2 ++ exit 127 ++fi ++ ++exec "$VITEST_BIN" run /workspace/repo/usercase-test-coderl/locale-routes.test.js --root /workspace/repo --environment node diff --git a/tasks/format-code-task-000677/tests/test.sh b/tasks/format-code-task-000677/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f7a1782f038f273f41e5ed3b84601fc6d957e04f --- /dev/null +++ b/tasks/format-code-task-000677/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/locale-routes.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-000677/tests/test_command.sh b/tasks/format-code-task-000677/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000677/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-000679/environment/Dockerfile b/tasks/format-code-task-000679/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1304ac14a6840880c717730d4316bc01b8b3ee0b --- /dev/null +++ b/tasks/format-code-task-000679/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:981bd4c9883cc7ebf20f51ed8603d965944b2d9e1a264051021fdd2d7636c0be diff --git a/tasks/format-code-task-000679/environment/setup/files/blocklist b/tasks/format-code-task-000679/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000679/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000679/environment/setup/setup.sh b/tasks/format-code-task-000679/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000679/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000679/tests/test.patch b/tasks/format-code-task-000679/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b3edf44d79971cfd46a1721e92e3a8d48d2ed2ea --- /dev/null +++ b/tasks/format-code-task-000679/tests/test.patch @@ -0,0 +1,295 @@ +diff --git a/pkg/cmd/release/create/create_test.go b/pkg/cmd/release/create/create_test.go +index a6f6a2d7a..7447519a3 100644 +--- a/pkg/cmd/release/create/create_test.go ++++ b/pkg/cmd/release/create/create_test.go +@@ -13,6 +13,7 @@ import ( + + "github.com/cli/cli/v2/internal/config" + "github.com/cli/cli/v2/internal/ghrepo" ++ "github.com/cli/cli/v2/internal/run" + "github.com/cli/cli/v2/pkg/cmd/release/shared" + "github.com/cli/cli/v2/pkg/cmdutil" + "github.com/cli/cli/v2/pkg/httpmock" +@@ -662,3 +663,260 @@ func Test_createRun_interactive(t *testing.T) { + }) + } + } ++ ++ ++ ++ ++ ++func Test_createRun_interactive_tagDescription(t *testing.T) { ++ tests := []struct { ++ name string ++ opts *CreateOptions ++ httpStubs func(*httpmock.Registry) ++ runStubs func(*run.CommandStubber) ++ askStubs func(*prompt.AskStubber) ++ wantEditorBody string ++ wantOut string ++ }{ ++ { ++ ++ ++ ++ name: "annotated tag with generated notes shows tag message option", ++ opts: &CreateOptions{TagName: "v1.2.3"}, ++ httpStubs: func(reg *httpmock.Registry) { ++ reg.Register(httpmock.REST("POST", "repos/OWNER/REPO/releases/generate-notes"), ++ httpmock.StatusStringResponse(200, `{ ++ "name": "generated name", ++ "body": "generated body" ++ }`)) ++ reg.Register(httpmock.REST("POST", "repos/OWNER/REPO/releases"), ++ httpmock.StatusStringResponse(201, `{ ++ "url": "https://api.github.com/releases/123", ++ "upload_url": "https://api.github.com/assets/upload", ++ "html_url": "https://github.com/OWNER/REPO/releases/tag/v1.2.3" ++ }`)) ++ }, ++ runStubs: func(rs *run.CommandStubber) { ++ ++ ++ ++ rs.Register(`git tag --list v1\.2\.3`, 0, "tag-subject\n\ntag-body") ++ }, ++ askStubs: func(as *prompt.AskStubber) { ++ as.StubPrompt("Title (optional)").AnswerDefault() ++ as.StubPrompt("Release notes"). ++ AssertOptions([]string{ ++ "Write my own", ++ "Write using generated notes as template", ++ "Write using git tag message as template", ++ "Leave blank", ++ }). ++ AnswerWith("Leave blank") ++ as.StubPrompt("Is this a prerelease?").AnswerWith(false) ++ as.StubPrompt("Submit?").AnswerWith("Publish release") ++ }, ++ wantOut: "https://github.com/OWNER/REPO/releases/tag/v1.2.3\n", ++ }, ++ { ++ ++ ++ ++ name: "lightweight tag with generated notes hides tag message option", ++ opts: &CreateOptions{TagName: "v1.2.3"}, ++ httpStubs: func(reg *httpmock.Registry) { ++ reg.Register(httpmock.REST("POST", "repos/OWNER/REPO/releases/generate-notes"), ++ httpmock.StatusStringResponse(200, `{ ++ "name": "generated name", ++ "body": "generated body" ++ }`)) ++ reg.Register(httpmock.REST("POST", "repos/OWNER/REPO/releases"), ++ httpmock.StatusStringResponse(201, `{ ++ "url": "https://api.github.com/releases/123", ++ "upload_url": "https://api.github.com/assets/upload", ++ "html_url": "https://github.com/OWNER/REPO/releases/tag/v1.2.3" ++ }`)) ++ }, ++ runStubs: func(rs *run.CommandStubber) { ++ ++ ++ ++ ++ rs.Register(`git tag --list v1\.2\.3`, 0, "") ++ }, ++ askStubs: func(as *prompt.AskStubber) { ++ as.StubPrompt("Title (optional)").AnswerDefault() ++ as.StubPrompt("Release notes"). ++ AssertOptions([]string{ ++ "Write my own", ++ "Write using generated notes as template", ++ "Leave blank", ++ }). ++ AnswerWith("Leave blank") ++ as.StubPrompt("Is this a prerelease?").AnswerWith(false) ++ as.StubPrompt("Submit?").AnswerWith("Publish release") ++ }, ++ wantOut: "https://github.com/OWNER/REPO/releases/tag/v1.2.3\n", ++ }, ++ { ++ ++ ++ ++ name: "tag description not fetched when --repo override is set", ++ opts: &CreateOptions{TagName: "v1.2.3", RepoOverride: "OWNER/REPO"}, ++ httpStubs: func(reg *httpmock.Registry) { ++ reg.Register(httpmock.REST("POST", "repos/OWNER/REPO/releases/generate-notes"), ++ httpmock.StatusStringResponse(200, `{ ++ "name": "generated name", ++ "body": "generated body" ++ }`)) ++ reg.Register(httpmock.REST("POST", "repos/OWNER/REPO/releases"), ++ httpmock.StatusStringResponse(201, `{ ++ "url": "https://api.github.com/releases/123", ++ "upload_url": "https://api.github.com/assets/upload", ++ "html_url": "https://github.com/OWNER/REPO/releases/tag/v1.2.3" ++ }`)) ++ }, ++ runStubs: func(rs *run.CommandStubber) { ++ ++ }, ++ askStubs: func(as *prompt.AskStubber) { ++ as.StubPrompt("Title (optional)").AnswerDefault() ++ as.StubPrompt("Release notes"). ++ AssertOptions([]string{ ++ "Write my own", ++ "Write using generated notes as template", ++ "Leave blank", ++ }). ++ AnswerWith("Leave blank") ++ as.StubPrompt("Is this a prerelease?").AnswerWith(false) ++ as.StubPrompt("Submit?").AnswerWith("Publish release") ++ }, ++ wantOut: "https://github.com/OWNER/REPO/releases/tag/v1.2.3\n", ++ }, ++ { ++ ++ ++ ++ ++ name: "selecting tag message template passes tag body to editor", ++ opts: &CreateOptions{TagName: "v1.2.3"}, ++ httpStubs: func(reg *httpmock.Registry) { ++ reg.Register(httpmock.REST("POST", "repos/OWNER/REPO/releases/generate-notes"), ++ httpmock.StatusStringResponse(200, `{ ++ "name": "generated name", ++ "body": "GENERATED-BODY-NOT-THIS-ONE" ++ }`)) ++ reg.Register(httpmock.REST("POST", "repos/OWNER/REPO/releases"), ++ httpmock.StatusStringResponse(201, `{ ++ "url": "https://api.github.com/releases/123", ++ "upload_url": "https://api.github.com/assets/upload", ++ "html_url": "https://github.com/OWNER/REPO/releases/tag/v1.2.3" ++ }`)) ++ }, ++ runStubs: func(rs *run.CommandStubber) { ++ rs.Register(`git tag --list v1\.2\.3`, 0, "MY-TAG-SUBJECT\n\nMY-TAG-BODY") ++ }, ++ askStubs: func(as *prompt.AskStubber) { ++ as.StubPrompt("Title (optional)").AnswerDefault() ++ as.StubPrompt("Release notes"). ++ AnswerWith("Write using git tag message as template") ++ as.StubPrompt("Is this a prerelease?").AnswerWith(false) ++ as.StubPrompt("Submit?").AnswerWith("Publish release") ++ }, ++ wantEditorBody: "MY-TAG-SUBJECT\n\nMY-TAG-BODY", ++ wantOut: "https://github.com/OWNER/REPO/releases/tag/v1.2.3\n", ++ }, ++ { ++ ++ ++ ++ ++ ++ name: "no generated notes API: annotated tag plus prev tag offers both options", ++ opts: &CreateOptions{TagName: "v1.2.3"}, ++ httpStubs: func(reg *httpmock.Registry) { ++ reg.Register(httpmock.REST("POST", "repos/OWNER/REPO/releases/generate-notes"), ++ httpmock.StatusStringResponse(404, `{}`)) ++ reg.Register(httpmock.REST("POST", "repos/OWNER/REPO/releases"), ++ httpmock.StatusStringResponse(201, `{ ++ "url": "https://api.github.com/releases/123", ++ "upload_url": "https://api.github.com/assets/upload", ++ "html_url": "https://github.com/OWNER/REPO/releases/tag/v1.2.3" ++ }`)) ++ }, ++ runStubs: func(rs *run.CommandStubber) { ++ rs.Register(`git tag --list v1\.2\.3`, 0, "tag-subject\n\ntag-body") ++ rs.Register(`git describe --tags --abbrev=0 v1\.2\.3\^`, 0, "v1.0.0\n") ++ rs.Register(`git -c log\.ShowSignature=false log`, 0, "feat: hello\x00") ++ }, ++ askStubs: func(as *prompt.AskStubber) { ++ as.StubPrompt("Title (optional)").AnswerWith("") ++ as.StubPrompt("Release notes"). ++ AssertOptions([]string{ ++ "Write my own", ++ "Write using commit log as template", ++ "Write using git tag message as template", ++ "Leave blank", ++ }). ++ AnswerWith("Leave blank") ++ as.StubPrompt("Is this a prerelease?").AnswerWith(false) ++ as.StubPrompt("Submit?").AnswerWith("Publish release") ++ }, ++ wantOut: "https://github.com/OWNER/REPO/releases/tag/v1.2.3\n", ++ }, ++ } ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ ios, _, stdout, stderr := iostreams.Test() ++ ios.SetStdoutTTY(true) ++ ios.SetStdinTTY(true) ++ ios.SetStderrTTY(true) ++ tt.opts.IO = ios ++ ++ reg := &httpmock.Registry{} ++ defer reg.Verify(t) ++ tt.httpStubs(reg) ++ tt.opts.HttpClient = func() (*http.Client, error) { ++ return &http.Client{Transport: reg}, nil ++ } ++ ++ tt.opts.BaseRepo = func() (ghrepo.Interface, error) { ++ return ghrepo.FromFullName("OWNER/REPO") ++ } ++ ++ tt.opts.Config = func() (config.Config, error) { ++ return config.NewBlankConfig(), nil ++ } ++ ++ var capturedEditorBody string ++ tt.opts.Edit = func(_, _, val string, _ io.Reader, _, _ io.Writer) (string, error) { ++ capturedEditorBody = val ++ return val, nil ++ } ++ ++ rs, restoreRun := run.Stub() ++ defer restoreRun(t) ++ if tt.runStubs != nil { ++ tt.runStubs(rs) ++ } ++ ++ //nolint:staticcheck // SA1019: prompt.InitAskStubber is deprecated: use NewAskStubber ++ as, teardown := prompt.InitAskStubber() ++ defer teardown() ++ if tt.askStubs != nil { ++ tt.askStubs(as) ++ } ++ ++ err := createRun(tt.opts) ++ require.NoError(t, err) ++ ++ assert.Equal(t, tt.wantOut, stdout.String()) ++ assert.Equal(t, "", stderr.String()) ++ ++ if tt.wantEditorBody != "" { ++ assert.Equal(t, tt.wantEditorBody, capturedEditorBody) ++ } ++ }) ++ } ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..c9bcea8d4 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./pkg/cmd/release/create/ -run Test_createRun_interactive_tagDescription -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test ./pkg/cmd/release/create/ -run Test_createRun_interactive_tagDescription -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000679/tests/test.sh b/tasks/format-code-task-000679/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b1405e540cce12a7ffc084a201a5a05f6a89391f --- /dev/null +++ b/tasks/format-code-task-000679/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +pkg/cmd/release/create/create_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-000679/tests/test_command.sh b/tasks/format-code-task-000679/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000679/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000683/environment/Dockerfile b/tasks/format-code-task-000683/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8c3c4a4493324fd9e964c99a6e2e4b5a2d367a27 --- /dev/null +++ b/tasks/format-code-task-000683/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e5596d132e87a4f0d7ee86858e17734e49140ce7c56f0de10dc0179bea486643 diff --git a/tasks/format-code-task-000683/environment/setup/files/blocklist b/tasks/format-code-task-000683/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000683/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000683/environment/setup/setup.sh b/tasks/format-code-task-000683/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000683/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000683/tests/test.patch b/tasks/format-code-task-000683/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..590ebb8c43a36f95dd5d86350a90eead40c9d4c5 --- /dev/null +++ b/tasks/format-code-task-000683/tests/test.patch @@ -0,0 +1,522 @@ +diff --git a/tests/data/placebo/test_delete_role/iam.CreateRole_1.json b/tests/data/placebo/test_delete_role/iam.CreateRole_1.json +new file mode 100644 +index 00000000000..07489b0e974 +--- /dev/null ++++ b/tests/data/placebo/test_delete_role/iam.CreateRole_1.json +@@ -0,0 +1,39 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Role": { ++ "Path": "/pratyush/", ++ "RoleName": "c7n-test-delete", ++ "RoleId": "AROA4WFP4XXCXKNGRNA2J", ++ "Arn": "arn:aws:iam::123456789:role/pratyush/c7n-test-delete", ++ "CreateDate": { ++ "__class__": "datetime", ++ "year": 2019, ++ "month": 4, ++ "day": 5, ++ "hour": 16, ++ "minute": 20, ++ "second": 6, ++ "microsecond": 0 ++ }, ++ "AssumeRolePolicyDocument": "%7B%22Version%22%3A%20%222012-10-17%22%2C%20%22Statement%22%3A%20%5B%7B%22Effect%22%3A%20%22Allow%22%2C%20%22Principal%22%3A%20%7B%22Service%22%3A%20%22ec2.amazonaws.com%22%7D%2C%20%22Action%22%3A%20%22sts%3AAssumeRole%22%7D%5D%7D", ++ "Tags": [ ++ { ++ "Key": "Name", ++ "Value": "pratyush" ++ } ++ ] ++ }, ++ "ResponseMetadata": { ++ "RequestId": "aca09b60-57be-11e9-9ff9-39d852a2d04e", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "aca09b60-57be-11e9-9ff9-39d852a2d04e", ++ "content-type": "text/xml", ++ "content-length": "921", ++ "date": "Fri, 05 Apr 2019 16:20:05 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_delete_role/iam.DeleteRole_1.json b/tests/data/placebo/test_delete_role/iam.DeleteRole_1.json +new file mode 100644 +index 00000000000..ae01db4620f +--- /dev/null ++++ b/tests/data/placebo/test_delete_role/iam.DeleteRole_1.json +@@ -0,0 +1,16 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "ResponseMetadata": { ++ "RequestId": "adc1e9f3-57be-11e9-9ff9-39d852a2d04e", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "adc1e9f3-57be-11e9-9ff9-39d852a2d04e", ++ "content-type": "text/xml", ++ "content-length": "200", ++ "date": "Fri, 05 Apr 2019 16:20:07 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_delete_role/iam.GetRole_1.json b/tests/data/placebo/test_delete_role/iam.GetRole_1.json +new file mode 100644 +index 00000000000..eb4ce514bbd +--- /dev/null ++++ b/tests/data/placebo/test_delete_role/iam.GetRole_1.json +@@ -0,0 +1,41 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Role": { ++ "Path": "/aws-service-role/support.amazonaws.com/", ++ "RoleName": "AWSServiceRoleForSupport", ++ "RoleId": "AROAJWGLHKEUYCDFCDPXG", ++ "Arn": "arn:aws:iam::123456789:role/aws-service-role/support.amazonaws.com/AWSServiceRoleForSupport", ++ "CreateDate": { ++ "__class__": "datetime", ++ "year": 2019, ++ "month": 1, ++ "day": 19, ++ "hour": 23, ++ "minute": 27, ++ "second": 57, ++ "microsecond": 0 ++ }, ++ "AssumeRolePolicyDocument": "%7B%22Version%22%3A%222012-10-17%22%2C%22Statement%22%3A%5B%7B%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22support.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D", ++ "Description": "Enables resource access for AWS to provide billing, administrative and support services", ++ "MaxSessionDuration": 3600, ++ "Tags": [ ++ { ++ "Key": "Name", ++ "Value": "CannotDelete" ++ } ++ ] ++ }, ++ "ResponseMetadata": { ++ "RequestId": "ad41bcc1-57be-11e9-9ff9-39d852a2d04e", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "ad41bcc1-57be-11e9-9ff9-39d852a2d04e", ++ "content-type": "text/xml", ++ "content-length": "1141", ++ "date": "Fri, 05 Apr 2019 16:20:06 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_delete_role/iam.GetRole_2.json b/tests/data/placebo/test_delete_role/iam.GetRole_2.json +new file mode 100644 +index 00000000000..7ca134f98d9 +--- /dev/null ++++ b/tests/data/placebo/test_delete_role/iam.GetRole_2.json +@@ -0,0 +1,40 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Role": { ++ "Path": "/pratyush/", ++ "RoleName": "c7n-test-delete", ++ "RoleId": "AROA4WFP4XXCXKNGRNA2J", ++ "Arn": "arn:aws:iam::123456789:role/pratyush/c7n-test-delete", ++ "CreateDate": { ++ "__class__": "datetime", ++ "year": 2019, ++ "month": 4, ++ "day": 5, ++ "hour": 16, ++ "minute": 20, ++ "second": 6, ++ "microsecond": 0 ++ }, ++ "AssumeRolePolicyDocument": "%7B%22Version%22%3A%222012-10-17%22%2C%22Statement%22%3A%5B%7B%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22ec2.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D", ++ "MaxSessionDuration": 3600, ++ "Tags": [ ++ { ++ "Key": "Name", ++ "Value": "pratyush" ++ } ++ ] ++ }, ++ "ResponseMetadata": { ++ "RequestId": "ad580459-57be-11e9-9ff9-39d852a2d04e", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "ad580459-57be-11e9-9ff9-39d852a2d04e", ++ "content-type": "text/xml", ++ "content-length": "934", ++ "date": "Fri, 05 Apr 2019 16:20:06 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_delete_role/iam.GetRole_3.json b/tests/data/placebo/test_delete_role/iam.GetRole_3.json +new file mode 100644 +index 00000000000..14bfc8184f5 +--- /dev/null ++++ b/tests/data/placebo/test_delete_role/iam.GetRole_3.json +@@ -0,0 +1,21 @@ ++{ ++ "status_code": 404, ++ "data": { ++ "Error": { ++ "Type": "Sender", ++ "Code": "NoSuchEntity", ++ "Message": "The role with name c7n-test-delete cannot be found." ++ }, ++ "ResponseMetadata": { ++ "RequestId": "add83096-57be-11e9-9ff9-39d852a2d04e", ++ "HTTPStatusCode": 404, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "add83096-57be-11e9-9ff9-39d852a2d04e", ++ "content-type": "text/xml", ++ "content-length": "295", ++ "date": "Fri, 05 Apr 2019 16:20:07 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_delete_role/iam.ListRoles_1.json b/tests/data/placebo/test_delete_role/iam.ListRoles_1.json +new file mode 100644 +index 00000000000..6525aa19de4 +--- /dev/null ++++ b/tests/data/placebo/test_delete_role/iam.ListRoles_1.json +@@ -0,0 +1,56 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Roles": [ ++ { ++ "Path": "/aws-service-role/support.amazonaws.com/", ++ "RoleName": "AWSServiceRoleForSupport", ++ "RoleId": "AROAJWGLHKEUYCDFCDPXG", ++ "Arn": "arn:aws:iam::123456789:role/aws-service-role/support.amazonaws.com/AWSServiceRoleForSupport", ++ "CreateDate": { ++ "__class__": "datetime", ++ "year": 2019, ++ "month": 1, ++ "day": 19, ++ "hour": 23, ++ "minute": 27, ++ "second": 57, ++ "microsecond": 0 ++ }, ++ "AssumeRolePolicyDocument": "%7B%22Version%22%3A%222012-10-17%22%2C%22Statement%22%3A%5B%7B%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22support.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D", ++ "Description": "Enables resource access for AWS to provide billing, administrative and support services", ++ "MaxSessionDuration": 3600 ++ }, ++ { ++ "Path": "/pratyush/", ++ "RoleName": "c7n-test-delete", ++ "RoleId": "AROA4WFP4XXCXKNGRNA2J", ++ "Arn": "arn:aws:iam::123456789:role/pratyush/c7n-test-delete", ++ "CreateDate": { ++ "__class__": "datetime", ++ "year": 2019, ++ "month": 4, ++ "day": 5, ++ "hour": 16, ++ "minute": 20, ++ "second": 6, ++ "microsecond": 0 ++ }, ++ "AssumeRolePolicyDocument": "%7B%22Version%22%3A%222012-10-17%22%2C%22Statement%22%3A%5B%7B%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22ec2.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D", ++ "MaxSessionDuration": 3600 ++ } ++ ], ++ "IsTruncated": false, ++ "ResponseMetadata": { ++ "RequestId": "acf9b7f1-57be-11e9-8cff-e94d12b1df40", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "acf9b7f1-57be-11e9-8cff-e94d12b1df40", ++ "content-type": "text/xml", ++ "content-length": "1712", ++ "date": "Fri, 05 Apr 2019 16:20:06 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_delete_role_error/iam.DeleteRole_1.json b/tests/data/placebo/test_delete_role_error/iam.DeleteRole_1.json +new file mode 100644 +index 00000000000..1c977a441ca +--- /dev/null ++++ b/tests/data/placebo/test_delete_role_error/iam.DeleteRole_1.json +@@ -0,0 +1,22 @@ ++{ ++ "status_code": 400, ++ "data": { ++ "Error": { ++ "Type": "Sender", ++ "Code": "UnmodifiableEntity", ++ "Message": "Cannot perform the operation on the protected role 'AWSServiceRoleForSupport' - this role is only modifiable by AWS" ++ }, ++ "ResponseMetadata": { ++ "RequestId": "c72034b3-57be-11e9-aaec-afc784271d41", ++ "HTTPStatusCode": 400, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "c72034b3-57be-11e9-aaec-afc784271d41", ++ "content-type": "text/xml", ++ "content-length": "365", ++ "date": "Fri, 05 Apr 2019 16:20:50 GMT", ++ "connection": "close" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_delete_role_error/iam.GetRole_1.json b/tests/data/placebo/test_delete_role_error/iam.GetRole_1.json +new file mode 100644 +index 00000000000..3842cffdca7 +--- /dev/null ++++ b/tests/data/placebo/test_delete_role_error/iam.GetRole_1.json +@@ -0,0 +1,41 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Role": { ++ "Path": "/aws-service-role/support.amazonaws.com/", ++ "RoleName": "AWSServiceRoleForSupport", ++ "RoleId": "AROAJWGLHKEUYCDFCDPXG", ++ "Arn": "arn:aws:iam::123456789:role/aws-service-role/support.amazonaws.com/AWSServiceRoleForSupport", ++ "CreateDate": { ++ "__class__": "datetime", ++ "year": 2019, ++ "month": 1, ++ "day": 19, ++ "hour": 23, ++ "minute": 27, ++ "second": 57, ++ "microsecond": 0 ++ }, ++ "AssumeRolePolicyDocument": "%7B%22Version%22%3A%222012-10-17%22%2C%22Statement%22%3A%5B%7B%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22support.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D", ++ "Description": "Enables resource access for AWS to provide billing, administrative and support services", ++ "MaxSessionDuration": 3600, ++ "Tags": [ ++ { ++ "Key": "Name", ++ "Value": "CannotDelete" ++ } ++ ] ++ }, ++ "ResponseMetadata": { ++ "RequestId": "c6cdf623-57be-11e9-b6e9-8730b231658b", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "c6cdf623-57be-11e9-b6e9-8730b231658b", ++ "content-type": "text/xml", ++ "content-length": "1141", ++ "date": "Fri, 05 Apr 2019 16:20:49 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_delete_role_error/iam.GetRole_2.json b/tests/data/placebo/test_delete_role_error/iam.GetRole_2.json +new file mode 100644 +index 00000000000..1773ac87f65 +--- /dev/null ++++ b/tests/data/placebo/test_delete_role_error/iam.GetRole_2.json +@@ -0,0 +1,41 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Role": { ++ "Path": "/aws-service-role/support.amazonaws.com/", ++ "RoleName": "AWSServiceRoleForSupport", ++ "RoleId": "AROAJWGLHKEUYCDFCDPXG", ++ "Arn": "arn:aws:iam::123456789:role/aws-service-role/support.amazonaws.com/AWSServiceRoleForSupport", ++ "CreateDate": { ++ "__class__": "datetime", ++ "year": 2019, ++ "month": 1, ++ "day": 19, ++ "hour": 23, ++ "minute": 27, ++ "second": 57, ++ "microsecond": 0 ++ }, ++ "AssumeRolePolicyDocument": "%7B%22Version%22%3A%222012-10-17%22%2C%22Statement%22%3A%5B%7B%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22support.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D", ++ "Description": "Enables resource access for AWS to provide billing, administrative and support services", ++ "MaxSessionDuration": 3600, ++ "Tags": [ ++ { ++ "Key": "Name", ++ "Value": "CannotDelete" ++ } ++ ] ++ }, ++ "ResponseMetadata": { ++ "RequestId": "c781b54b-57be-11e9-ae02-b77ac2ac5928", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "c781b54b-57be-11e9-ae02-b77ac2ac5928", ++ "content-type": "text/xml", ++ "content-length": "1141", ++ "date": "Fri, 05 Apr 2019 16:20:51 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/data/placebo/test_delete_role_error/iam.ListRoles_1.json b/tests/data/placebo/test_delete_role_error/iam.ListRoles_1.json +new file mode 100644 +index 00000000000..6905df50a0a +--- /dev/null ++++ b/tests/data/placebo/test_delete_role_error/iam.ListRoles_1.json +@@ -0,0 +1,38 @@ ++{ ++ "status_code": 200, ++ "data": { ++ "Roles": [ ++ { ++ "Path": "/aws-service-role/support.amazonaws.com/", ++ "RoleName": "AWSServiceRoleForSupport", ++ "RoleId": "AROAJWGLHKEUYCDFCDPXG", ++ "Arn": "arn:aws:iam::123456789:role/aws-service-role/support.amazonaws.com/AWSServiceRoleForSupport", ++ "CreateDate": { ++ "__class__": "datetime", ++ "year": 2019, ++ "month": 1, ++ "day": 19, ++ "hour": 23, ++ "minute": 27, ++ "second": 57, ++ "microsecond": 0 ++ }, ++ "AssumeRolePolicyDocument": "%7B%22Version%22%3A%222012-10-17%22%2C%22Statement%22%3A%5B%7B%22Effect%22%3A%22Allow%22%2C%22Principal%22%3A%7B%22Service%22%3A%22support.amazonaws.com%22%7D%2C%22Action%22%3A%22sts%3AAssumeRole%22%7D%5D%7D", ++ "Description": "Enables resource access for AWS to provide billing, administrative and support services", ++ "MaxSessionDuration": 3600 ++ } ++ ], ++ "IsTruncated": false, ++ "ResponseMetadata": { ++ "RequestId": "c665be34-57be-11e9-a38b-99de06aa243a", ++ "HTTPStatusCode": 200, ++ "HTTPHeaders": { ++ "x-amzn-requestid": "c665be34-57be-11e9-a38b-99de06aa243a", ++ "content-type": "text/xml", ++ "content-length": "1109", ++ "date": "Fri, 05 Apr 2019 16:20:48 GMT" ++ }, ++ "RetryAttempts": 0 ++ } ++ } ++} +\ No newline at end of file +diff --git a/tests/test_iam.py b/tests/test_iam.py +index a00cd612434..22a2814bbb7 100644 +--- a/tests/test_iam.py ++++ b/tests/test_iam.py +@@ -28,6 +28,7 @@ + from c7n.exceptions import PolicyValidationError + from c7n.filters.iamaccess import CrossAccountAccessFilter, PolicyChecker + from c7n.mu import LambdaManager, LambdaFunction, PythonPackageArchive ++from botocore.exceptions import ClientError + from c7n.resources.sns import SNS + from c7n.resources.iam import ( + UserMfaDevice, +@@ -1426,3 +1427,54 @@ def test_set_policy_detached(self): + + self.assertEqual(len(resources), 1) + self.assertIn('test-role-us-east-1', resources[0]['RoleName']) ++ ++ ++class DeleteRoleAction(BaseTest): ++ ++ @functional ++ def test_delete_role(self): ++ factory = self.replay_flight_data("test_delete_role") ++ policy_doc = json.dumps({ ++ "Version": "2012-10-17", ++ "Statement": [{ ++ "Effect": "Allow", ++ "Principal": { ++ "Service": "ec2.amazonaws.com" ++ }, ++ "Action": "sts:AssumeRole" ++ }] ++ }) ++ client = factory().client("iam") ++ client.create_role( ++ RoleName="c7n-test-delete", AssumeRolePolicyDocument=policy_doc, Path='/pratyush/', ++ Tags=[{'Key': 'Name', 'Value': 'pratyush'}]) ++ p = self.load_policy( ++ { ++ 'name': 'iam-attach-role-policy', ++ 'resource': 'iam-role', ++ 'filters': [{'tag:Name': 'pratyush'}], ++ "actions": ["delete"], ++ }, ++ session_factory=factory ++ ) ++ ++ resources = p.run() ++ self.assertEqual(len(resources), 1) ++ self.assertRaises(ClientError, client.get_role, RoleName=resources[0]['RoleName']) ++ ++ def test_delete_role_error(self): ++ factory = self.replay_flight_data("test_delete_role_error") ++ p = self.load_policy( ++ { ++ 'name': 'iam-delete-profile-roles', ++ 'resource': 'iam-role', ++ 'filters': [{'tag:Name': 'CannotDelete'}], ++ "actions": ["delete"], ++ }, ++ session_factory=factory ++ ) ++ resources = p.run() ++ self.assertEqual(len(resources), 1) ++ client = factory().client("iam") ++ self.assertTrue( ++ client.get_role(RoleName=resources[0]['RoleName']), 'AWSServiceRoleForSupport') +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+2VYU/bMBCG+ZxfceqkARNNSEqLhCgSgjIhJkCUaULTFDnOlXokcWY7pZX243dx ++mwIbgy+gaZsfqU16vjuf772kflKJLI2xmAQrr8Umsd3t2ivx89Xeh90ojKKtKOyQXxh2t3sr0H21 ++iu5RacMUwIqS0jzl99z6X4p/p79BbWIu85wVqa/HL7fHM/pHYa+71H+zF5H+W72wuwKbL1fC7/nP ++9ecpWOETTD3vDQxvheFjMBLOZ2YsC+j4YQhrBWKKKYykgkQayaVCoEkpmRGJyISZrXspTtp6Hl3a ++0I6NrZMeF9TjLINSya/IDYyUzEHLSnH0SlGCWKy3EXyI9t6G8B0ME2To1OHnolhuluGygKC+6QSV ++yjKRdGxtZiw0yCxFRQEpJkw/3KDVxO71Qz/sbOzSd7c1N3esbdPaIrIt8tbWyFqjXuuR4pqz1T2E ++FEssUiy4QP1gY+pIvZ5LfgMTrsoZlBnjmMjHjsvqHjaV+hPKSNfUV/itoiS6FqfSCJS5SFkmC4Tl ++0hqrzJi2SStqVC60FsU1FTFvTJNy3ZsLBG0OLU/kpVTmqf2Yhlg1fo21+a1n2qOPP99Tf179faLV ++L9C/i2/VZ93npqL+zOBWCYNUJtZDMp3BSNABtARhoESlRV1HrfCikbpKyI+j1h5nBvYgqLQKMslZ ++FpBqwWICaf6ClGLbJeM37Bp1sByeprqgKSiIY1EIE8c+qbO7C6vnV4Ozo9Vfzm2Hd9mbxeq7x821 ++GhuAU46lEbLQns1pnzM0sP9pCPTehQlT2oYKqgeS2XyWRorleCvVjYdTm4zc48PB0f7HD5fxxeD9 ++8dlpv9JtZHS88L7P/sHBYDiMTwZX8fFhfyTl/cXh4OBicHnPp58w9dBhOKTU8eXZyeC0P2I3WJd7 ++URVWHHpVXlPlxnaimaK8UcWa538jguXUx52dQ8zQ4IXMkKQWtfd0or0//dJzOBwOh8PhcDgcDofD ++4XA4HA6Hw+FwOBwOh+Mf4wcBe4+WACgAAA== +diff --git 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-000683/tests/test.sh b/tasks/format-code-task-000683/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..635b29257c2d8f19255a770e2b3c87a5c40d95f2 --- /dev/null +++ b/tasks/format-code-task-000683/tests/test.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +tests/data/placebo/test_delete_role/iam.CreateRole_1.json +tests/data/placebo/test_delete_role/iam.DeleteRole_1.json +tests/data/placebo/test_delete_role/iam.GetRole_1.json +tests/data/placebo/test_delete_role/iam.GetRole_2.json +tests/data/placebo/test_delete_role/iam.GetRole_3.json +tests/data/placebo/test_delete_role/iam.ListRoles_1.json +tests/data/placebo/test_delete_role_error/iam.DeleteRole_1.json +tests/data/placebo/test_delete_role_error/iam.GetRole_1.json +tests/data/placebo/test_delete_role_error/iam.GetRole_2.json +tests/data/placebo/test_delete_role_error/iam.ListRoles_1.json +tests/test_iam.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-000683/tests/test_command.sh b/tasks/format-code-task-000683/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000683/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000684/environment/Dockerfile b/tasks/format-code-task-000684/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..37e5a306da6574fe15de081a54d094bdf784d2dd --- /dev/null +++ b/tasks/format-code-task-000684/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2cb176d7b83af98bfe7d5a85f0cae0eed9ddce69905c57e48610740a60ca9869 diff --git a/tasks/format-code-task-000684/environment/setup/files/blocklist b/tasks/format-code-task-000684/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000684/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000684/environment/setup/setup.sh b/tasks/format-code-task-000684/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000684/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000684/tests/test.patch b/tasks/format-code-task-000684/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ddce523670771773847010bfef37e4409dc30874 --- /dev/null +++ b/tasks/format-code-task-000684/tests/test.patch @@ -0,0 +1,118 @@ +diff --git a/tests/test_s3_data_events_contract.py b/tests/test_s3_data_events_contract.py +new file mode 100644 +index 000000000..06306e5c2 +--- /dev/null ++++ b/tests/test_s3_data_events_contract.py +@@ -0,0 +1,103 @@ ++from unittest import TestCase ++ ++from c7n.resources import s3 ++ ++ ++class _TrailManager: ++ def __init__(self, trails): ++ self._trails = trails ++ ++ def resources(self): ++ return self._trails ++ ++ ++class _ResourceManager: ++ def __init__(self, trails, session_factory): ++ self._trail_manager = _TrailManager(trails) ++ self.session_factory = session_factory ++ ++ def get_resource_manager(self, resource_type): ++ assert resource_type == 'cloudtrail' ++ return self._trail_manager ++ ++ ++class _Client: ++ def __init__(self, selectors): ++ self.selectors = selectors ++ ++ def get_event_selectors(self, TrailName): ++ return {'EventSelectors': self.selectors.get(TrailName, [])} ++ ++ ++class _Session: ++ def __init__(self, selectors_by_region): ++ self.selectors_by_region = selectors_by_region ++ ++ def client(self, service, region_name=None): ++ assert service == 'cloudtrail' ++ return _Client(self.selectors_by_region.get(region_name, {})) ++ ++ ++class DataEventsContract(TestCase): ++ def run_filter(self, state, buckets, trails, selectors_by_region): ++ session = _Session(selectors_by_region) ++ manager = _ResourceManager(trails, object()) ++ original = s3.local_session ++ s3.local_session = lambda factory: session ++ self.addCleanup(setattr, s3, 'local_session', original) ++ return s3.DataEvents({'state': state}, manager).process( ++ [{'Name': name} for name in buckets]) ++ ++ def test_bucket_arn_object_suffix_is_normalized(self): ++ trails = [{'Name': 'trail', 'HomeRegion': 'us-east-1'}] ++ selectors = {'trail': [{'DataResources': [ ++ {'Type': 'AWS::S3::Object', ++ 'Values': ['arn:aws:s3:::alpha/*', 'arn:aws:s3:::beta/*']}]}]} ++ result = self.run_filter('present', ['alpha', 'beta', 'gamma'], trails, ++ {'us-east-1': selectors}) ++ self.assertEqual([b['Name'] for b in result], ['alpha', 'beta']) ++ ++ def test_wildcard_selector_covers_every_bucket(self): ++ trails = [{'Name': 'trail', 'HomeRegion': 'us-east-1'}] ++ selectors = {'trail': [{'DataResources': [ ++ {'Type': 'AWS::S3::Object', 'Values': ['arn:aws:s3:::*']}]}]} ++ result = self.run_filter('present', ['alpha', 'beta'], trails, ++ {'us-east-1': selectors}) ++ self.assertEqual([b['Name'] for b in result], ['alpha', 'beta']) ++ ++ def test_non_s3_and_management_selectors_are_ignored(self): ++ trails = [{'Name': 'trail', 'HomeRegion': 'us-east-1'}] ++ selectors = {'trail': [ ++ {'IncludeManagementEvents': True}, ++ {'DataResources': [{'Type': 'AWS::Lambda::Function', ++ 'Values': ['arn:aws:lambda:::fn']}]}]} ++ result = self.run_filter('present', ['alpha'], trails, ++ {'us-east-1': selectors}) ++ self.assertEqual(result, []) ++ ++ def test_absent_is_complement_of_present(self): ++ trails = [{'Name': 'trail', 'HomeRegion': 'us-east-1'}] ++ selectors = {'trail': [{'DataResources': [ ++ {'Type': 'AWS::S3::Object', 'Values': ['arn:aws:s3:::alpha']}]}]} ++ buckets = ['alpha', 'beta'] ++ present = self.run_filter('present', buckets, trails, ++ {'us-east-1': selectors}) ++ absent = self.run_filter('absent', buckets, trails, ++ {'us-east-1': selectors}) ++ self.assertEqual([b['Name'] for b in present], ['alpha']) ++ self.assertEqual([b['Name'] for b in absent], ['beta']) ++ ++ def test_selectors_are_combined_across_home_regions(self): ++ trails = [ ++ {'Name': 'east', 'HomeRegion': 'us-east-1'}, ++ {'Name': 'west', 'HomeRegion': 'us-west-2'}] ++ selectors = { ++ 'east': [{'DataResources': [{'Type': 'AWS::S3::Object', ++ 'Values': ['arn:aws:s3:::alpha']}]}], ++ 'west': [{'DataResources': [{'Type': 'AWS::S3::Object', ++ 'Values': ['arn:aws:s3:::beta']}]}]} ++ result = self.run_filter( ++ 'present', ['alpha', 'beta', 'gamma'], trails, ++ {'us-east-1': {'east': selectors['east']}, ++ 'us-west-2': {'west': selectors['west']}}) ++ self.assertEqual([b['Name'] for b in result], ['alpha', 'beta']) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++./.venv/bin/python -m pytest -q tests/test_s3_data_events_contract.py diff --git a/tasks/format-code-task-000684/tests/test.sh b/tasks/format-code-task-000684/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b01a15a65a4e7d0aacc0934978aa76bb398a2d5e --- /dev/null +++ b/tasks/format-code-task-000684/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_s3_data_events_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-000684/tests/test_command.sh b/tasks/format-code-task-000684/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000684/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000813/environment/Dockerfile b/tasks/format-code-task-000813/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d2f9da3bd7adabe6c92efe2d86e4330228b49d5b --- /dev/null +++ b/tasks/format-code-task-000813/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:217176b3ab1deb16626287c8117ee2ae57e2ce0b5e6af04f265650425a0f91df diff --git a/tasks/format-code-task-000813/environment/setup/files/blocklist b/tasks/format-code-task-000813/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000813/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000813/environment/setup/setup.sh b/tasks/format-code-task-000813/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000813/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000813/tests/test.patch b/tasks/format-code-task-000813/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e33bcc9477f4d45c3501f606b19a4049f119538a --- /dev/null +++ b/tasks/format-code-task-000813/tests/test.patch @@ -0,0 +1,488 @@ +diff --git a/usercase-test-coderl/test_recaptcha_client_submit.py b/usercase-test-coderl/test_recaptcha_client_submit.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_recaptcha_client_submit.py +@@ -0,0 +1,463 @@ ++ ++ ++import json ++import os ++import urllib.request as urllib_request ++from urllib.parse import parse_qs ++ ++import pytest ++from django.conf import settings ++from django.test import override_settings ++ ++if not settings.configured: ++ settings.configure(INSTALLED_APPS=[], SECRET_KEY="usercase-fixture") ++ ++from django_recaptcha import client ++ ++ ++class FakeHTTPResponse: ++ def __init__(self, body): ++ self.body = body ++ self.closed = False ++ self.read_calls = 0 ++ ++ def read(self): ++ self.read_calls += 1 ++ return self.body ++ ++ def close(self): ++ self.closed = True ++ ++ def __enter__(self): ++ return self ++ ++ def __exit__(self, exc_type, exc, tb): ++ self.close() ++ ++ ++def response_projection(response): ++ return { ++ "is_valid": response.is_valid, ++ "error_codes": response.error_codes, ++ "action": response.action, ++ "extra_data": response.extra_data, ++ } ++ ++ ++def assert_form_body(encoded, expected): ++ ++ assert isinstance(encoded, bytes) ++ parsed = parse_qs( ++ encoded.decode("utf-8"), keep_blank_values=True, strict_parsing=True ++ ) ++ for key, value in expected.items(): ++ assert parsed.get(key) == [value] ++ ++ ++def assert_required_headers(headers): ++ ++ assert headers["Content-type"] == "application/x-www-form-urlencoded" ++ assert headers["User-agent"] == "reCAPTCHA Django" ++ ++ ++def normalize_request_args(args, kwargs): ++ ++ normalized = dict(kwargs) ++ for name, value in zip(("url", "data", "headers"), args): ++ normalized.setdefault(name, value) ++ return normalized ++ ++ ++def patch_request_stack(monkeypatch, request_cls, build_opener_func, proxy_handler_cls=None): ++ ++ monkeypatch.setattr(client, "Request", request_cls, raising=False) ++ monkeypatch.setattr(urllib_request, "Request", request_cls) ++ monkeypatch.setattr(client, "build_opener", build_opener_func, raising=False) ++ monkeypatch.setattr(urllib_request, "build_opener", build_opener_func) ++ if proxy_handler_cls is not None: ++ monkeypatch.setattr(client, "ProxyHandler", proxy_handler_cls, raising=False) ++ monkeypatch.setattr(urllib_request, "ProxyHandler", proxy_handler_cls) ++ ++ ++def install_response(monkeypatch, body, captured=None): ++ fake_response = FakeHTTPResponse(body) ++ ++ class FakeRequest: ++ def __init__(self, *args, **kwargs): ++ request_kwargs = normalize_request_args(args, kwargs) ++ if captured is not None: ++ captured["params"] = request_kwargs.get("data") ++ captured["request_kwargs"] = request_kwargs ++ ++ class FakeOpener: ++ def open(self, request_object, timeout=None): ++ if captured is not None: ++ captured["opened_request_is_fake"] = isinstance(request_object, FakeRequest) ++ captured["timeout"] = timeout ++ return fake_response ++ ++ def fake_build_opener(*args): ++ if captured is not None: ++ captured["opener_args"] = args ++ return FakeOpener() ++ ++ patch_request_stack(monkeypatch, FakeRequest, fake_build_opener) ++ return fake_response ++ ++ ++def test_success_response_preserves_remaining_metadata(monkeypatch): ++ ++ ++ ++ ++ fake_response = install_response( ++ monkeypatch, ++ b'{"success": true, "challenge_ts": "2019-01-11T13:57:23Z", "hostname": "testkey.google.com"}', ++ ) ++ ++ actual = response_projection( ++ client.submit("token-alpha", "private-alpha", "203.0.113.10") ++ ) ++ ++ assert actual == { ++ "is_valid": True, ++ "error_codes": [], ++ "action": None, ++ "extra_data": { ++ "challenge_ts": "2019-01-11T13:57:23Z", ++ "hostname": "testkey.google.com", ++ }, ++ } ++ assert fake_response.closed is True ++ ++ assert fake_response.read_calls >= 1 ++ ++ ++def test_failure_response_exposes_error_codes(monkeypatch): ++ ++ ++ ++ ++ install_response( ++ monkeypatch, ++ b'{"success": false, "error-codes": ["invalid-input-response", "invalid-input-secret"]}', ++ ) ++ ++ actual = response_projection( ++ client.submit("token-beta", "private-beta", "198.51.100.7") ++ ) ++ ++ assert actual == { ++ "is_valid": False, ++ "error_codes": ["invalid-input-response", "invalid-input-secret"], ++ "action": None, ++ "extra_data": {}, ++ } ++ ++ ++def test_action_is_separated_from_score_and_other_metadata(monkeypatch): ++ ++ ++ ++ ++ captured = {} ++ install_response( ++ monkeypatch, ++ b'{"success": true, "action": "login", "score": 0.9, "hostname": "example.com", "apk_package_name": "com.example.app"}', ++ captured, ++ ) ++ ++ actual = response_projection( ++ client.submit("token gamma/space", "private+gamma", "2001:db8::1") ++ ) ++ ++ assert_form_body( ++ captured["params"], ++ { ++ "secret": "private+gamma", ++ "response": "token gamma/space", ++ "remoteip": "2001:db8::1", ++ }, ++ ) ++ assert actual == { ++ "is_valid": True, ++ "error_codes": [], ++ "action": "login", ++ "extra_data": { ++ "score": 0.9, ++ "hostname": "example.com", ++ "apk_package_name": "com.example.app", ++ }, ++ } ++ ++ ++def test_utf8_response_body_is_decoded_before_json_parsing(monkeypatch): ++ ++ ++ ++ ++ install_response( ++ monkeypatch, ++ b'{"success": true, "hostname": "caf\xc3\xa9.example", "challenge_ts": "2020-02-03T04:05:06Z"}', ++ ) ++ ++ actual = response_projection( ++ client.submit("token-utf8", "private-utf8", "203.0.113.77") ++ ) ++ ++ assert actual == { ++ "is_valid": True, ++ "error_codes": [], ++ "action": None, ++ "extra_data": { ++ "hostname": "caf\u00e9.example", ++ "challenge_ts": "2020-02-03T04:05:06Z", ++ }, ++ } ++ ++ ++def test_invalid_json_raises_json_decode_error(monkeypatch): ++ ++ ++ ++ ++ install_response(monkeypatch, b'{"success": true') ++ ++ with pytest.raises(json.JSONDecodeError): ++ client.submit("token-invalid-json", "private-invalid-json", "192.0.2.13") ++ ++ ++def test_request_uses_form_fields_headers_default_domain_and_timeout(monkeypatch): ++ ++ ++ ++ ++ records = {} ++ ++ class FakeRequest: ++ def __init__(self, *args, **kwargs): ++ records["request_kwargs"] = normalize_request_args(args, kwargs) ++ ++ class FakeOpener: ++ def open(self, request_object, timeout): ++ records["opened_request_is_fake"] = isinstance(request_object, FakeRequest) ++ records["timeout"] = timeout ++ return FakeHTTPResponse(b'{"success": true}') ++ ++ def fake_build_opener(*args): ++ records["opener_args"] = args ++ return FakeOpener() ++ ++ patch_request_stack(monkeypatch, FakeRequest, fake_build_opener) ++ ++ with override_settings(): ++ actual = response_projection( ++ client.submit("request token", "request-secret", "192.0.2.44") ++ ) ++ ++ request_kwargs = records["request_kwargs"] ++ ++ assert request_kwargs["url"] == "https://www.google.com/recaptcha/api/siteverify" ++ assert_form_body( ++ request_kwargs["data"], ++ { ++ "secret": "request-secret", ++ "response": "request token", ++ "remoteip": "192.0.2.44", ++ }, ++ ) ++ assert_required_headers(request_kwargs["headers"]) ++ ++ assert "opener_args" in records ++ assert records["opened_request_is_fake"] is True ++ assert records["timeout"] == 10 ++ assert actual == { ++ "is_valid": True, ++ "error_codes": [], ++ "action": None, ++ "extra_data": {}, ++ } ++ ++ ++def test_request_honors_domain_proxy_and_timeout_settings(monkeypatch): ++ ++ ++ ++ ++ records = {} ++ ++ class FakeRequest: ++ def __init__(self, *args, **kwargs): ++ records["request_kwargs"] = normalize_request_args(args, kwargs) ++ ++ class FakeOpener: ++ def open(self, request_object, timeout): ++ records["opened_request_is_fake"] = isinstance(request_object, FakeRequest) ++ records["timeout"] = timeout ++ return FakeHTTPResponse(b'{"success": true}') ++ ++ class FakeProxyHandler: ++ def __init__(self, proxies): ++ self.proxies = proxies ++ ++ def fake_build_opener(*args): ++ records["opener_args"] = args ++ return FakeOpener() ++ ++ patch_request_stack(monkeypatch, FakeRequest, fake_build_opener, FakeProxyHandler) ++ ++ with override_settings( ++ RECAPTCHA_DOMAIN="www.recaptcha.net", ++ RECAPTCHA_PROXY={"https": "https://proxy.example:8443"}, ++ RECAPTCHA_VERIFY_REQUEST_TIMEOUT=3, ++ ): ++ actual = response_projection( ++ client.submit("custom token", "custom-secret", "198.51.100.55") ++ ) ++ ++ request_kwargs = records["request_kwargs"] ++ ++ assert request_kwargs["url"] == "https://www.recaptcha.net/recaptcha/api/siteverify" ++ assert_form_body( ++ request_kwargs["data"], ++ { ++ "secret": "custom-secret", ++ "response": "custom token", ++ "remoteip": "198.51.100.55", ++ }, ++ ) ++ assert_required_headers(request_kwargs["headers"]) ++ ++ proxy_handlers = [ ++ arg for arg in records["opener_args"] if isinstance(arg, FakeProxyHandler) ++ ] ++ assert any( ++ handler.proxies == {"https": "https://proxy.example:8443"} ++ for handler in proxy_handlers ++ ) ++ assert records["opened_request_is_fake"] is True ++ assert records["timeout"] == 3 ++ assert actual == { ++ "is_valid": True, ++ "error_codes": [], ++ "action": None, ++ "extra_data": {}, ++ } ++ ++ ++def test_referential_transparency_for_same_arguments(monkeypatch): ++ bodies = [ ++ b'{"success": true, "challenge_ts": "2019-01-11T13:57:23Z", "hostname": "testkey.google.com"}', ++ b'{"success": true, "challenge_ts": "2019-01-11T13:57:23Z", "hostname": "testkey.google.com"}', ++ ] ++ ++ def install_next_response(monkeypatch, body): ++ fake_response = FakeHTTPResponse(body) ++ ++ class FakeRequest: ++ def __init__(self, *args, **kwargs): ++ request_kwargs = normalize_request_args(args, kwargs) ++ assert_form_body( ++ request_kwargs["data"], ++ { ++ "secret": "private-alpha", ++ "response": "token-alpha", ++ "remoteip": "203.0.113.10", ++ }, ++ ) ++ ++ class FakeOpener: ++ def open(self, request_object, timeout=None): ++ return fake_response ++ ++ def fake_build_opener(*args): ++ return FakeOpener() ++ ++ patch_request_stack(monkeypatch, FakeRequest, fake_build_opener) ++ ++ install_next_response(monkeypatch, bodies.pop(0)) ++ first = response_projection( ++ client.submit("token-alpha", "private-alpha", "203.0.113.10") ++ ) ++ install_next_response(monkeypatch, bodies.pop(0)) ++ second = response_projection( ++ client.submit("token-alpha", "private-alpha", "203.0.113.10") ++ ) ++ ++ actual = [first, second] ++ ++ assert actual == [ ++ { ++ "is_valid": True, ++ "error_codes": [], ++ "action": None, ++ "extra_data": { ++ "challenge_ts": "2019-01-11T13:57:23Z", ++ "hostname": "testkey.google.com", ++ }, ++ }, ++ { ++ "is_valid": True, ++ "error_codes": [], ++ "action": None, ++ "extra_data": { ++ "challenge_ts": "2019-01-11T13:57:23Z", ++ "hostname": "testkey.google.com", ++ }, ++ }, ++ ] ++ ++ ++def test_success_projection_with_caller_argument_list(monkeypatch): ++ install_response(monkeypatch, b'{"success": true, "hostname": "immutable.example"}') ++ inputs = ["mutable-token", "mutable-secret", "192.0.2.90"] ++ ++ actual = response_projection(client.submit(*inputs)) ++ ++ ++ assert actual == { ++ "is_valid": True, ++ "error_codes": [], ++ "action": None, ++ "extra_data": {"hostname": "immutable.example"}, ++ } ++ ++ ++def test_failure_projection_for_timeout_error_code(monkeypatch): ++ install_response( ++ monkeypatch, ++ b'{"success": false, "error-codes": ["timeout-or-duplicate"]}', ++ ) ++ actual = response_projection( ++ client.submit("token-process", "private-process", "198.51.100.200") ++ ) ++ ++ ++ assert actual == { ++ "is_valid": False, ++ "error_codes": ["timeout-or-duplicate"], ++ "action": None, ++ "extra_data": {}, ++ } ++ ++ ++def test_submit_returns_expected_response_from_non_repo_cwd(monkeypatch, tmp_path): ++ install_response(monkeypatch, b'{"success": true, "hostname": "side-effect.example"}') ++ ++ old_cwd = os.getcwd() ++ os.chdir(tmp_path) ++ try: ++ actual = response_projection( ++ client.submit("token-side-effect", "private-side-effect", "203.0.113.201") ++ ) ++ finally: ++ os.chdir(old_cwd) ++ ++ ++ ++ assert actual == { ++ "is_valid": True, ++ "error_codes": [], ++ "action": None, ++ "extra_data": {"hostname": "side-effect.example"}, ++ } +diff --git 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 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_recaptcha_client_submit.py -v diff --git a/tasks/format-code-task-000813/tests/test.sh b/tasks/format-code-task-000813/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..860fba7957c17c8d7b9550abd99dfd85d3334ebc --- /dev/null +++ b/tasks/format-code-task-000813/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_recaptcha_client_submit.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-000813/tests/test_command.sh b/tasks/format-code-task-000813/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000813/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-000814/environment/Dockerfile b/tasks/format-code-task-000814/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9b5658b2872b6091a7e697416c9fee0ce3f283a1 --- /dev/null +++ b/tasks/format-code-task-000814/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b90f42877c116f7e5a483d8bbec32f9351c0b3ce8cfa97aec467bee9e7ebf200 diff --git a/tasks/format-code-task-000814/environment/setup/files/blocklist b/tasks/format-code-task-000814/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000814/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000814/environment/setup/setup.sh b/tasks/format-code-task-000814/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000814/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000814/tests/test.patch b/tasks/format-code-task-000814/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4736868c431d7d9de81df5a39e6a357f052764be --- /dev/null +++ b/tasks/format-code-task-000814/tests/test.patch @@ -0,0 +1,194 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..1d5f9abf +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py -v"] ++} +diff --git a/tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py b/tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py +new file mode 100644 +index 00000000..28f9a57e +--- /dev/null ++++ b/tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py +@@ -0,0 +1,166 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++# pylint: disable=C0116 ++from typing import TextIO ++ ++from click.testing import CliRunner ++ ++from tests.conftest import write_to_file ++from src.djlint import main as djlint ++ ++ ++def _reformat(tmp_file: TextIO, runner: CliRunner, content: bytes, extra_args=None): ++ write_to_file(tmp_file.name, content) ++ args = [tmp_file.name, "--reformat"] ++ if extra_args: ++ args.extend(extra_args) ++ result = runner.invoke(djlint, args) ++ text = open(tmp_file.name, encoding="utf8").read() ++ return result, text ++ ++ ++def test_issue_example_preserve_blank_lines( ++ runner: CliRunner, tmp_file: TextIO ++) -> None: ++ ++ _, text = _reformat( ++ tmp_file, ++ runner, ++ b"{% block someblock %}{% endblock %}\n

\n", ++ ["--preserve-blank-lines"], ++ ) ++ ++ assert not text.startswith("\n") ++ ++ assert "
\n
\n" in text ++ ++ assert text == "{% block someblock %}{% endblock %}\n
\n
\n" ++ ++ ++def test_template_block_tag_at_file_start_no_leading_blank( ++ runner: CliRunner, tmp_file: TextIO ++) -> None: ++ _, text = _reformat( ++ tmp_file, ++ runner, ++ b"{% block someblock %}{% endblock %}\n", ++ ["--preserve-blank-lines"], ++ ) ++ assert not text.startswith("\n") ++ assert text == "{% block someblock %}{% endblock %}\n" ++ ++ ++def test_template_if_tag_at_file_start_no_leading_blank( ++ runner: CliRunner, tmp_file: TextIO ++) -> None: ++ _, text = _reformat( ++ tmp_file, ++ runner, ++ b"{% if x %}foo{% endif %}\n", ++ ["--preserve-blank-lines"], ++ ) ++ assert not text.startswith("\n") ++ assert text == "{% if x %}foo{% endif %}\n" ++ ++ ++def test_html_tag_at_file_start_no_leading_blank( ++ runner: CliRunner, tmp_file: TextIO ++) -> None: ++ _, text = _reformat( ++ tmp_file, ++ runner, ++ b"
hello
\n", ++ ["--preserve-blank-lines"], ++ ) ++ assert not text.startswith("\n") ++ assert text == "
hello
\n" ++ ++ ++def test_extends_tag_at_file_start_unchanged( ++ runner: CliRunner, tmp_file: TextIO ++) -> None: ++ ++ _, text = _reformat( ++ tmp_file, ++ runner, ++ b'{% extends "a.html" %}\n', ++ ["--preserve-blank-lines"], ++ ) ++ assert not text.startswith("\n") ++ assert text == '{% extends "a.html" %}\n' ++ ++ ++def test_template_tag_not_at_start_still_breaks( ++ runner: CliRunner, tmp_file: TextIO ++) -> None: ++ ++ ++ _, text = _reformat( ++ tmp_file, ++ runner, ++ b"text\n{% block x %}foo{% endblock %}\n", ++ ["--preserve-blank-lines"], ++ ) ++ ++ assert not text.startswith("\n") ++ assert text == "text\n{% block x %}foo{% endblock %}\n" ++ ++ ++def test_multiple_br_with_spaces_no_stray_blank_with_preserve( ++ runner: CliRunner, tmp_file: TextIO ++) -> None: ++ ++ ++ ++ ++ _, text = _reformat( ++ tmp_file, ++ runner, ++ b"

x

\n

\n", ++ ["--preserve-blank-lines"], ++ ) ++ ++ assert "
\n\n
" not in text ++ ++ assert "
\n \n
" not in text ++ assert text == "

x

\n
\n
\n" ++ ++ ++def test_multiple_br_with_spaces_no_preserve( ++ runner: CliRunner, tmp_file: TextIO ++) -> None: ++ ++ ++ _, text = _reformat( ++ tmp_file, ++ runner, ++ b"


\n", ++ ) ++ assert text == "
\n
\n
\n" ++ ++ ++def test_existing_preserve_blank_lines_html_unchanged( ++ runner: CliRunner, ++) -> None: ++ ++ ++ ++ result = runner.invoke( ++ djlint, ++ [ ++ "tests/test_config/test_preserve_blank_lines/html.html", ++ "--check", ++ "--preserve-leading-space", ++ "--preserve-blank-lines", ++ ], ++ ) ++ assert result.exit_code == 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 -v -rA tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py::test_issue_example_preserve_blank_lines tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py::test_template_block_tag_at_file_start_no_leading_blank tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py::test_template_if_tag_at_file_start_no_leading_blank tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py::test_html_tag_at_file_start_no_leading_blank tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py::test_extends_tag_at_file_start_unchanged tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py::test_template_tag_not_at_start_still_breaks tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py::test_multiple_br_with_spaces_no_stray_blank_with_preserve tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py::test_multiple_br_with_spaces_no_preserve tests/test_config/test_preserve_blank_lines/test_blank_line_at_start.py::test_existing_preserve_blank_lines_html_unchanged ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000814/tests/test.sh b/tasks/format-code-task-000814/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c9ba8b775a50a8f7d8f95c4434ef22c11d48055e --- /dev/null +++ b/tasks/format-code-task-000814/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_config/test_preserve_blank_lines/test_blank_line_at_start.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-000814/tests/test_command.sh b/tasks/format-code-task-000814/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000814/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000822/environment/Dockerfile b/tasks/format-code-task-000822/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..356f006df84745fa04c2269404c76aa5901b9c36 --- /dev/null +++ b/tasks/format-code-task-000822/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:de8b6719283fcc418cf1a467ebe901e2433a86498c04a2c4189bc120f10896cf diff --git a/tasks/format-code-task-000822/environment/setup/files/blocklist b/tasks/format-code-task-000822/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000822/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000822/environment/setup/setup.sh b/tasks/format-code-task-000822/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000822/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000822/tests/test.patch b/tasks/format-code-task-000822/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..047ef663664a055b1f3c2b03c412945a204545f0 --- /dev/null +++ b/tasks/format-code-task-000822/tests/test.patch @@ -0,0 +1,207 @@ +diff --git a/commands/scp_test.go b/commands/scp_test.go +index e4e020c9..78605642 100644 +--- a/commands/scp_test.go ++++ b/commands/scp_test.go +@@ -1,7 +1,9 @@ + package commands + + import ( ++ "errors" + "os/exec" ++ "strings" + "testing" + + "github.com/stretchr/testify/assert" +@@ -12,6 +14,8 @@ type MockHostInfo struct { + ip string + sshUsername string + sshKeyPath string ++ sshPort int ++ sshPortErr error + } + + func (h *MockHostInfo) GetMachineName() string { +@@ -30,6 +34,10 @@ func (h *MockHostInfo) GetSSHKeyPath() string { + return h.sshKeyPath + } + ++func (h *MockHostInfo) GetSSHPort() (int, error) { ++ return h.sshPort, h.sshPortErr ++} ++ + type MockHostInfoLoader struct { + hostInfo MockHostInfo + } +@@ -62,7 +70,8 @@ func TestGetInfoForRemoteScpArg(t *testing.T) { + host, path, opts, err := getInfoForScpArg("myfunhost:/home/docker/foo", &hostInfoLoader) + assert.Equal(t, "myfunhost", host.GetMachineName()) + assert.Equal(t, "/home/docker/foo", path) +- assert.Equal(t, []string{"-i", "/fake/keypath/id_rsa"}, opts) ++ assert.Contains(t, opts, "-i") ++ assert.Contains(t, opts, "/fake/keypath/id_rsa") + assert.NoError(t, err) + + host, path, opts, err = getInfoForScpArg("myfunhost:C:\\path", &hostInfoLoader) +@@ -99,21 +108,16 @@ func TestGetScpCmd(t *testing.T) { + + cmd, err := getScpCmd("/tmp/foo", "myfunhost:/home/docker/foo", true, &hostInfoLoader) + +- expectedArgs := append( +- baseSSHArgs, +- "-3", +- "-r", +- "-o", +- "IdentitiesOnly=yes", +- "-i", +- "/fake/keypath/id_rsa", +- "/tmp/foo", +- "root@12.34.56.78:/home/docker/foo", +- ) +- expectedCmd := exec.Command("/usr/bin/scp", expectedArgs...) +- +- assert.Equal(t, expectedCmd, cmd) + assert.NoError(t, err) ++ assert.NotNil(t, cmd) ++ ++ joined := strings.Join(cmd.Args, " ") ++ ++ assert.Contains(t, joined, "/tmp/foo") ++ assert.Contains(t, joined, "root@12.34.56.78:/home/docker/foo") ++ assert.Contains(t, joined, "-i /fake/keypath/id_rsa") ++ ++ assert.NotContains(t, cmd.Args, "-P") + } + + func TestGetScpCmdWithoutSshKey(t *testing.T) { +@@ -124,15 +128,100 @@ func TestGetScpCmdWithoutSshKey(t *testing.T) { + + cmd, err := getScpCmd("/tmp/foo", "myfunhost:/home/docker/foo", true, &hostInfoLoader) + +- expectedArgs := append( +- baseSSHArgs, +- "-3", +- "-r", +- "/tmp/foo", +- "user@1.2.3.4:/home/docker/foo", +- ) +- expectedCmd := exec.Command("/usr/bin/scp", expectedArgs...) ++ assert.NoError(t, err) ++ assert.NotNil(t, cmd) ++ joined := strings.Join(cmd.Args, " ") ++ assert.Contains(t, joined, "/tmp/foo") ++ assert.Contains(t, joined, "user@1.2.3.4:/home/docker/foo") ++ ++ assert.NotContains(t, cmd.Args, "-i") ++ ++ assert.NotContains(t, cmd.Args, "-P") ++} ++ ++ ++func argsContainsFlagValue(args []string, flag, value string) bool { ++ for i := 0; i < len(args)-1; i++ { ++ if args[i] == flag && args[i+1] == value { ++ return true ++ } ++ } ++ return false ++} ++ ++ ++ ++func TestGetScpCmdWithCustomPort(t *testing.T) { ++ hostInfoLoader := MockHostInfoLoader{MockHostInfo{ ++ ip: "104.131.33.10", ++ sshUsername: "root", ++ sshKeyPath: "/fake/keypath/id_rsa", ++ sshPort: 2222, ++ }} ++ ++ cmd, err := getScpCmd("myfile.txt", "myfunhost:myfile.txt", false, &hostInfoLoader) + +- assert.Equal(t, expectedCmd, cmd) + assert.NoError(t, err) ++ assert.NotNil(t, cmd) ++ ++ assert.True(t, argsContainsFlagValue(cmd.Args, "-P", "2222"), ++ "expected -P 2222 in scp args, got: %v", cmd.Args) ++ ++ joined := strings.Join(cmd.Args, " ") ++ assert.Contains(t, joined, "root@104.131.33.10") + } ++ ++ ++ ++func TestGetScpCmdPortValuePropagated(t *testing.T) { ++ hostInfoLoader := MockHostInfoLoader{MockHostInfo{ ++ ip: "10.0.0.1", ++ sshUsername: "ubuntu", ++ sshKeyPath: "/fake/keypath/id_rsa", ++ sshPort: 9999, ++ }} ++ ++ cmd, err := getScpCmd("/tmp/foo", "remote:/home/foo", false, &hostInfoLoader) ++ ++ assert.NoError(t, err) ++ assert.True(t, argsContainsFlagValue(cmd.Args, "-P", "9999"), ++ "expected -P 9999 in scp args, got: %v", cmd.Args) ++ ++ assert.False(t, argsContainsFlagValue(cmd.Args, "-P", "22")) ++ assert.False(t, argsContainsFlagValue(cmd.Args, "-P", "2222")) ++} ++ ++ ++ ++func TestGetScpCmdWithZeroPort(t *testing.T) { ++ hostInfoLoader := MockHostInfoLoader{MockHostInfo{ ++ ip: "1.2.3.4", ++ sshUsername: "root", ++ sshKeyPath: "/fake/keypath/id_rsa", ++ sshPort: 0, ++ }} ++ ++ cmd, err := getScpCmd("/tmp/foo", "remote:/home/foo", false, &hostInfoLoader) ++ ++ assert.NoError(t, err) ++ assert.NotContains(t, cmd.Args, "-P", ++ "unexpected -P flag for zero port: %v", cmd.Args) ++} ++ ++ ++ ++func TestGetScpCmd_LocalSourceLocalDest(t *testing.T) { ++ hostInfoLoader := MockHostInfoLoader{MockHostInfo{}} ++ cmd, err := getScpCmd("/tmp/a", "/tmp/b", false, &hostInfoLoader) ++ assert.NoError(t, err) ++ assert.NotNil(t, cmd) ++ assert.NotContains(t, cmd.Args, "-P") ++ ++ joined := strings.Join(cmd.Args, " ") ++ assert.Contains(t, joined, "/tmp/a") ++ assert.Contains(t, joined, "/tmp/b") ++} ++ ++ ++var _ = errors.New ++var _ = exec.Command +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..d804f37f +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["mkdir -p /tmp/gopath/src/github.com/docker && rm -f /tmp/gopath/src/github.com/docker/machine && ln -s \"$(pwd)\" /tmp/gopath/src/github.com/docker/machine && cd /tmp/gopath/src/github.com/docker/machine && GOPATH=/tmp/gopath:/go GO111MODULE=off go test ./commands/ -run 'TestGetScp|TestGetInfoFor|TestHostLocation|TestRemoteLocation' -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 ++mkdir -p /tmp/gopath/src/github.com/docker && rm -f /tmp/gopath/src/github.com/docker/machine && ln -s "$(pwd)" /tmp/gopath/src/github.com/docker/machine && cd /tmp/gopath/src/github.com/docker/machine && GOPATH=/tmp/gopath:/go GO111MODULE=off go test ./commands/ -run 'TestGetScp|TestGetInfoFor|TestHostLocation|TestRemoteLocation' -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000822/tests/test.sh b/tasks/format-code-task-000822/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5b06e93202c6f5db6988071d828d215239da30ce --- /dev/null +++ b/tasks/format-code-task-000822/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' +commands/scp_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-000822/tests/test_command.sh b/tasks/format-code-task-000822/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000822/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000825/environment/Dockerfile b/tasks/format-code-task-000825/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0f59e77761d297e4e344f0b7f0e259b1dbdbed08 --- /dev/null +++ b/tasks/format-code-task-000825/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a59ad964bed2ba95d130626651931b3673b429f98b7244346ceb37c6edec2cb6 diff --git a/tasks/format-code-task-000825/environment/setup/files/blocklist b/tasks/format-code-task-000825/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000825/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000825/environment/setup/setup.sh b/tasks/format-code-task-000825/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000825/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000825/tests/test.patch b/tasks/format-code-task-000825/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..978f6ebf1a17fecf0d1e269aff8a7331243201b5 --- /dev/null +++ b/tasks/format-code-task-000825/tests/test.patch @@ -0,0 +1,220 @@ +diff --git a/tests/test_backend_asciidoc.py b/tests/test_backend_asciidoc.py +new file mode 100644 +index 0000000..567d250 +--- /dev/null ++++ b/tests/test_backend_asciidoc.py +@@ -0,0 +1,192 @@ ++from io import BytesIO ++ ++import pytest ++from docling_core.types.doc import ( ++ DocItemLabel, ++ DoclingDocument, ++ ListItem, ++ PictureItem, ++ SectionHeaderItem, ++ TableItem, ++ TextItem, ++) ++ ++from docling.backend.abstract_backend import DeclarativeDocumentBackend ++from docling.backend.asciidoc_backend import AsciiDocBackend ++from docling.datamodel.base_models import ( ++ FormatToExtensions, ++ FormatToMimeType, ++ InputFormat, ++ MimeTypeToFormat, ++) ++from docling.datamodel.document import InputDocument ++ ++SAMPLE = """= The Document Title ++ ++This is the first paragraph ++spanning two lines. ++ ++== Introduction ++ ++Some intro text here. ++ ++=== Details ++ ++* First bullet ++* Second bullet ++* Third bullet ++ ++== Data ++ ++|=== ++| Name | Age | City ++| Alice | 30 | NYC ++| Bob | 25 | LA ++|=== ++ ++image::images/photo.png[] ++""" ++ ++ ++def _convert(text: str) -> DoclingDocument: ++ stream = BytesIO(text.encode("utf-8")) ++ in_doc = InputDocument( ++ path_or_stream=stream, ++ format=InputFormat.ASCIIDOC, ++ backend=AsciiDocBackend, ++ filename="sample.asciidoc", ++ ) ++ backend = in_doc._backend ++ assert isinstance(backend, AsciiDocBackend) ++ assert backend.is_valid() ++ return backend.convert() ++ ++ ++ ++ ++ ++ ++ ++def test_input_format_member_exists(): ++ assert hasattr(InputFormat, "ASCIIDOC") ++ assert InputFormat.ASCIIDOC.value == "asciidoc" ++ ++ ++def test_format_extensions_registered(): ++ exts = FormatToExtensions[InputFormat.ASCIIDOC] ++ assert "asciidoc" in exts ++ assert "adoc" in exts ++ ++ ++def test_mimetype_registered(): ++ assert "text/asciidoc" in FormatToMimeType[InputFormat.ASCIIDOC] ++ assert MimeTypeToFormat["text/asciidoc"] == InputFormat.ASCIIDOC ++ ++ ++ ++ ++ ++ ++ ++def test_backend_is_declarative(): ++ assert issubclass(AsciiDocBackend, DeclarativeDocumentBackend) ++ ++ ++def test_backend_capabilities(): ++ assert AsciiDocBackend.supported_formats() == {InputFormat.ASCIIDOC} ++ assert AsciiDocBackend.supports_pagination() is False ++ ++ ++def test_convert_returns_docling_document(): ++ doc = _convert(SAMPLE) ++ assert isinstance(doc, DoclingDocument) ++ ++ ++ ++ ++ ++ ++ ++def test_title_parsing(): ++ doc = _convert(SAMPLE) ++ titles = [ ++ item.text ++ for item, _ in doc.iterate_items() ++ if isinstance(item, TextItem) and item.label == DocItemLabel.TITLE ++ ] ++ assert titles == ["The Document Title"] ++ ++ ++def test_section_headers_and_levels(): ++ doc = _convert(SAMPLE) ++ headers = [ ++ (item.text, item.level) ++ for item, _ in doc.iterate_items() ++ if isinstance(item, SectionHeaderItem) ++ ] ++ assert headers == [ ++ ("Introduction", 1), ++ ("Details", 2), ++ ("Data", 1), ++ ] ++ ++ ++def test_list_items(): ++ doc = _convert(SAMPLE) ++ items = [ ++ item.text for item, _ in doc.iterate_items() if isinstance(item, ListItem) ++ ] ++ assert items == ["First bullet", "Second bullet", "Third bullet"] ++ ++ ++def test_numbered_list_items(): ++ text = """= T ++ ++1. one ++2. two ++3. three ++""" ++ doc = _convert(text) ++ items = [ ++ item.text for item, _ in doc.iterate_items() if isinstance(item, ListItem) ++ ] ++ assert items == ["one", "two", "three"] ++ ++ ++def test_paragraph_multiline_join(): ++ doc = _convert(SAMPLE) ++ paragraphs = [ ++ item.text ++ for item, _ in doc.iterate_items() ++ if isinstance(item, TextItem) and item.label == DocItemLabel.PARAGRAPH ++ ] ++ assert "This is the first paragraph spanning two lines." in paragraphs ++ assert "Some intro text here." in paragraphs ++ ++ ++def test_table_parsing(): ++ doc = _convert(SAMPLE) ++ tables = [item for item, _ in doc.iterate_items() if isinstance(item, TableItem)] ++ assert len(tables) == 1 ++ ++ table = tables[0] ++ assert table.data.num_rows == 3 ++ assert table.data.num_cols == 3 ++ ++ grid = { ++ (cell.start_row_offset_idx, cell.start_col_offset_idx): cell.text ++ for cell in table.data.table_cells ++ } ++ assert grid[(0, 0)] == "Name" ++ assert grid[(0, 1)] == "Age" ++ assert grid[(0, 2)] == "City" ++ assert grid[(1, 0)] == "Alice" ++ assert grid[(2, 2)] == "LA" ++ ++ ++def test_picture_parsing(): ++ doc = _convert(SAMPLE) ++ pictures = [ ++ item for item, _ in doc.iterate_items() if isinstance(item, PictureItem) ++ ] ++ assert len(pictures) == 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,17 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++PYTHON=/testbed/.venv/bin/python ++ ++ ++$PYTHON -m pytest tests/test_backend_docling_parse_v2.py tests/test_backend_pdfium.py -q ++ ++ ++$PYTHON -m pytest tests/test_backend_asciidoc.py -q diff --git a/tasks/format-code-task-000825/tests/test.sh b/tasks/format-code-task-000825/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..982cdf65a5fae538f41f9238b5a518cd61dcc00b --- /dev/null +++ b/tasks/format-code-task-000825/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_backend_asciidoc.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-000825/tests/test_command.sh b/tasks/format-code-task-000825/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000825/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000870/environment/Dockerfile b/tasks/format-code-task-000870/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8c9353eec744e251298fbc5e82854fb57fe6d708 --- /dev/null +++ b/tasks/format-code-task-000870/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:43d1692e0c20d15c76d146254849215990bb92d24e0c40ceff4f8cb62a69e6db diff --git a/tasks/format-code-task-000870/environment/setup/files/blocklist b/tasks/format-code-task-000870/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000870/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000870/environment/setup/setup.sh b/tasks/format-code-task-000870/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000870/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000870/tests/test.patch b/tasks/format-code-task-000870/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..098e3c4445a0e7707b8f700fac1147e8e3ba1eb8 --- /dev/null +++ b/tasks/format-code-task-000870/tests/test.patch @@ -0,0 +1,599 @@ +diff --git a/usercase-test-coderl/test_ocr_graphic_matching.py b/usercase-test-coderl/test_ocr_graphic_matching.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_ocr_graphic_matching.py +@@ -0,0 +1,560 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import gc ++from pathlib import Path ++from typing import List, Optional, Sequence, Tuple ++from unittest.mock import MagicMock ++ ++import PIL.Image ++import yaml ++ ++from sciencebeam_parser.document.layout_document import ( ++ LayoutBlock, ++ LayoutDocument, ++ LayoutGraphic, ++ LayoutLineMeta, ++ LayoutPage, ++ LayoutPageCoordinates, ++ LayoutPageMeta, ++) ++from sciencebeam_parser.document.semantic_document import ( ++ SemanticFigure, ++ SemanticGraphic, ++ SemanticLabel, ++ SemanticRawFigure, ++ SemanticTable, ++ iter_by_semantic_type_recursively, ++) ++from sciencebeam_parser.ocr_models.ocr_model import ( ++ OpticalCharacterRecognitionModel, ++ SimpleOpticalCharacterRecognitionModelResult, ++) ++from sciencebeam_parser.processors.fulltext.api import ( ++ FullTextProcessor, ++ FullTextProcessorConfig, ++ load_models, ++) ++from sciencebeam_parser.processors.fulltext.models import FullTextModels ++from sciencebeam_parser.processors.graphic_matching import ( ++ OpticalCharacterRecognitionGraphicMatcher, ++) ++from sciencebeam_parser.resources.default_config import DEFAULT_CONFIG_FILE ++ ++ ++PAGE_META = LayoutPageMeta.for_coordinates(LayoutPageCoordinates( ++ x=0, ++ y=0, ++ width=400, ++ height=600, ++ page_number=1, ++)) ++LINE_META = LayoutLineMeta(line_id=1, page_meta=PAGE_META) ++GRAPHIC_COORDINATES = LayoutPageCoordinates( ++ x=300, ++ y=500, ++ width=40, ++ height=40, ++ page_number=1, ++) ++ ++ ++class RecordingOcrModel: ++ def __init__(self, text_results: Sequence[str]): ++ self.text_results = list(text_results) ++ self.image_sizes: List[Tuple[int, int]] = [] ++ self.call_count = 0 ++ ++ def predict_single(self, image): ++ self.image_sizes.append(image.size) ++ if self.call_count < len(self.text_results): ++ text = self.text_results[self.call_count] ++ else: ++ text = self.text_results[-1] ++ self.call_count += 1 ++ return SimpleOpticalCharacterRecognitionModelResult(text) ++ ++ ++def _block(text: str, coordinates: LayoutPageCoordinates) -> LayoutBlock: ++ return LayoutBlock.for_text(text, coordinates=coordinates, line_meta=LINE_META) ++ ++ ++def _write_png(path: Path, size: Tuple[int, int] = (10, 10)) -> Path: ++ PIL.Image.new('RGB', size, (0, 1, 2)).save(path) ++ return path ++ ++ ++def _semantic_graphic( ++ local_file_path: Optional[Path] = None, ++ graphic_type: Optional[str] = None, ++ coordinates: LayoutPageCoordinates = GRAPHIC_COORDINATES, ++) -> SemanticGraphic: ++ return SemanticGraphic(layout_graphic=LayoutGraphic( ++ coordinates=coordinates, ++ local_file_path=str(local_file_path) if local_file_path else None, ++ graphic_type=graphic_type, ++ page_meta=PAGE_META, ++ )) ++ ++ ++def _figure( ++ label_text: str, ++ coordinates: Optional[LayoutPageCoordinates] = None ++) -> SemanticFigure: ++ return SemanticFigure([ ++ SemanticLabel(layout_block=_block( ++ label_text, ++ coordinates or LayoutPageCoordinates( ++ x=10, ++ y=10, ++ width=80, ++ height=20, ++ page_number=1, ++ ), ++ )) ++ ]) ++ ++ ++def _table(label_text: str) -> SemanticTable: ++ return SemanticTable([ ++ SemanticLabel(layout_block=_block( ++ label_text, ++ LayoutPageCoordinates(x=10, y=40, width=80, height=20, page_number=1), ++ )) ++ ]) ++ ++ ++def _snapshot_graphic_match_result(result, ocr_model: RecordingOcrModel): ++ return { ++ 'matches': len(result.graphic_matches), ++ 'unmatched': len(result.unmatched_graphics), ++ 'matched_labels': [ ++ match.candidate_semantic_content.get_text_by_type(SemanticLabel) ++ for match in result.graphic_matches ++ ], ++ 'ocr_call_count': ocr_model.call_count, ++ } ++ ++ ++def _fd_count() -> int: ++ return len(list(Path('/proc/self/fd').iterdir())) ++ ++ ++class FakeSegmentationLabelResult: ++ def __init__(self, body_document: LayoutDocument): ++ self.body_document = body_document ++ ++ def get_filtered_document_by_label(self, label: str) -> LayoutDocument: ++ if label == '': ++ return self.body_document ++ return LayoutDocument(pages=[]) ++ ++ ++class FakeSegmentationModel: ++ def __init__(self, body_document: LayoutDocument): ++ self.body_document = body_document ++ ++ def get_label_layout_document_result(self, layout_document, app_features_context): ++ return FakeSegmentationLabelResult(self.body_document) ++ ++ ++class FakeFullTextModel: ++ def __init__(self, raw_figure_block: LayoutBlock): ++ self.raw_figure_block = raw_figure_block ++ ++ def predict_labels_for_layout_document(self, layout_document, app_features_context): ++ return ['fulltext-labels'] ++ ++ def iter_entity_layout_blocks_for_labeled_layout_tokens(self, labeled_layout_tokens): ++ return [('
', self.raw_figure_block)] ++ ++ def update_section_with_entity_blocks(self, parent_section, entity_blocks, section_type): ++ for tag, block in entity_blocks: ++ assert tag == '
' ++ parent_section.add_content(SemanticRawFigure(layout_block=block)) ++ ++ ++class FakeFigureModel: ++ def __init__(self, figures: Sequence[SemanticFigure]): ++ self.figures = list(figures) ++ ++ def predict_labels_for_layout_documents(self, layout_documents, app_features_context): ++ return [['figure-labels']] ++ ++ def iter_semantic_content_for_labeled_layout_tokens(self, labeled_layout_tokens): ++ assert labeled_layout_tokens == ['figure-labels'] ++ return list(self.figures) ++ ++ ++def _fulltext_models_for_figures( ++ raw_figure_block: LayoutBlock, ++ figures: Sequence[SemanticFigure], ++ ocr_model: RecordingOcrModel, ++) -> FullTextModels: ++ body_document = LayoutDocument(pages=[LayoutPage( ++ blocks=[raw_figure_block], ++ meta=PAGE_META, ++ )]) ++ return FullTextModels( ++ segmentation_model=FakeSegmentationModel(body_document), ++ header_model=MagicMock(name='header_model'), ++ name_header_model=MagicMock(name='name_header_model'), ++ name_citation_model=MagicMock(name='name_citation_model'), ++ affiliation_address_model=MagicMock(name='affiliation_address_model'), ++ fulltext_model=FakeFullTextModel(raw_figure_block), ++ figure_model=FakeFigureModel(figures), ++ table_model=MagicMock(name='table_model'), ++ reference_segmenter_model=MagicMock(name='reference_segmenter_model'), ++ citation_model=MagicMock(name='citation_model'), ++ ocr_model=ocr_model, ++ ) ++ ++ ++def test_load_models_populates_ocr_model_only_when_fulltext_config_enables_it(): ++ ++ ++ ++ ++ app_config = yaml.safe_load(Path(DEFAULT_CONFIG_FILE).read_text(encoding='utf-8')) ++ ++ default_config = FullTextProcessorConfig.from_app_config(app_config) ++ ++ enabled_models = load_models( ++ app_config=app_config, ++ app_context=MagicMock(name='AppContext'), ++ fulltext_processor_config=default_config._replace(use_ocr_model=True), ++ ) ++ ++ ++ assert isinstance(enabled_models.ocr_model, OpticalCharacterRecognitionModel) ++ ++ ++def test_ocr_matcher_matches_exact_abbreviated_and_multiline_figure_labels(tmp_path: Path): ++ ++ ++ ++ ++ image_path = _write_png(tmp_path / 'figure.png') ++ semantic_graphic = _semantic_graphic(image_path) ++ ocr_model = RecordingOcrModel([ ++ 'Figure 1', ++ 'Fig 1', ++ 'Figure 1', ++ 'F 1', ++ 'Other\nFigure 1\nMore', ++ ]) ++ matcher = OpticalCharacterRecognitionGraphicMatcher(ocr_model=ocr_model) ++ ++ snapshots = [] ++ for candidate in [ ++ _figure('Figure 1'), ++ _figure('Figure 1'), ++ _figure('Figure 2'), ++ _figure('Figure 1'), ++ _figure('Figure 1'), ++ ]: ++ snapshots.append(_snapshot_graphic_match_result( ++ matcher.get_graphic_matches([semantic_graphic], [candidate]), ++ ocr_model, ++ )) ++ ++ assert snapshots == [ ++ {'matches': 1, 'unmatched': 0, 'matched_labels': ['Figure 1'], 'ocr_call_count': 1}, ++ {'matches': 1, 'unmatched': 0, 'matched_labels': ['Figure 1'], 'ocr_call_count': 2}, ++ {'matches': 0, 'unmatched': 1, 'matched_labels': [], 'ocr_call_count': 3}, ++ {'matches': 0, 'unmatched': 1, 'matched_labels': [], 'ocr_call_count': 4}, ++ {'matches': 1, 'unmatched': 0, 'matched_labels': ['Figure 1'], 'ocr_call_count': 5}, ++ ] ++ assert ocr_model.image_sizes == [(10, 10), (10, 10), (10, 10), (10, 10), (10, 10)] ++ ++ ++def test_ocr_matcher_matches_table_labels(tmp_path: Path): ++ ++ ++ ++ ++ image_path = _write_png(tmp_path / 'table.png') ++ ocr_model = RecordingOcrModel(['Table 1']) ++ result = OpticalCharacterRecognitionGraphicMatcher( ++ ocr_model=ocr_model ++ ).get_graphic_matches( ++ semantic_graphic_list=[_semantic_graphic(image_path)], ++ candidate_semantic_content_list=[_table('Table 1')], ++ ) ++ ++ assert { ++ 'matches': len(result.graphic_matches), ++ 'unmatched': len(result.unmatched_graphics), ++ 'matched_types': [ ++ type(match.candidate_semantic_content).__name__ ++ for match in result.graphic_matches ++ ], ++ 'matched_labels': [ ++ match.candidate_semantic_content.get_text_by_type(SemanticLabel) ++ for match in result.graphic_matches ++ ], ++ 'ocr_call_count': ocr_model.call_count, ++ } == { ++ 'matches': 1, ++ 'unmatched': 0, ++ 'matched_types': ['SemanticTable'], ++ 'matched_labels': ['Table 1'], ++ 'ocr_call_count': 1, ++ } ++ ++ ++def test_ocr_matcher_scales_large_non_svg_image_before_prediction(tmp_path: Path): ++ ++ ++ ++ ++ image_path = _write_png(tmp_path / 'large.png', size=(200, 100)) ++ ocr_model = RecordingOcrModel(['Figure 1']) ++ result = OpticalCharacterRecognitionGraphicMatcher( ++ ocr_model=ocr_model, ++ max_resolution=50, ++ ).get_graphic_matches( ++ semantic_graphic_list=[_semantic_graphic(image_path)], ++ candidate_semantic_content_list=[_figure('Figure 1')], ++ ) ++ ++ assert _snapshot_graphic_match_result(result, ocr_model) == { ++ 'matches': 1, ++ 'unmatched': 0, ++ 'matched_labels': ['Figure 1'], ++ 'ocr_call_count': 1, ++ } ++ assert ocr_model.image_sizes == [(50, 25)] ++ ++ ++def test_ocr_matcher_leaves_missing_path_and_svg_graphics_unmatched_without_ocr(tmp_path: Path): ++ ++ ++ ++ ++ svg_path = _write_png(tmp_path / 'svg.png') ++ missing_path_graphic = _semantic_graphic(local_file_path=None) ++ svg_graphic = _semantic_graphic(local_file_path=svg_path, graphic_type='svg') ++ ocr_model = RecordingOcrModel(['Figure 1']) ++ result = OpticalCharacterRecognitionGraphicMatcher( ++ ocr_model=ocr_model ++ ).get_graphic_matches( ++ semantic_graphic_list=[ ++ missing_path_graphic, ++ svg_graphic, ++ ], ++ candidate_semantic_content_list=[_figure('Figure 1')], ++ ) ++ ++ assert len(result.graphic_matches) == 0 ++ assert len(result.unmatched_graphics) == 2 ++ ++ assert {id(graphic) for graphic in result.unmatched_graphics} == { ++ id(missing_path_graphic), ++ id(svg_graphic), ++ } ++ assert ocr_model.call_count == 0 ++ assert ocr_model.image_sizes == [] ++ ++ ++def test_ocr_matcher_ignores_missing_local_file_path_before_matching(): ++ ++ ++ ++ ++ semantic_graphic = _semantic_graphic(local_file_path=None) ++ ocr_model = RecordingOcrModel(['Figure 1']) ++ matcher = OpticalCharacterRecognitionGraphicMatcher(ocr_model=ocr_model) ++ ++ result = matcher.get_graphic_matches( ++ semantic_graphic_list=[semantic_graphic], ++ candidate_semantic_content_list=[_figure('Figure 1')], ++ ) ++ ++ ++ assert len(result.graphic_matches) == 0 ++ assert list(result.unmatched_graphics) == [semantic_graphic] ++ assert ocr_model.call_count == 0 ++ ++ ++def test_matcher_instances_keep_independent_ocr_state(tmp_path: Path): ++ ++ ++ ++ ++ image_a_path = _write_png(tmp_path / 'a.png') ++ image_b_path = _write_png(tmp_path / 'b.png') ++ ocr_model_a = RecordingOcrModel(['Figure 1']) ++ ocr_model_b = RecordingOcrModel(['Figure 2']) ++ matcher_a = OpticalCharacterRecognitionGraphicMatcher(ocr_model=ocr_model_a) ++ matcher_b = OpticalCharacterRecognitionGraphicMatcher(ocr_model=ocr_model_b) ++ ++ result_a = matcher_a.get_graphic_matches( ++ semantic_graphic_list=[_semantic_graphic(image_a_path)], ++ candidate_semantic_content_list=[_figure('Figure 1')], ++ ) ++ assert _snapshot_graphic_match_result(result_a, ocr_model_a) == { ++ 'matches': 1, ++ 'unmatched': 0, ++ 'matched_labels': ['Figure 1'], ++ 'ocr_call_count': 1, ++ } ++ assert ocr_model_b.call_count == 0 ++ ++ result_b = matcher_b.get_graphic_matches( ++ semantic_graphic_list=[_semantic_graphic(image_b_path)], ++ candidate_semantic_content_list=[_figure('Figure 2')], ++ ) ++ assert _snapshot_graphic_match_result(result_b, ocr_model_b) == { ++ 'matches': 1, ++ 'unmatched': 0, ++ 'matched_labels': ['Figure 2'], ++ 'ocr_call_count': 1, ++ } ++ assert [ocr_model_a.call_count, ocr_model_b.call_count] == [1, 1] ++ ++ ++def test_same_matcher_can_reopen_image_on_repeated_calls(tmp_path: Path): ++ ++ ++ ++ ++ image_path = _write_png(tmp_path / 'repeat.png') ++ ocr_model = RecordingOcrModel(['Figure 1', 'Figure 1']) ++ matcher = OpticalCharacterRecognitionGraphicMatcher(ocr_model=ocr_model) ++ ++ snapshots = [] ++ for _ in range(2): ++ snapshots.append(_snapshot_graphic_match_result( ++ matcher.get_graphic_matches( ++ semantic_graphic_list=[_semantic_graphic(image_path)], ++ candidate_semantic_content_list=[_figure('Figure 1')], ++ ), ++ ocr_model, ++ )) ++ ++ assert snapshots == [ ++ {'matches': 1, 'unmatched': 0, 'matched_labels': ['Figure 1'], 'ocr_call_count': 1}, ++ {'matches': 1, 'unmatched': 0, 'matched_labels': ['Figure 1'], 'ocr_call_count': 2}, ++ ] ++ assert ocr_model.image_sizes == [(10, 10), (10, 10)] ++ ++ ++def test_fulltext_processor_uses_ocr_after_bounding_box_matching(tmp_path: Path): ++ ++ ++ ++ ++ near_path = _write_png(tmp_path / 'near.png') ++ far_path = _write_png(tmp_path / 'far.png') ++ figure_1_label_block = _block( ++ 'Figure 1', ++ LayoutPageCoordinates(x=10, y=10, width=80, height=20, page_number=1), ++ ) ++ figure_2_label_block = _block( ++ 'Figure 2', ++ LayoutPageCoordinates(x=10, y=200, width=80, height=20, page_number=1), ++ ) ++ raw_figure_block = _block( ++ 'raw figure text', ++ LayoutPageCoordinates(x=10, y=10, width=80, height=210, page_number=1), ++ ) ++ near_graphic = LayoutGraphic( ++ coordinates=LayoutPageCoordinates(x=10, y=10, width=80, height=20, page_number=1), ++ local_file_path=str(near_path), ++ page_meta=PAGE_META, ++ ) ++ far_graphic = LayoutGraphic( ++ coordinates=LayoutPageCoordinates(x=300, y=500, width=40, height=40, page_number=1), ++ local_file_path=str(far_path), ++ page_meta=PAGE_META, ++ ) ++ layout_document = LayoutDocument(pages=[LayoutPage( ++ blocks=[raw_figure_block], ++ graphics=[near_graphic, far_graphic], ++ meta=PAGE_META, ++ )]) ++ ocr_model = RecordingOcrModel(['Figure 2']) ++ fulltext_models = _fulltext_models_for_figures( ++ raw_figure_block=raw_figure_block, ++ figures=[ ++ SemanticFigure([SemanticLabel(layout_block=figure_1_label_block)]), ++ SemanticFigure([SemanticLabel(layout_block=figure_2_label_block)]), ++ ], ++ ocr_model=ocr_model, ++ ) ++ ++ semantic_document = FullTextProcessor( ++ fulltext_models, ++ FullTextProcessorConfig( ++ extract_front=False, ++ extract_acknowledgements=False, ++ extract_back_sections=False, ++ extract_references=False, ++ extract_citation_fields=False, ++ extract_figure_fields=True, ++ extract_table_fields=False, ++ extract_graphic_bounding_boxes=True, ++ use_ocr_model=True, ++ max_graphic_distance=0.01, ++ ), ++ ).get_semantic_document_for_layout_document(layout_document=layout_document) ++ ++ figure_graphic_file_names_by_label = {} ++ for figure in iter_by_semantic_type_recursively( ++ [semantic_document.body_section, semantic_document.back_section], ++ SemanticFigure, ++ ): ++ graphics = list(figure.iter_by_type(SemanticGraphic)) ++ figure_graphic_file_names_by_label[ ++ figure.get_text_by_type(SemanticLabel) ++ ] = [ ++ Path(graphic.layout_graphic.local_file_path).name ++ for graphic in graphics ++ ] ++ all_graphics = list(iter_by_semantic_type_recursively( ++ [semantic_document.body_section, semantic_document.back_section], ++ SemanticGraphic, ++ )) ++ ++ ++ assert figure_graphic_file_names_by_label == { ++ 'Figure 1': ['near.png'], ++ 'Figure 2': ['far.png'], ++ } ++ assert len(all_graphics) == 2 ++ assert ocr_model.call_count == 1 ++ assert ocr_model.image_sizes == [(10, 10)] ++ ++ ++def test_repeated_ocr_matcher_cycles_do_not_leak_image_file_descriptors(tmp_path: Path): ++ ++ ++ ++ ++ image_path = _write_png(tmp_path / 'leak-floor.png') ++ gc.collect() ++ fd_count_before = _fd_count() ++ ++ for _ in range(120): ++ ocr_model = RecordingOcrModel(['Figure 1']) ++ matcher = OpticalCharacterRecognitionGraphicMatcher(ocr_model=ocr_model) ++ result = matcher.get_graphic_matches( ++ semantic_graphic_list=[_semantic_graphic(image_path)], ++ candidate_semantic_content_list=[_figure('Figure 1')], ++ ) ++ assert len(result.graphic_matches) == 1 ++ assert len(result.unmatched_graphics) == 0 ++ assert ocr_model.call_count == 1 ++ del matcher ++ del ocr_model ++ ++ gc.collect() ++ assert _fd_count() <= fd_count_before + 3 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,29 @@ ++#!/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 ++export TF_CPP_MIN_LOG_LEVEL="${TF_CPP_MIN_LOG_LEVEL:-3}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_NO_INDEX=1 ++export HF_HUB_OFFLINE=1 ++export TRANSFORMERS_OFFLINE=1 ++ ++if [[ -x /workspace/repo/.venv/bin/python ]]; then ++ PYTHON_BIN=/workspace/repo/.venv/bin/python ++else ++ echo "error: required offline Python venv missing at /workspace/repo/.venv" >&2 ++ exit 1 ++fi ++ ++exec "$PYTHON_BIN" -m pytest -p no:cacheprovider /workspace/repo/usercase-test-coderl/test_ocr_graphic_matching.py -v diff --git a/tasks/format-code-task-000870/tests/test.sh b/tasks/format-code-task-000870/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..11a851f1d3908883dc8e4a22d84a8e505f13947c --- /dev/null +++ b/tasks/format-code-task-000870/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_ocr_graphic_matching.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-000870/tests/test_command.sh b/tasks/format-code-task-000870/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000870/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-000876/environment/Dockerfile b/tasks/format-code-task-000876/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c0d6d9056cb2118ab80277f7814bb589fd3c208d --- /dev/null +++ b/tasks/format-code-task-000876/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5d7d0c8b875c5622daf69074ac575e2f3c24339853fc91ed23c490c3ae961080 diff --git a/tasks/format-code-task-000876/environment/setup/files/blocklist b/tasks/format-code-task-000876/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000876/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000876/environment/setup/setup.sh b/tasks/format-code-task-000876/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000876/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000876/tests/test.patch b/tasks/format-code-task-000876/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..46f48c43293e2d98162bcb44a630063cc253725e --- /dev/null +++ b/tasks/format-code-task-000876/tests/test.patch @@ -0,0 +1,80 @@ +diff --git a/test/unit/rules/require-context-role-test.js b/test/unit/rules/require-context-role-test.js +index c81eccc6..371911e5 100644 +--- a/test/unit/rules/require-context-role-test.js ++++ b/test/unit/rules/require-context-role-test.js +@@ -35,6 +35,12 @@ generateRuleTests({ + '
{{#each someList as |item|}}{{/each}}
', + '
{{#if this.show}}{{#each someList as |item|}}{{/each}}{{/if}}
', + '
One
', ++ ++ '
', ++ '
', ++ '
Item One
', ++ '
Item
', ++ '
x
', + ], + + bad: [ +@@ -298,5 +304,40 @@ generateRuleTests({ + `); + }, + }, ++ { ++ // Only role="presentation"/"none" are transparent — a plain element ++ // with no role still breaks the context chain and should error. ++ template: '
Item One
', ++ verifyResults(results) { ++ expect(results.length).toBe(1); ++ expect(results[0].rule).toBe('require-context-role'); ++ expect(results[0].message).toMatch(/role of "tab"/); ++ expect(results[0].message).toMatch(/\[tablist\]/); ++ expect(results[0].source).toBe('role="tab"'); ++ }, ++ }, ++ { ++ // tab nested through a transparent presentation parent into the ++ // WRONG context role (tree, not tablist) should still error. ++ template: ++ '
Item One
', ++ verifyResults(results) { ++ expect(results.length).toBe(1); ++ expect(results[0].rule).toBe('require-context-role'); ++ expect(results[0].message).toMatch(/role of "tab"/); ++ expect(results[0].source).toBe('role="tab"'); ++ }, ++ }, ++ { ++ // listitem under a wrapper with no role (via presentation) lands at ++ // an unrelated context — still missing required parent. ++ template: ++ '
Item One
', ++ verifyResults(results) { ++ expect(results.length).toBe(1); ++ expect(results[0].rule).toBe('require-context-role'); ++ expect(results[0].message).toMatch(/role of "listitem"/); ++ }, ++ }, + ], + }); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..0a58f312 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["node --experimental-vm-modules ./node_modules/jest/bin/jest.js test/unit/rules/require-context-role-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 --experimental-vm-modules ./node_modules/jest/bin/jest.js test/unit/rules/require-context-role-test.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-000876/tests/test.sh b/tasks/format-code-task-000876/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..900cbc80f0e27b02f18a5366ff6aec1a4d04d491 --- /dev/null +++ b/tasks/format-code-task-000876/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test/unit/rules/require-context-role-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-000876/tests/test_command.sh b/tasks/format-code-task-000876/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000876/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-000877/environment/Dockerfile b/tasks/format-code-task-000877/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ee8116c3d5b283559321ab5822962489efdef749 --- /dev/null +++ b/tasks/format-code-task-000877/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:57aab86b7dd01ac72012a28fdd3819472aa5fdb9223149a61e7393ac85357497 diff --git a/tasks/format-code-task-000877/environment/setup/files/blocklist b/tasks/format-code-task-000877/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000877/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000877/environment/setup/setup.sh b/tasks/format-code-task-000877/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000877/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000877/tests/test.patch b/tasks/format-code-task-000877/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..765ca87b1a50fae308addf8cd96d08d8e997fb08 --- /dev/null +++ b/tasks/format-code-task-000877/tests/test.patch @@ -0,0 +1,455 @@ +diff --git a/usercase-test-coderl/unique_acceptance.cpp b/usercase-test-coderl/unique_acceptance.cpp +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/unique_acceptance.cpp +@@ -0,0 +1,405 @@ ++ ++ ++ ++ ++ ++ ++ ++#include ++#include ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++using Pair = std::pair; ++ ++int g_networkCalls = 0; ++ ++extern "C" int __wrap_socket(int, int, int) { ++ ++g_networkCalls; ++ return -1; ++} ++ ++extern "C" int __wrap_connect(int, const struct sockaddr *, socklen_t) { ++ ++g_networkCalls; ++ return -1; ++} ++ ++extern "C" int __wrap_getaddrinfo(const char *, ++ const char *, ++ const struct addrinfo *, ++ struct addrinfo **) { ++ ++g_networkCalls; ++ return EAI_FAIL; ++} ++ ++template ++rc::Shrinkable shrinkableWithShrinks(const T &value, std::vector shrinks) { ++ std::vector> shrinkables; ++ for (const auto &shrink : shrinks) { ++ shrinkables.push_back(rc::shrinkable::just(shrink)); ++ } ++ return rc::shrinkable::just( ++ value, rc::seq::fromContainer(std::move(shrinkables))); ++} ++ ++rc::Gen wideIntGen() { ++ return [](const rc::Random &random, int) { ++ auto r = random; ++ const auto bucket = static_cast(r.next() % 16); ++ const auto value = 10 + (bucket * 10); ++ return shrinkableWithShrinks(value, {value - 10, value - 7}); ++ }; ++} ++ ++rc::Gen widePairGen() { ++ return [](const rc::Random &random, int) { ++ auto r = random; ++ const auto bucket = static_cast(r.next() % 8); ++ const auto key = bucket + 1; ++ return shrinkableWithShrinks( ++ {key, 100}, {{key - 1, 100}, {key, 50}, {key + 1, 100}}); ++ }; ++} ++ ++rc::Gen singleKeyPairGen() { ++ return [](const rc::Random &random, int) { ++ auto r = random; ++ const auto value = static_cast(r.next() % 32); ++ return shrinkableWithShrinks({0, value}, {{0, value / 2}}); ++ }; ++} ++ ++template ++std::vector toVector(const Container &container) { ++ return std::vector(container.begin(), ++ container.end()); ++} ++ ++std::string showInts(const std::vector &values) { ++ std::ostringstream os; ++ os << "{"; ++ for (std::size_t i = 0; i < values.size(); ++i) { ++ if (i != 0) { ++ os << ", "; ++ } ++ os << values[i]; ++ } ++ os << "}"; ++ return os.str(); ++} ++ ++std::string showPairs(const std::vector &values) { ++ std::ostringstream os; ++ os << "{"; ++ for (std::size_t i = 0; i < values.size(); ++i) { ++ if (i != 0) { ++ os << ", "; ++ } ++ os << "{" << values[i].first << ", " << values[i].second << "}"; ++ } ++ os << "}"; ++ return os.str(); ++} ++ ++template ++std::vector firstShrinks(rc::Shrinkable shrinkable, ++ int limit) { ++ std::vector out; ++ auto shrinks = shrinkable.shrinks(); ++ for (int i = 0; i < limit; ++i) { ++ auto next = shrinks.next(); ++ if (!next) { ++ break; ++ } ++ out.push_back(next->value()); ++ } ++ return out; ++} ++ ++void require(bool condition, const std::string &message) { ++ if (!condition) { ++ throw std::runtime_error(message); ++ } ++} ++ ++void requireEqual(const std::vector &actual, ++ const std::vector &expected, ++ const std::string &label) { ++ if (actual != expected) { ++ throw std::runtime_error(label + ": expected " + showInts(expected) + ++ ", got " + showInts(actual)); ++ } ++} ++ ++void requireEqual(const std::vector &actual, ++ const std::vector &expected, ++ const std::string &label) { ++ if (actual != expected) { ++ throw std::runtime_error(label + ": expected " + showPairs(expected) + ++ ", got " + showPairs(actual)); ++ } ++} ++ ++void requireIntShrinks(const std::vector> &actual, ++ const std::vector> &expected, ++ const std::string &label) { ++ require(actual.size() == expected.size(), ++ label + ": expected " + std::to_string(expected.size()) + ++ " shrinks, got " + std::to_string(actual.size())); ++ for (std::size_t i = 0; i < expected.size(); ++i) { ++ requireEqual(actual[i], expected[i], ++ label + " shrink " + std::to_string(i)); ++ } ++} ++ ++void requirePairShrinks(const std::vector> &actual, ++ const std::vector> &expected, ++ const std::string &label) { ++ require(actual.size() == expected.size(), ++ label + ": expected " + std::to_string(expected.size()) + ++ " shrinks, got " + std::to_string(actual.size())); ++ for (std::size_t i = 0; i < expected.size(); ++i) { ++ requireEqual(actual[i], expected[i], ++ label + " shrink " + std::to_string(i)); ++ } ++} ++ ++template ++bool allDistinct(const std::vector &values) { ++ return std::set(values.begin(), values.end()).size() == values.size(); ++} ++ ++bool allDistinctKeys(const std::vector &values) { ++ std::set keys; ++ for (const auto &value : values) { ++ keys.insert(value.first); ++ } ++ return keys.size() == values.size(); ++} ++ ++std::set directoryEntries(const std::string &path) { ++ std::set entries; ++ DIR *dir = opendir(path.c_str()); ++ if (dir == nullptr) { ++ throw std::runtime_error("could not open directory " + path); ++ } ++ ++ while (auto *entry = readdir(dir)) { ++ const std::string name(entry->d_name); ++ if ((name != ".") && (name != "..")) { ++ entries.insert(name); ++ } ++ } ++ closedir(dir); ++ return entries; ++} ++ ++void testVariableVectorUniqueValuesAndShrinks() { ++ ++ ++ const auto generated = ++ rc::gen::unique>(wideIntGen())(rc::Random(0), 4); ++ ++ require(allDistinct(generated.value()), ++ "variable vector generated value has duplicates"); ++ ++ const auto shrinks = firstShrinks(generated, 11); ++ ++ for (const auto &shrink : shrinks) { ++ require(allDistinct(shrink), "variable vector shrink has duplicates"); ++ } ++} ++ ++void testFixedListHasRequestedLengthAndUniqueShrinks() { ++ ++ ++ const auto generated = ++ rc::gen::unique>(3, wideIntGen())(rc::Random(2), 4); ++ ++ require(generated.value().size() == 3, "fixed list generated length"); ++ require(allDistinct(toVector(generated.value())), ++ "fixed list generated value has duplicates"); ++ ++ const auto rawShrinks = firstShrinks(generated, 6); ++ std::vector> shrinks; ++ for (const auto &shrink : rawShrinks) { ++ shrinks.push_back(toVector(shrink)); ++ } ++ ++ for (const auto &shrink : shrinks) { ++ require(shrink.size() == 3, "fixed list shrink changed requested length"); ++ require(allDistinct(shrink), "fixed list shrink has duplicates"); ++ } ++} ++ ++void testVariableUniqueByUsesProjectedKeyOnly() { ++ ++ ++ const auto keyFn = [](const Pair &p) { return p.first; }; ++ const auto generated = ++ rc::gen::uniqueBy>(widePairGen(), keyFn)(rc::Random(0), ++ 4); ++ ++ require(allDistinctKeys(generated.value()), ++ "variable uniqueBy generated value has duplicate keys"); ++ ++ const auto shrinks = firstShrinks(generated, 12); ++ ++ for (const auto &shrink : shrinks) { ++ require(allDistinctKeys(shrink), "variable uniqueBy shrink has duplicate keys"); ++ } ++} ++ ++void testFixedUniqueByHasRequestedLengthAndKeys() { ++ ++ ++ const auto keyFn = [](const Pair &p) { return p.first; }; ++ const auto generated = rc::gen::uniqueBy>( ++ 2, widePairGen(), keyFn)(rc::Random(99), 4); ++ ++ require(generated.value().size() == 2, "fixed uniqueBy generated length"); ++ require(allDistinctKeys(generated.value()), ++ "fixed uniqueBy generated value has duplicate keys"); ++ ++ const auto shrinks = firstShrinks(generated, 6); ++ ++ for (const auto &shrink : shrinks) { ++ require(shrink.size() == 2, "fixed uniqueBy shrink changed requested length"); ++ require(allDistinctKeys(shrink), "fixed uniqueBy shrink has duplicate keys"); ++ } ++} ++ ++void testImpossibleUniqueThrowsGenerationFailure() { ++ ++ ++ const auto impossible = rc::gen::unique>(2, rc::gen::just(0)); ++ try { ++ (void)impossible(rc::Random(9), 3).value(); ++ } catch (const rc::GenerationFailure &e) { ++ ++ (void)e; ++ return; ++ } ++ throw std::runtime_error("expected rc::GenerationFailure"); ++} ++ ++void testImpossibleUniqueByThrowsGenerationFailure() { ++ const auto keyFn = [](const Pair &p) { return p.first; }; ++ ++ const auto impossible = ++ rc::gen::uniqueBy>(2, singleKeyPairGen(), keyFn); ++ try { ++ (void)impossible(rc::Random(11), 4).value(); ++ } catch (const rc::GenerationFailure &e) { ++ ++ (void)e; ++ return; ++ } ++ throw std::runtime_error("expected rc::GenerationFailure for duplicate keys"); ++} ++ ++void testReferentialTransparencyForSameGeneratorEvaluation() { ++ const auto generator = rc::gen::unique>(wideIntGen()); ++ const auto first = generator(rc::Random(3), 4).value(); ++ const auto second = generator(rc::Random(3), 4).value(); ++ ++ require(first == second, "same generator/random/size produced different values"); ++} ++ ++void testCreatingUniqueDoesNotMutateSuppliedGeneratorObject() { ++ const auto source = wideIntGen(); ++ const auto before = source(rc::Random(12), 4).value(); ++ const auto unique = rc::gen::unique>(source); ++ (void)unique; ++ const auto after = source(rc::Random(12), 4).value(); ++ ++ require(before == after, "creating unique mutated supplied generator object"); ++} ++ ++void testNoHiddenGlobalStateWithInProcessNoise() { ++ const auto original = rc::gen::unique>(wideIntGen()); ++ const auto baseline = original(rc::Random(5), 4).value(); ++ ++ (void)rc::gen::unique>(3, wideIntGen())(rc::Random(42), 4) ++ .value(); ++ const auto keyFn = [](const Pair &p) { return p.first; }; ++ (void)rc::gen::uniqueBy>(2, widePairGen(), keyFn)( ++ rc::Random(17), 4).value(); ++ ++ const auto afterNoise = original(rc::Random(5), 4).value(); ++ ++ require(baseline == afterNoise, "in-process generator noise affected result"); ++} ++ ++void testNoRelativeFilesystemSideEffects() { ++ const std::string cwd = "."; ++ const auto before = directoryEntries(cwd); ++ const auto networkBefore = g_networkCalls; ++ ++ const auto keyFn = [](const Pair &p) { return p.first; }; ++ (void)rc::gen::unique>(wideIntGen())(rc::Random(1), 4) ++ .value(); ++ (void)rc::gen::unique>(3, wideIntGen())(rc::Random(1), 4) ++ .value(); ++ (void)rc::gen::uniqueBy>(widePairGen(), keyFn)( ++ rc::Random(1), 4).value(); ++ (void)rc::gen::uniqueBy>(2, widePairGen(), keyFn)( ++ rc::Random(1), 4).value(); ++ ++ const auto after = directoryEntries(cwd); ++ require(before == after, "generator evaluation changed cwd entries"); ++ require(g_networkCalls == networkBefore, "generator evaluation touched network APIs"); ++} ++ ++int main() { ++ const std::vector> tests = { ++ {"variable vector unique values and shrinks", ++ &testVariableVectorUniqueValuesAndShrinks}, ++ {"fixed list requested length and unique shrinks", ++ &testFixedListHasRequestedLengthAndUniqueShrinks}, ++ {"variable uniqueBy projected key", &testVariableUniqueByUsesProjectedKeyOnly}, ++ {"fixed uniqueBy requested length and keys", ++ &testFixedUniqueByHasRequestedLengthAndKeys}, ++ {"impossible unique throws GenerationFailure", ++ &testImpossibleUniqueThrowsGenerationFailure}, ++ {"impossible uniqueBy throws GenerationFailure", ++ &testImpossibleUniqueByThrowsGenerationFailure}, ++ {"referential transparency", ++ &testReferentialTransparencyForSameGeneratorEvaluation}, ++ {"no mutation of supplied generator object", ++ &testCreatingUniqueDoesNotMutateSuppliedGeneratorObject}, ++ {"no hidden global state", &testNoHiddenGlobalStateWithInProcessNoise}, ++ {"no relative filesystem side effects", &testNoRelativeFilesystemSideEffects}, ++ }; ++ ++ int failures = 0; ++ for (const auto &test : tests) { ++ try { ++ test.second(); ++ std::cout << "PASS " << test.first << "\n"; ++ } catch (const std::exception &e) { ++ ++failures; ++ std::cerr << "FAIL " << test.first << ": " << e.what() << "\n"; ++ } ++ } ++ ++ if (failures != 0) { ++ std::cerr << failures << " acceptance test(s) failed\n"; ++ return EXIT_FAILURE; ++ } ++ return EXIT_SUCCESS; ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,40 @@ ++#!/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 ++ ++cmake -S . -B .fixture-build \ ++ -DRC_ENABLE_TESTS=OFF \ ++ -DRC_ENABLE_EXAMPLES=OFF \ ++ -DRC_INSTALL_ALL_EXTRAS=OFF \ ++ -DRC_ENABLE_CATCH=OFF \ ++ -DRC_ENABLE_DOCTEST=OFF \ ++ -DRC_ENABLE_GMOCK=OFF \ ++ -DRC_ENABLE_GTEST=OFF \ ++ -DRC_ENABLE_BOOST=OFF \ ++ -DRC_ENABLE_BOOST_TEST=OFF >/dev/null ++cmake --build .fixture-build --target rapidcheck -j"$(nproc)" >/dev/null ++ ++c++ -std=c++11 -Wall -Wextra \ ++ -I/workspace/repo/include \ ++ /workspace/repo/usercase-test-coderl/unique_acceptance.cpp \ ++ /workspace/repo/.fixture-build/librapidcheck.a \ ++ -Wl,--wrap=socket \ ++ -Wl,--wrap=connect \ ++ -Wl,--wrap=getaddrinfo \ ++ -o /workspace/repo/.fixture-build/unique_acceptance ++ ++tmpdir="$(mktemp -d)" ++trap 'rm -rf "$tmpdir"' EXIT ++cd "$tmpdir" ++exec /workspace/repo/.fixture-build/unique_acceptance diff --git a/tasks/format-code-task-000877/tests/test.sh b/tasks/format-code-task-000877/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bdfe9b647bc6e299b8f7d2c6b08bbf9ebf3a17ac --- /dev/null +++ b/tasks/format-code-task-000877/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/unique_acceptance.cpp +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-000877/tests/test_command.sh b/tasks/format-code-task-000877/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000877/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-000882/environment/Dockerfile b/tasks/format-code-task-000882/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c0e43d33acac00bdbacd3a90ae765479345a5c2c --- /dev/null +++ b/tasks/format-code-task-000882/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:00c7be7cdda55bbae88128ac50d49aabbcbc677953b04b969c493964e0437cba diff --git a/tasks/format-code-task-000882/environment/setup/files/blocklist b/tasks/format-code-task-000882/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000882/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000882/environment/setup/setup.sh b/tasks/format-code-task-000882/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-000882/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-000882/tests/test.patch b/tasks/format-code-task-000882/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..15773140817a02625f06cb210af9ef33fd5fc88d --- /dev/null +++ b/tasks/format-code-task-000882/tests/test.patch @@ -0,0 +1,507 @@ +diff --git a/usercase-test-coderl/stats_stateful.test.js b/usercase-test-coderl/stats_stateful.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/stats_stateful.test.js +@@ -0,0 +1,466 @@ ++const http = require('http') ++ ++const Stats = require('/workspace/repo/envoy-curses/src/stats.js') ++ ++function makeLog() { ++ return { ++ errors: [], ++ debugMessages: [], ++ error(message) { ++ this.errors.push(message) ++ }, ++ debug(message) { ++ this.debugMessages.push(message) ++ }, ++ } ++} ++ ++function expectUnknownSeriesError(log, statName) { ++ ++ expect(log.errors.length).toBe(1) ++ expect(log.errors[0]).toEqual(expect.stringContaining('unknown')) ++ expect(log.errors[0]).toEqual(expect.stringContaining(statName)) ++} ++ ++function sleep(ms) { ++ return new Promise(resolve => setTimeout(resolve, ms)) ++} ++ ++function withFakeNow(isoTimestamp, fn) { ++ const RealDate = Date ++ ++ function FakeDate(...args) { ++ if (this instanceof FakeDate) { ++ if (args.length === 0) { ++ return new RealDate(isoTimestamp) ++ } ++ return new RealDate(...args) ++ } ++ return RealDate(...args) ++ } ++ ++ FakeDate.now = () => new RealDate(isoTimestamp).getTime() ++ FakeDate.parse = RealDate.parse ++ FakeDate.UTC = RealDate.UTC ++ FakeDate.prototype = RealDate.prototype ++ global.Date = FakeDate ++ ++ return Promise.resolve() ++ .then(fn) ++ .finally(() => { ++ global.Date = RealDate ++ }) ++} ++ ++function waitForUpdated(stats, action) { ++ return new Promise((resolve, reject) => { ++ const timer = setTimeout(() => reject(new Error('timed out waiting for updated')), 1000) ++ stats.once('updated', () => { ++ clearTimeout(timer) ++ resolve() ++ }) ++ action() ++ }) ++} ++ ++function makeStatsServer(bodies) { ++ let requestIndex = 0 ++ const server = http.createServer((req, res) => { ++ const body = bodies[Math.min(requestIndex, bodies.length - 1)] ++ requestIndex++ ++ res.statusCode = 200 ++ res.end(body) ++ }) ++ ++ return new Promise(resolve => { ++ server.listen(0, '127.0.0.1', () => { ++ resolve({ ++ uri: `http://127.0.0.1:${server.address().port}/stats`, ++ requests: () => requestIndex, ++ close: () => new Promise(done => server.close(done)), ++ }) ++ }) ++ }) ++} ++ ++describe('Stats stateful model acceptance', () => { ++ test('constructor requires statsURI and applies default options', async () => { ++ ++ ++ let caught = null ++ try { ++ new Stats({log: makeLog()}) ++ } catch (err) { ++ caught = err ++ } ++ ++ expect(caught.constructor).toBe(Error) ++ expect(caught.message).toBe('Stats ctor: statsURI is required') ++ ++ const bodies = [] ++ const fakeTimes = [] ++ const expectedGaugeValues = [] ++ const expectedGaugeTimes = [] ++ for (let i = 0; i < 20; i++) { ++ bodies.push(`server.uptime: ${i}\nserver.memory_allocated: ${100 + i}\ncluster.demo.upstream_rq_total: ${7 + i}`) ++ const seconds = String(i).padStart(2, '0') ++ fakeTimes.push(`2020-01-01T09:00:${seconds}Z`) ++ if (i < 19) { ++ expectedGaugeValues.push(100 + i) ++ expectedGaugeTimes.push(`09:00:${seconds}`) ++ } ++ } ++ const server = await makeStatsServer(bodies) ++ const realSetInterval = global.setInterval ++ const scheduledIntervals = [] ++ ++ global.setInterval = (fn, ms) => { ++ scheduledIntervals.push({fn: fn, ms: ms}) ++ return 4242 ++ } ++ ++ try { ++ const stats = new Stats({ ++ statsURI: server.uri, ++ log: makeLog(), ++ }) ++ ++ expect(stats.getStatsTable(/^server\./)).toEqual([ ++ ['Stat Name', 'Stat Value'], ++ ]) ++ expect(Array.from(stats.getStatNames('cluster.demo.')).sort()).toEqual([]) ++ ++ await withFakeNow(fakeTimes[0], () => { ++ return waitForUpdated(stats, () => stats.start()) ++ }) ++ ++ ++ expect(scheduledIntervals.length).toBe(1) ++ expect(scheduledIntervals[0].ms).toBe(1000) ++ ++ for (let i = 1; i < fakeTimes.length; i++) { ++ await withFakeNow(fakeTimes[i], () => { ++ return waitForUpdated(stats, () => stats.pollStats()) ++ }) ++ } ++ ++ ++ expect(stats.getSeriesAsGauge('server.memory_allocated')).toEqual({ ++ x: expectedGaugeTimes, ++ y: expectedGaugeValues, ++ }) ++ } finally { ++ global.setInterval = realSetInterval ++ await server.close() ++ } ++ }) ++ ++ test('pollStats parses colon-delimited stats and refreshes current table state', async () => { ++ ++ ++ const server = await makeStatsServer([ ++ 'server.uptime: 10\nserver.memory_allocated: 100\ncluster.demo.upstream_rq_total: 7', ++ ]) ++ ++ try { ++ const stats = new Stats({ ++ statsURI: server.uri, ++ log: makeLog(), ++ bufferSize: 4, ++ pollingInterval: 250, ++ }) ++ let updatedCount = 0 ++ stats.on('updated', () => { ++ updatedCount++ ++ }) ++ ++ await withFakeNow('2020-01-01T09:10:11Z', () => { ++ return waitForUpdated(stats, () => stats.pollStats()) ++ }) ++ ++ expect(updatedCount).toBe(1) ++ expect(stats.getCurrentStatValue('server.uptime')).toBe(10) ++ expect(stats.getStatsTable(/^server\./)).toEqual([ ++ ['Stat Name', 'Stat Value'], ++ ['server.uptime', '10'], ++ ['server.memory_allocated', '100'], ++ ]) ++ expect(Array.from(stats.getStatNames('cluster.demo.')).sort()).toEqual([ ++ 'upstream_rq_total', ++ ]) ++ } finally { ++ await server.close() ++ } ++ }) ++ ++ test('counter and gauge series traverse stored circular samples with literal timestamps', async () => { ++ ++ ++ const server = await makeStatsServer([ ++ 'server.uptime: 10\nserver.memory_allocated: 100\ncluster.demo.upstream_rq_total: 7', ++ 'server.uptime: 20\nserver.memory_allocated: 130\ncluster.demo.upstream_rq_total: 12', ++ 'server.uptime: 30\nserver.memory_allocated: 125\ncluster.demo.upstream_rq_total: 20', ++ 'server.uptime: 40\nserver.memory_allocated: 140\ncluster.demo.upstream_rq_total: 30', ++ ]) ++ ++ try { ++ const stats = new Stats({ ++ statsURI: server.uri, ++ log: makeLog(), ++ bufferSize: 4, ++ pollingInterval: 250, ++ }) ++ const fakeTimes = [ ++ '2020-01-01T09:10:11Z', ++ '2020-01-01T09:10:12Z', ++ '2020-01-01T09:10:13Z', ++ '2020-01-01T09:10:14Z', ++ ] ++ ++ for (let i = 0; i < fakeTimes.length; i++) { ++ await withFakeNow(fakeTimes[i], () => { ++ return waitForUpdated(stats, () => stats.pollStats()) ++ }) ++ } ++ ++ expect(stats.getCurrentStatValue('server.uptime')).toBe(40) ++ expect(stats.getSeries('cluster.demo.upstream_rq_total')).toEqual({ ++ x: ['09:10:12', '09:10:13'], ++ y: [5, 8], ++ }) ++ expect(stats.getSeriesAsGauge('server.memory_allocated')).toEqual({ ++ x: ['09:10:11', '09:10:12', '09:10:13'], ++ y: [100, 130, 125], ++ }) ++ } finally { ++ await server.close() ++ } ++ }) ++ ++ test('unknown stat lookups log errors and return literal miss values', async () => { ++ ++ ++ const currentLog = makeLog() ++ const currentStats = new Stats({ ++ statsURI: 'http://127.0.0.1:65535/stats', ++ log: currentLog, ++ bufferSize: 4, ++ }) ++ ++ expect(currentStats.getCurrentStatValue('missing.stat')).toBe('err - missing.stat') ++ expectUnknownSeriesError(currentLog, 'missing.stat') ++ ++ const counterLog = makeLog() ++ const counterStats = new Stats({ ++ statsURI: 'http://127.0.0.1:65535/stats', ++ log: counterLog, ++ bufferSize: 4, ++ }) ++ ++ expect(counterStats.getSeries('missing.stat')).toBe(null) ++ expectUnknownSeriesError(counterLog, 'missing.stat') ++ ++ const gaugeLog = makeLog() ++ const gaugeStats = new Stats({ ++ statsURI: 'http://127.0.0.1:65535/stats', ++ log: gaugeLog, ++ bufferSize: 4, ++ }) ++ ++ expect(gaugeStats.getSeriesAsGauge('missing.stat')).toBe(null) ++ expectUnknownSeriesError(gaugeLog, 'missing.stat') ++ }) ++ ++ test('failed fetches are logged and do not emit updated', async () => { ++ ++ ++ const log = makeLog() ++ const stats = new Stats({ ++ statsURI: 'ftp://127.0.0.1/stats', ++ log: log, ++ bufferSize: 4, ++ }) ++ let updatedCount = 0 ++ stats.on('updated', () => { ++ updatedCount++ ++ }) ++ ++ stats.pollStats() ++ await sleep(50) ++ ++ expect(updatedCount).toBe(0) ++ ++ expect(log.errors.length).toBe(1) ++ expect(log.errors[0]).toMatch(/^Error polling stats: .+/) ++ }) ++ ++ test('start performs an immediate poll and schedules interval polling', async () => { ++ ++ ++ const server = await makeStatsServer([ ++ 'server.uptime: 10\nserver.memory_allocated: 100\ncluster.demo.upstream_rq_total: 7', ++ 'server.uptime: 11\nserver.memory_allocated: 105\ncluster.demo.upstream_rq_total: 8', ++ ]) ++ const realSetInterval = global.setInterval ++ const scheduledIntervals = [] ++ ++ global.setInterval = (fn, ms) => { ++ scheduledIntervals.push({fn: fn, ms: ms}) ++ return 4242 ++ } ++ ++ try { ++ const stats = new Stats({ ++ statsURI: server.uri, ++ log: makeLog(), ++ bufferSize: 4, ++ pollingInterval: 25, ++ }) ++ let updatedCount = 0 ++ stats.on('updated', () => { ++ updatedCount++ ++ }) ++ ++ await withFakeNow('2020-01-01T08:00:01Z', () => { ++ return waitForUpdated(stats, () => stats.start()) ++ }) ++ ++ expect(updatedCount).toBe(1) ++ expect(scheduledIntervals.length).toBe(1) ++ expect(scheduledIntervals[0].ms).toBe(25) ++ expect(stats.getCurrentStatValue('server.uptime')).toBe(10) ++ ++ await withFakeNow('2020-01-01T08:00:02Z', () => { ++ return waitForUpdated(stats, () => scheduledIntervals[0].fn()) ++ }) ++ ++ expect(updatedCount).toBe(2) ++ expect(stats.getCurrentStatValue('server.uptime')).toBe(11) ++ expect(server.requests()).toBe(2) ++ } finally { ++ global.setInterval = realSetInterval ++ await server.close() ++ } ++ }) ++ ++ test('two Stats instances keep independent in-memory samples', async () => { ++ ++ ++ const serverA = await makeStatsServer([ ++ 'server.uptime: 1\nserver.memory_allocated: 10\ncluster.demo.upstream_rq_total: 3', ++ 'server.uptime: 2\nserver.memory_allocated: 20\ncluster.demo.upstream_rq_total: 4', ++ ]) ++ const serverB = await makeStatsServer([ ++ 'server.uptime: 100\nserver.memory_allocated: 1000\ncluster.demo.upstream_rq_total: 30', ++ ]) ++ ++ try { ++ const statsA = new Stats({ ++ statsURI: serverA.uri, ++ log: makeLog(), ++ bufferSize: 4, ++ }) ++ const statsB = new Stats({ ++ statsURI: serverB.uri, ++ log: makeLog(), ++ bufferSize: 4, ++ }) ++ ++ await withFakeNow('2020-01-01T07:00:01Z', () => { ++ return waitForUpdated(statsA, () => statsA.pollStats()) ++ }) ++ await withFakeNow('2020-01-01T07:00:02Z', () => { ++ return waitForUpdated(statsA, () => statsA.pollStats()) ++ }) ++ await withFakeNow('2020-01-01T07:00:03Z', () => { ++ return waitForUpdated(statsB, () => statsB.pollStats()) ++ }) ++ ++ expect(statsA.getCurrentStatValue('server.uptime')).toBe(2) ++ expect(statsB.getCurrentStatValue('server.uptime')).toBe(100) ++ expect(statsA.getStatsTable(/^server\./)).toEqual([ ++ ['Stat Name', 'Stat Value'], ++ ['server.uptime', '2'], ++ ['server.memory_allocated', '20'], ++ ]) ++ expect(statsB.getStatsTable(/^server\./)).toEqual([ ++ ['Stat Name', 'Stat Value'], ++ ['server.uptime', '100'], ++ ['server.memory_allocated', '1000'], ++ ]) ++ } finally { ++ await serverA.close() ++ await serverB.close() ++ } ++ }) ++ ++ test('updated event listeners observe each refreshed model update', async () => { ++ ++ ++ const server = await makeStatsServer([ ++ 'server.uptime: 5\nserver.memory_allocated: 50\ncluster.demo.upstream_rq_total: 9', ++ 'server.uptime: 6\nserver.memory_allocated: 55\ncluster.demo.upstream_rq_total: 10', ++ ]) ++ ++ try { ++ const stats = new Stats({ ++ statsURI: server.uri, ++ log: makeLog(), ++ bufferSize: 4, ++ }) ++ let updatedCount = 0 ++ const listener = () => { ++ updatedCount++ ++ } ++ stats.on('updated', listener) ++ ++ await withFakeNow('2020-01-01T06:00:01Z', () => { ++ return waitForUpdated(stats, () => stats.pollStats()) ++ }) ++ ++ expect(updatedCount).toBe(1) ++ expect(stats.getCurrentStatValue('server.uptime')).toBe(5) ++ ++ await withFakeNow('2020-01-01T06:00:02Z', () => { ++ return waitForUpdated(stats, () => stats.pollStats()) ++ }) ++ ++ ++ expect(updatedCount).toBe(2) ++ expect(stats.getCurrentStatValue('server.uptime')).toBe(6) ++ } finally { ++ await server.close() ++ } ++ }) ++ ++ test('repeated construct-poll cycles refresh independent in-memory models', async () => { ++ ++ ++ const server = await makeStatsServer([ ++ 'server.uptime: 1\nserver.memory_allocated: 2\ncluster.demo.upstream_rq_total: 3', ++ ]) ++ ++ try { ++ for (let i = 0; i < 5; i++) { ++ const stats = new Stats({ ++ statsURI: server.uri, ++ log: makeLog(), ++ bufferSize: 4, ++ pollingInterval: 1000, ++ }) ++ await withFakeNow('2020-01-01T05:00:01Z', () => { ++ return waitForUpdated(stats, () => stats.pollStats()) ++ }) ++ ++ expect(stats.getCurrentStatValue('server.uptime')).toBe(1) ++ expect(stats.getStatsTable(/^server\./)).toEqual([ ++ ['Stat Name', 'Stat Value'], ++ ['server.uptime', '1'], ++ ['server.memory_allocated', '2'], ++ ]) ++ } ++ } finally { ++ await server.close() ++ } ++ }) ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,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/envoy-curses ++ ++if [ ! -d node_modules ]; then ++ echo "envoy-curses/node_modules is missing; dependencies must be preinstalled for offline test execution" >&2 ++ exit 1 ++fi ++ ++if [ ! -x ./node_modules/.bin/jest ]; then ++ echo "envoy-curses local Jest binary is missing; dependencies must be preinstalled for offline test execution" >&2 ++ exit 1 ++fi ++ ++export npm_config_audit=false ++export npm_config_fund=false ++export npm_config_offline=true ++export NO_UPDATE_NOTIFIER=1 ++ ++exec ./node_modules/.bin/jest --rootDir /workspace/repo /workspace/repo/usercase-test-coderl/stats_stateful.test.js --runInBand diff --git a/tasks/format-code-task-000882/tests/test.sh b/tasks/format-code-task-000882/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..745899d23fea158713c138e0cbd4fbe7ccf7218d --- /dev/null +++ b/tasks/format-code-task-000882/tests/test.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/stats_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-000882/tests/test_command.sh b/tasks/format-code-task-000882/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-000882/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-000883/environment/Dockerfile b/tasks/format-code-task-000883/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..18eb933df76ee730648ad34abd56ec724aa1517e --- /dev/null +++ b/tasks/format-code-task-000883/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6369479195e03a4e383a7e4df3488abf3df596ec7db798e72a7db3ea267b02dd diff --git a/tasks/format-code-task-000883/environment/setup/files/blocklist b/tasks/format-code-task-000883/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-000883/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-000883/environment/setup/setup.sh b/tasks/format-code-task-000883/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-000883/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-000883/tests/test.patch b/tasks/format-code-task-000883/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..165e641169d8c97c747ef5c95094efd2890c88ac --- /dev/null +++ b/tasks/format-code-task-000883/tests/test.patch @@ -0,0 +1,100 @@ +diff --git a/spec/erector/html_spec.rb b/spec/erector/html_spec.rb +index a7378a7..9ee4208 100644 +--- a/spec/erector/html_spec.rb ++++ b/spec/erector/html_spec.rb +@@ -506,4 +506,45 @@ + erector { close_tag :foo; close_tag :bar }.should == "" + end + end ++ ++ describe "exception handling" do ++ class RenderWithReturn < Erector::Widget ++ def content ++ h2 do ++ return "returned_value" ++ text "don't get here" ++ end ++ end ++ end ++ ++ it "closes tags when a block returns" do ++ RenderWithReturn.new.to_html.should == "

" ++ end ++ ++ it "closes tags when a block throws and the exception is caught" do ++ erector do ++ begin ++ div do ++ raise "no way" ++ text "not reached" ++ end ++ rescue ++ end ++ end.should == "
" ++ end ++ ++ it "closes tags when throwing block versus text exception" do ++ erector do ++ begin ++ span "a value" do ++ text "a block" ++ end ++ rescue ArgumentError => e ++ e.to_s.should include( ++ "You can't pass both a block and a value") ++ end ++ end.should == "" ++ end ++ end ++ + end +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,34 @@ ++H4sIAAAAAAAAA+1ZbY8TORLmc/+KviAdg8R0/P4yB0i3MAvogEUs6HSfRmW7PBORpLPdHQ6+7G+/ ++6mSSTCbzsuzNcjptKlLSXbaryq6nqmynCvPROJ3g9PPw3h9FjMhqvfgluvy7eOZacCGUNdreY5wb ++ru6V+g+z6ALN2w6asrzX1HV3U7/b2v9Pqdr4/wVO8miMd6+jd7BR6lr/C2bW/heMk/8lM+Zeye7e ++lF36k/u/redNxHJw1nWz9mg4bObh6ylO2qpuTgdFQY/loGsQu3o2WL418An7lqaez8qjhJ9xXM8m ++OO3KVBdluezTzjAOHpWDX5/Kig3W7Gb9OK0/1aejZjQocJqK//Uq/HlpN/6rcR0/3amOW+LfCMM3 ++8S+oTnDFpNjH//egF8dvKCQbnNQdHpVXZYEhtffh3B7RQ1mmUc6H49iWB7wylXi4YK6iuWdyX8lD ++gCaeGXU4Hk3nXw5Pp/NlP9IEMZYHvz4teaV+09jJvB1/y+Bm8vuUrsd9u0KyNUHz79H0G4Z9cebk ++vxj3e6a4NfTmWc7q8dfTcd2VB6ySlV4yl9145Sq+YnxCYshKrXDQNOWBrPj6tcfNgiNXrHPmYawb ++XOhcNLLtRvxC3x10o3raXttpQmlqt/Wi9AXfbI9q57NZ3XTXjNtWvGjXq/Eb4D99QislKvaofFyK ++y2bdrODc6EWDu1PJ69ZFk102nVfuZazytcKNe0kUefhhUbx7/fcPP/70/s3P1GUneHd4PXp65sVg ++23rfdFiDnF63QL95vyhiB6RF8fz43fHb58dvn7067q1b4bpYArD/aYo11hZrs1iY87kXxbOXx8/+ ++8fPHxdTCfJrGSChVFau4eli2ZyC0eZKYBwbe6Jgt1SBjwKLy6KThLKCNIqv+3XAuVVQCtHFMhSCd ++jFGo4IrdxLgS7QFZEjGATSplSSehjC4mZ5gA+lLeS8yRpQyeZOdMor3xmAP3zHsjit+UXlfalAnO ++o042kPVKRYEoDbNeCcWiQRCg0GRgUTvfPyflbApmUXyDkf52bYvMsVLnpBcpp5gEp2UCr1II6GOM ++XLqEwHjwNggVg0iR5su5iuBdoMklWvBgr1S3lcJXmqTnPumco5QKkrUOFHgMzuVEKxuDCzwH7aID ++LSCafra9WZlJh9aqfLOmrUn5iDzSYtBaBh+NDVxrhkFLC8CdREieI60WPQSRpYGETCSXkgDrczDX ++qNqk+5UiS8sTErkm8GAhRO4C04zs5yBjTtII4qYIRgQUjjmtYlScW8+lJnxeCY3twrLWZLPMATRh ++0EQtIUiORuRoonDZMs2ZTzxk2oopqU20JnMpAqnVVjjC7Q2adl0lsmbWGcEyctHHkPFBB24l50EK ++LQn3XMvECJuEmcSMVy54YZJhjnl75frtFq+1NuWiZ4YQaAxG0BQ52iQtckLU2QPPmifjwQoUwSiC ++C6HDBhVRegTZA+NyuVuJ1j6RzKxRRhKuJI/S90izkZP1kBWFqCZfiCzIJyIbUNI7mmTCzA3kYrto ++rmMUbDZeUJTzFDC6oEWffoK0MkTaDCvnRNA6R50EKmVBcACg3pLJRF4rLpXelVwyTWhyGoUJzw49 ++jyBtSCmo4AGyVFprHhT5IRGkvPIB6fCdgTKBk5bx4mIBXwuNCnSMnmfGhRQ2SU7hZigTakXzz55g ++mlz2kZArOURlaMbJUQwFljMPxeVtwNpvtPF3CpijaPaOUmt2JlkyGaU1ljtyYWQheqUIlUFIRQgx ++WUifnWDa2eLKYr+SDrSGkhzNyXE2GAYuRCBXyR7gPCWgXJu0puXN2VNKD6iMlOSC5ISjbFXcuCVY ++JyUJKkmgZKYZ6UBQZC96stIySTozIQy14Ropzp2mWWWUwDxlD+0oMIqr9wUr8cxRbpH04VZLmRWJ ++JfMp2wRNRShTBTKUpRzFMIUupSqRqBPIwDhkntRmiS5vDtYKKE+i1pY5KwghmHtXGOsZp+BBDIoF ++Fr2zGiTJd5LmkLXKwUrHo7Kx2N1irB0gmZJZisyjoYxGhSdQ9QPplENKm5SZjXfeCm0hC2MJmQQc ++Qx7SlAZlgqL44ePb56+Pn5f/fPXhJSlaVuz9VcHd0oXzfzwdncR6MoOuasJd6rjt/o8Ccn3+pxjp ++z/+0W9mf/78HNfjLfET58wF5/0Fxv3wHXTwrn714VWEbYYYvP7x5XXZ1OVnw38/DVzqh+DLgGXwe ++1VQtUj190JXLzmU7mp6OsfxlXnfYPiziGNq2fPy4l9efBsYjaE8m2J3VqTyqm9HpyUbJo/Jo89Jv ++pzGXG8ZB2zUke3mAuTRy1VadtvNwMPjrfen/1t89Phj03fvrxf0V47V0If7JZV2fACYwTVV7dnc6 ++bvv/R+gL//9w1ce/4fv7/+9C9/8ynLfNMIymQ8JAGaA9K1rsykOc1+VsNMMMo3ERU7mAR8B0XpZP ++Xhy/+fHV6+MnK/5w9ya5fP/xh3/99O7Dk8Fhc1W3TcEZnO8R+68hNrThqpvhWTcZn/QcKkf78N3T ++nva0pz3taU972tOe7oD+A+G91xwAKAAA +diff --git 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-000883/tests/test.sh b/tasks/format-code-task-000883/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f6ecd8d5be779128581e24f101f781d3a1b392de --- /dev/null +++ b/tasks/format-code-task-000883/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' +spec/erector/html_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-000883/tests/test_command.sh b/tasks/format-code-task-000883/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-000883/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001100/environment/Dockerfile b/tasks/format-code-task-001100/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a934efdde348cf9c879a558d4c78f8c47e8e9486 --- /dev/null +++ b/tasks/format-code-task-001100/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:73a372be3b8321d0969482d5bdfaa44d6186b9ec3fede07b984d8cdd130de26c diff --git a/tasks/format-code-task-001100/environment/setup/files/blocklist b/tasks/format-code-task-001100/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001100/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001100/environment/setup/setup.sh b/tasks/format-code-task-001100/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001100/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001100/tests/test.patch b/tasks/format-code-task-001100/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3e5a3a9ea0a873040687dc9fe43b4a53b1f9e66d --- /dev/null +++ b/tasks/format-code-task-001100/tests/test.patch @@ -0,0 +1,153 @@ +diff --git a/tests/core/tests/test_import_context.py b/tests/core/tests/test_import_context.py +new file mode 100644 +index 0000000..3379ac7 +--- /dev/null ++++ b/tests/core/tests/test_import_context.py +@@ -0,0 +1,137 @@ ++import tablib ++ ++from django.test import TestCase ++ ++from import_export import fields, resources, widgets ++ ++from ..models import Book, Category ++ ++ ++class ImportContextResource(resources.ModelResource): ++ categories = fields.Field( ++ attribute="categories", ++ widget=widgets.ManyToManyWidget(Category, field="name", separator="|"), ++ ) ++ delete = fields.Field(widget=widgets.BooleanWidget()) ++ ++ class Meta: ++ model = Book ++ exclude = ("imported",) ++ ++ def __init__(self, *args, **kwargs): ++ self.events = [] ++ super().__init__(*args, **kwargs) ++ ++ def before_import(self, dataset, using_transactions, dry_run, **kwargs): ++ self.events.append(("before_import", kwargs.copy())) ++ return super().before_import(dataset, using_transactions, dry_run, **kwargs) ++ ++ def before_import_row(self, row, row_number=None, **kwargs): ++ self.events.append(("before_import_row", row_number, kwargs.copy())) ++ return super().before_import_row(row, row_number=row_number, **kwargs) ++ ++ def after_import_instance(self, instance, new, row_number=None, **kwargs): ++ self.events.append(("after_import_instance", row_number, kwargs.copy())) ++ return super().after_import_instance(instance, new, row_number=row_number, **kwargs) ++ ++ def validate_instance(self, instance, import_validation_errors=None, validate_unique=True, **kwargs): ++ self.events.append(("validate_instance", kwargs.copy())) ++ return super().validate_instance(instance, import_validation_errors, validate_unique, **kwargs) ++ ++ def skip_row(self, instance, original, row, import_validation_errors=None, **kwargs): ++ self.events.append(("skip_row", kwargs.copy())) ++ return super().skip_row(instance, original, row, import_validation_errors, **kwargs) ++ ++ def before_save_instance(self, instance, using_transactions, dry_run, **kwargs): ++ self.events.append(("before_save_instance", kwargs.copy())) ++ return super().before_save_instance(instance, using_transactions, dry_run, **kwargs) ++ ++ def save_instance(self, instance, is_create, using_transactions=True, dry_run=False, **kwargs): ++ self.events.append(("save_instance", kwargs.copy())) ++ return super().save_instance(instance, is_create, using_transactions, dry_run, **kwargs) ++ ++ def after_save_instance(self, instance, using_transactions, dry_run, **kwargs): ++ self.events.append(("after_save_instance", kwargs.copy())) ++ return super().after_save_instance(instance, using_transactions, dry_run, **kwargs) ++ ++ def save_m2m(self, instance, data, using_transactions, dry_run, **kwargs): ++ self.events.append(("save_m2m", kwargs.copy())) ++ return super().save_m2m(instance, data, using_transactions, dry_run, **kwargs) ++ ++ def for_delete(self, row, instance, **kwargs): ++ self.events.append(("for_delete", kwargs.copy())) ++ return self.fields["delete"].clean(row) ++ ++ def before_delete_instance(self, instance, dry_run, **kwargs): ++ self.events.append(("before_delete_instance", kwargs.copy())) ++ return super().before_delete_instance(instance, dry_run, **kwargs) ++ ++ def delete_instance(self, instance, using_transactions=True, dry_run=False, **kwargs): ++ self.events.append(("delete_instance", kwargs.copy())) ++ return super().delete_instance(instance, using_transactions, dry_run, **kwargs) ++ ++ def after_delete_instance(self, instance, dry_run, **kwargs): ++ self.events.append(("after_delete_instance", kwargs.copy())) ++ return super().after_delete_instance(instance, dry_run, **kwargs) ++ ++ def after_import_row(self, row, row_result, row_number=None, **kwargs): ++ self.events.append(("after_import_row", row_number, kwargs.copy())) ++ return super().after_import_row(row, row_result, row_number=row_number, **kwargs) ++ ++ def after_import(self, dataset, result, using_transactions, dry_run, **kwargs): ++ self.events.append(("after_import", kwargs.copy())) ++ return super().after_import(dataset, result, using_transactions, dry_run, **kwargs) ++ ++ ++class ImportContextPropagationTest(TestCase): ++ def test_context_reaches_create_lifecycle_and_m2m(self): ++ category = Category.objects.create(name="Context category") ++ dataset = tablib.Dataset( ++ [None, "Context book", "", "", "0", "", "", "", category.name], ++ headers=["id", "name", "author", "author_email", "delete", "published", "published_time", "price", "categories"], ++ ) ++ resource = ImportContextResource() ++ ++ result = resource.import_data( ++ dataset, raise_errors=True, actor="alice", tenant_id="tenant-7", enabled=False ++ ) ++ ++ expected = {"actor": "alice", "tenant_id": "tenant-7", "enabled": False} ++ self.assertFalse(result.has_errors()) ++ self.assertEqual(Book.objects.get(name="Context book").categories.get(), category) ++ names = [event[0] for event in resource.events] ++ for name in ( ++ "before_import", "before_import_row", "after_import_instance", ++ "for_delete", "validate_instance", "skip_row", "before_save_instance", ++ "save_instance", "after_save_instance", "save_m2m", "after_import_row", "after_import", ++ ): ++ self.assertIn(name, names) ++ for event in resource.events: ++ self.assertEqual(event[-1], expected) ++ ++ def test_context_reaches_delete_lifecycle(self): ++ book = Book.objects.create(name="Delete me") ++ dataset = tablib.Dataset([book.pk, book.name, "1"], headers=["id", "name", "delete"]) ++ resource = ImportContextResource() ++ ++ result = resource.import_data(dataset, raise_errors=True, actor="bob", tenant_id="tenant-9") ++ ++ self.assertFalse(Book.objects.filter(pk=book.pk).exists()) ++ self.assertEqual(result.rows[0].import_type, "delete") ++ events = {event[0]: event[-1] for event in resource.events} ++ for name in ("for_delete", "before_delete_instance", "delete_instance", "after_delete_instance"): ++ self.assertEqual(events[name], {"actor": "bob", "tenant_id": "tenant-9"}) ++ ++ def test_import_without_context_keeps_legacy_hook_signatures_working(self): ++ class LegacyResource(resources.ModelResource): ++ class Meta: ++ model = Book ++ ++ def before_save_instance(self, instance, using_transactions, dry_run): ++ return super().before_save_instance(instance, using_transactions, dry_run) ++ ++ dataset = tablib.Dataset(headers=["id", "name"]) ++ dataset.append([None, "Legacy book"]) ++ result = LegacyResource().import_data(dataset, raise_errors=True) ++ self.assertFalse(result.has_errors()) ++ self.assertTrue(Book.objects.filter(name="Legacy book").exists()) +diff --git 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 tests/manage.py test core.tests.test_import_context --settings=settings diff --git a/tasks/format-code-task-001100/tests/test.sh b/tasks/format-code-task-001100/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..451c37087618d9990e6b387f23a9b8ec9c6b5bd4 --- /dev/null +++ b/tasks/format-code-task-001100/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/core/tests/test_import_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-001100/tests/test_command.sh b/tasks/format-code-task-001100/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001100/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001107/environment/Dockerfile b/tasks/format-code-task-001107/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ab572528899108ee646c4b9608daa91fecddda8a --- /dev/null +++ b/tasks/format-code-task-001107/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f75e1179c64cfdfd7b44d0b328786d9c9602ae4c1f4e6de87691921c1df21368 diff --git a/tasks/format-code-task-001107/environment/setup/files/blocklist b/tasks/format-code-task-001107/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001107/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001107/environment/setup/setup.sh b/tasks/format-code-task-001107/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001107/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001107/tests/test.patch b/tasks/format-code-task-001107/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..82b39b407dd49441f866d4fc09b91bdc77dc612c --- /dev/null +++ b/tasks/format-code-task-001107/tests/test.patch @@ -0,0 +1,127 @@ +diff --git a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/NestedDisabledMatcherTest.java b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/NestedDisabledMatcherTest.java +new file mode 100644 +index 000000000..7e4bba0d5 +--- /dev/null ++++ b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/NestedDisabledMatcherTest.java +@@ -0,0 +1,104 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++package edu.umd.cs.findbugs.filter; ++ ++import java.io.ByteArrayOutputStream; ++import java.io.ByteArrayInputStream; ++import java.nio.charset.StandardCharsets; ++ ++import edu.umd.cs.findbugs.BugInstance; ++ ++ ++public class NestedDisabledMatcherTest { ++ ++ public static void main(String[] args) throws Exception { ++ NestedDisabledMatcherTest test = new NestedDisabledMatcherTest(); ++ test.disabledLeafIsIgnoredInsideAnd(); ++ test.disabledGroupIsIgnoredInsideMatch(); ++ test.disabledBranchIsIgnoredInsideOrAndNot(); ++ test.topLevelDisablementStillWorks(); ++ test.nestedDisablementSurvivesXmlRoundTrip(); ++ } ++ ++ void disabledLeafIsIgnoredInsideAnd() throws Exception { ++ Filter filter = parse("" ++ + "" ++ + "" ++ + ""); ++ ++ BugInstance bug = new BugInstance("UUF_UNUSED_FIELD", 1).addClass("example.Target"); ++ check(filter.match(bug), "disabled leaf must not make And fail"); ++ ++ BugInstance otherClass = new BugInstance("UUF_UNUSED_FIELD", 1).addClass("example.Other"); ++ check(!filter.match(otherClass), "enabled class matcher must remain effective"); ++ } ++ ++ void disabledGroupIsIgnoredInsideMatch() throws Exception { ++ Filter filter = parse("" ++ + "" ++ + "" ++ + ""); ++ ++ BugInstance target = new BugInstance("UUF_UNUSED_FIELD", 1).addClass("example.Target"); ++ check(filter.match(target), "disabled group must be ignored"); ++ ++ BugInstance otherClass = new BugInstance("UUF_UNUSED_FIELD", 1).addClass("example.Other"); ++ check(!filter.match(otherClass), "enabled class matcher must remain effective"); ++ } ++ ++ void disabledBranchIsIgnoredInsideOrAndNot() throws Exception { ++ Filter orFilter = parse("" ++ + "" ++ + "" ++ + ""); ++ BugInstance bug = new BugInstance("UUF_UNUSED_FIELD", 1); ++ check(!orFilter.match(bug), "disabled Or branch must be ignored"); ++ ++ Filter notFilter = parse("" ++ + "" ++ + ""); ++ check(notFilter.match(bug), "disabled Not matcher must be ignored"); ++ } ++ ++ void topLevelDisablementStillWorks() throws Exception { ++ Filter filter = parse(""); ++ BugInstance bug = new BugInstance("UUF_UNUSED_FIELD", 1); ++ check(!filter.match(bug), "top-level disabled matcher must remain disabled"); ++ } ++ ++ void nestedDisablementSurvivesXmlRoundTrip() throws Exception { ++ Filter original = parse("" ++ + "" ++ + "" ++ + ""); ++ ++ ByteArrayOutputStream output = new ByteArrayOutputStream(); ++ original.writeAsXML(output); ++ String xml = output.toString(StandardCharsets.UTF_8.name()); ++ check(xml.contains("disabled=\"true\""), "disabled attribute must be serialized"); ++ ++ Filter restored = new Filter(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); ++ BugInstance target = new BugInstance("UUF_UNUSED_FIELD", 1).addClass("example.Target"); ++ BugInstance other = new BugInstance("OTHER_PATTERN", 1).addClass("example.Other"); ++ check(restored.match(target), "round-tripped enabled branch must match"); ++ check(!restored.match(other), "round-tripped disabled branch must stay disabled"); ++ } ++ ++ private Filter parse(String body) throws Exception { ++ String xml = "" ++ + "" + body + ""; ++ return new Filter(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); ++ } ++ ++ private static void check(boolean condition, String message) { ++ if (!condition) { ++ throw new AssertionError(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,12 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++REPO_DIR="$(git rev-parse --show-toplevel)" ++CLASSPATH="${REPO_DIR}/spotbugs/build/classes/java/main:${REPO_DIR}/spotbugs/build/classes/java/gui:${REPO_DIR}/spotbugs/build/resources/main:${REPO_DIR}/spotbugs/build/resources/gui:${REPO_DIR}/spotbugs-annotations/build/classes/java/main:${REPO_DIR}/spotbugs/.libs/*" ++"${REPO_DIR}/gradlew" :spotbugs:compileJava --offline --no-daemon --console=plain ++TMP_DIR="$(mktemp -d)" ++trap 'rm -rf "${TMP_DIR}"' EXIT ++javac -proc:none -cp "${CLASSPATH}" -d "${TMP_DIR}" \ ++ "${REPO_DIR}/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/NestedDisabledMatcherTest.java" ++java -cp "${TMP_DIR}:${CLASSPATH}" edu.umd.cs.findbugs.filter.NestedDisabledMatcherTest diff --git a/tasks/format-code-task-001107/tests/test.sh b/tasks/format-code-task-001107/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cad12d8ff5f4c1daa3c406d009a25388a1e50c68 --- /dev/null +++ b/tasks/format-code-task-001107/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' +spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/NestedDisabledMatcherTest.java +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001107/tests/test_command.sh b/tasks/format-code-task-001107/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001107/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001109/environment/Dockerfile b/tasks/format-code-task-001109/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a4fe4eae96eae9e205b6b89e0e5a00a9c3b159b1 --- /dev/null +++ b/tasks/format-code-task-001109/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:051b1947a28a7041f83aa6cf56a6512e2fd17dd898428b99fc28fc09d5d07c8c diff --git a/tasks/format-code-task-001109/environment/setup/files/blocklist b/tasks/format-code-task-001109/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001109/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001109/environment/setup/setup.sh b/tasks/format-code-task-001109/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001109/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001109/tests/test.patch b/tasks/format-code-task-001109/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ff14e522051aa7398a4107f656e3ac3c21a83891 --- /dev/null +++ b/tasks/format-code-task-001109/tests/test.patch @@ -0,0 +1,113 @@ +diff --git a/tests/test_robust_topology_contract.py b/tests/test_robust_topology_contract.py +new file mode 100644 +index 0000000..d1d80c8 +--- /dev/null ++++ b/tests/test_robust_topology_contract.py +@@ -0,0 +1,97 @@ ++import unittest ++from copy import deepcopy ++from types import SimpleNamespace as NS ++ ++from aio_pika.robust_exchange import RobustExchange ++from aio_pika.robust_queue import RobustQueue ++ ++ ++class Raw: ++ def __init__(self): ++ self.events = [] ++ self.fail = set() ++ ++ async def exchange_declare(self, name, **kw): ++ self.events.append(("exchange_declare", name)); return NS() ++ async def exchange_bind(self, *, source, destination, routing_key, arguments): ++ self.events.append(("exchange_bind", source, destination, routing_key, deepcopy(arguments))); return NS() ++ async def exchange_unbind(self, *, source, destination, routing_key, arguments): ++ if "exchange_unbind" in self.fail: self.fail.remove("exchange_unbind"); raise RuntimeError("unbind") ++ self.events.append(("exchange_unbind", source, destination, routing_key, deepcopy(arguments))); return NS() ++ async def queue_declare(self, *, queue, **kw): ++ self.events.append(("queue_declare", queue)); return NS(queue=queue) ++ async def queue_bind(self, queue, *, exchange, routing_key, arguments): ++ self.events.append(("queue_bind", queue, exchange, routing_key, deepcopy(arguments))); return NS() ++ async def queue_unbind(self, *, queue, exchange, routing_key, arguments): ++ if "queue_unbind" in self.fail: self.fail.remove("queue_unbind"); raise RuntimeError("unbind") ++ self.events.append(("queue_unbind", queue, exchange, routing_key, deepcopy(arguments))); return NS() ++ async def basic_consume(self, *, consumer_tag, **kw): ++ tag = consumer_tag or "generated"; self.events.append(("basic_consume", kw["queue"], tag)); return NS(consumer_tag=tag) ++ async def basic_cancel(self, consumer_tag, *, nowait): ++ if "basic_cancel" in self.fail: self.fail.remove("basic_cancel"); raise RuntimeError("cancel") ++ self.events.append(("basic_cancel", consumer_tag)); return NS() ++ ++ ++class RobustTopologyContractTest(unittest.IsolatedAsyncioTestCase): ++ def conn(self): return NS(loop=self._asyncioTestLoop) ++ def ex(self, raw): ++ return RobustExchange(self.conn(), raw, "destination", auto_delete=False, ++ durable=True, internal=False, passive=False, arguments=None) ++ def q(self, raw): ++ return RobustQueue(self.conn(), raw, "jobs", durable=True, exclusive=False, ++ auto_delete=False, arguments=None, passive=False) ++ async def replay(self, obj, raw): await obj.on_reconnect(NS(_channel=raw)) ++ ++ async def test_exchange_replay_preserves_distinct_snapshots_once(self): ++ raw, ex, args = Raw(), None, {"version": 1}; ex = self.ex(raw) ++ await ex.bind("source", routing_key="red", arguments=args); args["version"] = 99 ++ await ex.bind("source", routing_key="blue", arguments={"version": 2}) ++ await ex.bind("source", routing_key="blue", arguments={"version": 2}) ++ replay = Raw(); await self.replay(ex, replay) ++ self.assertEqual(replay.events, [("exchange_declare", "destination"), ++ ("exchange_bind", "source", "destination", "red", {"version": 1}), ++ ("exchange_bind", "source", "destination", "blue", {"version": 2})]) ++ again = Raw(); await self.replay(ex, again); self.assertEqual(again.events, replay.events) ++ ++ async def test_exchange_unbind_removes_only_exact_binding(self): ++ ex = self.ex(Raw()); await ex.bind("source", routing_key="same", arguments={"slot": 1}); await ex.bind("source", routing_key="same", arguments={"slot": 2}) ++ await ex.unbind("source", routing_key="same", arguments={"slot": 1}); replay = Raw(); await self.replay(ex, replay) ++ self.assertEqual([e for e in replay.events if e[0] == "exchange_bind"], [("exchange_bind", "source", "destination", "same", {"slot": 2})]) ++ ++ async def test_failed_exchange_unbind_keeps_binding(self): ++ raw, ex = Raw(), None; ex = self.ex(raw); await ex.bind("source", routing_key="kept", arguments={"slot": 1}); raw.fail.add("exchange_unbind") ++ with self.assertRaises(RuntimeError): await ex.unbind("source", routing_key="kept", arguments={"slot": 1}) ++ replay = Raw(); await self.replay(ex, replay); self.assertIn(("exchange_bind", "source", "destination", "kept", {"slot": 1}), replay.events) ++ ++ async def test_robust_false_exchange_binding_is_not_replayed(self): ++ ex = self.ex(Raw()); await ex.bind("source", routing_key="temporary", robust=False); replay = Raw(); await self.replay(ex, replay) ++ self.assertEqual(replay.events, [("exchange_declare", "destination")]) ++ ++ async def test_queue_replay_orders_distinct_bindings_before_consumers(self): ++ raw, q, args = Raw(), None, {"version": 1}; q = self.q(raw) ++ await q.bind("events", routing_key="work", arguments=args); args["version"] = 99 ++ await q.bind("events", routing_key="work", arguments={"version": 2}); await q.bind("events", routing_key="work", arguments={"version": 2}) ++ async def durable(message): return message ++ async def temporary(message): return message ++ await q.consume(durable, consumer_tag="durable"); await q.consume(temporary, consumer_tag="temporary", robust=False) ++ replay = Raw(); await self.replay(q, replay) ++ self.assertEqual(replay.events, [("queue_declare", "jobs"), ("queue_bind", "jobs", "events", "work", {"version": 1}), ("queue_bind", "jobs", "events", "work", {"version": 2}), ("basic_consume", "jobs", "durable")]) ++ again = Raw(); await self.replay(q, again); self.assertEqual(again.events, replay.events) ++ ++ async def test_queue_unbind_removes_only_exact_binding(self): ++ q = self.q(Raw()); await q.bind("events", routing_key="same", arguments={"slot": 1}); await q.bind("events", routing_key="same", arguments={"slot": 2}) ++ await q.unbind("events", routing_key="same", arguments={"slot": 1}); replay = Raw(); await self.replay(q, replay) ++ self.assertEqual([e for e in replay.events if e[0] == "queue_bind"], [("queue_bind", "jobs", "events", "same", {"slot": 2})]) ++ ++ async def test_failed_queue_unbind_keeps_binding(self): ++ raw, q = Raw(), None; q = self.q(raw); await q.bind("events", routing_key="kept", arguments={"slot": 1}); raw.fail.add("queue_unbind") ++ with self.assertRaises(RuntimeError): await q.unbind("events", routing_key="kept", arguments={"slot": 1}) ++ replay = Raw(); await self.replay(q, replay); self.assertIn(("queue_bind", "jobs", "events", "kept", {"slot": 1}), replay.events) ++ ++ async def test_cancel_updates_replay_only_after_success(self): ++ raw, q = Raw(), None; q = self.q(raw) ++ async def consumer(message): return message ++ await q.consume(consumer, consumer_tag="removed"); await q.consume(consumer, consumer_tag="kept"); await q.cancel("removed"); raw.fail.add("basic_cancel") ++ with self.assertRaises(RuntimeError): await q.cancel("kept") ++ replay = Raw(); await self.replay(q, replay); self.assertEqual([e for e in replay.events if e[0] == "basic_consume"], [("basic_consume", "jobs", "kept")]) ++ +diff --git 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 ++ ++ ++./.venv/bin/pytest -q tests/test_robust_topology_contract.py diff --git a/tasks/format-code-task-001109/tests/test.sh b/tasks/format-code-task-001109/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7a0d24e9c126854d83e2cb4efa97d39a41428ac3 --- /dev/null +++ b/tasks/format-code-task-001109/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_robust_topology_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-001109/tests/test_command.sh b/tasks/format-code-task-001109/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001109/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001131/environment/Dockerfile b/tasks/format-code-task-001131/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2f157c60719c1442611ae26e69ef89c4d4e8a094 --- /dev/null +++ b/tasks/format-code-task-001131/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:527a767d3d65aca25cd9b75dda103eb49273d6b27aaacb19bc3cd88f6cc659cb diff --git a/tasks/format-code-task-001131/environment/setup/files/blocklist b/tasks/format-code-task-001131/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001131/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001131/environment/setup/setup.sh b/tasks/format-code-task-001131/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001131/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001131/tests/test.patch b/tasks/format-code-task-001131/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..36a967421c41be7014a88ff7d3dbd560dc567408 --- /dev/null +++ b/tasks/format-code-task-001131/tests/test.patch @@ -0,0 +1,379 @@ +diff --git a/codespec_metadata_v8_test.go b/codespec_metadata_v8_test.go +new file mode 100644 +index 0000000..d0f701a +--- /dev/null ++++ b/codespec_metadata_v8_test.go +@@ -0,0 +1,364 @@ ++package sarama ++ ++import ( ++ "bytes" ++ "reflect" ++ "testing" ++) ++ ++func codespecSetExportedField(t *testing.T, target interface{}, name string, value interface{}) { ++ t.Helper() ++ v := reflect.ValueOf(target) ++ if v.Kind() != reflect.Ptr || v.IsNil() { ++ t.Fatalf("%s target must be a non-nil pointer", name) ++ } ++ f := v.Elem().FieldByName(name) ++ if !f.IsValid() || !f.CanSet() { ++ t.Fatalf("%T must expose a settable public field named %s", target, name) ++ } ++ want := reflect.ValueOf(value) ++ if !want.Type().AssignableTo(f.Type()) { ++ t.Fatalf("%T.%s has type %s; want %s", target, name, f.Type(), want.Type()) ++ } ++ f.Set(want) ++} ++ ++func codespecExportedField(t *testing.T, target interface{}, name string) interface{} { ++ t.Helper() ++ v := reflect.ValueOf(target) ++ if v.Kind() == reflect.Ptr { ++ if v.IsNil() { ++ t.Fatalf("cannot inspect %s on nil %T", name, target) ++ } ++ v = v.Elem() ++ } ++ f := v.FieldByName(name) ++ if !f.IsValid() || !f.CanInterface() { ++ t.Fatalf("%T must expose a public field named %s", target, name) ++ } ++ return f.Interface() ++} ++ ++func codespecEncodeBody(t *testing.T, body encoder) []byte { ++ t.Helper() ++ encoded, err := encode(body, nil) ++ if err != nil { ++ t.Fatalf("encode failed: %v", err) ++ } ++ return encoded ++} ++ ++func TestCodespecMetadataRequestVersionsAndFlags(t *testing.T) { ++ legacyBody := []byte{0xff, 0xff, 0xff, 0xff, 0x01} ++ for _, version := range []int16{6, 7} { ++ req := &MetadataRequest{Version: version, AllowAutoTopicCreation: true} ++ got := codespecEncodeBody(t, req) ++ if !bytes.Equal(got, legacyBody) { ++ t.Errorf("metadata request v%d body = %v; want v5-compatible %v", version, got, legacyBody) ++ } ++ decoded := &MetadataRequest{} ++ if err := versionedDecode(got, decoded, version); err != nil { ++ t.Fatalf("decode metadata request v%d: %v", version, err) ++ } ++ if !reflect.DeepEqual(decoded, req) { ++ t.Errorf("metadata request v%d round trip = %#v; want %#v", version, decoded, req) ++ } ++ } ++ ++ flagCases := []struct { ++ name string ++ clusterFlag bool ++ topicFlag bool ++ trailingWire []byte ++ }{ ++ {"cluster-only", true, false, []byte{0x01, 0x00}}, ++ {"topic-only", false, true, []byte{0x00, 0x01}}, ++ } ++ for _, tc := range flagCases { ++ t.Run(tc.name, func(t *testing.T) { ++ req := &MetadataRequest{Version: 8, Topics: []string{"orders"}} ++ codespecSetExportedField(t, req, "IncludeClusterAuthorizedOperations", tc.clusterFlag) ++ codespecSetExportedField(t, req, "IncludeTopicAuthorizedOperations", tc.topicFlag) ++ wantV8 := append([]byte{ ++ 0x00, 0x00, 0x00, 0x01, ++ 0x00, 0x06, 'o', 'r', 'd', 'e', 'r', 's', ++ 0x00, ++ }, tc.trailingWire...) ++ encoded := codespecEncodeBody(t, req) ++ if !bytes.Equal(encoded, wantV8) { ++ t.Fatalf("metadata request v8 body = %v; want %v", encoded, wantV8) ++ } ++ ++ decoded := &MetadataRequest{} ++ if err := versionedDecode(encoded, decoded, 8); err != nil { ++ t.Fatalf("decode v8 request: %v", err) ++ } ++ if !reflect.DeepEqual(decoded.Topics, []string{"orders"}) || decoded.AllowAutoTopicCreation { ++ t.Fatalf("decoded v8 base fields = %#v", decoded) ++ } ++ if got := codespecExportedField(t, decoded, "IncludeClusterAuthorizedOperations"); got != tc.clusterFlag { ++ t.Errorf("decoded IncludeClusterAuthorizedOperations = %v; want %v", got, tc.clusterFlag) ++ } ++ if got := codespecExportedField(t, decoded, "IncludeTopicAuthorizedOperations"); got != tc.topicFlag { ++ t.Errorf("decoded IncludeTopicAuthorizedOperations = %v; want %v", got, tc.topicFlag) ++ } ++ }) ++ } ++ ++ if _, err := encode(&MetadataRequest{Version: 9}, nil); err == nil { ++ t.Error("metadata request v9 encoded successfully; versions above 8 must remain unsupported") ++ } ++} ++ ++func TestCodespecMetadataRequestMinimumBrokerVersions(t *testing.T) { ++ cases := []struct { ++ name string ++ request int16 ++ brokerVersion KafkaVersion ++ }{ ++ {"v6-before-2.0", 6, V1_1_1_0}, ++ {"v7-before-2.1", 7, V2_0_1_0}, ++ {"v8-before-2.3", 8, V2_2_0_0}, ++ } ++ for i, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ mock := NewMockBroker(t, int32(50+i)) ++ defer mock.Close() ++ mock.SetHandlerByMap(map[string]MockResponse{ ++ "MetadataRequest": NewMockMetadataResponse(t), ++ }) ++ broker := NewBroker(mock.Addr()) ++ config := NewConfig() ++ config.Version = tc.brokerVersion ++ if err := broker.Open(config); err != nil { ++ t.Fatalf("open broker: %v", err) ++ } ++ defer safeClose(t, broker) ++ if _, err := broker.GetMetadata(&MetadataRequest{Version: tc.request}); err != ErrUnsupportedVersion { ++ t.Errorf("metadata v%d against Kafka %s returned %v; want ErrUnsupportedVersion", tc.request, tc.name, err) ++ } ++ }) ++ } ++} ++ ++func TestCodespecMetadataResponseV6Compatibility(t *testing.T) { ++ wire := []byte{ ++ 0x00, 0x00, 0x00, 0x05, ++ 0x00, 0x00, 0x00, 0x00, ++ 0x00, 0x09, 'c', 'l', 'u', 's', 't', 'e', 'r', 'I', 'd', ++ 0x00, 0x00, 0x00, 0x02, ++ 0x00, 0x00, 0x00, 0x00, ++ } ++ response := &MetadataResponse{} ++ if err := versionedDecode(wire, response, 6); err != nil { ++ t.Fatalf("decode v6 response: %v", err) ++ } ++ if response.Version != 6 || response.ThrottleTimeMs != 5 || response.ControllerID != 2 || response.ClusterID == nil || *response.ClusterID != "clusterId" { ++ t.Fatalf("decoded v6 response = %#v", response) ++ } ++ if got := codespecEncodeBody(t, response); !bytes.Equal(got, wire) { ++ t.Errorf("re-encoded v6 response = %v; want %v", got, wire) ++ } ++} ++ ++func TestCodespecMetadataResponseV7LeaderEpoch(t *testing.T) { ++ wire := []byte{ ++ 0x00, 0x00, 0x00, 0x05, ++ 0x00, 0x00, 0x00, 0x00, ++ 0xff, 0xff, ++ 0x00, 0x00, 0x00, 0x02, ++ 0x00, 0x00, 0x00, 0x01, ++ 0x00, 0x00, ++ 0x00, 0x03, 'f', 'o', 'o', ++ 0x00, ++ 0x00, 0x00, 0x00, 0x01, ++ 0x00, 0x04, ++ 0x00, 0x00, 0x00, 0x01, ++ 0x00, 0x00, 0x00, 0x07, ++ 0x00, 0x00, 0x00, 0x09, ++ 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, ++ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, ++ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, ++ } ++ response := &MetadataResponse{} ++ if err := versionedDecode(wire, response, 7); err != nil { ++ t.Fatalf("decode v7 response: %v", err) ++ } ++ if len(response.Topics) != 1 || len(response.Topics[0].Partitions) != 1 { ++ t.Fatalf("decoded v7 topics = %#v", response.Topics) ++ } ++ partition := response.Topics[0].Partitions[0] ++ if got := codespecExportedField(t, partition, "LeaderEpoch"); got != int32(9) { ++ t.Errorf("decoded LeaderEpoch = %v; want 9", got) ++ } ++ if got := codespecEncodeBody(t, response); !bytes.Equal(got, wire) { ++ t.Errorf("re-encoded v7 response = %v; want %v", got, wire) ++ } ++} ++ ++func TestCodespecMetadataResponseV8AuthorizedOperations(t *testing.T) { ++ wire := []byte{ ++ 0x00, 0x00, 0x00, 0x03, ++ 0x00, 0x00, 0x00, 0x00, ++ 0xff, 0xff, ++ 0x00, 0x00, 0x00, 0x02, ++ 0x01, 0x02, 0x03, 0x04, ++ 0x00, 0x00, 0x00, 0x01, ++ 0x00, 0x00, ++ 0x00, 0x03, 'f', 'o', 'o', ++ 0x01, ++ 0x00, 0x00, 0x00, 0x01, ++ 0x00, 0x00, ++ 0x00, 0x00, 0x00, 0x03, ++ 0x00, 0x00, 0x00, 0x05, ++ 0x00, 0x00, 0x00, 0x0b, ++ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, ++ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, ++ 0x00, 0x00, 0x00, 0x00, ++ 0x80, 0x00, 0x00, 0x00, ++ } ++ response := &MetadataResponse{} ++ if err := versionedDecode(wire, response, 8); err != nil { ++ t.Fatalf("decode v8 response: %v", err) ++ } ++ if got := codespecExportedField(t, response, "ClusterAuthorizedOperations"); got != int32(0x01020304) { ++ t.Errorf("decoded ClusterAuthorizedOperations = %v; want 0x01020304", got) ++ } ++ if len(response.Topics) != 1 || !response.Topics[0].IsInternal { ++ t.Fatalf("decoded v8 topics = %#v", response.Topics) ++ } ++ if len(response.Topics[0].Partitions) != 1 { ++ t.Fatalf("decoded v8 partitions = %#v", response.Topics[0].Partitions) ++ } ++ if got := codespecExportedField(t, response.Topics[0].Partitions[0], "LeaderEpoch"); got != int32(11) { ++ t.Errorf("decoded v8 LeaderEpoch = %v; want 11", got) ++ } ++ if got := codespecExportedField(t, response.Topics[0], "TopicAuthorizedOperations"); got != int32(-2147483648) { ++ t.Errorf("decoded TopicAuthorizedOperations = %v; want -2147483648", got) ++ } ++ if got := codespecEncodeBody(t, response); !bytes.Equal(got, wire) { ++ t.Errorf("re-encoded v8 response = %v; want %v", got, wire) ++ } ++} ++ ++func TestCodespecMetadataClientVersionSelection(t *testing.T) { ++ cases := []struct { ++ name string ++ kafka KafkaVersion ++ want int16 ++ }{ ++ {"pre-0.10", V0_9_0_1, 0}, ++ {"0.10", V0_10_0_0, 1}, ++ {"0.11", V0_11_0_2, 1}, ++ {"1.0", V1_0_0_0, 5}, ++ {"1.1", V1_1_1_0, 5}, ++ {"2.0", V2_0_0_0, 6}, ++ {"2.1", V2_1_0_0, 7}, ++ {"2.2", V2_2_0_0, 7}, ++ {"2.3", V2_3_0_0, 8}, ++ {"2.4", V2_4_0_0, 8}, ++ } ++ for i, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ mock := NewMockBroker(t, int32(100+i)) ++ defer mock.Close() ++ mock.SetHandlerByMap(map[string]MockResponse{ ++ "MetadataRequest": NewMockMetadataResponse(t), ++ }) ++ config := NewConfig() ++ config.Version = tc.kafka ++ config.Metadata.Retry.Max = 0 ++ client, err := NewClient([]string{mock.Addr()}, config) ++ if err != nil { ++ t.Fatalf("NewClient: %v", err) ++ } ++ defer safeClose(t, client) ++ ++ requests := codespecMetadataRequests(mock.History()) ++ if len(requests) == 0 { ++ t.Fatal("client sent no metadata request") ++ } ++ got := requests[0] ++ if got.Version != tc.want { ++ t.Errorf("Kafka %s client metadata version = %d; want %d", tc.name, got.Version, tc.want) ++ } ++ if tc.want == 8 { ++ if value := codespecExportedField(t, got, "IncludeClusterAuthorizedOperations"); value != false { ++ t.Errorf("client requested cluster authorized operations: %v", value) ++ } ++ if value := codespecExportedField(t, got, "IncludeTopicAuthorizedOperations"); value != false { ++ t.Errorf("client requested topic authorized operations: %v", value) ++ } ++ } ++ }) ++ } ++} ++ ++func codespecMetadataRequests(history []RequestResponse) []*MetadataRequest { ++ var requests []*MetadataRequest ++ for _, exchange := range history { ++ if request, ok := exchange.Request.(*MetadataRequest); ok { ++ requests = append(requests, request) ++ } ++ } ++ return requests ++} ++ ++func TestCodespecMetadataAdminVersionSelection(t *testing.T) { ++ cases := []struct { ++ name string ++ kafka KafkaVersion ++ want int16 ++ }{ ++ {"1.0", V1_0_0_0, 5}, ++ {"1.1", V1_1_1_0, 5}, ++ {"2.0", V2_0_0_0, 6}, ++ {"2.1", V2_1_0_0, 7}, ++ {"2.2", V2_2_0_0, 7}, ++ {"2.3", V2_3_0_0, 8}, ++ {"2.4", V2_4_0_0, 8}, ++ } ++ for caseIndex, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ mock := NewMockBroker(t, int32(200+caseIndex)) ++ defer mock.Close() ++ mock.SetHandlerByMap(map[string]MockResponse{ ++ "MetadataRequest": NewMockMetadataResponse(t). ++ SetController(mock.BrokerID()). ++ SetBroker(mock.Addr(), mock.BrokerID()), ++ }) ++ config := NewConfig() ++ config.Version = tc.kafka ++ config.Metadata.Retry.Max = 0 ++ admin, err := NewClusterAdmin([]string{mock.Addr()}, config) ++ if err != nil { ++ t.Fatalf("NewClusterAdmin: %v", err) ++ } ++ defer safeClose(t, admin) ++ if _, err := admin.DescribeTopics([]string{"orders"}); err != nil { ++ t.Fatalf("DescribeTopics: %v", err) ++ } ++ if _, _, err := admin.DescribeCluster(); err != nil { ++ t.Fatalf("DescribeCluster: %v", err) ++ } ++ ++ requests := codespecMetadataRequests(mock.History()) ++ if len(requests) != 3 { ++ t.Fatalf("metadata request count = %d; want initial refresh plus two admin calls", len(requests)) ++ } ++ for i, request := range requests { ++ if request.Version != tc.want { ++ t.Errorf("metadata request %d version = %d; want %d", i, request.Version, tc.want) ++ } ++ if tc.want == 8 { ++ if value := codespecExportedField(t, request, "IncludeClusterAuthorizedOperations"); value != false { ++ t.Errorf("metadata request %d cluster flag = %v; want false", i, value) ++ } ++ if value := codespecExportedField(t, request, "IncludeTopicAuthorizedOperations"); value != false { ++ t.Errorf("metadata request %d topic flag = %v; want false", i, value) ++ } ++ } ++ } ++ }) ++ } ++} +diff --git 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 -count=1 -run '^(TestCodespecMetadata.*|TestMetadataRequestV[0-5]|TestEmptyMetadataResponseV0|TestMetadataResponseWithBrokersV1|TestMetadataResponseWithOfflineReplicasV5)$' . diff --git a/tasks/format-code-task-001131/tests/test.sh b/tasks/format-code-task-001131/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..60bc3d4cf16001da41b253d55f56bdd2013cf037 --- /dev/null +++ b/tasks/format-code-task-001131/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_metadata_v8_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-001131/tests/test_command.sh b/tasks/format-code-task-001131/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001131/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001136/environment/Dockerfile b/tasks/format-code-task-001136/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0fbe99fe4723a9e4187c8a643018c53612986654 --- /dev/null +++ b/tasks/format-code-task-001136/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:23498a761ed6e4cac59f9ae34ac8d59128f88277e235fc2a65aa42af4b191354 diff --git a/tasks/format-code-task-001136/environment/setup/files/blocklist b/tasks/format-code-task-001136/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001136/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001136/environment/setup/setup.sh b/tasks/format-code-task-001136/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001136/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001136/tests/test.patch b/tasks/format-code-task-001136/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1a38dd3a7bde6b3fee3b17aedcb91b928029650e --- /dev/null +++ b/tasks/format-code-task-001136/tests/test.patch @@ -0,0 +1,314 @@ +diff --git a/tests/apps/migrations/auto/test_schema_differ_rename_hints.py b/tests/apps/migrations/auto/test_schema_differ_rename_hints.py +new file mode 100644 +index 00000000..1a25c9e6 +--- /dev/null ++++ b/tests/apps/migrations/auto/test_schema_differ_rename_hints.py +@@ -0,0 +1,297 @@ ++from __future__ import annotations ++ ++import typing as t ++from unittest import TestCase ++from unittest.mock import patch ++ ++from piccolo.apps.migrations.auto import DiffableTable, SchemaDiffer ++from piccolo.columns.column_types import Varchar ++ ++ ++def make_column(name: str, length: int = 255) -> Varchar: ++ column = Varchar(length=length) ++ column._meta.name = name ++ return column ++ ++ ++def make_table( ++ class_name: str, ++ tablename: str, ++ *columns: Varchar, ++) -> DiffableTable: ++ return DiffableTable( ++ class_name=class_name, ++ tablename=tablename, ++ columns=list(columns), ++ ) ++ ++ ++class TestSchemaDifferRenameHints(TestCase): ++ def make_differ( ++ self, ++ schema: t.List[DiffableTable], ++ schema_snapshot: t.List[DiffableTable], ++ **kwargs: t.Any, ++ ) -> SchemaDiffer: ++ try: ++ return SchemaDiffer( ++ schema=schema, ++ schema_snapshot=schema_snapshot, ++ **kwargs, ++ ) ++ except TypeError as exception: ++ self.fail( ++ "SchemaDiffer must accept table_rename_hints and " ++ f"column_rename_hints: {exception}" ++ ) ++ ++ def test_explicit_table_hints_are_authoritative_and_deterministic(self): ++ schema_snapshot = [ ++ make_table("LegacyVenue", "legacy_venue", make_column("capacity")), ++ make_table("LegacyBand", "legacy_band", make_column("code")), ++ make_table("LegacyCrew", "legacy_crew", make_column("name")), ++ ] ++ schema = [ ++ make_table( ++ "Hall", ++ "hall", ++ make_column("capacity"), ++ make_column("address"), ++ ), ++ make_table( ++ "Act", "act", make_column("code"), make_column("stage_name") ++ ), ++ make_table("Crew", "crew", make_column("role")), ++ ] ++ ++ with patch("builtins.input", side_effect=AssertionError("prompted")): ++ differ = self.make_differ( ++ schema, ++ schema_snapshot, ++ table_rename_hints={ ++ "LegacyVenue": "Hall", ++ "LegacyBand": "Act", ++ }, ++ ) ++ ++ self.assertEqual( ++ differ.rename_tables.statements, ++ [ ++ "manager.rename_table(old_class_name='LegacyBand', " ++ "old_tablename='legacy_band', new_class_name='Act', " ++ "new_tablename='act')", ++ "manager.rename_table(old_class_name='LegacyVenue', " ++ "old_tablename='legacy_venue', new_class_name='Hall', " ++ "new_tablename='hall')", ++ ], ++ ) ++ self.assertEqual( ++ differ.create_tables.statements, ++ ["manager.add_table('Crew', tablename='crew')"], ++ ) ++ self.assertEqual( ++ differ.drop_tables.statements, ++ [ ++ "manager.drop_table(class_name='LegacyCrew', " ++ "tablename='legacy_crew')" ++ ], ++ ) ++ self.assertEqual(len(differ.new_table_columns.statements), 1) ++ self.assertIn( ++ "table_class_name='Crew'", ++ differ.new_table_columns.statements[0], ++ ) ++ self.assertIn( ++ "column_name='role'", differ.new_table_columns.statements[0] ++ ) ++ ++ def test_column_hints_are_scoped_and_preserve_other_deltas(self): ++ schema_snapshot = [ ++ make_table( ++ "Venue", ++ "venue", ++ make_column("title"), ++ ), ++ make_table( ++ "Band", ++ "band", ++ make_column("title"), ++ make_column("obsolete"), ++ ), ++ ] ++ schema = [ ++ make_table("Venue", "venue", make_column("display")), ++ make_table( ++ "Band", ++ "band", ++ make_column("name"), ++ make_column("genre"), ++ ), ++ ] ++ ++ differ = self.make_differ( ++ schema, ++ schema_snapshot, ++ auto_input="n", ++ column_rename_hints={ ++ "Venue": {"title": "display"}, ++ "Band": {"title": "name"}, ++ }, ++ ) ++ ++ self.assertEqual( ++ differ.rename_columns.statements, ++ [ ++ "manager.rename_column(table_class_name='Band', " ++ "tablename='band', old_column_name='title', " ++ "new_column_name='name')", ++ "manager.rename_column(table_class_name='Venue', " ++ "tablename='venue', old_column_name='title', " ++ "new_column_name='display')", ++ ], ++ ) ++ self.assertEqual(len(differ.add_columns.statements), 1) ++ self.assertIn("column_name='genre'", differ.add_columns.statements[0]) ++ self.assertEqual( ++ differ.drop_columns.statements, ++ [ ++ "manager.drop_column(table_class_name='Band', " ++ "tablename='band', column_name='obsolete')" ++ ], ++ ) ++ ++ def test_renamed_column_can_also_be_altered_after_table_rename(self): ++ old_column = make_column("title", length=50) ++ new_column = make_column("name", length=120) ++ schema_snapshot = [make_table("LegacyBand", "legacy_band", old_column)] ++ schema = [make_table("Band", "bands", new_column)] ++ ++ differ = self.make_differ( ++ schema, ++ schema_snapshot, ++ auto_input="n", ++ table_rename_hints={"LegacyBand": "Band"}, ++ column_rename_hints={"Band": {"title": "name"}}, ++ ) ++ ++ self.assertEqual( ++ differ.rename_tables.statements, ++ [ ++ "manager.rename_table(old_class_name='LegacyBand', " ++ "old_tablename='legacy_band', new_class_name='Band', " ++ "new_tablename='bands')" ++ ], ++ ) ++ self.assertEqual( ++ differ.rename_columns.statements, ++ [ ++ "manager.rename_column(table_class_name='Band', " ++ "tablename='bands', old_column_name='title', " ++ "new_column_name='name')" ++ ], ++ ) ++ self.assertEqual(differ.add_columns.statements, []) ++ self.assertEqual(differ.drop_columns.statements, []) ++ self.assertEqual( ++ differ.alter_columns.statements, ++ [ ++ "manager.alter_column(table_class_name='Band', " ++ "tablename='bands', column_name='name', " ++ "params={'length': 120}, old_params={'length': 50}, " ++ "column_class=Varchar, old_column_class=Varchar)" ++ ], ++ ) ++ ++ def test_generating_statements_is_repeatable_and_does_not_mutate_inputs( ++ self, ++ ): ++ old_column = make_column("title") ++ new_column = make_column("name") ++ schema_snapshot = [make_table("LegacyBand", "legacy_band", old_column)] ++ schema = [make_table("Band", "band", new_column)] ++ ++ differ = self.make_differ( ++ schema, ++ schema_snapshot, ++ auto_input="n", ++ table_rename_hints={"LegacyBand": "Band"}, ++ column_rename_hints={"Band": {"title": "name"}}, ++ ) ++ first = [ ++ list(group.statements) for group in differ.get_alter_statements() ++ ] ++ second = [ ++ list(group.statements) for group in differ.get_alter_statements() ++ ] ++ ++ self.assertEqual(first, second) ++ self.assertEqual(schema_snapshot[0].class_name, "LegacyBand") ++ self.assertEqual(schema_snapshot[0].tablename, "legacy_band") ++ self.assertEqual(old_column._meta.name, "title") ++ self.assertEqual(schema[0].class_name, "Band") ++ self.assertEqual(schema[0].tablename, "band") ++ self.assertEqual(new_column._meta.name, "name") ++ ++ def test_invalid_table_hints_are_rejected_at_construction(self): ++ schema_snapshot = [ ++ make_table("LegacyBand", "legacy_band", make_column("title")), ++ make_table("LegacyVenue", "legacy_venue", make_column("label")), ++ ] ++ schema = [ ++ make_table("Band", "band", make_column("name")), ++ make_table("Venue", "venue", make_column("display")), ++ ] ++ cases = [ ++ {"Missing": "Band"}, ++ {"LegacyBand": "Missing"}, ++ {"LegacyBand": "Band", "LegacyVenue": "Band"}, ++ ] ++ ++ for hints in cases: ++ with self.subTest(hints=hints): ++ try: ++ with self.assertRaises(ValueError): ++ SchemaDiffer( ++ schema=schema, ++ schema_snapshot=schema_snapshot, ++ auto_input="n", ++ table_rename_hints=hints, ++ ) ++ except TypeError as exception: ++ self.fail( ++ "SchemaDiffer must accept table_rename_hints: " ++ f"{exception}" ++ ) ++ ++ def test_invalid_column_hints_are_rejected_at_construction(self): ++ schema_snapshot = [ ++ make_table( ++ "Band", ++ "band", ++ make_column("title"), ++ make_column("code"), ++ ) ++ ] ++ schema = [make_table("Band", "band", make_column("name"))] ++ cases = [ ++ {"Missing": {"title": "name"}}, ++ {"Band": {"missing": "name"}}, ++ {"Band": {"title": "missing"}}, ++ {"Band": {"title": "name", "code": "name"}}, ++ ] ++ ++ for hints in cases: ++ with self.subTest(hints=hints): ++ try: ++ with self.assertRaises(ValueError): ++ SchemaDiffer( ++ schema=schema, ++ schema_snapshot=schema_snapshot, ++ auto_input="n", ++ column_rename_hints=hints, ++ ) ++ except TypeError as exception: ++ self.fail( ++ "SchemaDiffer must accept column_rename_hints: " ++ f"{exception}" ++ ) +diff --git 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=/usr/local/lib/python3.14/dist-packages python3.14 -S -m unittest -v \ ++ tests.apps.migrations.auto.test_schema_differ_rename_hints \ ++ tests.apps.migrations.auto.test_schema_differ diff --git a/tasks/format-code-task-001136/tests/test.sh b/tasks/format-code-task-001136/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7134923bb623fe4ac8b61eddebbc2d6435c50920 --- /dev/null +++ b/tasks/format-code-task-001136/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/apps/migrations/auto/test_schema_differ_rename_hints.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-001136/tests/test_command.sh b/tasks/format-code-task-001136/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001136/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001138/environment/Dockerfile b/tasks/format-code-task-001138/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6293156bcd7d3c6d4bd1e8c27553f7e7852e7ab8 --- /dev/null +++ b/tasks/format-code-task-001138/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1d4c0a7c57aa56cfa7c5e7b523120216647c2ea0e212a6e7198f4cab8d414dd2 diff --git a/tasks/format-code-task-001138/environment/setup/files/blocklist b/tasks/format-code-task-001138/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001138/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001138/environment/setup/setup.sh b/tasks/format-code-task-001138/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001138/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001138/tests/test.patch b/tasks/format-code-task-001138/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a0c8a876415b82b5718f517208a900b92b1448ba --- /dev/null +++ b/tasks/format-code-task-001138/tests/test.patch @@ -0,0 +1,139 @@ +diff --git a/tests/synthesis_dsl_builder_tests.py b/tests/synthesis_dsl_builder_tests.py +new file mode 100644 +index 0000000000..75eed4eaf8 +--- /dev/null ++++ b/tests/synthesis_dsl_builder_tests.py +@@ -0,0 +1,124 @@ ++import os ++import unittest ++ ++os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.test_settings') ++import django ++django.setup() ++ ++from arches.app.search.elasticsearch_dsl_builder import ( ++ Bool, Match, Query, Range, SimpleQueryString, Terms ++) ++ ++ ++class _SearchSpy(object): ++ def __init__(self): ++ self.calls = [] ++ ++ def search(self, **kwargs): ++ self.calls.append(kwargs) ++ return kwargs ++ ++ ++class DslBuilderContractTests(unittest.TestCase): ++ def test_and_filters_are_emitted_as_an_explicit_clause(self): ++ query = Query(_SearchSpy()) ++ query.add_filter(Terms(field='kind', terms='place')) ++ query.add_filter({'term': {'status': 'active'}}, operator='and') ++ query.prepare() ++ self.assertEqual( ++ query.dsl['query']['filtered']['filter'], ++ {'and': [ ++ {'terms': {'kind': ['place']}}, ++ {'term': {'status': 'active'}}, ++ ]} ++ ) ++ ++ def test_or_filters_and_query_clause_coexist(self): ++ query = Query(_SearchSpy()) ++ query.add_filter(Terms(field='kind', terms=['place']), operator='or') ++ query.add_filter(Terms(field='kind', terms=['building']), operator='or') ++ query.add_query(Bool(must=Match(field='name', query='museum'))) ++ query.prepare() ++ self.assertEqual( ++ query.dsl['query']['filtered']['filter'], ++ {'or': [ ++ {'terms': {'kind': ['place']}}, ++ {'terms': {'kind': ['building']}}, ++ ]} ++ ) ++ self.assertEqual(query.dsl['query']['filtered']['query']['bool']['must'], [ ++ {'match': {'name': { ++ 'query': 'museum', 'type': 'boolean', 'operator': 'or', ++ 'max_expansions': 10, ++ }}} ++ ]) ++ ++ def test_filter_operator_is_validated(self): ++ with self.assertRaises(ValueError): ++ Query(_SearchSpy()).add_filter(Terms(field='x', terms='y'), operator='xor') ++ ++ def test_bool_merge_keeps_all_three_boolean_buckets(self): ++ left = Bool( ++ must=Match(field='title', query='old'), ++ should=Terms(field='type', terms='book'), ++ must_not={'exists': {'field': 'deleted'}}, ++ ) ++ right = Bool( ++ must=Match(field='title', query='new'), ++ should=Terms(field='type', terms='article'), ++ must_not={'term': {'state': 'hidden'}}, ++ ) ++ left.merge(right) ++ self.assertEqual(len(left.dsl['bool']['must']), 2) ++ self.assertEqual(len(left.dsl['bool']['should']), 2) ++ self.assertEqual(len(left.dsl['bool']['must_not']), 2) ++ self.assertEqual(left.dsl['bool']['must_not'][1], {'term': {'state': 'hidden'}}) ++ ++ def test_range_preserves_zero_boost_and_rejects_conflicting_bounds(self): ++ self.assertEqual( ++ Range(field='score', gte=0, boost=0).dsl, ++ {'range': {'score': {'boost': 0, 'gte': 0}}} ++ ) ++ with self.assertRaises(Exception): ++ Range(field='score') ++ with self.assertRaises(Exception): ++ Range(field='score', gte=1, gt=0) ++ with self.assertRaises(Exception): ++ Range(field='score', lte=1, lt=2) ++ ++ def test_match_preserves_explicit_zero_fuzziness(self): ++ self.assertEqual( ++ Match(field='name', query='x', fuzziness=0).dsl['match']['name']['fuzziness'], ++ 0 ++ ) ++ ++ def test_simple_query_string_emits_its_declared_query_type(self): ++ self.assertEqual( ++ SimpleQueryString( ++ field=['name', 'description'], query='heritage', operator='and', ++ analyzer='standard', flags='OR|AND' ++ ).dsl, ++ {'simple_query_string': { ++ 'fields': ['name', 'description'], ++ 'query': 'heritage', ++ 'default_operator': 'and', ++ 'analyzer': 'standard', ++ 'flags': 'OR|AND', ++ }} ++ ) ++ scalar = SimpleQueryString(field='name', query='heritage') ++ self.assertEqual(scalar.dsl['simple_query_string']['fields'], 'name') ++ ++ def test_query_search_uses_prepared_dsl_and_honors_zero_pagination(self): ++ spy = _SearchSpy() ++ query = Query(spy, start=0, limit=0, fields=[]) ++ result = query.search(index='records', doc_type='resource') ++ self.assertEqual(result['body']['from'], 0) ++ self.assertEqual(result['body']['size'], 0) ++ self.assertEqual(result['body']['fields'], []) ++ self.assertEqual(result['index'], 'records') ++ self.assertEqual(result['doc_type'], 'resource') ++ ++ ++if __name__ == '__main__': ++ unittest.main() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++DJANGO_SETTINGS_MODULE=tests.test_settings python tests/synthesis_dsl_builder_tests.py diff --git a/tasks/format-code-task-001138/tests/test.sh b/tasks/format-code-task-001138/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f89d08f0ce775064c4ed671da6edb23d7d36c40c --- /dev/null +++ b/tasks/format-code-task-001138/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/synthesis_dsl_builder_tests.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-001138/tests/test_command.sh b/tasks/format-code-task-001138/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001138/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001152/environment/Dockerfile b/tasks/format-code-task-001152/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..517eb6c9aeae35801b55ac3c7aab55a0be09123d --- /dev/null +++ b/tasks/format-code-task-001152/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:05bccff5abeae2670614da1112c8c6a5667ccb152cf3d3dccdecc18393b2495b diff --git a/tasks/format-code-task-001152/environment/setup/files/blocklist b/tasks/format-code-task-001152/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001152/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001152/environment/setup/setup.sh b/tasks/format-code-task-001152/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001152/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001152/tests/test.patch b/tasks/format-code-task-001152/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..752e257083cc4bc87d02b5c5e6af810137582cd6 --- /dev/null +++ b/tasks/format-code-task-001152/tests/test.patch @@ -0,0 +1,188 @@ +diff --git a/tests/unit/models/reddit/test_draft_contract.py b/tests/unit/models/reddit/test_draft_contract.py +new file mode 100644 +index 00000000..61d38f4e +--- /dev/null ++++ b/tests/unit/models/reddit/test_draft_contract.py +@@ -0,0 +1,173 @@ ++from unittest import mock ++ ++import pytest ++ ++from praw.models import Draft, Subreddit ++ ++from ... import UnitTest ++ ++ ++def _payload(call): ++ return call.kwargs["data"] if "data" in call.kwargs else call.args[1] ++ ++ ++class TestDraftSourceSemantics(UnitTest): ++ def test_create_rejects_simultaneous_sources_including_empty_text(self): ++ with mock.patch.object(self.reddit, "post", return_value=object()): ++ with pytest.raises(TypeError, match="Exactly one"): ++ self.reddit.drafts.create(selftext="", url="https://example.test") ++ ++ def test_create_preserves_empty_text_as_markdown_body(self): ++ with mock.patch.object(self.reddit, "post", return_value=object()) as post: ++ self.reddit.drafts.create(selftext="", title="title") ++ payload = _payload(post.call_args) ++ assert payload["kind"] == "markdown" ++ assert payload["body"] == "" ++ ++ def test_create_preserves_link_source_and_kind(self): ++ with mock.patch.object(self.reddit, "post", return_value=object()) as post: ++ self.reddit.drafts.create(url="https://example.test", title="title") ++ payload = _payload(post.call_args) ++ assert payload["kind"] == "link" ++ assert payload["body"] == "https://example.test" ++ ++ def test_create_keeps_title_only_drafts_valid(self): ++ with mock.patch.object(self.reddit, "post", return_value=object()) as post: ++ self.reddit.drafts.create(title="title") ++ assert _payload(post.call_args)["title"] == "title" ++ ++ def test_update_preserves_empty_text_and_explicit_false(self): ++ subreddit = Subreddit(self.reddit, "contract_sub") ++ draft = Draft( ++ self.reddit, ++ _data={ ++ "id": "draft-id", ++ "body": "old body", ++ "kind": "markdown", ++ "subreddit": subreddit, ++ }, ++ ) ++ replacement = Draft( ++ self.reddit, ++ _data={ ++ "id": "draft-id", ++ "body": "", ++ "kind": "markdown", ++ "subreddit": subreddit, ++ }, ++ ) ++ with mock.patch.object( ++ self.reddit, "put", return_value=replacement ++ ) as put, mock.patch.object(self.reddit, "drafts", return_value=[replacement]): ++ draft.update(selftext="", nsfw=False) ++ payload = _payload(put.call_args) ++ assert payload["kind"] == "markdown" ++ assert payload["body"] == "" ++ assert payload["nsfw"] is False ++ ++ def test_submit_explicit_falsy_overrides_draft_values(self): ++ subreddit = Subreddit(self.reddit, "contract_sub") ++ draft = Draft( ++ self.reddit, ++ _data={ ++ "id": "draft-id", ++ "body": "saved body", ++ "kind": "markdown", ++ "subreddit": subreddit, ++ "title": "saved title", ++ "nsfw": True, ++ "spoiler": True, ++ }, ++ ) ++ with mock.patch.object(Subreddit, "submit", return_value=object()) as submit: ++ draft.submit(selftext="", title="", nsfw=False, spoiler=False) ++ assert submit.call_args.kwargs["selftext"] == "" ++ assert submit.call_args.kwargs["title"] == "" ++ assert submit.call_args.kwargs["nsfw"] is False ++ assert submit.call_args.kwargs["spoiler"] is False ++ ++ def test_submit_switches_content_source_without_leaking_saved_source(self): ++ subreddit = Subreddit(self.reddit, "contract_sub") ++ draft = Draft( ++ self.reddit, ++ _data={ ++ "id": "draft-id", ++ "body": "saved body", ++ "kind": "markdown", ++ "subreddit": subreddit, ++ }, ++ ) ++ with mock.patch.object(Subreddit, "submit", return_value=object()) as submit: ++ draft.submit(url="https://new.example") ++ kwargs = submit.call_args.kwargs ++ assert kwargs["url"] == "https://new.example" ++ assert "selftext" not in kwargs ++ ++ def test_submit_without_overrides_inherits_saved_values(self): ++ subreddit = Subreddit(self.reddit, "contract_sub") ++ draft = Draft( ++ self.reddit, ++ _data={ ++ "id": "draft-id", ++ "body": "saved body", ++ "kind": "markdown", ++ "subreddit": subreddit, ++ "nsfw": True, ++ }, ++ ) ++ with mock.patch.object(Subreddit, "submit", return_value=object()) as submit: ++ draft.submit() ++ kwargs = submit.call_args.kwargs ++ assert kwargs["selftext"] == "saved body" ++ assert kwargs["nsfw"] is True ++ assert kwargs["draft_id"] == "draft-id" ++ ++ def test_submit_rejects_two_explicit_sources_before_dispatch(self): ++ subreddit = Subreddit(self.reddit, "contract_sub") ++ draft = Draft( ++ self.reddit, ++ _data={ ++ "id": "draft-id", ++ "body": "saved", ++ "kind": "markdown", ++ "subreddit": subreddit, ++ }, ++ ) ++ with mock.patch.object(Subreddit, "submit", return_value=object()) as submit: ++ with pytest.raises(TypeError, match="Exactly one"): ++ draft.submit(selftext="new", url="https://new.example") ++ ++ def test_submit_string_subreddit_override_is_used(self): ++ source = Subreddit(self.reddit, "source_sub") ++ draft = Draft( ++ self.reddit, ++ _data={ ++ "id": "draft-id", ++ "body": "saved body", ++ "kind": "markdown", ++ "subreddit": source, ++ }, ++ ) ++ target = Subreddit(self.reddit, "target_sub") ++ target.submit = mock.Mock(return_value=object()) ++ source.submit = mock.Mock(side_effect=AssertionError("wrong subreddit")) ++ with mock.patch.object( ++ self.reddit, "subreddit", return_value=target ++ ): ++ draft.submit(subreddit="target_sub") ++ assert target.submit.call_args.kwargs["selftext"] == "saved body" ++ ++ def test_submit_uses_saved_subreddit_without_override(self): ++ source = Subreddit(self.reddit, "source_sub") ++ source.submit = mock.Mock(return_value=object()) ++ draft = Draft( ++ self.reddit, ++ _data={ ++ "id": "draft-id", ++ "body": "saved body", ++ "kind": "markdown", ++ "subreddit": source, ++ }, ++ ) ++ draft.submit() ++ assert source.submit.call_args.kwargs["selftext"] == "saved 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,4 @@ ++#!/bin/bash ++set -euo pipefail ++ ++pytest -q tests/unit/models/reddit/test_draft_contract.py diff --git a/tasks/format-code-task-001152/tests/test.sh b/tasks/format-code-task-001152/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1d07d244498d8283a45dad61cdb302a8f1ec0e4d --- /dev/null +++ b/tasks/format-code-task-001152/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/models/reddit/test_draft_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-001152/tests/test_command.sh b/tasks/format-code-task-001152/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001152/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001153/environment/Dockerfile b/tasks/format-code-task-001153/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0f44f4fd797d7449038252ae74870da388285db3 --- /dev/null +++ b/tasks/format-code-task-001153/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a19dcd6f26feb9c4146b47e15af5e4c2425d7837ff61111cc02618e0ddfed07d diff --git a/tasks/format-code-task-001153/environment/setup/files/blocklist b/tasks/format-code-task-001153/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001153/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001153/environment/setup/setup.sh b/tasks/format-code-task-001153/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001153/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001153/tests/test.patch b/tasks/format-code-task-001153/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..61b692ad8bb3dad7dc15832d5a1a04d15cfd2689 --- /dev/null +++ b/tasks/format-code-task-001153/tests/test.patch @@ -0,0 +1,127 @@ +diff --git a/x/evm/types/tx_args_contract_test.go b/x/evm/types/tx_args_contract_test.go +new file mode 100644 +index 00000000..b721a898 +--- /dev/null ++++ b/x/evm/types/tx_args_contract_test.go +@@ -0,0 +1,112 @@ ++package types ++ ++import ( ++ "math/big" ++ "testing" ++ ++ "github.com/ethereum/go-ethereum/common" ++ "github.com/ethereum/go-ethereum/common/hexutil" ++ ethtypes "github.com/ethereum/go-ethereum/core/types" ++ "github.com/stretchr/testify/require" ++) ++ ++func txBig(v int64) *hexutil.Big { b := hexutil.Big(*big.NewInt(v)); return &b } ++func txUint(v uint64) *hexutil.Uint64 { u := hexutil.Uint64(v); return &u } ++ ++func TestTransactionArgsContract_EncodingModes(t *testing.T) { ++ to := common.HexToAddress("0x1111111111111111111111111111111111111111") ++ t.Run("legacy when no typed fee or access list", func(t *testing.T) { ++ args := TransactionArgs{To: &to, Gas: txUint(21000), GasPrice: txBig(7), Value: txBig(3), Nonce: txUint(9)} ++ tx := args.ToTransaction().AsTransaction() ++ require.Equal(t, uint8(ethtypes.LegacyTxType), tx.Type()) ++ require.Equal(t, uint64(9), tx.Nonce()) ++ require.Equal(t, uint64(21000), tx.Gas()) ++ require.Equal(t, big.NewInt(7), tx.GasPrice()) ++ require.Equal(t, big.NewInt(3), tx.Value()) ++ }) ++ t.Run("access list selects typed transaction", func(t *testing.T) { ++ args := TransactionArgs{To: &to, Gas: txUint(50000), GasPrice: txBig(2), AccessList: ðtypes.AccessList{{Address: to}}} ++ tx := args.ToTransaction().AsTransaction() ++ require.Equal(t, uint8(ethtypes.AccessListTxType), tx.Type()) ++ require.Len(t, tx.AccessList(), 1) ++ }) ++ t.Run("either dynamic fee field selects EIP-1559", func(t *testing.T) { ++ args := TransactionArgs{To: &to, Gas: txUint(50000), MaxPriorityFeePerGas: txBig(4), ChainID: txBig(99)} ++ tx := args.ToTransaction().AsTransaction() ++ require.Equal(t, uint8(ethtypes.DynamicFeeTxType), tx.Type()) ++ require.Equal(t, big.NewInt(4), tx.GasTipCap()) ++ require.Equal(t, big.NewInt(99), tx.ChainId()) ++ }) ++ t.Run("max fee alone still selects EIP-1559 with zero tip", func(t *testing.T) { ++ args := TransactionArgs{To: &to, Gas: txUint(50000), MaxFeePerGas: txBig(12)} ++ tx := args.ToTransaction().AsTransaction() ++ require.Equal(t, uint8(ethtypes.DynamicFeeTxType), tx.Type()) ++ require.Equal(t, big.NewInt(12), tx.GasFeeCap()) ++ require.Equal(t, big.NewInt(0), tx.GasTipCap()) ++ }) ++} ++ ++func TestTransactionArgsContract_DataCompatibility(t *testing.T) { ++ to := common.HexToAddress("0x2222222222222222222222222222222222222222") ++ data := hexutil.Bytes{0xaa, 0xbb} ++ empty := hexutil.Bytes{} ++ t.Run("input takes precedence when both are present", func(t *testing.T) { ++ args := TransactionArgs{To: &to, Data: &data, Input: &hexutil.Bytes{0x01}} ++ require.Equal(t, []byte{0x01}, args.GetData()) ++ require.Equal(t, []byte{0x01}, args.ToTransaction().AsTransaction().Data()) ++ }) ++ t.Run("explicit empty input is preserved", func(t *testing.T) { ++ args := TransactionArgs{To: &to, Data: &data, Input: &empty} ++ require.Empty(t, args.GetData()) ++ require.Empty(t, args.ToTransaction().AsTransaction().Data()) ++ }) ++ t.Run("neither data field yields nil calldata", func(t *testing.T) { ++ args := TransactionArgs{To: &to} ++ require.Nil(t, args.GetData()) ++ require.Nil(t, args.ToTransaction().AsTransaction().Data()) ++ }) ++} ++ ++func TestTransactionArgsContract_ToMessageFees(t *testing.T) { ++ from := common.HexToAddress("0x3333333333333333333333333333333333333333") ++ to := common.HexToAddress("0x4444444444444444444444444444444444444444") ++ t.Run("mixed legacy and dynamic fees are rejected", func(t *testing.T) { ++ args := TransactionArgs{From: &from, To: &to, GasPrice: txBig(10), MaxFeePerGas: txBig(20)} ++ _, err := args.ToMessage(100000, big.NewInt(1)) ++ require.EqualError(t, err, "both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified") ++ }) ++ t.Run("gas cap limits requested gas", func(t *testing.T) { ++ args := TransactionArgs{From: &from, To: &to, Gas: txUint(90000), GasPrice: txBig(2), Value: txBig(5)} ++ msg, err := args.ToMessage(50000, nil) ++ require.NoError(t, err) ++ require.Equal(t, uint64(50000), msg.Gas()) ++ require.Equal(t, big.NewInt(2), msg.GasPrice()) ++ }) ++ t.Run("base fee backfills effective gas price", func(t *testing.T) { ++ args := TransactionArgs{From: &from, To: &to, MaxFeePerGas: txBig(100), MaxPriorityFeePerGas: txBig(7)} ++ msg, err := args.ToMessage(0, big.NewInt(30)) ++ require.NoError(t, err) ++ require.Equal(t, big.NewInt(37), msg.GasPrice()) ++ require.Equal(t, big.NewInt(100), msg.GasFeeCap()) ++ require.Equal(t, big.NewInt(7), msg.GasTipCap()) ++ }) ++ t.Run("dynamic fees require a base fee", func(t *testing.T) { ++ args := TransactionArgs{From: &from, To: &to, MaxFeePerGas: txBig(100), MaxPriorityFeePerGas: txBig(7)} ++ _, err := args.ToMessage(0, nil) ++ require.Error(t, err) ++ require.Contains(t, err.Error(), "maxFeePerGas or maxPriorityFeePerGas specified but london is not active yet") ++ }) ++ t.Run("fee cap cannot be below tip", func(t *testing.T) { ++ args := TransactionArgs{From: &from, To: &to, MaxFeePerGas: txBig(6), MaxPriorityFeePerGas: txBig(7)} ++ _, err := args.ToMessage(0, big.NewInt(1)) ++ require.Error(t, err) ++ require.Contains(t, err.Error(), "maxFeePerGas") ++ require.Contains(t, err.Error(), "maxPriorityFeePerGas") ++ }) ++ t.Run("explicit zero gas is not replaced by cap", func(t *testing.T) { ++ args := TransactionArgs{From: &from, To: &to, Gas: txUint(0), GasPrice: txBig(2)} ++ msg, err := args.ToMessage(50000, nil) ++ require.NoError(t, err) ++ require.Equal(t, uint64(0), msg.Gas()) ++ }) ++} +diff --git 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 ./x/evm/types diff --git a/tasks/format-code-task-001153/tests/test.sh b/tasks/format-code-task-001153/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fd7f0a963db960a67b5d783feb5ecd963437885c --- /dev/null +++ b/tasks/format-code-task-001153/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' +x/evm/types/tx_args_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-001153/tests/test_command.sh b/tasks/format-code-task-001153/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001153/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001154/environment/Dockerfile b/tasks/format-code-task-001154/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3f9ef034c07e7ec5dbcd53f1e92cff425bc9c6f0 --- /dev/null +++ b/tasks/format-code-task-001154/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d12e5ca575d649e0c928ddff2ed18799fb42e7125062ebb9c7c4a4702d7913d3 diff --git a/tasks/format-code-task-001154/environment/setup/files/blocklist b/tasks/format-code-task-001154/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001154/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001154/environment/setup/setup.sh b/tasks/format-code-task-001154/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001154/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001154/tests/test.patch b/tasks/format-code-task-001154/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0ea1cbd30e5d4ec9a6a751ed20a7aec1e5af6661 --- /dev/null +++ b/tasks/format-code-task-001154/tests/test.patch @@ -0,0 +1,102 @@ +diff --git a/test/dialects/vertica_copy_extensions_test.py b/test/dialects/vertica_copy_extensions_test.py +new file mode 100644 +index 000000000..2785241b7 +--- /dev/null ++++ b/test/dialects/vertica_copy_extensions_test.py +@@ -0,0 +1,85 @@ ++ ++ ++from sqlfluff.core import Linter ++ ++ ++def assert_copy_parses(sql: str, statement_type: str = "copy_statement") -> None: ++ ++ parsed = Linter(dialect="vertica").parse_string(sql) ++ assert not parsed.violations, [str(violation) for violation in parsed.violations] ++ assert parsed.tree.raw == sql ++ assert "unparsable" not in parsed.tree.type_set() ++ assert len(list(parsed.tree.recursive_crawl(statement_type))) == 1 ++ ++ ++def assert_copy_rejected(sql: str) -> None: ++ ++ parsed = Linter(dialect="vertica").parse_string(sql) ++ assert parsed.violations ++ ++ ++def test_vertica_copy_with_filter() -> None: ++ ++ assert_copy_parses( ++ "COPY events FROM 's3://bucket/events.csv' " ++ "WITH FILTER decompress() REJECTMAX 25;" ++ ) ++ ++ ++def test_vertica_copy_with_parser_and_local_native_source() -> None: ++ ++ assert_copy_parses( ++ "COPY events FROM LOCAL '/var/load/events.dat' NATIVE VARCHAR " ++ "WITH PARSER parse_events();" ++ ) ++ ++ ++def test_vertica_copy_on_node() -> None: ++ ++ assert_copy_parses("COPY events FROM 'events.dat' ON worker_node_1;") ++ ++ ++def test_vertica_copy_on_any_node() -> None: ++ ++ assert_copy_parses("COPY events FROM 'events.dat' ON ANY NODE;") ++ ++ ++def test_vertica_copy_extensions_compose_with_columns_and_options() -> None: ++ ++ assert_copy_parses( ++ "COPY events (event_id, payload FILLER VARCHAR(128)) " ++ "FROM 'events.orc' ORC WITH PARSER parse_events() " ++ "WITH FILTER decompress() ON worker_node_1 TRAILING NULLCOLS;" ++ ) ++ ++ ++def test_vertica_copy_extensions_follow_source() -> None: ++ ++ assert_copy_rejected("COPY events WITH PARSER parse_events() FROM 'events.csv';") ++ assert_copy_rejected("COPY events WITH FILTER decompress() FROM 'events.csv';") ++ ++ ++def test_vertica_copy_extensions_require_operands() -> None: ++ ++ assert_copy_rejected("COPY events FROM 'events.csv' WITH FILTER;") ++ assert_copy_rejected("COPY events FROM 'events.csv' ON;") ++ ++ ++def test_vertica_external_table_copy_extensions() -> None: ++ ++ assert_copy_parses( ++ "CREATE EXTERNAL TABLE ext_events (event_id INT) AS COPY " ++ "FROM 'events.orc' ORC WITH PARSER parse_events() " ++ "WITH FILTER decompress() ON worker_node_1;", ++ statement_type="create_external_table_statement", ++ ) ++ ++ ++def test_vertica_external_table_copy_column_options() -> None: ++ ++ assert_copy_parses( ++ "CREATE EXTERNAL TABLE ext_events (event_id INT) AS COPY " ++ "COLUMN OPTION (payload FILLER VARCHAR(128)) FROM 'events.csv' " ++ "WITH FILTER decompress() ON ANY NODE;", ++ statement_type="create_external_table_statement", ++ ) +diff --git 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 ++ ++ ++pytest -q test/dialects/vertica_copy_extensions_test.py \ ++ test/dialects/dialects_test.py -k 'vertica and (base_file_parse or copy or external_table)' diff --git a/tasks/format-code-task-001154/tests/test.sh b/tasks/format-code-task-001154/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0016c5475f2df2dead267fa55850ad27763616db --- /dev/null +++ b/tasks/format-code-task-001154/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/dialects/vertica_copy_extensions_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-001154/tests/test_command.sh b/tasks/format-code-task-001154/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001154/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001155/environment/Dockerfile b/tasks/format-code-task-001155/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2785701b86a8bb9aa81aa3cd4ab0f293ec817944 --- /dev/null +++ b/tasks/format-code-task-001155/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:152fc3d87e9a731d67b57f6e2a4016fb2dbab6db87a162fecc19cee999ea66a0 diff --git a/tasks/format-code-task-001155/environment/setup/files/blocklist b/tasks/format-code-task-001155/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001155/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001155/environment/setup/setup.sh b/tasks/format-code-task-001155/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001155/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001155/tests/test.patch b/tasks/format-code-task-001155/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..56445b0e214edad10baf6a402e975b68afc83df4 --- /dev/null +++ b/tasks/format-code-task-001155/tests/test.patch @@ -0,0 +1,114 @@ +diff --git a/packages/sdk/src/across/rateModel.history.test.ts b/packages/sdk/src/across/rateModel.history.test.ts +new file mode 100644 +index 00000000..374ce577 +--- /dev/null ++++ b/packages/sdk/src/across/rateModel.history.test.ts +@@ -0,0 +1,98 @@ ++import assert from "assert"; ++import { ethers } from "ethers"; ++import { RateModelDictionary, parseAndReturnRateModelFromString, RateModelEvent } from "./rateModel"; ++ ++const TOKEN_A = "0x000000000000000000000000000000000000000a"; ++const TOKEN_B = "0x000000000000000000000000000000000000000b"; ++const model = (value: string) => JSON.stringify({ UBar: value, R0: "0", R1: "1", R2: "2" }); ++const event = (l1Token: string, blockNumber: number, transactionIndex: number, logIndex: number, value: string): RateModelEvent => ({ l1Token, blockNumber, transactionIndex, logIndex, rateModel: model(value) }); ++ ++function history(dictionary: RateModelDictionary, token: string, blockNumber?: number) { ++ const api = dictionary as RateModelDictionary & { getRateModelEvents?: (address: string, atBlock?: number) => RateModelEvent[] }; ++ assert.equal(typeof api.getRateModelEvents, "function", "rate model event history API is required"); ++ return api.getRateModelEvents!(token, blockNumber); ++} ++ ++describe("historical rate model dictionary", () => { ++ test("requires exactly the four documented rate-model keys", () => { ++ assert.deepStrictEqual(parseAndReturnRateModelFromString('{"R2":"2","UBar":"u","R0":"0","R1":"1"}'), { UBar: "u", R0: "0", R1: "1", R2: "2" }); ++ assert.throws(() => parseAndReturnRateModelFromString('{"UBar":"u","R0":"0","R1":"1"}')); ++ assert.throws(() => parseAndReturnRateModelFromString('{"UBar":"u","R0":"0","R1":"1","R2":"2","extra":"x"}')); ++ }); ++ ++ test("requires every rate-model value to be a string", () => { ++ assert.throws(() => parseAndReturnRateModelFromString('{"UBar":0,"R0":"0","R1":"1","R2":"2"}')); ++ }); ++ ++ test("does not mutate event batches supplied by callers", () => { ++ const dictionary = new RateModelDictionary(); ++ const first = [event(TOKEN_A, 10, 1, 0, "ten"), event(TOKEN_A, 0, 0, 0, "zero")]; ++ const original = JSON.parse(JSON.stringify(first)); ++ dictionary.updateWithEvents(first); ++ assert.deepStrictEqual(first, original); ++ }); ++ ++ test("merges batches and deduplicates event identity", () => { ++ const dictionary = new RateModelDictionary(); ++ dictionary.updateWithEvents([event(TOKEN_A, 10, 1, 0, "ten"), event(TOKEN_A, 0, 0, 0, "zero")]); ++ dictionary.updateWithEvents([event(TOKEN_B, 5, 0, 0, "five"), event(TOKEN_A, 10, 1, 0, "ten")]); ++ assert.deepStrictEqual(history(dictionary, TOKEN_A).map((item) => [item.blockNumber, item.transactionIndex, item.logIndex]), [[0, 0, 0], [10, 1, 0]]); ++ assert.equal(history(dictionary, TOKEN_B)[0].rateModel, model("five")); ++ }); ++ ++ test("filters public event history and protects the index from caller mutation", () => { ++ const dictionary = new RateModelDictionary(); ++ dictionary.updateWithEvents([event(TOKEN_A, 10, 1, 0, "ten"), event(TOKEN_A, 0, 0, 0, "zero")]); ++ assert.equal(history(dictionary, TOKEN_A, 0).length, 1); ++ assert.equal(history(dictionary, TOKEN_A, 0)[0].rateModel, model("zero")); ++ const snapshot = history(dictionary, TOKEN_A); ++ snapshot[0].rateModel = model("caller mutation"); ++ assert.equal(history(dictionary, TOKEN_A)[0].rateModel, model("zero")); ++ assert.throws(() => history(dictionary, TOKEN_B)); ++ assert.throws(() => history(dictionary, TOKEN_A, -1)); ++ }); ++ ++ test("uses transaction and log order for same-block historical lookup", () => { ++ const dictionary = new RateModelDictionary(); ++ dictionary.updateWithEvents([event(TOKEN_A, 7, 1, 1, "tx1log1"), event(TOKEN_A, 7, 2, 0, "tx2"), event(TOKEN_A, 7, 1, 3, "tx1log3")]); ++ assert.equal(dictionary.getRateModelForBlockNumber(TOKEN_A, 7).UBar, "tx2"); ++ assert.throws(() => dictionary.getRateModelForBlockNumber(TOKEN_A, 6)); ++ }); ++ ++ test("honors block zero as an explicit historical boundary", () => { ++ const dictionary = new RateModelDictionary(); ++ dictionary.updateWithEvents([event(TOKEN_B, 0, 0, 0, "b"), event(TOKEN_A, 3, 0, 0, "a")]); ++ assert.equal(dictionary.getRateModelForBlockNumber(TOKEN_B, 0).UBar, "b"); ++ assert.deepStrictEqual(dictionary.getL1TokensFromRateModel(0), [ethers.utils.getAddress(TOKEN_B)]); ++ assert.throws(() => dictionary.getRateModelForBlockNumber(TOKEN_A, 0)); ++ }); ++ ++ test("returns sorted checksummed token addresses", () => { ++ const dictionary = new RateModelDictionary(); ++ dictionary.updateWithEvents([event(TOKEN_B, 0, 0, 0, "b"), event(TOKEN_A, 3, 0, 0, "a")]); ++ assert.deepStrictEqual(dictionary.getL1TokensFromRateModel(), [ethers.utils.getAddress(TOKEN_A), ethers.utils.getAddress(TOKEN_B)]); ++ }); ++ ++ function assertAtomicRejection(invalid: RateModelEvent) { ++ const dictionary = new RateModelDictionary(); ++ dictionary.updateWithEvents([event(TOKEN_A, 4, 0, 0, "good")]); ++ assert.throws(() => dictionary.updateWithEvents([event(TOKEN_B, 5, 0, 0, "ok"), invalid])); ++ assert.deepStrictEqual(dictionary.getL1TokensFromRateModel(), [ethers.utils.getAddress(TOKEN_A)]); ++ assert.equal(dictionary.getRateModelForBlockNumber(TOKEN_A).UBar, "good"); ++ assert.throws(() => dictionary.getRateModelForBlockNumber(TOKEN_B)); ++ assert.throws(() => dictionary.getRateModelForBlockNumber(TOKEN_A, 3)); ++ } ++ ++ test("rejects negative block numbers atomically", () => assertAtomicRejection(event(TOKEN_A, -1, 0, 0, "bad"))); ++ test("rejects non-integer transaction indexes atomically", () => assertAtomicRejection(event(TOKEN_A, 5, 1.5, 0, "bad"))); ++ test("rejects invalid token addresses atomically", () => assertAtomicRejection(event("not-an-address", 5, 0, 0, "bad"))); ++ test("rejects invalid rate-model payloads atomically", () => assertAtomicRejection({ ...event(TOKEN_A, 5, 0, 0, "bad"), rateModel: '{"UBar":0,"R0":"0","R1":"1","R2":"2"}' })); ++ ++ test("rejects conflicting replays without changing existing history", () => { ++ const dictionary = new RateModelDictionary(); ++ dictionary.updateWithEvents([event(TOKEN_A, 4, 0, 0, "good")]); ++ assert.throws(() => dictionary.updateWithEvents([event(TOKEN_A, 4, 0, 0, "different")])); ++ assert.equal(history(dictionary, TOKEN_A).length, 1); ++ assert.equal(dictionary.getRateModelForBlockNumber(TOKEN_A).UBar, "good"); ++ }); ++}); +diff --git 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 ++ ++ ++yarn workspace @uma/sdk test rateModel.history.test.ts --runInBand --watch=false diff --git a/tasks/format-code-task-001155/tests/test.sh b/tasks/format-code-task-001155/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..00efd7edf816e23b713b9dc78d4b1274586e3412 --- /dev/null +++ b/tasks/format-code-task-001155/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' +packages/sdk/src/across/rateModel.history.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-001155/tests/test_command.sh b/tasks/format-code-task-001155/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001155/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001198/environment/Dockerfile b/tasks/format-code-task-001198/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6e412b979385477bae59d2cc5f342ded53b04611 --- /dev/null +++ b/tasks/format-code-task-001198/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0ed669f6e9f99f082624fb110af3b365a7a47bb1220448eb7e32ea9249ec3494 diff --git a/tasks/format-code-task-001198/environment/setup/files/blocklist b/tasks/format-code-task-001198/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001198/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001198/environment/setup/setup.sh b/tasks/format-code-task-001198/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001198/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001198/tests/test.patch b/tasks/format-code-task-001198/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3eb35487ff4fe4553f2d1cd5d47380c60c838f13 --- /dev/null +++ b/tasks/format-code-task-001198/tests/test.patch @@ -0,0 +1,434 @@ +diff --git a/tests/checks/codespec_profile_composition_test.py b/tests/checks/codespec_profile_composition_test.py +new file mode 100644 +index 0000000..851f809 +--- /dev/null ++++ b/tests/checks/codespec_profile_composition_test.py +@@ -0,0 +1,416 @@ ++import sys ++import types ++ ++import pytest ++ ++from fontbakery.checkrunner import CheckRunner ++from fontbakery.configuration import Configuration ++from fontbakery.fonts_profile import profile_factory, setup_context ++from fontbakery.status import FAIL, INFO, PASS, WARN ++ ++ ++FILE_SIZE_CHECK = "com.google.fonts/check/file_size" ++UNITS_PER_EM_CHECK = "com.google.fonts/check/unitsperem" ++ ++ ++class ResultCollector: ++ def __init__(self): ++ self.results = [] ++ ++ def start(self, order): ++ self.order = order ++ ++ def receive_result(self, result): ++ self.results.append(result) ++ ++ def end(self): ++ pass ++ ++ ++def install_profile(monkeypatch, short_name, profile_data): ++ full_name = f"fontbakery.profiles.{short_name}" ++ module = types.ModuleType(full_name) ++ module.PROFILE = profile_data ++ monkeypatch.setitem(sys.modules, full_name, module) ++ return module ++ ++ ++def run_file_size_check(profile, path, check_config=None): ++ supplied = { ++ "explicit_checks": [FILE_SIZE_CHECK], ++ "full_lists": True, ++ } ++ if check_config is not None: ++ supplied[FILE_SIZE_CHECK] = check_config ++ runner = CheckRunner( ++ profile, ++ setup_context([str(path)]), ++ Configuration(**supplied), ++ ) ++ collector = ResultCollector() ++ runner.run([collector]) ++ assert len(collector.results) == 1 ++ return collector.results[0].results ++ ++ ++def only_subresult(results): ++ assert len(results) == 1 ++ return results[0] ++ ++ ++def test_codespec_nested_defaults_merge_in_include_order(monkeypatch): ++ base = install_profile( ++ monkeypatch, ++ "codespec_defaults_base", ++ { ++ "name": "codespec-defaults-base", ++ "sections": {"Base": [FILE_SIZE_CHECK]}, ++ "configuration_defaults": { ++ FILE_SIZE_CHECK: { ++ "WARN_SIZE": 10, ++ "FAIL_SIZE": 100, ++ "base_marker": "base", ++ } ++ }, ++ }, ++ ) ++ middle = install_profile( ++ monkeypatch, ++ "codespec_defaults_middle", ++ { ++ "name": "codespec-defaults-middle", ++ "include_profiles": ["codespec_defaults_base"], ++ "sections": {}, ++ "configuration_defaults": { ++ FILE_SIZE_CHECK: { ++ "WARN_SIZE": 20, ++ "middle_marker": "middle", ++ } ++ }, ++ }, ++ ) ++ install_profile( ++ monkeypatch, ++ "codespec_defaults_sibling", ++ { ++ "name": "codespec-defaults-sibling", ++ "sections": {}, ++ "configuration_defaults": { ++ FILE_SIZE_CHECK: { ++ "WARN_SIZE": 30, ++ "sibling_marker": "sibling", ++ } ++ }, ++ }, ++ ) ++ ++ middle_profile = profile_factory(middle) ++ assert middle_profile.configuration_defaults[FILE_SIZE_CHECK] == { ++ "WARN_SIZE": 20, ++ "FAIL_SIZE": 100, ++ "base_marker": "base", ++ "middle_marker": "middle", ++ } ++ ++ root = install_profile( ++ monkeypatch, ++ "codespec_defaults_root", ++ { ++ "name": "codespec-defaults-root", ++ "include_profiles": [ ++ "codespec_defaults_middle", ++ "codespec_defaults_sibling", ++ ], ++ "sections": {}, ++ "configuration_defaults": { ++ FILE_SIZE_CHECK: { ++ "root_marker": "root", ++ } ++ }, ++ }, ++ ) ++ profile = profile_factory(root) ++ assert profile.configuration_defaults[FILE_SIZE_CHECK] == { ++ "WARN_SIZE": 30, ++ "FAIL_SIZE": 100, ++ "base_marker": "base", ++ "middle_marker": "middle", ++ "sibling_marker": "sibling", ++ "root_marker": "root", ++ } ++ ++ ++def test_codespec_user_check_config_merges_over_profile_defaults( ++ monkeypatch, tmp_path ++): ++ module = install_profile( ++ monkeypatch, ++ "codespec_runtime_config", ++ { ++ "name": "codespec-runtime-config", ++ "sections": {"Runtime": [FILE_SIZE_CHECK]}, ++ "configuration_defaults": { ++ FILE_SIZE_CHECK: {"WARN_SIZE": 40, "FAIL_SIZE": 100} ++ }, ++ }, ++ ) ++ profile = profile_factory(module) ++ ++ font_path = tmp_path / "configured.ttf" ++ font_path.write_bytes(b"x" * 60) ++ result = only_subresult( ++ run_file_size_check(profile, font_path, {"WARN_SIZE": 55}) ++ ) ++ assert (result.status, result.message.code) == (WARN, "large-font") ++ ++ small_font_path = tmp_path / "explicit-zero.ttf" ++ small_font_path.write_bytes(b"x" * 20) ++ result = only_subresult( ++ run_file_size_check(profile, small_font_path, {"WARN_SIZE": 0}) ++ ) ++ assert (result.status, result.message.code) == (WARN, "large-font") ++ ++ ++def test_codespec_override_rules_merge_by_message_code(monkeypatch, tmp_path): ++ install_profile( ++ monkeypatch, ++ "codespec_override_base", ++ { ++ "name": "codespec-override-base", ++ "sections": {"Policy": [FILE_SIZE_CHECK]}, ++ "overrides": { ++ FILE_SIZE_CHECK: [ ++ { ++ "code": "large-font", ++ "status": "INFO", ++ "reason": "Base profile accepts moderately large files.", ++ }, ++ { ++ "code": "massive-font", ++ "status": "WARN", ++ "reason": "Base profile only warns for massive files.", ++ }, ++ ] ++ }, ++ }, ++ ) ++ child = install_profile( ++ monkeypatch, ++ "codespec_override_child", ++ { ++ "name": "codespec-override-child", ++ "include_profiles": ["codespec_override_base"], ++ "sections": {}, ++ "configuration_defaults": { ++ FILE_SIZE_CHECK: {"WARN_SIZE": 40, "FAIL_SIZE": 100} ++ }, ++ "overrides": { ++ FILE_SIZE_CHECK: [ ++ { ++ "code": "massive-font", ++ "status": "FAIL", ++ "reason": "Child profile rejects massive files.", ++ } ++ ] ++ }, ++ }, ++ ) ++ profile = profile_factory(child) ++ ++ moderate = tmp_path / "moderate.ttf" ++ moderate.write_bytes(b"x" * 60) ++ result = only_subresult(run_file_size_check(profile, moderate)) ++ assert (result.status, result.message.code) == (INFO, "large-font") ++ ++ massive = tmp_path / "massive.ttf" ++ massive.write_bytes(b"x" * 120) ++ result = only_subresult(run_file_size_check(profile, massive)) ++ assert (result.status, result.message.code) == (FAIL, "massive-font") ++ ++ ++def test_codespec_later_include_then_local_override_wins(monkeypatch, tmp_path): ++ for suffix, status in (("first", "INFO"), ("second", "FAIL")): ++ install_profile( ++ monkeypatch, ++ f"codespec_ordered_override_{suffix}", ++ { ++ "name": f"codespec-ordered-override-{suffix}", ++ "sections": {suffix: [FILE_SIZE_CHECK]} if suffix == "first" else {}, ++ "overrides": { ++ FILE_SIZE_CHECK: [ ++ { ++ "code": "large-font", ++ "status": status, ++ "reason": f"Policy from {suffix} include.", ++ } ++ ] ++ }, ++ }, ++ ) ++ ++ ordered_root = install_profile( ++ monkeypatch, ++ "codespec_ordered_override_root", ++ { ++ "name": "codespec-ordered-override-root", ++ "include_profiles": [ ++ "codespec_ordered_override_first", ++ "codespec_ordered_override_second", ++ ], ++ "sections": {}, ++ "configuration_defaults": { ++ FILE_SIZE_CHECK: {"WARN_SIZE": 40, "FAIL_SIZE": 100} ++ }, ++ }, ++ ) ++ font_path = tmp_path / "ordered.ttf" ++ font_path.write_bytes(b"x" * 60) ++ result = only_subresult( ++ run_file_size_check(profile_factory(ordered_root), font_path) ++ ) ++ assert (result.status, result.message.code) == (FAIL, "large-font") ++ ++ local_root = install_profile( ++ monkeypatch, ++ "codespec_local_override_root", ++ { ++ "name": "codespec-local-override-root", ++ "include_profiles": ["codespec_ordered_override_root"], ++ "sections": {}, ++ "configuration_defaults": { ++ FILE_SIZE_CHECK: {"WARN_SIZE": 40, "FAIL_SIZE": 100} ++ }, ++ "overrides": { ++ FILE_SIZE_CHECK: [ ++ { ++ "code": "large-font", ++ "status": "PASS", ++ "reason": "The including profile has final say.", ++ } ++ ] ++ }, ++ }, ++ ) ++ result = only_subresult( ++ run_file_size_check(profile_factory(local_root), font_path) ++ ) ++ assert (result.status, result.message.code) == (PASS, "large-font") ++ ++ ++def test_codespec_duplicate_checks_keep_first_section(monkeypatch): ++ install_profile( ++ monkeypatch, ++ "codespec_duplicate_first", ++ { ++ "name": "codespec-duplicate-first", ++ "sections": { ++ "First section": [FILE_SIZE_CHECK, UNITS_PER_EM_CHECK] ++ }, ++ }, ++ ) ++ install_profile( ++ monkeypatch, ++ "codespec_duplicate_second", ++ { ++ "name": "codespec-duplicate-second", ++ "sections": {"Second section": [FILE_SIZE_CHECK]}, ++ }, ++ ) ++ root = install_profile( ++ monkeypatch, ++ "codespec_duplicate_root", ++ { ++ "name": "codespec-duplicate-root", ++ "include_profiles": [ ++ "codespec_duplicate_first", ++ "codespec_duplicate_second", ++ ], ++ "sections": {"Root section": [FILE_SIZE_CHECK]}, ++ }, ++ ) ++ profile = profile_factory(root) ++ placements = [ ++ (section.name, check.id) ++ for section in profile.sections ++ for check in section.checks ++ ] ++ assert placements == [ ++ ("First section", FILE_SIZE_CHECK), ++ ("First section", UNITS_PER_EM_CHECK), ++ ] ++ ++ ++def test_codespec_profile_compilation_is_deeply_isolated(monkeypatch): ++ source = { ++ "name": "codespec-isolated", ++ "sections": {"Policy": [FILE_SIZE_CHECK]}, ++ "configuration_defaults": { ++ FILE_SIZE_CHECK: {"WARN_SIZE": 40, "FAIL_SIZE": 100} ++ }, ++ "overrides": { ++ FILE_SIZE_CHECK: [ ++ { ++ "code": "large-font", ++ "status": "INFO", ++ "reason": "Original policy.", ++ } ++ ] ++ }, ++ } ++ module = install_profile(monkeypatch, "codespec_isolated", source) ++ first = profile_factory(module) ++ ++ source["configuration_defaults"][FILE_SIZE_CHECK]["WARN_SIZE"] = 999 ++ source["overrides"][FILE_SIZE_CHECK][0]["status"] = "FAIL" ++ assert first.configuration_defaults[FILE_SIZE_CHECK]["WARN_SIZE"] == 40 ++ assert first.overrides[FILE_SIZE_CHECK][0]["status"] == "INFO" ++ ++ first.configuration_defaults[FILE_SIZE_CHECK]["FAIL_SIZE"] = 777 ++ first.overrides[FILE_SIZE_CHECK][0]["reason"] = "Mutated result." ++ assert source["configuration_defaults"][FILE_SIZE_CHECK]["FAIL_SIZE"] == 100 ++ assert source["overrides"][FILE_SIZE_CHECK][0]["reason"] == "Original policy." ++ ++ second = profile_factory(module) ++ assert second.configuration_defaults[FILE_SIZE_CHECK] == { ++ "WARN_SIZE": 999, ++ "FAIL_SIZE": 100, ++ } ++ assert second.overrides[FILE_SIZE_CHECK][0]["reason"] == "Original policy." ++ ++ ++def test_codespec_include_cycle_reports_the_chain(monkeypatch): ++ first = install_profile( ++ monkeypatch, ++ "codespec_cycle_first", ++ { ++ "name": "codespec-cycle-first", ++ "include_profiles": ["codespec_cycle_second"], ++ "sections": {}, ++ }, ++ ) ++ install_profile( ++ monkeypatch, ++ "codespec_cycle_second", ++ { ++ "name": "codespec-cycle-second", ++ "include_profiles": ["codespec_cycle_third"], ++ "sections": {}, ++ }, ++ ) ++ install_profile( ++ monkeypatch, ++ "codespec_cycle_third", ++ { ++ "name": "codespec-cycle-third", ++ "include_profiles": ["codespec_cycle_first"], ++ "sections": {}, ++ }, ++ ) ++ ++ with pytest.raises(ValueError) as exc_info: ++ profile_factory(first) ++ ++ message = str(exc_info.value).lower() ++ assert "cycle" in message ++ for name in ("codespec_cycle_first", "codespec_cycle_second", "codespec_cycle_third"): ++ assert name 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,7 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++pytest -q \ ++ tests/checks/codespec_profile_composition_test.py \ ++ tests/checks/external_profile_test.py diff --git a/tasks/format-code-task-001198/tests/test.sh b/tasks/format-code-task-001198/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4374923731be0debaf83e327e3db3409a9976266 --- /dev/null +++ b/tasks/format-code-task-001198/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/checks/codespec_profile_composition_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-001198/tests/test_command.sh b/tasks/format-code-task-001198/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001198/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001199/environment/Dockerfile b/tasks/format-code-task-001199/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..57426510c2ec4cf119611e4b0c1f6c8165e8e7ce --- /dev/null +++ b/tasks/format-code-task-001199/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d742532f0949b0b6fb392f75c9f01e7de97ad7e495a812d67606c8ba0e225ef4 diff --git a/tasks/format-code-task-001199/environment/setup/files/blocklist b/tasks/format-code-task-001199/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001199/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001199/environment/setup/setup.sh b/tasks/format-code-task-001199/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001199/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001199/tests/test.patch b/tasks/format-code-task-001199/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..080003cd86778b467905e00304ab1e059341f594 --- /dev/null +++ b/tasks/format-code-task-001199/tests/test.patch @@ -0,0 +1,36 @@ +diff --git a/tests/test_checks_googlefonts.py b/tests/test_checks_googlefonts.py +index 1c0fe4ba61..87042c21bb 100644 +--- a/tests/test_checks_googlefonts.py ++++ b/tests/test_checks_googlefonts.py +@@ -4331,7 +4331,7 @@ def test_check_article_images(): + # Test case for ARTICLE with missing visual files + family_directory = portable_path("data/test/article_missing_visual_file") + assert_results_contain( +- check(MockFont(family_directory=family_directory)), WARN, "missing-visual-file" ++ check(MockFont(family_directory=family_directory)), FATAL, "missing-visual-file" + ) + + # TODO: +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+3T0WrCMBQGYK99iuD10jZqFbzd/V7ASYjpaRvWJtKcVn37RSk6hE3GFBmer9Ck ++JE1/ctJo3Zoqk2C7eHAvSTBP02MbXLbHvkjHIlwzkYR5QqTz6YCld0v0RetRNYwNGufwp3nXxv+p ++6Fx/BI9Su7pWNot8ebtvXKm/SJPpqf7JWIT6T2fhGLDkdhG+9+T11xk7Fn4N2dC7ttFweo6j7nAs ++1sbGSqPpFMJws8fSWcZrFnphGjvcfH90StAfXhbOFRXkzqKPNnvGO/Y+ZIzzDDxUoK+/slicx2Su ++alPtZam8rIwG6+FyudGv1uugQaNVJWvAxmgvGyga8N4460d/W1rtwMtaoS6XmUJ1fC3WKuxfl8ev ++h3a5zbB82RYlriLEnNcuS3j4elthwt+chdUjIog+guC1CRthC35Y5iFRxn2UcYhgfMhjuWuRu5w3 ++yhaP2Z5Jn2nSZ1K7i0zDR//DhBBCCCGEEEIIIYQQQgghhBBCCHlunzdRo1IAKAAA +diff --git 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-001199/tests/test.sh b/tasks/format-code-task-001199/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fdf35ecedc21816446dd3324360e95bbe0623eda --- /dev/null +++ b/tasks/format-code-task-001199/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_checks_googlefonts.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-001199/tests/test_command.sh b/tasks/format-code-task-001199/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001199/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001303/environment/Dockerfile b/tasks/format-code-task-001303/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6663e392cc748e7acebb386094aadc19983bca1e --- /dev/null +++ b/tasks/format-code-task-001303/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fbd8fe838f1104e8f0af52ab36d348227bd017d44a95e8ffd39b30fa791f797e diff --git a/tasks/format-code-task-001303/environment/setup/files/blocklist b/tasks/format-code-task-001303/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001303/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001303/environment/setup/setup.sh b/tasks/format-code-task-001303/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001303/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001303/tests/test.patch b/tasks/format-code-task-001303/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d549b3a27fa58107d7661d22a19f7c968fe49787 --- /dev/null +++ b/tasks/format-code-task-001303/tests/test.patch @@ -0,0 +1,455 @@ +diff --git a/usercase-test-coderl/retry_test.go b/usercase-test-coderl/retry_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/retry_test.go +@@ -0,0 +1,427 @@ ++package usercase_test_coderl ++ ++import ( ++ "context" ++ "errors" ++ "fmt" ++ "reflect" ++ "strings" ++ "sync" ++ "testing" ++ "time" ++ ++ "github.com/go-kit/kit/endpoint" ++ "github.com/go-kit/kit/sd/lb" ++) ++ ++type sequenceBalancer struct { ++ mu sync.Mutex ++ endpoints []endpoint.Endpoint ++ calls int ++} ++ ++func (b *sequenceBalancer) Endpoint() (endpoint.Endpoint, error) { ++ b.mu.Lock() ++ defer b.mu.Unlock() ++ if len(b.endpoints) == 0 { ++ return nil, lb.ErrNoEndpoints ++ } ++ e := b.endpoints[b.calls%len(b.endpoints)] ++ b.calls++ ++ return e, nil ++} ++ ++func (b *sequenceBalancer) Calls() int { ++ b.mu.Lock() ++ defer b.mu.Unlock() ++ return b.calls ++} ++ ++func responseEndpoint(response interface{}) endpoint.Endpoint { ++ return func(context.Context, interface{}) (interface{}, error) { ++ return response, nil ++ } ++} ++ ++func errorEndpoint(err error) endpoint.Endpoint { ++ return func(context.Context, interface{}) (interface{}, error) { ++ return nil, err ++ } ++} ++ ++func blockingEndpoint(started chan<- struct{}) endpoint.Endpoint { ++ return func(ctx context.Context, request interface{}) (interface{}, error) { ++ close(started) ++ <-ctx.Done() ++ return nil, errors.New("endpoint returned after timeout") ++ } ++} ++ ++func requestFixture() map[string]interface{} { ++ return map[string]interface{}{ ++ "id": "request-17", ++ "tags": []string{"alpha", "beta"}, ++ } ++} ++ ++func copyRequest(in map[string]interface{}) map[string]interface{} { ++ out := make(map[string]interface{}, len(in)) ++ for k, v := range in { ++ switch typed := v.(type) { ++ case []string: ++ out[k] = append([]string(nil), typed...) ++ default: ++ out[k] = typed ++ } ++ } ++ return out ++} ++ ++func retryErrorValue(t *testing.T, err error) lb.RetryError { ++ t.Helper() ++ ++ ++ switch retryErr := err.(type) { ++ case lb.RetryError: ++ return retryErr ++ case *lb.RetryError: ++ if retryErr == nil { ++ t.Fatalf("expected lb.RetryError, got nil *lb.RetryError") ++ } ++ return *retryErr ++ default: ++ t.Fatalf("expected lb.RetryError, got %T: %v", err, err) ++ return lb.RetryError{} ++ } ++} ++ ++func assertRetryErrorFields(t *testing.T, retryErr lb.RetryError, final string, raw []string) { ++ t.Helper() ++ ++ if retryErr.Final == nil || retryErr.Final.Error() != final { ++ t.Fatalf("RetryError.Final = %v, want %q", retryErr.Final, final) ++ } ++ if len(retryErr.RawErrors) != len(raw) { ++ t.Fatalf("len(RawErrors) = %d, want %d", len(retryErr.RawErrors), len(raw)) ++ } ++ for i, want := range raw { ++ if retryErr.RawErrors[i] == nil || retryErr.RawErrors[i].Error() != want { ++ t.Fatalf("RawErrors[%d] = %v, want %q", i, retryErr.RawErrors[i], want) ++ } ++ } ++} ++ ++func assertRetryError(t *testing.T, err error, final string, raw []string, full string) { ++ t.Helper() ++ retryErr := retryErrorValue(t, err) ++ assertRetryErrorFields(t, retryErr, final, raw) ++ if retryErr.Error() != full { ++ t.Fatalf("RetryError.Error() = %q, want %q", retryErr.Error(), full) ++ } ++} ++ ++func assertRetryErrorContains(t *testing.T, err error, final string, raw []string, substrings ...string) { ++ t.Helper() ++ retryErr := retryErrorValue(t, err) ++ assertRetryErrorFields(t, retryErr, final, raw) ++ for _, substring := range substrings { ++ if !strings.Contains(retryErr.Error(), substring) { ++ t.Fatalf("RetryError.Error() = %q, want substring %q", retryErr.Error(), substring) ++ } ++ } ++} ++ ++func TestRetrySucceedsOnThirdAttempt(t *testing.T) { ++ ++ ++ req := requestFixture() ++ balancer := &sequenceBalancer{endpoints: []endpoint.Endpoint{ ++ errorEndpoint(errors.New("error one")), ++ errorEndpoint(errors.New("error two")), ++ responseEndpoint("ok"), ++ }} ++ ++ resp, err := lb.Retry(3, time.Second, balancer)(context.Background(), req) ++ ++ if err != nil { ++ t.Fatalf("err = %v, want nil", err) ++ } ++ if resp != "ok" { ++ t.Fatalf("resp = %#v, want %q", resp, "ok") ++ } ++ if balancer.Calls() != 3 { ++ t.Fatalf("balancer calls = %d, want 3", balancer.Calls()) ++ } ++} ++ ++func TestRetryStopsAtAttemptLimitWithAggregatedRetryError(t *testing.T) { ++ ++ ++ balancer := &sequenceBalancer{endpoints: []endpoint.Endpoint{ ++ errorEndpoint(errors.New("error one")), ++ errorEndpoint(errors.New("error two")), ++ responseEndpoint("ok"), ++ }} ++ ++ resp, err := lb.Retry(2, time.Second, balancer)(context.Background(), requestFixture()) ++ ++ if resp != nil { ++ t.Fatalf("resp = %#v, want nil", resp) ++ } ++ assertRetryError(t, err, "error two", []string{"error one", "error two"}, "error two (previously: error one)") ++ if balancer.Calls() != 2 { ++ t.Fatalf("balancer calls = %d, want 2", balancer.Calls()) ++ } ++} ++ ++func TestRetrySurfacesNoEndpointsThroughRetryPath(t *testing.T) { ++ ++ ++ balancer := &sequenceBalancer{} ++ ++ resp, err := lb.Retry(3, time.Second, balancer)(context.Background(), requestFixture()) ++ ++ if resp != nil { ++ t.Fatalf("resp = %#v, want nil", resp) ++ } ++ assertRetryError(t, err, "no endpoints available", []string{ ++ "no endpoints available", ++ "no endpoints available", ++ "no endpoints available", ++ }, "no endpoints available (previously: no endpoints available; no endpoints available)") ++} ++ ++func TestRetryReturnsDeadlineExceededWhenAttemptOutlivesTimeout(t *testing.T) { ++ ++ ++ started := make(chan struct{}) ++ balancer := &sequenceBalancer{endpoints: []endpoint.Endpoint{blockingEndpoint(started)}} ++ ++ respCh := make(chan interface{}, 1) ++ errCh := make(chan error, 1) ++ go func() { ++ resp, err := lb.Retry(5, 20*time.Millisecond, balancer)(context.Background(), requestFixture()) ++ respCh <- resp ++ errCh <- err ++ }() ++ <-started ++ ++ resp := <-respCh ++ err := <-errCh ++ if resp != nil { ++ t.Fatalf("resp = %#v, want nil", resp) ++ } ++ if !errors.Is(err, context.DeadlineExceeded) { ++ t.Fatalf("err = %T %v, want context deadline exceeded", err, err) ++ } ++} ++ ++func TestRetryWithCallbackStopsImmediatelyWithoutReplacement(t *testing.T) { ++ ++ ++ attempts := []string{} ++ balancer := &sequenceBalancer{endpoints: []endpoint.Endpoint{ ++ errorEndpoint(errors.New("error one")), ++ errorEndpoint(errors.New("error two")), ++ }} ++ cb := func(n int, received error) (bool, error) { ++ attempts = append(attempts, fmt.Sprintf("%d:%s", n, received.Error())) ++ return false, nil ++ } ++ ++ resp, err := lb.RetryWithCallback(time.Second, balancer, cb)(context.Background(), requestFixture()) ++ ++ if resp != nil { ++ t.Fatalf("resp = %#v, want nil", resp) ++ } ++ assertRetryError(t, err, "error one", []string{"error one"}, "error one") ++ if !reflect.DeepEqual(attempts, []string{"1:error one"}) { ++ t.Fatalf("callback attempts = %#v, want %#v", attempts, []string{"1:error one"}) ++ } ++ if balancer.Calls() != 1 { ++ t.Fatalf("balancer calls = %d, want 1", balancer.Calls()) ++ } ++} ++ ++func TestRetryWithCallbackUsesReplacementErrorAsFinal(t *testing.T) { ++ ++ ++ attempts := []string{} ++ replacement := errors.New("replacement final") ++ balancer := &sequenceBalancer{endpoints: []endpoint.Endpoint{ ++ errorEndpoint(errors.New("error one")), ++ errorEndpoint(errors.New("error three")), ++ responseEndpoint("late"), ++ }} ++ cb := func(n int, received error) (bool, error) { ++ attempts = append(attempts, fmt.Sprintf("%d:%s", n, received.Error())) ++ if n == 2 { ++ return false, replacement ++ } ++ return true, nil ++ } ++ ++ resp, err := lb.RetryWithCallback(time.Second, balancer, cb)(context.Background(), requestFixture()) ++ ++ if resp != nil { ++ t.Fatalf("resp = %#v, want nil", resp) ++ } ++ ++ assertRetryErrorContains(t, err, "replacement final", []string{"error one", "error three"}, "replacement final", "previously:", "error one") ++ if !reflect.DeepEqual(attempts, []string{"1:error one", "2:error three"}) { ++ t.Fatalf("callback attempts = %#v, want %#v", attempts, []string{"1:error one", "2:error three"}) ++ } ++} ++ ++func TestRetryWithNilCallbackRetriesUntilSuccess(t *testing.T) { ++ ++ ++ balancer := &sequenceBalancer{endpoints: []endpoint.Endpoint{ ++ errorEndpoint(errors.New("error one")), ++ errorEndpoint(errors.New("error two")), ++ responseEndpoint("eventual"), ++ }} ++ ++ resp, err := lb.RetryWithCallback(time.Second, balancer, nil)(context.Background(), requestFixture()) ++ ++ if err != nil { ++ t.Fatalf("err = %v, want nil", err) ++ } ++ if resp != "eventual" { ++ t.Fatalf("resp = %#v, want %q", resp, "eventual") ++ } ++ if balancer.Calls() != 3 { ++ t.Fatalf("balancer calls = %d, want 3", balancer.Calls()) ++ } ++} ++ ++func TestRetryWithCallbackPanicsOnNilBalancer(t *testing.T) { ++ ++ ++ defer func() { ++ got := recover() ++ if got != "nil Balancer" { ++ t.Fatalf("panic = %#v, want %#v", got, "nil Balancer") ++ } ++ }() ++ ++ _ = lb.RetryWithCallback(time.Second, nil, nil) ++} ++ ++func TestRetryErrorStringWithSingleAndMultipleFailures(t *testing.T) { ++ ++ ++ oneFailure := lb.RetryError{ ++ RawErrors: []error{errors.New("error one")}, ++ Final: errors.New("error one"), ++ } ++ threeFailures := lb.RetryError{ ++ RawErrors: []error{errors.New("error one"), errors.New("error two"), errors.New("error three")}, ++ Final: errors.New("error three"), ++ } ++ ++ if oneFailure.Error() != "error one" { ++ t.Fatalf("single failure Error() = %q, want %q", oneFailure.Error(), "error one") ++ } ++ if threeFailures.Error() != "error three (previously: error one; error two)" { ++ t.Fatalf("three failure Error() = %q, want %q", threeFailures.Error(), "error three (previously: error one; error two)") ++ } ++} ++ ++func TestRetryEndpointIsReferentiallyTransparentForSameInput(t *testing.T) { ++ req := requestFixture() ++ makeRetry := func() endpoint.Endpoint { ++ return lb.Retry(3, time.Second, &sequenceBalancer{endpoints: []endpoint.Endpoint{ ++ errorEndpoint(errors.New("error one")), ++ errorEndpoint(errors.New("error two")), ++ responseEndpoint("ok"), ++ }}) ++ } ++ ++ resp1, err1 := makeRetry()(context.Background(), req) ++ resp2, err2 := makeRetry()(context.Background(), req) ++ ++ if resp1 != "ok" || err1 != nil { ++ t.Fatalf("first call = (%#v, %v), want (%q, nil)", resp1, err1, "ok") ++ } ++ if resp2 != "ok" || err2 != nil { ++ t.Fatalf("second call = (%#v, %v), want (%q, nil)", resp2, err2, "ok") ++ } ++} ++ ++func TestRetryDoesNotMutateCallerRequest(t *testing.T) { ++ req := requestFixture() ++ before := copyRequest(req) ++ balancer := &sequenceBalancer{endpoints: []endpoint.Endpoint{ ++ errorEndpoint(errors.New("error one")), ++ responseEndpoint("ok"), ++ }} ++ ++ resp, err := lb.Retry(2, time.Second, balancer)(context.Background(), req) ++ ++ if resp != "ok" || err != nil { ++ t.Fatalf("call = (%#v, %v), want (%q, nil)", resp, err, "ok") ++ } ++ if !reflect.DeepEqual(req, before) { ++ t.Fatalf("request mutated: got %#v, want %#v", req, before) ++ } ++} ++ ++func TestRetryResultSurvivesInProcessNoise(t *testing.T) { ++ makeRetry := func() endpoint.Endpoint { ++ return lb.Retry(3, time.Second, &sequenceBalancer{endpoints: []endpoint.Endpoint{ ++ errorEndpoint(errors.New("error one")), ++ errorEndpoint(errors.New("error two")), ++ responseEndpoint("ok"), ++ }}) ++ } ++ baselineResp, baselineErr := makeRetry()(context.Background(), requestFixture()) ++ ++ noiseResp, noiseErr := lb.RetryWithCallback(time.Second, &sequenceBalancer{endpoints: []endpoint.Endpoint{ ++ errorEndpoint(errors.New("noise one")), ++ responseEndpoint("noise ok"), ++ }}, nil)(context.Background(), map[string]interface{}{"id": "noise"}) ++ if noiseResp != "noise ok" || noiseErr != nil { ++ t.Fatalf("noise call = (%#v, %v), want (%q, nil)", noiseResp, noiseErr, "noise ok") ++ } ++ _, _ = lb.Retry(1, time.Second, &sequenceBalancer{})(context.Background(), map[string]interface{}{"id": "empty-noise"}) ++ ++ repeatedResp, repeatedErr := makeRetry()(context.Background(), requestFixture()) ++ ++ if baselineResp != "ok" || baselineErr != nil { ++ t.Fatalf("baseline = (%#v, %v), want (%q, nil)", baselineResp, baselineErr, "ok") ++ } ++ if repeatedResp != "ok" || repeatedErr != nil { ++ t.Fatalf("repeated = (%#v, %v), want (%q, nil)", repeatedResp, repeatedErr, "ok") ++ } ++} ++ ++func TestRetryPassesSameRequestToEveryAttempt(t *testing.T) { ++ req := &struct { ++ ID string ++ }{ID: "request-17"} ++ seen := 0 ++ checkSameRequest := func(response interface{}, err error) endpoint.Endpoint { ++ return func(_ context.Context, got interface{}) (interface{}, error) { ++ if got != req { ++ t.Fatalf("endpoint request = %#v, want original request %#v", got, req) ++ } ++ seen++ ++ return response, err ++ } ++ } ++ ++ resp, err := lb.Retry(3, time.Second, &sequenceBalancer{endpoints: []endpoint.Endpoint{ ++ checkSameRequest(nil, errors.New("error one")), ++ checkSameRequest(nil, errors.New("error two")), ++ checkSameRequest("ok", nil), ++ }})(context.Background(), req) ++ ++ if resp != "ok" || err != nil { ++ t.Fatalf("call = (%#v, %v), want (%q, nil)", resp, err, "ok") ++ } ++ ++ if seen != 3 { ++ t.Fatalf("endpoint calls = %d, want 3", seen) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,18 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++exec go test -mod=readonly -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001303/tests/test.sh b/tasks/format-code-task-001303/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1a63f06cc78c987df61fc00bfd56c4e2fcde121b --- /dev/null +++ b/tasks/format-code-task-001303/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/retry_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-001303/tests/test_command.sh b/tasks/format-code-task-001303/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001303/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-001304/environment/Dockerfile b/tasks/format-code-task-001304/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0238554322a7624d6f7591381d5783647fe03b04 --- /dev/null +++ b/tasks/format-code-task-001304/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:aef0726a2587f21b15687cfa5d79d671d39c30b3f34a70b7e1d54b44fcbb185e diff --git a/tasks/format-code-task-001304/environment/setup/files/blocklist b/tasks/format-code-task-001304/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001304/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001304/environment/setup/setup.sh b/tasks/format-code-task-001304/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001304/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001304/tests/test.patch b/tasks/format-code-task-001304/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a5e509bd08a74f4fe181b0a67f24ab6d3dc3d82f --- /dev/null +++ b/tasks/format-code-task-001304/tests/test.patch @@ -0,0 +1,521 @@ +diff --git a/usercase-test-coderl/amqp_publisher_test.go b/usercase-test-coderl/amqp_publisher_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/amqp_publisher_test.go +@@ -0,0 +1,489 @@ ++package usercase_test_coderl ++ ++import ( ++ "context" ++ "encoding/json" ++ "errors" ++ "testing" ++ "time" ++ ++ amqptransport "github.com/go-kit/kit/transport/amqp" ++ amqp "github.com/rabbitmq/amqp091-go" ++) ++ ++type squadronRequest struct { ++ Squadron int `json:"s"` ++} ++ ++type squadronResponse struct { ++ Squadron int `json:"s"` ++ Name string `json:"n"` ++} ++ ++type publishCall struct { ++ Exchange string ++ Key string ++ Mandatory bool ++ Immediate bool ++ Message amqp.Publishing ++} ++ ++type consumeCall struct { ++ Queue string ++ Consumer string ++ AutoAck bool ++ Exclusive bool ++ NoLocal bool ++ NoWait bool ++ Args amqp.Table ++} ++ ++type recordingChannel struct { ++ publishes []publishCall ++ consumes []consumeCall ++ deliveries []amqp.Delivery ++} ++ ++func (ch *recordingChannel) Publish(exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error { ++ ch.publishes = append(ch.publishes, publishCall{ ++ Exchange: exchange, ++ Key: key, ++ Mandatory: mandatory, ++ Immediate: immediate, ++ Message: msg, ++ }) ++ return nil ++} ++ ++func (ch *recordingChannel) Consume(queue, consumer string, autoAck, exclusive, noLocal, noWait bool, args amqp.Table) (<-chan amqp.Delivery, error) { ++ ch.consumes = append(ch.consumes, consumeCall{ ++ Queue: queue, ++ Consumer: consumer, ++ AutoAck: autoAck, ++ Exclusive: exclusive, ++ NoLocal: noLocal, ++ NoWait: noWait, ++ Args: args, ++ }) ++ out := make(chan amqp.Delivery, len(ch.deliveries)) ++ for _, delivery := range ch.deliveries { ++ out <- delivery ++ } ++ return out, nil ++} ++ ++type ackRecorder struct { ++ count int ++ tags []uint64 ++ multiple []bool ++} ++ ++func (a *ackRecorder) Ack(tag uint64, multiple bool) error { ++ a.count++ ++ a.tags = append(a.tags, tag) ++ a.multiple = append(a.multiple, multiple) ++ return nil ++} ++ ++func (a *ackRecorder) Nack(tag uint64, multiple bool, requeue bool) error { ++ return nil ++} ++ ++func (a *ackRecorder) Reject(tag uint64, requeue bool) error { ++ return nil ++} ++ ++func encodeJSONRequest(_ context.Context, pub *amqp.Publishing, request interface{}) error { ++ body, err := json.Marshal(request) ++ if err != nil { ++ return err ++ } ++ pub.Body = body ++ pub.ContentType = "application/json" ++ return nil ++} ++ ++func decodeJSONResponse(_ context.Context, delivery *amqp.Delivery) (interface{}, error) { ++ var response squadronResponse ++ if err := json.Unmarshal(delivery.Body, &response); err != nil { ++ return nil, err ++ } ++ return response, nil ++} ++ ++func mustResponseBody(t *testing.T, response squadronResponse) []byte { ++ t.Helper() ++ body, err := json.Marshal(response) ++ if err != nil { ++ t.Fatal(err) ++ } ++ return body ++} ++ ++func TestPublisherEndpointPublishesConsumesMatchesAcksAndDecodes(t *testing.T) { ++ ++ ++ acker := &ackRecorder{} ++ channel := &recordingChannel{ ++ deliveries: []amqp.Delivery{ ++ {CorrelationId: "wrong", Body: []byte(`{"s":1,"n":"wrong"}`)}, ++ {CorrelationId: "correlation", Body: []byte(`{"s":437,"n":"husky"}`), Acknowledger: acker, DeliveryTag: 9}, ++ }, ++ } ++ queue := &amqp.Queue{Name: "some queue"} ++ afterSeen := "" ++ ++ publisher := amqptransport.NewPublisher( ++ channel, ++ queue, ++ encodeJSONRequest, ++ decodeJSONResponse, ++ amqptransport.PublisherBefore( ++ amqptransport.SetCorrelationID("correlation"), ++ amqptransport.SetPublishExchange("fleet"), ++ amqptransport.SetPublishKey("requests"), ++ amqptransport.SetConsumeAutoAck(false), ++ amqptransport.SetConsumeArgs(amqp.Table{"priority": "gold"}), ++ ), ++ amqptransport.PublisherAfter(func(ctx context.Context, delivery *amqp.Delivery) context.Context { ++ afterSeen = delivery.CorrelationId + ":" + string(delivery.Body) ++ return ctx ++ }), ++ ) ++ ++ actual, err := publisher.Endpoint()(context.Background(), squadronRequest{Squadron: 437}) ++ if err != nil { ++ t.Fatalf("unexpected endpoint error: %v", err) ++ } ++ ++ if got := actual.(squadronResponse); got != (squadronResponse{Squadron: 437, Name: "husky"}) { ++ t.Fatalf("decoded response = %#v, want %#v", got, squadronResponse{Squadron: 437, Name: "husky"}) ++ } ++ if len(channel.publishes) != 1 { ++ t.Fatalf("publish call count = %d, want 1", len(channel.publishes)) ++ } ++ if channel.publishes[0].Exchange != "fleet" { ++ t.Fatalf("publish exchange = %q, want %q", channel.publishes[0].Exchange, "fleet") ++ } ++ if channel.publishes[0].Key != "requests" { ++ t.Fatalf("publish key = %q, want %q", channel.publishes[0].Key, "requests") ++ } ++ ++ if channel.publishes[0].Message.CorrelationId != "correlation" { ++ t.Fatalf("publishing CorrelationId = %q, want %q", channel.publishes[0].Message.CorrelationId, "correlation") ++ } ++ if channel.publishes[0].Message.ContentType != "application/json" { ++ t.Fatalf("publishing ContentType = %q, want %q", channel.publishes[0].Message.ContentType, "application/json") ++ } ++ if string(channel.publishes[0].Message.Body) != `{"s":437}` { ++ t.Fatalf("publishing Body = %s, want %s", string(channel.publishes[0].Message.Body), `{"s":437}`) ++ } ++ if len(channel.consumes) != 1 { ++ t.Fatalf("consume call count = %d, want 1", len(channel.consumes)) ++ } ++ if channel.consumes[0].Queue != "some queue" { ++ t.Fatalf("consume queue = %q, want %q", channel.consumes[0].Queue, "some queue") ++ } ++ ++ if channel.consumes[0].AutoAck != false { ++ t.Fatalf("consume autoAck = %v, want false", channel.consumes[0].AutoAck) ++ } ++ if got := channel.consumes[0].Args["priority"]; got != "gold" { ++ t.Fatalf("consume args priority = %#v, want %q", got, "gold") ++ } ++ if acker.count != 1 { ++ t.Fatalf("ack count = %d, want 1", acker.count) ++ } ++ if len(acker.tags) != 1 || acker.tags[0] != 9 { ++ t.Fatalf("ack tags = %#v, want []uint64{9}", acker.tags) ++ } ++ ++ if afterSeen != `correlation:{"s":437,"n":"husky"}` { ++ t.Fatalf("after hook saw %q, want %q", afterSeen, `correlation:{"s":437,"n":"husky"}`) ++ } ++} ++ ++func TestPublisherEndpointReturnsEncodeErrorBeforePublishOrConsume(t *testing.T) { ++ ++ ++ channel := &recordingChannel{} ++ publisher := amqptransport.NewPublisher( ++ channel, ++ &amqp.Queue{Name: "some queue"}, ++ func(context.Context, *amqp.Publishing, interface{}) error { return errors.New("err!") }, ++ decodeJSONResponse, ++ ) ++ ++ actual, err := publisher.Endpoint()(context.Background(), squadronRequest{Squadron: 437}) ++ ++ if actual != nil { ++ t.Fatalf("response = %#v, want nil", actual) ++ } ++ if err == nil { ++ t.Fatal("error = nil, want errors.New(\"err!\")") ++ } ++ if err.Error() != "err!" { ++ t.Fatalf("error message = %q, want %q", err.Error(), "err!") ++ } ++ if len(channel.publishes) != 0 { ++ t.Fatalf("publish call count = %d, want 0", len(channel.publishes)) ++ } ++ if len(channel.consumes) != 0 { ++ t.Fatalf("consume call count = %d, want 0", len(channel.consumes)) ++ } ++} ++ ++func TestPublisherEndpointReturnsDecodeErrorAfterMatchedReply(t *testing.T) { ++ ++ ++ channel := &recordingChannel{ ++ deliveries: []amqp.Delivery{ ++ {CorrelationId: "correlation", Body: []byte(`{"s":437,"n":"husky"}`)}, ++ }, ++ } ++ publisher := amqptransport.NewPublisher( ++ channel, ++ &amqp.Queue{Name: "some queue"}, ++ encodeJSONRequest, ++ func(context.Context, *amqp.Delivery) (interface{}, error) { return nil, errors.New("err!") }, ++ amqptransport.PublisherBefore(amqptransport.SetCorrelationID("correlation")), ++ ) ++ ++ actual, err := publisher.Endpoint()(context.Background(), squadronRequest{Squadron: 437}) ++ ++ if actual != nil { ++ t.Fatalf("response = %#v, want nil", actual) ++ } ++ if err == nil { ++ t.Fatal("error = nil, want errors.New(\"err!\")") ++ } ++ if err.Error() != "err!" { ++ t.Fatalf("error message = %q, want %q", err.Error(), "err!") ++ } ++ if len(channel.publishes) != 1 { ++ t.Fatalf("publish call count = %d, want 1", len(channel.publishes)) ++ } ++ if len(channel.consumes) != 1 { ++ t.Fatalf("consume call count = %d, want 1", len(channel.consumes)) ++ } ++} ++ ++func TestPublisherTimeoutReturnsContextDeadlineExceeded(t *testing.T) { ++ ++ ++ channel := &recordingChannel{} ++ publisher := amqptransport.NewPublisher( ++ channel, ++ &amqp.Queue{Name: "some queue"}, ++ encodeJSONRequest, ++ decodeJSONResponse, ++ amqptransport.PublisherBefore(amqptransport.SetCorrelationID("missing")), ++ amqptransport.PublisherTimeout(5*time.Millisecond), ++ ) ++ ++ actual, err := publisher.Endpoint()(context.Background(), squadronRequest{Squadron: 437}) ++ ++ if actual != nil { ++ t.Fatalf("response = %#v, want nil", actual) ++ } ++ if !errors.Is(err, context.DeadlineExceeded) { ++ t.Fatalf("error = %#v, want context.DeadlineExceeded", err) ++ } ++ ++ if err == nil { ++ t.Fatal("error = nil, want context.DeadlineExceeded") ++ } ++ if len(channel.publishes) != 1 { ++ t.Fatalf("publish call count = %d, want 1", len(channel.publishes)) ++ } ++ if len(channel.consumes) != 1 { ++ t.Fatalf("consume call count = %d, want 1", len(channel.consumes)) ++ } ++} ++ ++func TestSetConsumeAutoAckTrueDoesNotAckMatchedDelivery(t *testing.T) { ++ ++ ++ acker := &ackRecorder{} ++ channel := &recordingChannel{ ++ deliveries: []amqp.Delivery{ ++ {CorrelationId: "correlation", Body: []byte(`{"s":437,"n":"husky"}`), Acknowledger: acker, DeliveryTag: 10}, ++ }, ++ } ++ publisher := amqptransport.NewPublisher( ++ channel, ++ &amqp.Queue{Name: "some queue"}, ++ encodeJSONRequest, ++ decodeJSONResponse, ++ amqptransport.PublisherBefore( ++ amqptransport.SetCorrelationID("correlation"), ++ amqptransport.SetConsumeAutoAck(true), ++ ), ++ ) ++ ++ actual, err := publisher.Endpoint()(context.Background(), squadronRequest{Squadron: 437}) ++ if err != nil { ++ t.Fatalf("unexpected endpoint error: %v", err) ++ } ++ if got := actual.(squadronResponse); got != (squadronResponse{Squadron: 437, Name: "husky"}) { ++ t.Fatalf("decoded response = %#v, want %#v", got, squadronResponse{Squadron: 437, Name: "husky"}) ++ } ++ if channel.consumes[0].AutoAck != true { ++ t.Fatalf("consume autoAck = %v, want true", channel.consumes[0].AutoAck) ++ } ++ if acker.count != 0 { ++ t.Fatalf("ack count = %d, want 0", acker.count) ++ } ++} ++ ++func TestSendAndForgetDelivererPublishesWithoutConsuming(t *testing.T) { ++ ++ ++ channel := &recordingChannel{} ++ publisher := amqptransport.NewPublisher( ++ channel, ++ &amqp.Queue{Name: "some queue"}, ++ encodeJSONRequest, ++ func(context.Context, *amqp.Delivery) (interface{}, error) { return "forgotten", nil }, ++ amqptransport.PublisherBefore( ++ amqptransport.SetCorrelationID("fire"), ++ amqptransport.SetPublishExchange("fleet"), ++ amqptransport.SetPublishKey("events"), ++ ), ++ amqptransport.PublisherDeliverer(amqptransport.SendAndForgetDeliverer), ++ amqptransport.PublisherTimeout(time.Hour), ++ ) ++ ++ actual, err := publisher.Endpoint()(context.Background(), squadronRequest{Squadron: 437}) ++ if err != nil { ++ t.Fatalf("unexpected endpoint error: %v", err) ++ } ++ if actual != "forgotten" { ++ t.Fatalf("response = %#v, want %q", actual, "forgotten") ++ } ++ if len(channel.publishes) != 1 { ++ t.Fatalf("publish call count = %d, want 1", len(channel.publishes)) ++ } ++ if len(channel.consumes) != 0 { ++ t.Fatalf("consume call count = %d, want 0", len(channel.consumes)) ++ } ++ if channel.publishes[0].Exchange != "fleet" { ++ t.Fatalf("publish exchange = %q, want %q", channel.publishes[0].Exchange, "fleet") ++ } ++ if channel.publishes[0].Key != "events" { ++ t.Fatalf("publish key = %q, want %q", channel.publishes[0].Key, "events") ++ } ++ if channel.publishes[0].Message.CorrelationId != "fire" { ++ t.Fatalf("publishing CorrelationId = %q, want %q", channel.publishes[0].Message.CorrelationId, "fire") ++ } ++} ++ ++func TestPublisherInstancesKeepIndependentState(t *testing.T) { ++ ++ ++ channelA := &recordingChannel{ ++ deliveries: []amqp.Delivery{ ++ {CorrelationId: "a", Body: []byte(`{"s":101,"n":"alpha"}`)}, ++ }, ++ } ++ channelB := &recordingChannel{ ++ deliveries: []amqp.Delivery{ ++ {CorrelationId: "b", Body: []byte(`{"s":202,"n":"bravo"}`)}, ++ }, ++ } ++ publisherA := amqptransport.NewPublisher( ++ channelA, ++ &amqp.Queue{Name: "qa"}, ++ encodeJSONRequest, ++ decodeJSONResponse, ++ amqptransport.PublisherBefore( ++ amqptransport.SetCorrelationID("a"), ++ amqptransport.SetPublishKey("ka"), ++ ), ++ ) ++ publisherB := amqptransport.NewPublisher( ++ channelB, ++ &amqp.Queue{Name: "qb"}, ++ encodeJSONRequest, ++ decodeJSONResponse, ++ amqptransport.PublisherBefore( ++ amqptransport.SetCorrelationID("b"), ++ amqptransport.SetPublishKey("kb"), ++ ), ++ ) ++ ++ actualA, errA := publisherA.Endpoint()(context.Background(), squadronRequest{Squadron: 101}) ++ actualB, errB := publisherB.Endpoint()(context.Background(), squadronRequest{Squadron: 202}) ++ ++ if errA != nil { ++ t.Fatalf("publisher A error = %v, want nil", errA) ++ } ++ if errB != nil { ++ t.Fatalf("publisher B error = %v, want nil", errB) ++ } ++ if got := actualA.(squadronResponse); got != (squadronResponse{Squadron: 101, Name: "alpha"}) { ++ t.Fatalf("publisher A response = %#v, want %#v", got, squadronResponse{Squadron: 101, Name: "alpha"}) ++ } ++ if got := actualB.(squadronResponse); got != (squadronResponse{Squadron: 202, Name: "bravo"}) { ++ t.Fatalf("publisher B response = %#v, want %#v", got, squadronResponse{Squadron: 202, Name: "bravo"}) ++ } ++ ++ if channelA.consumes[0].Queue != "qa" { ++ t.Fatalf("publisher A consume queue = %q, want %q", channelA.consumes[0].Queue, "qa") ++ } ++ if channelB.consumes[0].Queue != "qb" { ++ t.Fatalf("publisher B consume queue = %q, want %q", channelB.consumes[0].Queue, "qb") ++ } ++ if channelA.publishes[0].Key != "ka" { ++ t.Fatalf("publisher A key = %q, want %q", channelA.publishes[0].Key, "ka") ++ } ++ if channelB.publishes[0].Key != "kb" { ++ t.Fatalf("publisher B key = %q, want %q", channelB.publishes[0].Key, "kb") ++ } ++ if channelA.publishes[0].Message.CorrelationId != "a" { ++ t.Fatalf("publisher A correlation = %q, want %q", channelA.publishes[0].Message.CorrelationId, "a") ++ } ++ if channelB.publishes[0].Message.CorrelationId != "b" { ++ t.Fatalf("publisher B correlation = %q, want %q", channelB.publishes[0].Message.CorrelationId, "b") ++ } ++} ++ ++func TestPublisherConstructUseCyclesDoNotLeakGoroutinesOrFDs(t *testing.T) { ++ ++ ++ body := mustResponseBody(t, squadronResponse{Squadron: 437, Name: "husky"}) ++ totalPublishes := 0 ++ totalConsumes := 0 ++ ++ for i := 0; i < 100; i++ { ++ channel := &recordingChannel{ ++ deliveries: []amqp.Delivery{ ++ {CorrelationId: "correlation", Body: body}, ++ }, ++ } ++ publisher := amqptransport.NewPublisher( ++ channel, ++ &amqp.Queue{Name: "some queue"}, ++ encodeJSONRequest, ++ decodeJSONResponse, ++ amqptransport.PublisherBefore(amqptransport.SetCorrelationID("correlation")), ++ ) ++ actual, err := publisher.Endpoint()(context.Background(), squadronRequest{Squadron: 437}) ++ if err != nil { ++ t.Fatalf("cycle %d endpoint error = %v, want nil", i, err) ++ } ++ if got := actual.(squadronResponse); got != (squadronResponse{Squadron: 437, Name: "husky"}) { ++ t.Fatalf("cycle %d response = %#v, want %#v", i, got, squadronResponse{Squadron: 437, Name: "husky"}) ++ } ++ totalPublishes += len(channel.publishes) ++ totalConsumes += len(channel.consumes) ++ } ++ ++ ++ if totalPublishes != 100 { ++ t.Fatalf("publish calls across cycles = %d, want 100", totalPublishes) ++ } ++ if totalConsumes != 100 { ++ t.Fatalf("consume calls across cycles = %d, want 100", totalConsumes) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,22 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++ ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++export GOVCS='*:off' ++export GOFLAGS="-mod=readonly" ++ ++exec go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001304/tests/test.sh b/tasks/format-code-task-001304/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea7caa98e8c879c4adb01c4877485ea536070ef3 --- /dev/null +++ b/tasks/format-code-task-001304/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/amqp_publisher_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-001304/tests/test_command.sh b/tasks/format-code-task-001304/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001304/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-001332/environment/Dockerfile b/tasks/format-code-task-001332/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1d7d54eae97d22edb9bac028797185065a13a559 --- /dev/null +++ b/tasks/format-code-task-001332/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4d9f35094065e85763af20dbc63053eedce3302e8d3c4df1c3de15932f390553 diff --git a/tasks/format-code-task-001332/environment/setup/files/blocklist b/tasks/format-code-task-001332/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001332/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001332/environment/setup/setup.sh b/tasks/format-code-task-001332/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001332/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001332/tests/test.patch b/tasks/format-code-task-001332/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7d71c0cdc78f5556c1e2d5c04b03cbf1d2fdec2b --- /dev/null +++ b/tasks/format-code-task-001332/tests/test.patch @@ -0,0 +1,195 @@ +diff --git a/mujoco_warp/_src/jac_test.py b/mujoco_warp/_src/jac_test.py +new file mode 100644 +index 0000000..e6d59df +--- /dev/null ++++ b/mujoco_warp/_src/jac_test.py +@@ -0,0 +1,163 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import mujoco ++import numpy as np ++import warp as wp ++from absl.testing import absltest ++from absl.testing import parameterized ++ ++import mujoco_warp as mjwarp ++ ++from . import test_util ++ ++wp.config.verify_cuda = True ++ ++_TOLERANCE = 5e-5 ++ ++ ++def _assert_eq(a, b, name): ++ tol = _TOLERANCE * 10 ++ err_msg = f"mismatch: {name}" ++ np.testing.assert_allclose(a, b, err_msg=err_msg, atol=tol, rtol=tol) ++ ++ ++def _mj_jac(mjm, mjd, point, body): ++ jacp = np.zeros((3, mjm.nv)) ++ jacr = np.zeros((3, mjm.nv)) ++ mujoco.mj_jac(mjm, mjd, jacp, jacr, np.asarray(point, dtype=float), body) ++ return jacp, jacr ++ ++ ++class JacTest(parameterized.TestCase): ++ @parameterized.parameters(2, 5, 9) ++ def test_jac_matches_mujoco(self, body): ++ ++ np.random.seed(0) ++ mjm, mjd, m, d = test_util.fixture("pendula.xml") ++ ++ point = mjd.xpos[body].copy() ++ mj_jacp, mj_jacr = _mj_jac(mjm, mjd, point, body) ++ ++ wp_point = wp.from_numpy( ++ np.expand_dims(point, axis=0).astype(np.float32), dtype=wp.float32 ++ ) ++ jacp, jacr = mjwarp.jac(m, d, wp_point, body) ++ ++ self.assertEqual(jacp.numpy().shape, (1, mjm.nv, 3)) ++ self.assertEqual(jacr.numpy().shape, (1, mjm.nv, 3)) ++ ++ _assert_eq(jacp.numpy()[0], mj_jacp.T, f"jacp (body {body})") ++ _assert_eq(jacr.numpy()[0], mj_jacr.T, f"jacr (body {body})") ++ ++ def test_jac_zero_for_uninvolved_dofs(self): ++ ++ np.random.seed(0) ++ mjm, mjd, m, d = test_util.fixture("pendula.xml") ++ ++ body = 2 ++ point = mjd.xpos[body].copy() ++ wp_point = wp.from_numpy( ++ np.expand_dims(point, axis=0).astype(np.float32), dtype=wp.float32 ++ ) ++ jacp, jacr = mjwarp.jac(m, d, wp_point, body) ++ ++ ++ influences = np.zeros(mjm.nv, dtype=bool) ++ for dof in range(mjm.nv): ++ b = body ++ dof_body = mjm.dof_bodyid[dof] ++ while b != 0: ++ if b == dof_body: ++ influences[dof] = True ++ break ++ b = mjm.body_parentid[b] ++ ++ ++ self.assertTrue(influences.any()) ++ self.assertFalse(influences.all()) ++ ++ jacp_np = jacp.numpy()[0] ++ jacr_np = jacr.numpy()[0] ++ for dof in range(mjm.nv): ++ if not influences[dof]: ++ _assert_eq(jacp_np[dof], np.zeros(3), f"jacp dof {dof}") ++ _assert_eq(jacr_np[dof], np.zeros(3), f"jacr dof {dof}") ++ ++ def test_jac_world_body_is_zero(self): ++ ++ np.random.seed(0) ++ mjm, mjd, m, d = test_util.fixture("pendula.xml") ++ ++ point = np.array([0.1, 0.2, 0.3]) ++ wp_point = wp.from_numpy( ++ np.expand_dims(point, axis=0).astype(np.float32), dtype=wp.float32 ++ ) ++ jacp, jacr = mjwarp.jac(m, d, wp_point, 0) ++ ++ _assert_eq(jacp.numpy()[0], np.zeros((mjm.nv, 3)), "jacp world") ++ _assert_eq(jacr.numpy()[0], np.zeros((mjm.nv, 3)), "jacr world") ++ ++ def test_jac_batched(self): ++ ++ np.random.seed(0) ++ mjm = mujoco.MjModel.from_xml_path( ++ (test_util.epath.resource_path("mujoco_warp") / "test_data" / "pendula.xml").as_posix() ++ ) ++ mjm.opt.jacobian = True ++ mjd0 = mujoco.MjData(mjm) ++ mjd0.qvel = np.random.uniform(-0.01, 0.01, mjm.nv) ++ mujoco.mj_step(mjm, mjd0, 3) ++ mujoco.mj_forward(mjm, mjd0) ++ ++ mjd1 = mujoco.MjData(mjm) ++ mjd1.qvel = np.random.uniform(-0.01, 0.01, mjm.nv) ++ mujoco.mj_step(mjm, mjd1, 7) ++ mujoco.mj_forward(mjm, mjd1) ++ ++ body = 5 ++ m = mjwarp.put_model(mjm) ++ ++ d = mjwarp.put_data(mjm, mjd0, nworld=2) ++ qpos = np.stack([mjd0.qpos, mjd1.qpos]).astype(np.float32) ++ qvel = np.stack([mjd0.qvel, mjd1.qvel]).astype(np.float32) ++ d.qpos = wp.from_numpy(qpos, dtype=wp.float32) ++ d.qvel = wp.from_numpy(qvel, dtype=wp.float32) ++ mjwarp.kinematics(m, d) ++ mjwarp.com_pos(m, d) ++ mjwarp.com_vel(m, d) ++ ++ point0 = mjd0.xpos[body].copy() ++ point1 = mjd1.xpos[body].copy() ++ wp_point = wp.from_numpy( ++ np.stack([point0, point1]).astype(np.float32), dtype=wp.float32 ++ ) ++ jacp, jacr = mjwarp.jac(m, d, wp_point, body) ++ self.assertEqual(jacp.numpy().shape, (2, mjm.nv, 3)) ++ ++ mj0_p, mj0_r = _mj_jac(mjm, mjd0, point0, body) ++ mj1_p, mj1_r = _mj_jac(mjm, mjd1, point1, body) ++ ++ _assert_eq(jacp.numpy()[0], mj0_p.T, "jacp world 0") ++ _assert_eq(jacr.numpy()[0], mj0_r.T, "jacr world 0") ++ _assert_eq(jacp.numpy()[1], mj1_p.T, "jacp world 1") ++ _assert_eq(jacr.numpy()[1], mj1_r.T, "jacr world 1") ++ ++ ++if __name__ == "__main__": ++ wp.init() ++ absltest.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,21 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++PYTEST="/testbed/.venv/bin/python -m pytest" ++ ++ ++$PYTEST mujoco_warp/_src/support_test.py -q ++ ++ ++$PYTEST mujoco_warp/_src/jac_test.py -q diff --git a/tasks/format-code-task-001332/tests/test.sh b/tasks/format-code-task-001332/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b2214577dda4d4c30c977c802d2aa570080aa38c --- /dev/null +++ b/tasks/format-code-task-001332/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' +mujoco_warp/_src/jac_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-001332/tests/test_command.sh b/tasks/format-code-task-001332/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001332/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001335/environment/Dockerfile b/tasks/format-code-task-001335/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ffdb94c407e00520112a94a15f64e012409c6ae8 --- /dev/null +++ b/tasks/format-code-task-001335/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a6a0d1c2f8d4b787b1a67cf71251ad076190ebea5cf65a51e76e41935276ae41 diff --git a/tasks/format-code-task-001335/environment/setup/files/blocklist b/tasks/format-code-task-001335/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001335/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001335/environment/setup/setup.sh b/tasks/format-code-task-001335/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001335/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001335/tests/test.patch b/tasks/format-code-task-001335/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..56461fb518f99d7bfd83b2dfd1d5786315451638 --- /dev/null +++ b/tasks/format-code-task-001335/tests/test.patch @@ -0,0 +1,218 @@ +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,193 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++PYTHON=${PYTHON:-/usr/local/bin/python} ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++ ++ ++ ++( cd /workspace/repo && "$PYTHON" -m pip install --no-index --no-deps --disable-pip-version-check --no-build-isolation -e . >/tmp/arxiv_latex_cleaner_fixture_pip.log 2>&1 ) \ ++ || { echo "FAIL: build; see /tmp/arxiv_latex_cleaner_fixture_pip.log" >&2; exit 1; } ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" ++ ++fail() { ++ echo "FAIL: $*" >&2 ++ exit 1 ++} ++ ++run_cleaner() { ++ "$PYTHON" -m arxiv_latex_cleaner "$@" ++} ++ ++make_minimal_project() { ++ local project=$1 ++ mkdir -p "$project" ++ cat > "$project/main.tex" <<'EOF' ++\begin{document} ++\x{a} ++\end{document} ++EOF ++} ++ ++ ++ ++ ++project="$TMP/paper" ++mkdir -p "$project/figures" "$project/sections" ++printf 'PANEL-A-DATA\n' > "$project/figures/panel-a.pdf" ++printf 'PANEL-B-DATA\n' > "$project/figures/panel-b.pdf" ++printf 'PANEL-TIKZ-DATA\n' > "$project/figures/panel-tikz.pdf" ++printf 'UNUSED-DATA\n' > "$project/figures/unused.pdf" ++cat > "$project/main.tex" <<'EOF' ++\documentclass{article} ++\begin{document} ++Before. ++\figcomp{panel-a}{.45}{.8} ++\figcomp{panel-b}{ .50 }{ .70 } ++\input{sections/detail.tikz} ++\macrokeep{Alpha}{Beta} ++\nomatch{left alone} ++\end{document} ++EOF ++cat > "$project/sections/detail.tikz" <<'EOF' ++Tikz retained file start. ++\figcomp{panel-tikz}{.25}{.6} ++Tikz retained file end. ++EOF ++cat > "$TMP/valid_config.yaml" <<'EOF' ++patterns_and_insertions: ++ - pattern: '(?:\\figcomp{\s*)(?P.*?)\s*}\s*{\s*(?P.*?)\s*}\s*{\s*(?P.*?)\s*}' ++ insertion: '\parbox[c]{{ {box} \linewidth}}{{\includegraphics[width={width}\linewidth]{{figures/{path}}}}}' ++ description: Replace figcomp ++ - pattern: '(?:\\macrokeep{(?P.*?)}{(?P.*?)})' ++ insertion: "Start {first}\n Middle {second} End" ++ description: Preserve macro whitespace ++ strip_whitespace: false ++ - pattern: '(?:\\unusedmacro{(?P.*?)})' ++ insertion: 'UNUSED {value}' ++ description: No matching macro ++EOF ++run_cleaner "$project" --config "$TMP/valid_config.yaml" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++ ++[ -d "${project}_arXiv" ] || fail "F1 missing output directory" ++ ++ ++ ++ ++"$PYTHON" - "${project}_arXiv/main.tex" "${project}_arXiv/sections/detail.tikz" <<'PY' \ ++ || fail "F1 transformed TeX/TikZ content did not satisfy spec-level checks" ++import pathlib ++import sys ++ ++main = pathlib.Path(sys.argv[1]).read_text() ++detail = pathlib.Path(sys.argv[2]).read_text() ++ ++required_main = [ ++ r"\parbox[c]{.45\linewidth}{\includegraphics[width=.8\linewidth]{figures/panel-a}}", ++ r"\parbox[c]{.50\linewidth}{\includegraphics[width=.70\linewidth]{figures/panel-b}}", ++ r"\input{sections/detail.tikz}", ++ "Start Alpha\n Middle Beta End", ++ r"\nomatch{left alone}", ++] ++for needle in required_main: ++ assert needle in main, needle ++ ++for needle in [ ++ r"\figcomp{panel-a}{.45}{.8}", ++ r"\figcomp{panel-b}{ .50 }{ .70 }", ++ r"\macrokeep{Alpha}{Beta}", ++ "UNUSED", ++]: ++ assert needle not in main, needle ++ ++required_detail = [ ++ "Tikz retained file start.", ++ r"\parbox[c]{.25\linewidth}{\includegraphics[width=.6\linewidth]{figures/panel-tikz}}", ++ "Tikz retained file end.", ++] ++for needle in required_detail: ++ assert needle in detail, needle ++ ++assert r"\figcomp{panel-tikz}{.25}{.6}" not in detail ++PY ++[ -f "${project}_arXiv/figures/panel-a.pdf" ] || fail "F1 missing generated reference panel-a.pdf" ++[ -f "${project}_arXiv/figures/panel-b.pdf" ] || fail "F1 missing generated reference panel-b.pdf" ++[ -f "${project}_arXiv/figures/panel-tikz.pdf" ] || fail "F1 missing generated reference panel-tikz.pdf" ++[ ! -e "${project}_arXiv/figures/unused.pdf" ] || fail "F1 copied unreferenced unused.pdf" ++[ "$(sha256sum "${project}_arXiv/figures/panel-a.pdf" | awk '{print $1}')" = "d2533f624aed3fa58264453c40894982affa68b7346c983ea71b7b332db4b843" ] \ ++ || fail "F1 panel-a.pdf hash mismatch" ++[ "$(sha256sum "${project}_arXiv/figures/panel-b.pdf" | awk '{print $1}')" = "e70973c1f7d08c83820a5d7cc06230f9352c4a10b342f50f8ad627ff9693b337" ] \ ++ || fail "F1 panel-b.pdf hash mismatch" ++[ "$(sha256sum "${project}_arXiv/figures/panel-tikz.pdf" | awk '{print $1}')" = "599fbbfd827e55db635686b7de1e2a5f2b73a7fc0c6cfe096c0714344f5f6ff6" ] \ ++ || fail "F1 panel-tikz.pdf hash mismatch" ++ ++ ++ ++ ++bad_project="$TMP/missing_pattern_paper" ++make_minimal_project "$bad_project" ++cat > "$TMP/missing_pattern.yaml" <<'EOF' ++patterns_and_insertions: ++ - insertion: 'Y' ++ description: Missing pattern ++EOF ++run_cleaner "$bad_project" --config "$TMP/missing_pattern.yaml" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F2 wanted non-zero exit" ++ ++ ++ ++ ++ ++ ++bad_project="$TMP/missing_insertion_paper" ++make_minimal_project "$bad_project" ++cat > "$TMP/missing_insertion.yaml" <<'EOF' ++patterns_and_insertions: ++ - pattern: '(?:\\x{(?P.*?)})' ++ description: Missing insertion ++EOF ++run_cleaner "$bad_project" --config "$TMP/missing_insertion.yaml" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F3 wanted non-zero exit" ++ ++ ++ ++ ++ ++ ++bad_project="$TMP/missing_description_paper" ++make_minimal_project "$bad_project" ++cat > "$TMP/missing_description.yaml" <<'EOF' ++patterns_and_insertions: ++ - pattern: '(?:\\x{(?P.*?)})' ++ insertion: 'Y' ++EOF ++run_cleaner "$bad_project" --config "$TMP/missing_description.yaml" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F4 wanted non-zero exit" ++ ++ ++ ++ ++ ++ ++bad_project="$TMP/bad_regex_paper" ++make_minimal_project "$bad_project" ++cat > "$TMP/bad_regex.yaml" <<'EOF' ++patterns_and_insertions: ++ - pattern: '([unclosed' ++ insertion: 'Y' ++ description: Bad regex ++EOF ++run_cleaner "$bad_project" --config "$TMP/bad_regex.yaml" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F5 wanted non-zero exit" ++ ++ ++ ++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 PYTHON="${PYTHON:-/usr/local/bin/python}" ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-001335/tests/test.sh b/tasks/format-code-task-001335/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-001335/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-001335/tests/test_command.sh b/tasks/format-code-task-001335/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001335/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-001358/environment/Dockerfile b/tasks/format-code-task-001358/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0174425d24bf033d77a5fdd466d4babcefc38de3 --- /dev/null +++ b/tasks/format-code-task-001358/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c8399b717de301cded00fae99283df90512ced42b0bb175e951eb01b393d1288 diff --git a/tasks/format-code-task-001358/environment/setup/files/blocklist b/tasks/format-code-task-001358/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001358/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001358/environment/setup/setup.sh b/tasks/format-code-task-001358/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001358/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001358/tests/test.patch b/tasks/format-code-task-001358/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f81d14992a43b746ebf78479c8381f06a5792e5c --- /dev/null +++ b/tasks/format-code-task-001358/tests/test.patch @@ -0,0 +1,421 @@ +diff --git a/usercase-test-coderl/dgram_logstream_test.go b/usercase-test-coderl/dgram_logstream_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/dgram_logstream_test.go +@@ -0,0 +1,388 @@ ++//go:build unix ++ ++package usercase_test_coderl ++ ++import ( ++ "context" ++ "errors" ++ "net" ++ "os" ++ "path/filepath" ++ "runtime" ++ "sync" ++ "testing" ++ "time" ++ ++ "github.com/google/mtail/internal/tailer/logstream" ++) ++ ++ ++ ++ ++ ++ ++const receiveTimeout = 2 * time.Second ++ ++ ++ ++const cleanupStressCycles = 25 ++const cleanupFDSlack = 12 ++const cleanupGoroutineSlack = 16 ++ ++type alwaysWaker struct{} ++ ++func (alwaysWaker) Wake() <-chan struct{} { ++ ch := make(chan struct{}) ++ close(ch) ++ return ch ++} ++ ++func TestUDPDatagramStreamEmitsReceivedLines(t *testing.T) { ++ ++ ++ var wg sync.WaitGroup ++ ctx, cancel := context.WithCancel(context.Background()) ++ defer cancel() ++ ++ addr := freeUDPAddr(t) ++ pathname := "udp://" + addr ++ stream, err := logstream.New(ctx, &wg, alwaysWaker{}, pathname, logstream.OneShotDisabled) ++ if err != nil { ++ t.Fatalf("New(%q) error = %v, want nil", pathname, err) ++ } ++ defer finishStream(t, cancel, &wg, stream.Lines()) ++ ++ sendDatagram(t, "udp", addr, []byte("alpha\n")) ++ first := receiveLine(t, stream.Lines()) ++ if first.Filename != pathname { ++ t.Fatalf("first Filename = %q, want %q", first.Filename, pathname) ++ } ++ if first.Line != "alpha" { ++ t.Fatalf("first Line = %q, want %q", first.Line, "alpha") ++ } ++ ++ sendDatagram(t, "udp", addr, []byte("beta\n")) ++ second := receiveLine(t, stream.Lines()) ++ if second.Filename != pathname { ++ t.Fatalf("second Filename = %q, want %q", second.Filename, pathname) ++ } ++ if second.Line != "beta" { ++ t.Fatalf("second Line = %q, want %q", second.Line, "beta") ++ } ++} ++ ++func TestUnixgramDatagramStreamEmitsReceivedLine(t *testing.T) { ++ ++ ++ var wg sync.WaitGroup ++ ctx, cancel := context.WithCancel(context.Background()) ++ defer cancel() ++ ++ addr := filepath.Join(t.TempDir(), "mtail.sock") ++ pathname := "unixgram://" + addr ++ stream, err := logstream.New(ctx, &wg, alwaysWaker{}, pathname, logstream.OneShotDisabled) ++ if err != nil { ++ t.Fatalf("New(%q) error = %v, want nil", pathname, err) ++ } ++ defer finishStream(t, cancel, &wg, stream.Lines()) ++ ++ sendDatagram(t, "unixgram", addr, []byte("alpha\n")) ++ line := receiveLine(t, stream.Lines()) ++ if line.Filename != pathname { ++ t.Fatalf("Filename = %q, want %q", line.Filename, pathname) ++ } ++ if line.Line != "alpha" { ++ t.Fatalf("Line = %q, want %q", line.Line, "alpha") ++ } ++} ++ ++func TestDatagramStreamEmptyAddressReturnsSpecificError(t *testing.T) { ++ ++ ++ for _, pathname := range []string{"udp://", "unixgram://"} { ++ var wg sync.WaitGroup ++ stream, err := logstream.New(context.Background(), &wg, alwaysWaker{}, pathname, logstream.OneShotDisabled) ++ if stream != nil { ++ t.Fatalf("New(%q) stream = %#v, want nil", pathname, stream) ++ } ++ if !errors.Is(err, logstream.ErrEmptySocketAddress) { ++ t.Fatalf("New(%q) error = %v, want ErrEmptySocketAddress", pathname, err) ++ } ++ } ++} ++ ++func TestCancelFlushesPartialLineAndClosesChannel(t *testing.T) { ++ ++ ++ var wg sync.WaitGroup ++ ctx, cancel := context.WithCancel(context.Background()) ++ ++ addr := freeUDPAddr(t) ++ pathname := "udp://" + addr ++ stream, err := logstream.New(ctx, &wg, alwaysWaker{}, pathname, logstream.OneShotDisabled) ++ if err != nil { ++ t.Fatalf("New(%q) error = %v, want nil", pathname, err) ++ } ++ ++ sendDatagram(t, "udp", addr, []byte("partial")) ++ time.Sleep(25 * time.Millisecond) ++ cancel() ++ ++ line := receiveLine(t, stream.Lines()) ++ if line.Filename != pathname { ++ t.Fatalf("Filename = %q, want %q", line.Filename, pathname) ++ } ++ if line.Line != "partial" { ++ t.Fatalf("Line = %q, want %q", line.Line, "partial") ++ } ++ waitForWaitGroup(t, &wg) ++ assertClosed(t, stream.Lines()) ++} ++ ++func TestOneShotZeroLengthDatagramEndsStreamAfterPriorLines(t *testing.T) { ++ ++ ++ var wg sync.WaitGroup ++ ctx, cancel := context.WithCancel(context.Background()) ++ defer cancel() ++ ++ addr := freeUDPAddr(t) ++ pathname := "udp://" + addr ++ stream, err := logstream.New(ctx, &wg, alwaysWaker{}, pathname, logstream.OneShotEnabled) ++ if err != nil { ++ t.Fatalf("New(%q) error = %v, want nil", pathname, err) ++ } ++ ++ sendDatagram(t, "udp", addr, []byte("before-zero\n")) ++ line := receiveLine(t, stream.Lines()) ++ if line.Filename != pathname { ++ t.Fatalf("Filename = %q, want %q", line.Filename, pathname) ++ } ++ if line.Line != "before-zero" { ++ t.Fatalf("Line = %q, want %q", line.Line, "before-zero") ++ } ++ ++ sendDatagram(t, "udp", addr, []byte{}) ++ waitForWaitGroup(t, &wg) ++ assertClosed(t, stream.Lines()) ++} ++ ++func TestCancelCanBeCalledTwiceAfterDatagramStreamCleanup(t *testing.T) { ++ ++ ++ var wg sync.WaitGroup ++ ctx, cancel := context.WithCancel(context.Background()) ++ ++ addr := freeUDPAddr(t) ++ stream, err := logstream.New(ctx, &wg, alwaysWaker{}, "udp://"+addr, logstream.OneShotDisabled) ++ if err != nil { ++ t.Fatalf("New udp stream error = %v, want nil", err) ++ } ++ ++ cancel() ++ cancel() ++ waitForWaitGroup(t, &wg) ++ assertClosed(t, stream.Lines()) ++} ++ ++func TestDatagramStreamsKeepIndependentState(t *testing.T) { ++ ++ ++ var wgA sync.WaitGroup ++ ctxA, cancelA := context.WithCancel(context.Background()) ++ addrA := freeUDPAddr(t) ++ pathA := "udp://" + addrA ++ streamA, err := logstream.New(ctxA, &wgA, alwaysWaker{}, pathA, logstream.OneShotDisabled) ++ if err != nil { ++ t.Fatalf("New(%q) error = %v, want nil", pathA, err) ++ } ++ defer finishStream(t, cancelA, &wgA, streamA.Lines()) ++ ++ var wgB sync.WaitGroup ++ ctxB, cancelB := context.WithCancel(context.Background()) ++ addrB := freeUDPAddr(t) ++ pathB := "udp://" + addrB ++ streamB, err := logstream.New(ctxB, &wgB, alwaysWaker{}, pathB, logstream.OneShotDisabled) ++ if err != nil { ++ t.Fatalf("New(%q) error = %v, want nil", pathB, err) ++ } ++ defer finishStream(t, cancelB, &wgB, streamB.Lines()) ++ ++ sendDatagram(t, "udp", addrA, []byte("alpha\n")) ++ lineA := receiveLine(t, streamA.Lines()) ++ if lineA.Filename != pathA { ++ t.Fatalf("streamA Filename = %q, want %q", lineA.Filename, pathA) ++ } ++ if lineA.Line != "alpha" { ++ t.Fatalf("streamA Line = %q, want %q", lineA.Line, "alpha") ++ } ++ assertNoLine(t, streamB.Lines(), 50*time.Millisecond) ++ ++ sendDatagram(t, "udp", addrB, []byte("bravo\n")) ++ lineB := receiveLine(t, streamB.Lines()) ++ if lineB.Filename != pathB { ++ t.Fatalf("streamB Filename = %q, want %q", lineB.Filename, pathB) ++ } ++ if lineB.Line != "bravo" { ++ t.Fatalf("streamB Line = %q, want %q", lineB.Line, "bravo") ++ } ++} ++ ++func TestDatagramStreamRepeatedCreateUseCancelDoesNotLeakResources(t *testing.T) { ++ ++ ++ runtime.GC() ++ startFDs := countFDs(t) ++ startGoroutines := runtime.NumGoroutine() ++ ++ for i := 0; i < cleanupStressCycles; i++ { ++ var wg sync.WaitGroup ++ ctx, cancel := context.WithCancel(context.Background()) ++ addr := freeUDPAddr(t) ++ pathname := "udp://" + addr ++ stream, err := logstream.New(ctx, &wg, alwaysWaker{}, pathname, logstream.OneShotDisabled) ++ if err != nil { ++ t.Fatalf("cycle %d New(%q) error = %v, want nil", i, pathname, err) ++ } ++ ++ sendDatagram(t, "udp", addr, []byte("cycle\n")) ++ line := receiveLine(t, stream.Lines()) ++ if line.Filename != pathname { ++ t.Fatalf("cycle %d Filename = %q, want %q", i, line.Filename, pathname) ++ } ++ if line.Line != "cycle" { ++ t.Fatalf("cycle %d Line = %q, want %q", i, line.Line, "cycle") ++ } ++ ++ cancel() ++ waitForWaitGroup(t, &wg) ++ assertClosed(t, stream.Lines()) ++ } ++ ++ runtime.GC() ++ time.Sleep(50 * time.Millisecond) ++ endFDs := countFDs(t) ++ endGoroutines := runtime.NumGoroutine() ++ ++ if endFDs > startFDs+cleanupFDSlack { ++ t.Fatalf("fd count after cleanup = %d, want at most %d", endFDs, startFDs+cleanupFDSlack) ++ } ++ if endGoroutines > startGoroutines+cleanupGoroutineSlack { ++ t.Fatalf("goroutines after cleanup = %d, want at most %d", endGoroutines, startGoroutines+cleanupGoroutineSlack) ++ } ++} ++ ++func freeUDPAddr(t *testing.T) string { ++ t.Helper() ++ conn, err := net.ListenPacket("udp", "127.0.0.1:0") ++ if err != nil { ++ t.Fatalf("ListenPacket udp 127.0.0.1:0 error = %v", err) ++ } ++ addr := conn.LocalAddr().String() ++ if err := conn.Close(); err != nil { ++ t.Fatalf("closing free-port probe error = %v", err) ++ } ++ return addr ++} ++ ++func sendDatagram(t *testing.T, network, address string, payload []byte) { ++ t.Helper() ++ conn, err := net.Dial(network, address) ++ if err != nil { ++ t.Fatalf("Dial(%q, %q) error = %v", network, address, err) ++ } ++ defer conn.Close() ++ if _, err := conn.Write(payload); err != nil { ++ t.Fatalf("Write(%q, %q, %q) error = %v", network, address, string(payload), err) ++ } ++} ++ ++func receiveLine[T any](t *testing.T, lines <-chan T) T { ++ t.Helper() ++ timer := time.NewTimer(receiveTimeout) ++ defer timer.Stop() ++ select { ++ case line, ok := <-lines: ++ if !ok { ++ t.Fatalf("Lines channel closed before receiving expected line") ++ } ++ return line ++ case <-timer.C: ++ t.Fatalf("timed out waiting for LogLine") ++ } ++ var zero T ++ return zero ++} ++ ++func assertNoLine[T any](t *testing.T, lines <-chan T, d time.Duration) { ++ t.Helper() ++ timer := time.NewTimer(d) ++ defer timer.Stop() ++ select { ++ case line, ok := <-lines: ++ t.Fatalf("unexpected line from independent stream: ok=%v line=%#v", ok, line) ++ case <-timer.C: ++ } ++} ++ ++func assertClosed[T any](t *testing.T, lines <-chan T) { ++ t.Helper() ++ timer := time.NewTimer(receiveTimeout) ++ defer timer.Stop() ++ select { ++ case line, ok := <-lines: ++ if ok { ++ t.Fatalf("Lines channel yielded %#v, want closed channel", line) ++ } ++ case <-timer.C: ++ t.Fatalf("timed out waiting for Lines channel to close") ++ } ++} ++ ++func waitForWaitGroup(t *testing.T, wg *sync.WaitGroup) { ++ t.Helper() ++ done := make(chan struct{}) ++ go func() { ++ wg.Wait() ++ close(done) ++ }() ++ timer := time.NewTimer(receiveTimeout) ++ defer timer.Stop() ++ select { ++ case <-done: ++ case <-timer.C: ++ t.Fatalf("timed out waiting for stream wait group") ++ } ++} ++ ++func finishStream[T any](t *testing.T, cancel context.CancelFunc, wg *sync.WaitGroup, lines <-chan T) { ++ t.Helper() ++ cancel() ++ waitForWaitGroup(t, wg) ++ drainUntilClosed(t, lines) ++} ++ ++func drainUntilClosed[T any](t *testing.T, lines <-chan T) { ++ t.Helper() ++ timer := time.NewTimer(receiveTimeout) ++ defer timer.Stop() ++ for { ++ select { ++ case _, ok := <-lines: ++ if !ok { ++ return ++ } ++ case <-timer.C: ++ t.Fatalf("timed out draining Lines channel") ++ } ++ } ++} ++ ++func countFDs(t *testing.T) int { ++ t.Helper() ++ entries, err := os.ReadDir("/proc/self/fd") ++ if err != nil { ++ t.Fatalf("ReadDir(/proc/self/fd) error = %v", err) ++ } ++ return len(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,23 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++ ++ ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++export GOVCS='*:off' ++ ++exec go test -v -count=1 -mod=readonly ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001358/tests/test.sh b/tasks/format-code-task-001358/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..471ecf4b3f3141957364f5567a2496a8bc2bce91 --- /dev/null +++ b/tasks/format-code-task-001358/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/dgram_logstream_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-001358/tests/test_command.sh b/tasks/format-code-task-001358/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001358/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-001360/environment/Dockerfile b/tasks/format-code-task-001360/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c6ddda7acbe6e04a2b6db8182290e68ee33cb97b --- /dev/null +++ b/tasks/format-code-task-001360/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6e43c3a534f9469094a480a8ae88b03398a34f9e8668103a25a7a4fcadd6883e diff --git a/tasks/format-code-task-001360/environment/setup/files/blocklist b/tasks/format-code-task-001360/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001360/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001360/environment/setup/setup.sh b/tasks/format-code-task-001360/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001360/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001360/tests/test.patch b/tasks/format-code-task-001360/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..34ec01ade6895f907059330fe4d1c039fc77668e --- /dev/null +++ b/tasks/format-code-task-001360/tests/test.patch @@ -0,0 +1,253 @@ +diff --git a/usercase-test-coderl/test_custom_parse_decorators.py b/usercase-test-coderl/test_custom_parse_decorators.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_custom_parse_decorators.py +@@ -0,0 +1,226 @@ ++ ++ ++ ++ ++ ++ ++ ++import copy ++import contextlib ++import io ++import json ++import socket ++import subprocess ++import sys ++import textwrap ++ ++import pytest ++ ++import fire ++from fire import decorators ++ ++ ++class NamedCountComponent: ++ ++ @decorators.SetParseFns(count=int) ++ def double(self, count): ++ return 2 * count ++ ++ ++class MixedParserComponent: ++ ++ @decorators.SetParseFns(float, arg2=str) ++ def example(self, arg1, arg2): ++ return arg1, arg2 ++ ++ ++class DefaultParserComponent: ++ ++ @decorators.SetParseFn(str) ++ def example(self, arg1, arg2=None, *varargs, **kwargs): ++ return arg1, arg2, varargs, kwargs ++ ++ ++class NamedOnlyComponent: ++ ++ @decorators.SetParseFn(str, 'mode') ++ def choose(self, count, mode='0', enabled=True, payload=None): ++ return count, mode, enabled, payload ++ ++ ++class PrecedenceComponent: ++ ++ @decorators.SetParseFn(str) ++ @decorators.SetParseFns( ++ lambda value: 'pos:' + value, ++ arg1=lambda value: 'named:' + value, ++ arg2=lambda value: 'arg2:' + value) ++ def values(self, arg1, arg2, arg3): ++ return arg1, arg2, arg3 ++ ++ ++class DirectCallComponent: ++ ++ @decorators.SetParseFns(int) ++ def echo(self, value): ++ return value, type(value).__name__ ++ ++ ++class ErrorComponent: ++ ++ @decorators.SetParseFns(count=int) ++ def double(self, count): ++ return 2 * count ++ ++ ++def _stable_json(value): ++ return json.dumps(value, sort_keys=True, separators=(',', ':')) ++ ++ ++def test_set_parse_fns_named_parser_is_used_for_matching_parameter(): ++ ++ ++ ++ actual = fire.Fire(NamedCountComponent, command=['double', '2']) ++ ++ assert actual == 4 ++ ++ ++def test_set_parse_fns_positional_parser_wins_over_named_parser(): ++ ++ ++ ++ actual = fire.Fire(MixedParserComponent, command=['example', '10', '10']) ++ ++ assert actual == (10.0, '10') ++ ++ ++def test_set_parse_fn_default_parser_applies_to_args_varargs_and_kwargs(): ++ ++ ++ ++ actual = fire.Fire( ++ DefaultParserComponent, ++ command=['example', '1', '--arg2=2', '3', '4', '--kwarg=5']) ++ ++ assert actual == ('1', '2', ('3', '4'), {'kwarg': '5'}) ++ ++ ++def test_set_parse_fn_named_argument_does_not_override_normal_parsing_elsewhere(): ++ ++ ++ ++ actual = fire.Fire( ++ NamedOnlyComponent, ++ command=[ ++ 'choose', '7', '--mode=08', '--enabled=False', ++ '--payload={a: [1, 2]}' ++ ]) ++ ++ assert actual == (7, '08', False, {'a': [1, 2]}) ++ ++ ++def test_parser_selection_order_positional_named_default_normal(): ++ ++ ++ ++ actual = fire.Fire(PrecedenceComponent, command=['values', 'x', '2', '3']) ++ ++ assert actual == ('pos:x', 'arg2:2', '3') ++ ++ ++def test_direct_python_call_is_not_reparsed_by_decorator_metadata(): ++ ++ ++ ++ actual = DirectCallComponent().echo('9') ++ ++ assert actual == ('9', 'str') ++ ++ ++def test_selected_parser_exception_propagates_without_fallback(): ++ ++ ++ ++ with pytest.raises(ValueError) as exc_info: ++ fire.Fire(ErrorComponent, command=['double', 'bad']) ++ ++ ++ assert exc_info.type is ValueError ++ ++ ++def test_referential_transparency_for_same_command(): ++ command = ['choose', '7', '--mode=08', '--enabled=False', ++ '--payload={a: [1, 2]}'] ++ ++ assert fire.Fire(NamedOnlyComponent, command=command) == fire.Fire( ++ NamedOnlyComponent, command=command) ++ ++ ++def test_fire_does_not_mutate_caller_command_tokens(): ++ command = ['example', '1', '--arg2=2', '3', '4', '--kwarg=5'] ++ before = copy.deepcopy(command) ++ ++ actual = fire.Fire(DefaultParserComponent, command=command) ++ ++ assert actual == ('1', '2', ('3', '4'), {'kwarg': '5'}) ++ assert command == before ++ ++ ++def test_no_global_state_cache_across_fresh_python_process(tmp_path): ++ command = ['values', 'x', '2', '3'] ++ with contextlib.redirect_stdout(io.StringIO()): ++ in_process = fire.Fire(PrecedenceComponent, command=command) ++ script = textwrap.dedent(""" ++ import contextlib ++ import io ++ import json ++ import sys ++ sys.path.insert(0, '/workspace/repo') ++ import fire ++ from fire import decorators ++ ++ class PrecedenceComponent: ++ @decorators.SetParseFn(str) ++ @decorators.SetParseFns( ++ lambda value: 'pos:' + value, ++ arg1=lambda value: 'named:' + value, ++ arg2=lambda value: 'arg2:' + value) ++ def values(self, arg1, arg2, arg3): ++ return arg1, arg2, arg3 ++ ++ with contextlib.redirect_stdout(io.StringIO()): ++ result = fire.Fire(PrecedenceComponent, command=['values', 'x', '2', '3']) ++ sys.stdout.write(json.dumps(result, sort_keys=True, separators=(',', ':'))) ++ """) ++ script_path = tmp_path / 'fresh_process_check.py' ++ script_path.write_text(script, encoding='utf-8') ++ ++ completed = subprocess.run( ++ [sys.executable, str(script_path)], ++ check=True, ++ cwd='/workspace/repo', ++ text=True, ++ stdout=subprocess.PIPE, ++ stderr=subprocess.PIPE) ++ ++ assert _stable_json(in_process) == '["pos:x","arg2:2","3"]' ++ assert completed.stdout == '["pos:x","arg2:2","3"]' ++ ++ ++def test_no_undeclared_relative_file_writes_or_network(tmp_path, monkeypatch): ++ def forbidden_socket(*args, **kwargs): ++ raise AssertionError('network access is not declared for parse decorators') ++ ++ monkeypatch.chdir(tmp_path) ++ monkeypatch.setattr(socket, 'socket', forbidden_socket) ++ before = sorted(path.relative_to(tmp_path).as_posix() ++ for path in tmp_path.rglob('*')) ++ ++ actual = fire.Fire(MixedParserComponent, command=['example', '10', '10']) ++ ++ after = sorted(path.relative_to(tmp_path).as_posix() ++ for path in tmp_path.rglob('*')) ++ assert actual == (10.0, '10') ++ 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,17 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PYTEST_ADDOPTS= ++exec /usr/bin/python -m pytest /workspace/repo/usercase-test-coderl/test_custom_parse_decorators.py -v diff --git a/tasks/format-code-task-001360/tests/test.sh b/tasks/format-code-task-001360/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..63ee9048ee8ed717f5718df5e876b8c99fcc19c0 --- /dev/null +++ b/tasks/format-code-task-001360/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_custom_parse_decorators.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-001360/tests/test_command.sh b/tasks/format-code-task-001360/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001360/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-001361/environment/Dockerfile b/tasks/format-code-task-001361/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6a83783183e2584d2ef4728f4674a23142696a7a --- /dev/null +++ b/tasks/format-code-task-001361/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c4f7769cbb2f1de24c658d63f28944fc5dbe1ee3b1b525bb13aa29d23ac2dee3 diff --git a/tasks/format-code-task-001361/environment/setup/files/blocklist b/tasks/format-code-task-001361/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001361/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001361/environment/setup/setup.sh b/tasks/format-code-task-001361/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001361/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001361/tests/test.patch b/tasks/format-code-task-001361/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..59a92680ce0884c1289cb9f7f3ea0694bed3c34f --- /dev/null +++ b/tasks/format-code-task-001361/tests/test.patch @@ -0,0 +1,338 @@ +diff --git a/usercase-test-coderl/notifier_rate_limit_test.go b/usercase-test-coderl/notifier_rate_limit_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/notifier_rate_limit_test.go +@@ -0,0 +1,301 @@ ++package usercase_test_coderl ++ ++import ( ++ "fmt" ++ "os" ++ "path/filepath" ++ "reflect" ++ "sort" ++ "strings" ++ "testing" ++ "time" ++ ++ "github.com/google/seesaw/engine/config" ++) ++ ++func TestNotifierInitialNotificationLimitsLargeStartupBurst(t *testing.T) { ++ ++ ++ dir := t.TempDir() ++ clusterFile := filepath.Join(dir, "cluster.pb") ++ writeClusterFile(t, clusterFile, names(1, 14), 1000) ++ ++ n := newNotifier(t, clusterFile, "initial-limit") ++ defer n.Shutdown() ++ ++ note := receiveNotification(t, n.C) ++ assertVserverCount(t, note, 10) ++ ++ assertOnlyVserversFrom(t, note, names(1, 14)) ++} ++ ++func TestNotifierReloadKeepsUnchangedAndLimitsLargeAdditions(t *testing.T) { ++ ++ ++ dir := t.TempDir() ++ clusterFile := filepath.Join(dir, "cluster.pb") ++ writeClusterFile(t, clusterFile, names(1, 3), 1000) ++ ++ n := newNotifier(t, clusterFile, "reload-add") ++ defer n.Shutdown() ++ ++ initial := receiveNotification(t, n.C) ++ assertVserverNames(t, initial, []string{"vs-01", "vs-02", "vs-03"}) ++ ++ writeClusterFile(t, clusterFile, names(1, 14), 2000) ++ n.SetSource(config.SourceDisk) ++ reload := receiveNotification(t, n.C) ++ ++ assertVserverCount(t, reload, 13) ++ assertHasVservers(t, reload, []string{"vs-01", "vs-02", "vs-03"}) ++ ++ assertOnlyVserversFrom(t, reload, names(1, 14)) ++} ++ ++func TestNotifierReloadDeletionLimitTakesPriorityOverAdditions(t *testing.T) { ++ ++ ++ dir := t.TempDir() ++ clusterFile := filepath.Join(dir, "cluster.pb") ++ writeClusterFile(t, clusterFile, names(1, 1), 1000) ++ ++ n := newNotifier(t, clusterFile, "reload-delete-priority") ++ defer n.Shutdown() ++ ++ initial := receiveNotification(t, n.C) ++ assertVserverNames(t, initial, []string{"vs-01"}) ++ ++ writeClusterFile(t, clusterFile, names(1, 11), 2000) ++ n.SetSource(config.SourceDisk) ++ expanded := receiveNotification(t, n.C) ++ assertVserverCount(t, expanded, 11) ++ ++ writeClusterFile(t, clusterFile, []string{"vs-50", "vs-51"}, 3000) ++ requireNoError(t, n.Reload(), "reload after replacing config") ++ reload := receiveNotification(t, n.C) ++ ++ assertVserverCount(t, reload, 1) ++ assertMissingVservers(t, reload, []string{"vs-50", "vs-51"}) ++} ++ ++func TestNotifierReloadFromElevenConfiguredToNoneLeavesOneDeferredDeletion(t *testing.T) { ++ ++ ++ dir := t.TempDir() ++ clusterFile := filepath.Join(dir, "cluster.pb") ++ writeClusterFile(t, clusterFile, names(1, 1), 1000) ++ ++ n := newNotifier(t, clusterFile, "reload-delete") ++ defer n.Shutdown() ++ ++ initial := receiveNotification(t, n.C) ++ assertVserverNames(t, initial, []string{"vs-01"}) ++ ++ writeClusterFile(t, clusterFile, names(1, 11), 2000) ++ n.SetSource(config.SourceDisk) ++ expanded := receiveNotification(t, n.C) ++ assertVserverCount(t, expanded, 11) ++ ++ writeClusterFile(t, clusterFile, nil, 3000) ++ requireNoError(t, n.Reload(), "reload after removing all vservers") ++ reload := receiveNotification(t, n.C) ++ assertVserverCount(t, reload, 1) ++} ++ ++func TestNotifierReloadAfterEarlierUpdateContinuesToLimitAdditions(t *testing.T) { ++ ++ ++ dir := t.TempDir() ++ clusterFile := filepath.Join(dir, "cluster.pb") ++ writeClusterFile(t, clusterFile, names(1, 1), 1000) ++ ++ n := newNotifier(t, clusterFile, "explicit-reload") ++ defer n.Shutdown() ++ receiveNotification(t, n.C) ++ ++ writeClusterFile(t, clusterFile, names(1, 11), 2000) ++ n.SetSource(config.SourceDisk) ++ expanded := receiveNotification(t, n.C) ++ assertVserverNames(t, expanded, names(1, 11)) ++ ++ writeClusterFile(t, clusterFile, names(1, 22), 3000) ++ ++ requireNoError(t, n.Reload(), "explicit reload after expanding config") ++ reload := receiveNotification(t, n.C) ++ assertVserverCount(t, reload, 21) ++ assertHasVservers(t, reload, names(1, 11)) ++ assertOnlyVserversFrom(t, reload, names(1, 22)) ++} ++ ++func TestNotifierInstancesMaintainIndependentReloadState(t *testing.T) { ++ ++ ++ dirA := t.TempDir() ++ fileA := filepath.Join(dirA, "cluster.pb") ++ writeClusterFile(t, fileA, names(1, 3), 1000) ++ a := newNotifier(t, fileA, "instance-a") ++ defer a.Shutdown() ++ initialA := receiveNotification(t, a.C) ++ assertVserverNames(t, initialA, []string{"vs-01", "vs-02", "vs-03"}) ++ ++ dirB := t.TempDir() ++ fileB := filepath.Join(dirB, "cluster.pb") ++ writeClusterFile(t, fileB, names(20, 4), 1000) ++ b := newNotifier(t, fileB, "instance-b") ++ defer b.Shutdown() ++ initialB := receiveNotification(t, b.C) ++ assertVserverNames(t, initialB, []string{"vs-20", "vs-21", "vs-22", "vs-23"}) ++ ++ writeClusterFile(t, fileA, names(1, 14), 2000) ++ a.SetSource(config.SourceDisk) ++ reloadA := receiveNotification(t, a.C) ++ assertVserverCount(t, reloadA, 13) ++ assertHasVservers(t, reloadA, []string{"vs-01", "vs-02", "vs-03"}) ++ ++ writeClusterFile(t, fileB, names(20, 5), 2000) ++ b.SetSource(config.SourceDisk) ++ reloadB := receiveNotification(t, b.C) ++ assertVserverNames(t, reloadB, []string{"vs-20", "vs-21", "vs-22", "vs-23", "vs-24"}) ++} ++ ++func TestNotifierLifecycleAppliesStartupLimitAcrossCycles(t *testing.T) { ++ ++ ++ for i := 0; i < 100; i++ { ++ dir := t.TempDir() ++ clusterFile := filepath.Join(dir, "cluster.pb") ++ writeClusterFile(t, clusterFile, names(1, 14), int64(1000+i)) ++ n := newNotifier(t, clusterFile, fmt.Sprintf("leak-floor-%03d", i)) ++ note := receiveNotification(t, n.C) ++ assertVserverCount(t, note, 10) ++ n.Shutdown() ++ } ++ ++} ++ ++func newNotifier(t *testing.T, clusterFile, clusterName string) *config.Notifier { ++ t.Helper() ++ ec := config.DefaultEngineConfig() ++ ec.ClusterFile = clusterFile ++ ec.ClusterName = clusterName ++ ec.ConfigInterval = time.Hour ++ ++ ec.ConfigServers = nil ++ ec.ConfigServerPort = 1 ++ ec.ConfigServerTimeout = time.Millisecond ++ ec.MaxPeerConfigSyncErrors = 1 ++ ++ n, err := config.NewNotifier(&ec) ++ requireNoError(t, err, "NewNotifier") ++ ++ if n.C == nil { ++ t.Fatalf("NewNotifier returned nil notification channel") ++ } ++ return n ++} ++ ++func receiveNotification(t *testing.T, ch <-chan config.Notification) config.Notification { ++ t.Helper() ++ select { ++ case note := <-ch: ++ return note ++ case <-time.After(2 * time.Second): ++ t.Fatal("timed out waiting for config notification") ++ } ++ return config.Notification{} ++} ++ ++func writeClusterFile(t *testing.T, path string, vservers []string, lastUpdated int64) { ++ t.Helper() ++ var b strings.Builder ++ fmt.Fprintf(&b, "seesaw_vip <\n fqdn: %q\n ipv4: \"192.0.2.10/24\"\n status: PRODUCTION\n>\n", "seesaw-vip.example.com.") ++ fmt.Fprintf(&b, "metadata <\n last_updated: %d\n>\n", lastUpdated) ++ for i, name := range vservers { ++ fmt.Fprintf(&b, "vserver <\n") ++ fmt.Fprintf(&b, " name: %q\n", name) ++ fmt.Fprintf(&b, " rp: %q\n", "acceptance@example.com") ++ fmt.Fprintf(&b, " entry_address <\n") ++ fmt.Fprintf(&b, " fqdn: %q\n", name+".example.com.") ++ fmt.Fprintf(&b, " ipv4: \"192.0.2.%d/24\"\n", 20+i) ++ fmt.Fprintf(&b, " status: PRODUCTION\n") ++ fmt.Fprintf(&b, " >\n") ++ fmt.Fprintf(&b, " vserver_entry <\n") ++ fmt.Fprintf(&b, " protocol: TCP\n") ++ fmt.Fprintf(&b, " port: 80\n") ++ fmt.Fprintf(&b, " >\n") ++ fmt.Fprintf(&b, ">\n") ++ } ++ if err := os.WriteFile(path, []byte(b.String()), 0644); err != nil { ++ t.Fatalf("WriteFile(%q) failed: %v", path, err) ++ } ++} ++ ++func names(start, count int) []string { ++ out := make([]string, 0, count) ++ for i := start; i < start+count; i++ { ++ out = append(out, fmt.Sprintf("vs-%02d", i)) ++ } ++ return out ++} ++ ++func assertVserverCount(t *testing.T, note config.Notification, want int) { ++ t.Helper() ++ if got := len(note.Cluster.Vservers); got != want { ++ t.Fatalf("notification vserver count = %d, want %d; names=%v", got, want, sortedVserverNames(note)) ++ } ++} ++ ++func assertVserverNames(t *testing.T, note config.Notification, want []string) { ++ t.Helper() ++ got := sortedVserverNames(note) ++ if !reflect.DeepEqual(got, want) { ++ t.Fatalf("notification vserver names = %v, want %v", got, want) ++ } ++} ++ ++func assertHasVservers(t *testing.T, note config.Notification, want []string) { ++ t.Helper() ++ for _, name := range want { ++ if _, ok := note.Cluster.Vservers[name]; !ok { ++ t.Fatalf("notification missing vserver %q; names=%v", name, sortedVserverNames(note)) ++ } ++ } ++} ++ ++func assertMissingVservers(t *testing.T, note config.Notification, wantMissing []string) { ++ t.Helper() ++ for _, name := range wantMissing { ++ if _, ok := note.Cluster.Vservers[name]; ok { ++ t.Fatalf("notification unexpectedly included vserver %q; names=%v", name, sortedVserverNames(note)) ++ } ++ } ++} ++ ++func assertOnlyVserversFrom(t *testing.T, note config.Notification, allowed []string) { ++ t.Helper() ++ allowedSet := make(map[string]bool, len(allowed)) ++ for _, name := range allowed { ++ allowedSet[name] = true ++ } ++ for name := range note.Cluster.Vservers { ++ if !allowedSet[name] { ++ t.Fatalf("notification included vserver %q outside configured set %v; names=%v", name, allowed, sortedVserverNames(note)) ++ } ++ } ++} ++ ++func sortedVserverNames(note config.Notification) []string { ++ names := make([]string, 0, len(note.Cluster.Vservers)) ++ for name := range note.Cluster.Vservers { ++ names = append(names, name) ++ } ++ sort.Strings(names) ++ return names ++} ++ ++func requireNoError(t *testing.T, err error, action string) { ++ t.Helper() ++ if err != nil { ++ t.Fatalf("%s returned error: %v", action, err) ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,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 GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++export PATH="/root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.0.linux-amd64/bin:/root/go/bin:${PATH}" ++command -v protoc >/dev/null ++command -v protoc-gen-go >/dev/null ++test "$(go env GOVERSION)" = "go1.24.0" ++make proto >/dev/null ++ ++exec go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001361/tests/test.sh b/tasks/format-code-task-001361/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cb3995ecd7170c68b8548979b404066d796784be --- /dev/null +++ b/tasks/format-code-task-001361/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/notifier_rate_limit_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-001361/tests/test_command.sh b/tasks/format-code-task-001361/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001361/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-001366/environment/Dockerfile b/tasks/format-code-task-001366/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..305ff718598564399a7e675d168d978bdf8076df --- /dev/null +++ b/tasks/format-code-task-001366/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3d267b27489431d7e209532873cf1e1b3b8f6ce1a8c6141bbd2b9dd8854b549e diff --git a/tasks/format-code-task-001366/environment/setup/files/blocklist b/tasks/format-code-task-001366/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001366/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001366/environment/setup/setup.sh b/tasks/format-code-task-001366/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001366/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001366/tests/test.patch b/tasks/format-code-task-001366/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..35afa81befa11723ac1b45ae00057372ffaa8286 --- /dev/null +++ b/tasks/format-code-task-001366/tests/test.patch @@ -0,0 +1,127 @@ +diff --git a/internal/gengapic/client_init_test.go b/internal/gengapic/client_init_test.go +index c9d32d953..67013637c 100644 +--- a/internal/gengapic/client_init_test.go ++++ b/internal/gengapic/client_init_test.go +@@ -403,7 +403,7 @@ func TestClientInit(t *testing.T) { + {Path: "google.golang.org/grpc/metadata"}: true, + {Path: "google.golang.org/api/option"}: true, + {Name: "gtransport", Path: "google.golang.org/api/transport/grpc"}: true, +- {Name: "iampb", Path: "google.golang.org/genproto/googleapis/iam/v1"}: true, ++ {Name: "iampb", Path: "cloud.google.com/go/iam/apiv1/iampb"}: true, + {Name: "locationpb", Path: "google.golang.org/genproto/googleapis/cloud/location"}: true, + {Name: "mypackagepb", Path: "github.com/googleapis/mypackage"}: true, + }, +@@ -456,10 +456,10 @@ func TestClientInit(t *testing.T) { + serv: servLRO, + parameter: proto.String("go-gapic-package=path;mypackage"), + imports: map[pbinfo.ImportSpec]bool{ +- {Name: "gtransport", Path: "google.golang.org/api/transport/grpc"}: true, +- {Name: "longrunningpb", Path: "google.golang.org/genproto/googleapis/longrunning"}: true, +- {Name: "lroauto", Path: "cloud.google.com/go/longrunning/autogen"}: true, +- {Name: "mypackagepb", Path: "github.com/googleapis/mypackage"}: true, ++ {Name: "gtransport", Path: "google.golang.org/api/transport/grpc"}: true, ++ {Name: "longrunningpb", Path: "cloud.google.com/go/longrunning/autogen/longrunningpb"}: true, ++ {Name: "lroauto", Path: "cloud.google.com/go/longrunning/autogen"}: true, ++ {Name: "mypackagepb", Path: "github.com/googleapis/mypackage"}: true, + {Path: "context"}: true, + {Path: "google.golang.org/api/option"}: true, + {Path: "google.golang.org/grpc"}: true, +diff --git a/internal/gengapic/example_test.go b/internal/gengapic/example_test.go +index 974d7021b..60eff343f 100644 +--- a/internal/gengapic/example_test.go ++++ b/internal/gengapic/example_test.go +@@ -192,10 +192,10 @@ func TestExample(t *testing.T) { + {Path: "context"}: true, + {Path: "google.golang.org/api/iterator"}: true, + {Path: "io"}: true, +- {Name: "iampb", Path: "google.golang.org/genproto/googleapis/iam/v1"}: true, +- {Name: "locationpb", Path: "google.golang.org/genproto/googleapis/cloud/location"}: true, +- {Name: "longrunningpb", Path: "google.golang.org/genproto/googleapis/longrunning"}: true, +- {Name: "mypackagepb", Path: "mypackage"}: true, ++ {Name: "iampb", Path: "cloud.google.com/go/iam/apiv1/iampb"}: true, ++ {Name: "locationpb", Path: "google.golang.org/genproto/googleapis/cloud/location"}: true, ++ {Name: "longrunningpb", Path: "cloud.google.com/go/longrunning/autogen/longrunningpb"}: true, ++ {Name: "mypackagepb", Path: "mypackage"}: true, + }, + }, + { +@@ -208,10 +208,10 @@ func TestExample(t *testing.T) { + {Path: "context"}: true, + {Path: "google.golang.org/api/iterator"}: true, + {Path: "io"}: true, +- {Name: "iampb", Path: "google.golang.org/genproto/googleapis/iam/v1"}: true, +- {Name: "locationpb", Path: "google.golang.org/genproto/googleapis/cloud/location"}: true, +- {Name: "longrunningpb", Path: "google.golang.org/genproto/googleapis/longrunning"}: true, +- {Name: "mypackagepb", Path: "mypackage"}: true, ++ {Name: "iampb", Path: "cloud.google.com/go/iam/apiv1/iampb"}: true, ++ {Name: "locationpb", Path: "google.golang.org/genproto/googleapis/cloud/location"}: true, ++ {Name: "longrunningpb", Path: "cloud.google.com/go/longrunning/autogen/longrunningpb"}: true, ++ {Name: "mypackagepb", Path: "mypackage"}: true, + }, + }, + { +@@ -224,10 +224,10 @@ func TestExample(t *testing.T) { + {Path: "context"}: true, + {Path: "google.golang.org/api/iterator"}: true, + {Path: "io"}: true, +- {Name: "iampb", Path: "google.golang.org/genproto/googleapis/iam/v1"}: true, +- {Name: "locationpb", Path: "google.golang.org/genproto/googleapis/cloud/location"}: true, +- {Name: "longrunningpb", Path: "google.golang.org/genproto/googleapis/longrunning"}: true, +- {Name: "mypackagepb", Path: "mypackage"}: true, ++ {Name: "iampb", Path: "cloud.google.com/go/iam/apiv1/iampb"}: true, ++ {Name: "locationpb", Path: "google.golang.org/genproto/googleapis/cloud/location"}: true, ++ {Name: "longrunningpb", Path: "cloud.google.com/go/longrunning/autogen/longrunningpb"}: true, ++ {Name: "mypackagepb", Path: "mypackage"}: true, + }, + }, + { +@@ -240,10 +240,10 @@ func TestExample(t *testing.T) { + {Path: "context"}: true, + {Path: "google.golang.org/api/iterator"}: true, + {Path: "io"}: true, +- {Name: "iampb", Path: "google.golang.org/genproto/googleapis/iam/v1"}: true, +- {Name: "locationpb", Path: "google.golang.org/genproto/googleapis/cloud/location"}: true, +- {Name: "longrunningpb", Path: "google.golang.org/genproto/googleapis/longrunning"}: true, +- {Name: "mypackagepb", Path: "mypackage"}: true, ++ {Name: "iampb", Path: "cloud.google.com/go/iam/apiv1/iampb"}: true, ++ {Name: "locationpb", Path: "google.golang.org/genproto/googleapis/cloud/location"}: true, ++ {Name: "longrunningpb", Path: "cloud.google.com/go/longrunning/autogen/longrunningpb"}: true, ++ {Name: "mypackagepb", Path: "mypackage"}: true, + }, + }, + { +diff --git a/internal/gengapic/genrest_test.go b/internal/gengapic/genrest_test.go +index 4d9dd71bc..6b8b31cec 100644 +--- a/internal/gengapic/genrest_test.go ++++ b/internal/gengapic/genrest_test.go +@@ -835,7 +835,7 @@ func TestGenRestMethod(t *testing.T) { + {Path: "net/url"}: true, + {Path: "time"}: true, + {Name: "foopb", Path: "google.golang.org/genproto/cloud/foo/v1"}: true, +- {Name: "longrunningpb", Path: "google.golang.org/genproto/googleapis/longrunning"}: true, ++ {Name: "longrunningpb", Path: "cloud.google.com/go/longrunning/autogen/longrunningpb"}: true, + }, + }, + { +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+3SS0vDQBAH8JzzKdbqNa+2SU4exPoCxfq4l81m2iwmu2WzKQp+eNMEaRG0lxYR ++/7/LzCTDzpKJnzWyzGekVoFzKGErjeMutr7GLo/iYRQlSZimiRO2WTR2WHywG21passNY47R2v7U ++t+v9H+Vv9m+ptjOhq4qr3K+L/c3Ytf9RMtrsPxy2+x8nUeqwcH9X+N4/3//xUZBJFWS8LtyaLPPI ++FTnr/oWMcneh2TplfiCVJaN4GSxILfhSioB5K+YJ3Sh7GjHPNIoNntve81KSsjdK2vd1efHKq2VJ ++J11xReqxDXdkC513T6bcFlNueFV35UND5m2rviU+v5RU5n3Zn32t9ctWeb/sJz2RWUlBEy0+Z5Hh ++liY0501pz5q8bRY0cH/7kwMAAAAAAAAAAAAAAAAAAAAA7M0HHeVa+wAoAAA= +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001366/tests/test.sh b/tasks/format-code-task-001366/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..db5ed29cb1565f10ec0012e6caf35b0e2da8e2f2 --- /dev/null +++ b/tasks/format-code-task-001366/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' +internal/gengapic/client_init_test.go +internal/gengapic/example_test.go +internal/gengapic/genrest_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-001366/tests/test_command.sh b/tasks/format-code-task-001366/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001366/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001367/environment/Dockerfile b/tasks/format-code-task-001367/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fd089ea9bf9ab5ae21bd5e7ecddaaf57eee80f10 --- /dev/null +++ b/tasks/format-code-task-001367/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f7fbd8b2de3d5e5f544bf81269535aa52e712124833d54094790caffe113caf1 diff --git a/tasks/format-code-task-001367/environment/setup/files/blocklist b/tasks/format-code-task-001367/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001367/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001367/environment/setup/setup.sh b/tasks/format-code-task-001367/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001367/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001367/tests/test.patch b/tasks/format-code-task-001367/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..254695026da75315a3906d5124b2cc4856096ad8 --- /dev/null +++ b/tasks/format-code-task-001367/tests/test.patch @@ -0,0 +1,90 @@ +diff --git a/logging/logging_test.go b/logging/logging_test.go +index 495303ed94..d042a893bc 100644 +--- a/logging/logging_test.go ++++ b/logging/logging_test.go +@@ -806,3 +806,63 @@ func TestSeverityUnmarshal(t *testing.T) { + t.Fatalf("Severity: got %v, want %v", entry.Severity, logging.Error) + } + } ++ ++ ++ ++func TestSeverityMarshalThenUnmarshalEntry(t *testing.T) { ++ entry := logging.Entry{Payload: "test log", Severity: logging.Info} ++ j, err := json.Marshal(entry) ++ if err != nil { ++ t.Fatalf("Marshal: %v", err) ++ } ++ var entryU logging.Entry ++ if err := json.Unmarshal(j, &entryU); err != nil { ++ t.Fatalf("Unmarshal: %v", err) ++ } ++ if entryU.Severity != logging.Info { ++ t.Fatalf("Severity round-trip: got %v, want %v", entryU.Severity, logging.Info) ++ } ++} ++ ++ ++ ++ ++ ++func TestSeverityUnmarshalFromNumber(t *testing.T) { ++ ++ ++ j := []byte(`{"severity": 200, "payload": "test"}`) ++ var entry logging.Entry ++ if err := json.Unmarshal(j, &entry); err != nil { ++ t.Fatalf("Unmarshal from numeric severity: %v", err) ++ } ++ if entry.Severity != logging.Info { ++ t.Fatalf("Severity: got %v (%d), want %v (%d)", ++ entry.Severity, int(entry.Severity), logging.Info, int(logging.Info)) ++ } ++} ++ ++ ++ ++func TestSeverityUnmarshalRawNumber(t *testing.T) { ++ var s logging.Severity ++ if err := json.Unmarshal([]byte("500"), &s); err != nil { ++ t.Fatalf("Unmarshal raw number: %v", err) ++ } ++ if s != logging.Error { ++ t.Fatalf("Severity: got %v (%d), want %v (%d)", ++ s, int(s), logging.Error, int(logging.Error)) ++ } ++} ++ ++ ++ ++func TestSeverityUnmarshalFromStringPreserved(t *testing.T) { ++ var s logging.Severity ++ if err := json.Unmarshal([]byte(`"Info"`), &s); err != nil { ++ t.Fatalf("Unmarshal from string: %v", err) ++ } ++ if s != logging.Info { ++ t.Fatalf("Severity: got %v, want %v", s, logging.Info) ++ } ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..16dc9a6818 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd logging && go test -run 'TestSeverityMarshalThenUnmarshalEntry|TestSeverityUnmarshalFromNumber|TestSeverityUnmarshalRawNumber|TestSeverityUnmarshalFromStringPreserved|TestSeverityUnmarshal$' -count=1 -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 ++cd logging && go test -run 'TestSeverityMarshalThenUnmarshalEntry|TestSeverityUnmarshalFromNumber|TestSeverityUnmarshalRawNumber|TestSeverityUnmarshalFromStringPreserved|TestSeverityUnmarshal$' -count=1 -v . ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001367/tests/test.sh b/tasks/format-code-task-001367/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ca8b841e3aa8753780f7cbd6173fb9b382505131 --- /dev/null +++ b/tasks/format-code-task-001367/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' +logging/logging_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-001367/tests/test_command.sh b/tasks/format-code-task-001367/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001367/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001392/environment/Dockerfile b/tasks/format-code-task-001392/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..2ac1389fb0fb408d27edcaca5c39f1549a150734 --- /dev/null +++ b/tasks/format-code-task-001392/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:dc11b33d1c2cfecf86af122b811b3068755ce0484486e561b8f4d834f605f2e3 diff --git a/tasks/format-code-task-001392/environment/setup/files/blocklist b/tasks/format-code-task-001392/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001392/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001392/environment/setup/setup.sh b/tasks/format-code-task-001392/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001392/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001392/tests/test.patch b/tasks/format-code-task-001392/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..85d13a49a560bb102aae31d2149923f99509768f --- /dev/null +++ b/tasks/format-code-task-001392/tests/test.patch @@ -0,0 +1,161 @@ +diff --git a/pkg/canary/writer/push_test.go b/pkg/canary/writer/push_test.go +index ad9848498..49bd08c5d 100644 +--- a/pkg/canary/writer/push_test.go ++++ b/pkg/canary/writer/push_test.go +@@ -1,6 +1,7 @@ + package writer + + import ( ++ "crypto/tls" + "encoding/base64" + "fmt" + "math" +@@ -42,7 +43,7 @@ func Test_Push(t *testing.T) { + defer mock.Close() + + // without TLS +- push, err := NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "stream", "stdout", nil, "", "", "", &backoff, log.NewNopLogger()) ++ push, err := NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "stream", "stdout", false, nil, "", "", "", &backoff, log.NewNopLogger()) + require.NoError(t, err) + ts, payload := testPayload() + n, err := push.Write([]byte(payload)) +@@ -52,7 +53,7 @@ func Test_Push(t *testing.T) { + assertResponse(t, resp, false, labelSet("name", "loki-canary", "stream", "stdout"), ts, payload) + + // with basic Auth +- push, err = NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "stream", "stdout", nil, "", testUsername, testPassword, &backoff, log.NewNopLogger()) ++ push, err = NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "stream", "stdout", false, nil, "", testUsername, testPassword, &backoff, log.NewNopLogger()) + require.NoError(t, err) + ts, payload = testPayload() + n, err = push.Write([]byte(payload)) +@@ -62,7 +63,7 @@ func Test_Push(t *testing.T) { + assertResponse(t, resp, true, labelSet("name", "loki-canary", "stream", "stdout"), ts, payload) + + // with custom labels +- push, err = NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "pod", "abc", nil, "", testUsername, testPassword, &backoff, log.NewNopLogger()) ++ push, err = NewPush(mock.Listener.Addr().String(), "test1", 2*time.Second, config.DefaultHTTPClientConfig, "name", "loki-canary", "pod", "abc", false, nil, "", testUsername, testPassword, &backoff, log.NewNopLogger()) + require.NoError(t, err) + ts, payload = testPayload() + n, err = push.Write([]byte(payload)) +@@ -177,3 +178,99 @@ func testPayload() (time.Time, string) { + + return ts, payload + } ++ ++ ++ ++ ++func Test_Push_TLS_Scheme(t *testing.T) { ++ backoffCfg := backoff.Config{ ++ MinBackoff: 300 * time.Millisecond, ++ MaxBackoff: 5 * time.Minute, ++ MaxRetries: 10, ++ } ++ ++ addr := "loki-internal.alb:443" ++ ++ cases := []struct { ++ name string ++ useTLS bool ++ withTLSCfg bool ++ wantScheme string ++ }{ ++ { ++ name: "useTLS=true with nil tlsCfg uses https", ++ useTLS: true, ++ withTLSCfg: false, ++ wantScheme: "https", ++ }, ++ { ++ name: "useTLS=false with nil tlsCfg uses http", ++ useTLS: false, ++ withTLSCfg: false, ++ wantScheme: "http", ++ }, ++ } ++ ++ for _, tc := range cases { ++ t.Run(tc.name, func(t *testing.T) { ++ var tlsCfg *tls.Config ++ if tc.withTLSCfg { ++ tlsCfg = &tls.Config{} ++ } ++ push, err := NewPush( ++ addr, "test1", 2*time.Second, ++ config.DefaultHTTPClientConfig, ++ "name", "loki-canary", ++ "stream", "stdout", ++ tc.useTLS, ++ tlsCfg, ++ "", ++ "", "", ++ &backoffCfg, ++ log.NewNopLogger(), ++ ) ++ require.NoError(t, err) ++ require.NotNil(t, push) ++ ++ wantURL := tc.wantScheme + "://" + addr + pushEndpoint ++ assert.Equal(t, wantURL, push.lokiURL, ++ "useTLS=%v should produce URL with scheme %q", ++ tc.useTLS, tc.wantScheme) ++ assert.True(t, strings.HasPrefix(push.lokiURL, tc.wantScheme+"://"), ++ "lokiURL %q should start with %q://", push.lokiURL, tc.wantScheme) ++ }) ++ } ++} ++ ++ ++ ++func Test_Push_IssueRepro_TLSTrueProducesHTTPSURL(t *testing.T) { ++ backoffCfg := backoff.Config{ ++ MinBackoff: 300 * time.Millisecond, ++ MaxBackoff: 5 * time.Minute, ++ MaxRetries: 10, ++ } ++ ++ push, err := NewPush( ++ "loki-internal.alb:443", ++ "", ++ 10*time.Second, ++ config.DefaultHTTPClientConfig, ++ "canary-id", "canary-1234", ++ "source", "stdout", ++ true, ++ nil, ++ "", ++ "LOKI_USER", "LOKI_PASSWORD", ++ &backoffCfg, ++ log.NewNopLogger(), ++ ) ++ require.NoError(t, err) ++ require.NotNil(t, push) ++ ++ assert.True(t, strings.HasPrefix(push.lokiURL, "https://"), ++ "expected https URL when -tls=true was passed, got %q", push.lokiURL) ++ assert.False(t, strings.HasPrefix(push.lokiURL, "http://"), ++ "URL must NOT be http:// when -tls=true (the original bug)") ++ assert.Equal(t, "https://loki-internal.alb:443/loki/api/v1/push", push.lokiURL) ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..3cc57ef89 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./pkg/canary/writer/... -run 'Test_Push' -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test ./pkg/canary/writer/... -run 'Test_Push' -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001392/tests/test.sh b/tasks/format-code-task-001392/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ce15de0c0d97dade9346d422f91fb55c893a5e0a --- /dev/null +++ b/tasks/format-code-task-001392/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/canary/writer/push_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-001392/tests/test_command.sh b/tasks/format-code-task-001392/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001392/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001393/environment/Dockerfile b/tasks/format-code-task-001393/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..84ecb19b1c04d354a8e4e83b53a4f436e72b544b --- /dev/null +++ b/tasks/format-code-task-001393/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8b75ed1b07bdbce2c12e361272102e94a61c94fef5c3a4112e793fe6240b1c8e diff --git a/tasks/format-code-task-001393/environment/setup/files/blocklist b/tasks/format-code-task-001393/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001393/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001393/environment/setup/setup.sh b/tasks/format-code-task-001393/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001393/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001393/tests/test.patch b/tasks/format-code-task-001393/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..91f0ff5504e2974285ea015b72e799db380e504d --- /dev/null +++ b/tasks/format-code-task-001393/tests/test.patch @@ -0,0 +1,107 @@ +diff --git a/engine/apps/webhooks/tests/test_webhook.py b/engine/apps/webhooks/tests/test_webhook.py +index 4c8cb69a..4a2e4241 100644 +--- a/engine/apps/webhooks/tests/test_webhook.py ++++ b/engine/apps/webhooks/tests/test_webhook.py +@@ -4,6 +4,7 @@ import pytest + from requests.auth import HTTPBasicAuth + + from apps.webhooks.models import Webhook ++from apps.webhooks.models.webhook import PUBLIC_WEBHOOK_HTTP_METHODS + from apps.webhooks.utils import ( + OUTGOING_WEBHOOK_TIMEOUT, + InvalidWebhookData, +@@ -231,7 +232,7 @@ def test_make_request(make_organization, make_custom_webhook): + organization = make_organization() + + with patch("apps.webhooks.models.webhook.requests") as mock_requests: +- for method in ("GET", "POST", "PUT", "DELETE", "OPTIONS"): ++ for method in ("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"): + webhook = make_custom_webhook(organization=organization, http_method=method) + webhook.make_request("url", {"foo": "bar"}) + expected_call = getattr(mock_requests, method.lower()) +@@ -244,6 +245,63 @@ def test_make_request(make_organization, make_custom_webhook): + webhook.make_request("url", {"foo": "bar"}) + + ++def test_public_webhook_http_methods_includes_patch(): ++ assert "PATCH" in PUBLIC_WEBHOOK_HTTP_METHODS ++ ++ assert set(PUBLIC_WEBHOOK_HTTP_METHODS) == {"GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"} ++ ++ ++@pytest.mark.django_db ++def test_make_request_patch_dispatches_to_requests_patch(make_organization, make_custom_webhook): ++ organization = make_organization() ++ webhook = make_custom_webhook(organization=organization, http_method="PATCH") ++ with patch("apps.webhooks.models.webhook.requests") as mock_requests: ++ webhook.make_request("url", {"foo": "bar"}) ++ ++ assert mock_requests.patch.called ++ assert mock_requests.patch.call_args == call("url", timeout=OUTGOING_WEBHOOK_TIMEOUT, foo="bar") ++ assert not mock_requests.get.called ++ assert not mock_requests.post.called ++ assert not mock_requests.put.called ++ assert not mock_requests.delete.called ++ assert not mock_requests.options.called ++ ++ ++@pytest.mark.django_db ++def test_build_request_kwargs_patch_forward_all(make_organization, make_custom_webhook): ++ organization = make_organization() ++ webhook = make_custom_webhook(organization=organization, http_method="PATCH", forward_all=True) ++ request_kwargs = webhook.build_request_kwargs({"foo": "bar"}) ++ ++ assert request_kwargs == {"headers": {}, "json": {"foo": "bar"}} ++ ++ ++@pytest.mark.django_db ++def test_build_request_kwargs_patch_custom_data(make_organization, make_custom_webhook): ++ organization = make_organization() ++ webhook = make_custom_webhook( ++ organization=organization, http_method="PATCH", data="{{foo}}", forward_all=False ++ ) ++ request_kwargs = webhook.build_request_kwargs({"foo": "bar", "something": "else"}) ++ ++ assert request_kwargs == {"headers": {}, "data": "bar"} ++ ++ ++@pytest.mark.django_db ++def test_make_request_patch_with_forwarded_data(make_organization, make_custom_webhook): ++ """End-to-end: PATCH webhook forwards json body via requests.patch.""" ++ organization = make_organization() ++ webhook = make_custom_webhook(organization=organization, http_method="PATCH", forward_all=True) ++ event_data = {"alert_group_id": "x", "alert_payload": {"msg": "hi"}} ++ request_kwargs = webhook.build_request_kwargs(event_data) ++ with patch("apps.webhooks.models.webhook.requests") as mock_requests: ++ webhook.make_request("http://example.com", request_kwargs) ++ assert mock_requests.patch.called ++ assert mock_requests.patch.call_args == call( ++ "http://example.com", timeout=OUTGOING_WEBHOOK_TIMEOUT, headers={}, json=event_data ++ ) ++ ++ + @pytest.mark.django_db + def test_escaping_payload_with_double_quotes(make_organization, make_custom_webhook): + organization = make_organization() +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..9d7d0538 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd engine && DATABASE_TYPE=sqlite3 DJANGO_SETTINGS_MODULE=settings.ci-test python -m pytest apps/webhooks/tests/test_webhook.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 ++cd engine && DATABASE_TYPE=sqlite3 DJANGO_SETTINGS_MODULE=settings.ci-test python -m pytest apps/webhooks/tests/test_webhook.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001393/tests/test.sh b/tasks/format-code-task-001393/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..098695cbe8b2ba0fbf926bb3dbb05f6788f7701b --- /dev/null +++ b/tasks/format-code-task-001393/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' +engine/apps/webhooks/tests/test_webhook.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-001393/tests/test_command.sh b/tasks/format-code-task-001393/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001393/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001394/environment/Dockerfile b/tasks/format-code-task-001394/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d51f3b401325908433dc29a727d8987ef0afd2a4 --- /dev/null +++ b/tasks/format-code-task-001394/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4dc7b2fe0b6fc730863ff410fb9748005170a4e52527e5c27f2bb8ef234ea7a4 diff --git a/tasks/format-code-task-001394/environment/setup/files/blocklist b/tasks/format-code-task-001394/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001394/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001394/environment/setup/setup.sh b/tasks/format-code-task-001394/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001394/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001394/tests/test.patch b/tasks/format-code-task-001394/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e9003e8e4eca53d4dc41568fac4d6ebc6b924395 --- /dev/null +++ b/tasks/format-code-task-001394/tests/test.patch @@ -0,0 +1,167 @@ +diff --git a/engine/apps/user_management/tests/test_organization.py b/engine/apps/user_management/tests/test_organization.py +index 91915500..d2969ea1 100644 +--- a/engine/apps/user_management/tests/test_organization.py ++++ b/engine/apps/user_management/tests/test_organization.py +@@ -269,3 +269,140 @@ def test_get_notifiable_direct_paging_integrations( + escalation_chain = make_escalation_chain(org) + make_channel_filter(arc, is_default=True, notify_in_slack=False, escalation_chain=escalation_chain) + _assert(org, arc) ++ ++ ++@pytest.mark.django_db ++def test_get_notifiable_direct_paging_integrations_no_duplicates_two_routes_escalation( ++ make_organization, ++ make_alert_receive_channel, ++ make_channel_filter, ++ make_escalation_chain, ++): ++ """ ++ Regression test for: ++ /escalate Slack Dropdown Duplicates Teams for Each Route in Direct Paging. ++ ++ Minimal reproduction: a Direct Paging integration with 2 routes (1 default ++ wired to an escalation chain + 1 non-default) must appear exactly once, ++ not once per route. ++ """ ++ org = make_organization() ++ arc = make_alert_receive_channel(org, integration=AlertReceiveChannel.INTEGRATION_DIRECT_PAGING) ++ escalation_chain = make_escalation_chain(org) ++ make_channel_filter(arc, is_default=True, notify_in_slack=False, escalation_chain=escalation_chain) ++ make_channel_filter(arc, is_default=False) ++ ++ results = list(org.get_notifiable_direct_paging_integrations()) ++ ++ assert arc in results ++ assert results.count(arc) == 1 ++ assert len(results) == 1 ++ ++ ++@pytest.mark.django_db ++def test_get_notifiable_direct_paging_integrations_no_duplicates_two_routes_notification_backend( ++ make_organization, ++ make_alert_receive_channel, ++ make_channel_filter, ++): ++ """ ++ Direct Paging integration whose default route uses a custom messaging ++ backend, plus one extra non-default route, must appear exactly once. ++ """ ++ org = make_organization() ++ arc = make_alert_receive_channel(org, integration=AlertReceiveChannel.INTEGRATION_DIRECT_PAGING) ++ make_channel_filter( ++ arc, ++ is_default=True, ++ notify_in_slack=False, ++ notification_backends={"MSTEAMS": {"channel": "test", "enabled": True}}, ++ ) ++ make_channel_filter(arc, is_default=False) ++ ++ results = list(org.get_notifiable_direct_paging_integrations()) ++ ++ assert arc in results ++ assert results.count(arc) == 1 ++ assert len(results) == 1 ++ ++ ++@pytest.mark.django_db ++def test_get_notifiable_direct_paging_integrations_three_routes_no_full_duplication( ++ make_organization, ++ make_alert_receive_channel, ++ make_channel_filter, ++ make_escalation_chain, ++): ++ """ ++ Issue reproduction: integration with 3 routes (1 default + 2 non-default) ++ must NOT appear 3 times in the queryset. The user-visible bug was that the ++ same team was shown once per route in the Slack /escalate dropdown. ++ """ ++ org = make_organization() ++ arc = make_alert_receive_channel(org, integration=AlertReceiveChannel.INTEGRATION_DIRECT_PAGING) ++ escalation_chain = make_escalation_chain(org) ++ make_channel_filter(arc, is_default=True, notify_in_slack=False, escalation_chain=escalation_chain) ++ make_channel_filter(arc, is_default=False) ++ make_channel_filter(arc, is_default=False) ++ ++ results = list(org.get_notifiable_direct_paging_integrations()) ++ ++ ++ assert arc in results ++ assert len(results) < 3 ++ assert results.count(arc) < 3 ++ ++ ++@pytest.mark.django_db ++def test_get_notifiable_direct_paging_integrations_five_routes_no_full_duplication( ++ make_organization, ++ make_alert_receive_channel, ++ make_channel_filter, ++ make_escalation_chain, ++): ++ """ ++ Integration with many routes (5: 1 default + 4 non-default) must NOT appear ++ once per route. (Per the bug report, BASE happens to cap at 3 entries ++ irrespective of route count, so a strict `<3` upper bound here catches the ++ duplicate-team behavior.) ++ """ ++ org = make_organization() ++ arc = make_alert_receive_channel(org, integration=AlertReceiveChannel.INTEGRATION_DIRECT_PAGING) ++ escalation_chain = make_escalation_chain(org) ++ make_channel_filter(arc, is_default=True, notify_in_slack=False, escalation_chain=escalation_chain) ++ for _ in range(4): ++ make_channel_filter(arc, is_default=False) ++ ++ results = list(org.get_notifiable_direct_paging_integrations()) ++ ++ assert arc in results ++ assert len(results) < 3 ++ assert results.count(arc) < 3 ++ ++ ++@pytest.mark.django_db ++def test_get_notifiable_direct_paging_integrations_three_routes_notification_backend_no_full_duplication( ++ make_organization, ++ make_alert_receive_channel, ++ make_channel_filter, ++): ++ """ ++ Integration qualifying via notification_backends with 3 routes must NOT ++ appear once per route. ++ """ ++ org = make_organization() ++ arc = make_alert_receive_channel(org, integration=AlertReceiveChannel.INTEGRATION_DIRECT_PAGING) ++ make_channel_filter( ++ arc, ++ is_default=True, ++ notify_in_slack=False, ++ notification_backends={"MSTEAMS": {"channel": "test", "enabled": True}}, ++ ) ++ make_channel_filter(arc, is_default=False) ++ make_channel_filter(arc, is_default=False) ++ ++ results = list(org.get_notifiable_direct_paging_integrations()) ++ ++ assert arc in results ++ assert len(results) < 3 ++ assert results.count(arc) < 3 +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..e035be95 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd engine && DATABASE_TYPE=sqlite3 DJANGO_SETTINGS_MODULE=settings.ci-test python -m pytest apps/user_management/tests/test_organization.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 ++cd engine && DATABASE_TYPE=sqlite3 DJANGO_SETTINGS_MODULE=settings.ci-test python -m pytest apps/user_management/tests/test_organization.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001394/tests/test.sh b/tasks/format-code-task-001394/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d931329c4f55deb272a200c9913066cfaca71827 --- /dev/null +++ b/tasks/format-code-task-001394/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' +engine/apps/user_management/tests/test_organization.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-001394/tests/test_command.sh b/tasks/format-code-task-001394/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001394/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001395/environment/Dockerfile b/tasks/format-code-task-001395/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e269da19da49c026c7213d5c9e4ac33b6888d64f --- /dev/null +++ b/tasks/format-code-task-001395/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:874d5174dd0291392cfea93b5e3be143259fd4d78c9e97d4257fb7514b2883e8 diff --git a/tasks/format-code-task-001395/environment/setup/files/blocklist b/tasks/format-code-task-001395/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001395/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001395/environment/setup/setup.sh b/tasks/format-code-task-001395/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001395/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001395/tests/test.patch b/tasks/format-code-task-001395/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..101a58f1c0b0992c110082ffa84e1d36761ac34a --- /dev/null +++ b/tasks/format-code-task-001395/tests/test.patch @@ -0,0 +1,151 @@ +diff --git a/pkg/tanka/load_test.go b/pkg/tanka/load_test.go +index dc2b59ab3..d7e317fec 100644 +--- a/pkg/tanka/load_test.go ++++ b/pkg/tanka/load_test.go +@@ -1,6 +1,10 @@ + package tanka + + import ( ++ "errors" ++ "io/fs" ++ "os" ++ "reflect" + "testing" + + "github.com/grafana/tanka/pkg/kubernetes/manifest" +@@ -157,11 +161,11 @@ func TestLoadSelectEnvironment(t *testing.T) { + + // Empty options, match all environments + _, err = Load("./testdata/cases/multiple-inline-envs", Opts{}) +- assert.EqualError(t, err, "found multiple Environments in './testdata/cases/multiple-inline-envs'. Use `--name` to select a single one: \n - project1-env1\n - project1-env2\n - project2-env1") ++ assertMultipleEnvsError(t, err, "", "project1-env1", "project1-env2", "project2-env1") + + // Partial match two environments + _, err = Load("./testdata/cases/multiple-inline-envs", Opts{Name: "env1"}) +- assert.EqualError(t, err, "found multiple Environments in './testdata/cases/multiple-inline-envs'. Use `--name` to select a single one: \n - project1-env1\n - project2-env1") ++ assertMultipleEnvsError(t, err, "env1", "project1-env1", "project2-env1") + + // Partial match + result, err := Load("./testdata/cases/multiple-inline-envs", Opts{Name: "project2"}) +@@ -174,6 +178,54 @@ func TestLoadSelectEnvironment(t *testing.T) { + assert.Equal(t, "project1-env1", result.Env.Metadata.Name) + } + ++func TestLoadSelectEnvironmentIncludesRequestedNameOnAmbiguousMatch(t *testing.T) { ++ _, err := Load("./testdata/cases/multiple-inline-envs", Opts{Name: "env1"}) ++ assertMultipleEnvsError(t, err, "env1", "project1-env1", "project2-env1") ++ ++ _, err = Load("./testdata/cases/multiple-inline-envs", Opts{Name: "project1"}) ++ assertMultipleEnvsError(t, err, "project1", "project1-env1", "project1-env2") ++} ++ ++func TestLoadEnvironmentFallsBackToNameFromCurrentDirectory(t *testing.T) { ++ cwd, err := os.Getwd() ++ require.NoError(t, err) ++ ++ require.NoError(t, os.Chdir("./testdata/cases/multiple-inline-envs")) ++ t.Cleanup(func() { ++ require.NoError(t, os.Chdir(cwd)) ++ }) ++ ++ _, err = Load("env1", Opts{}) ++ assertMultipleEnvsError(t, err, "env1", "project1-env1", "project2-env1") ++ ++ result, err := Load("project2", Opts{}) ++ require.NoError(t, err) ++ assert.Equal(t, "project2-env1", result.Env.Metadata.Name) ++ ++ result, err = Load("project1-env1", Opts{}) ++ require.NoError(t, err) ++ assert.Equal(t, "project1-env1", result.Env.Metadata.Name) ++} ++ ++func TestLoadEnvironmentDoesNotFallbackOnNonNotExistStatError(t *testing.T) { ++ cwd, err := os.Getwd() ++ require.NoError(t, err) ++ ++ require.NoError(t, os.Chdir("./testdata/cases/multiple-inline-envs")) ++ t.Cleanup(func() { ++ require.NoError(t, os.Chdir(cwd)) ++ }) ++ ++ invalidPath := "not-a-valid\x00path" ++ _, err = Load(invalidPath, Opts{}) ++ require.Error(t, err) ++ ++ var pathErr *fs.PathError ++ require.Truef(t, errors.As(err, &pathErr), "expected a filesystem path error, got %T: %v", err, err) ++ assert.False(t, os.IsNotExist(err), "invalid path errors must not be treated as missing paths") ++ assert.Equal(t, invalidPath, pathErr.Path) ++} ++ + func TestLoadSelectEnvironmentFullMatchHasPriority(t *testing.T) { + // `base` matches both `base` and `base-and-more` + // However, the full match should win +@@ -186,3 +238,40 @@ func TestLoadFailsWhenBothSpecAndInline(t *testing.T) { + _, err := Load("./testdata/cases/static-and-inline", Opts{Name: "inline"}) + assert.EqualError(t, err, "found a tanka Environment resource. Check that you aren't using a spec.json and inline environments simultaneously") + } ++ ++func assertMultipleEnvsError(t *testing.T, err error, name string, envs ...string) { ++ t.Helper() ++ require.Error(t, err) ++ ++ var multiple ErrMultipleEnvs ++ require.Truef(t, errors.As(err, &multiple), "expected ErrMultipleEnvs, got %T: %v", err, err) ++ ++ v := reflect.ValueOf(multiple) ++ var gotName string ++ var gotEnvs []string ++ for i := 0; i < v.NumField(); i++ { ++ field := v.Field(i) ++ switch field.Kind() { ++ case reflect.String: ++ s := field.String() ++ if s == name { ++ gotName = s ++ } ++ case reflect.Slice: ++ if field.Type().Elem().Kind() == reflect.String { ++ values := make([]string, field.Len()) ++ for i := range values { ++ values[i] = field.Index(i).String() ++ } ++ gotEnvs = values ++ } ++ } ++ } ++ ++ if name == "" { ++ assert.Empty(t, gotName) ++ } else { ++ assert.Equal(t, name, gotName) ++ } ++ assert.ElementsMatch(t, envs, gotEnvs) ++} +diff --git 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) ++ go test -v -run 'TestLoad$|TestLoadFailsWhenBothSpecAndInline$' ./pkg/tanka/ ++ ;; ++ new) ++ go test -v -run 'TestLoadSelectEnvironment$|TestLoadSelectEnvironmentIncludesRequestedNameOnAmbiguousMatch$|TestLoadEnvironmentFallsBackToNameFromCurrentDirectory$|TestLoadEnvironmentDoesNotFallbackOnNonNotExistStatError$' ./pkg/tanka/ ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001395/tests/test.sh b/tasks/format-code-task-001395/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ccf4bb6e8f669ea8b0243dcf4b1d240a3ae82e15 --- /dev/null +++ b/tasks/format-code-task-001395/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/tanka/load_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-001395/tests/test_command.sh b/tasks/format-code-task-001395/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001395/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-001508/environment/Dockerfile b/tasks/format-code-task-001508/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f84e988d4581e51f05cd2f84b91fec143c688a33 --- /dev/null +++ b/tasks/format-code-task-001508/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e94b8a232f6685060644db4056e59042086079d070721950bd7653a37fec4b8e diff --git a/tasks/format-code-task-001508/environment/setup/files/blocklist b/tasks/format-code-task-001508/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001508/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001508/environment/setup/setup.sh b/tasks/format-code-task-001508/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001508/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001508/tests/test.patch b/tasks/format-code-task-001508/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..36cc0933a0850897312e6f500025e978736ee613 --- /dev/null +++ b/tasks/format-code-task-001508/tests/test.patch @@ -0,0 +1,90 @@ +diff --git a/tests/components/prusalink/conftest.py b/tests/components/prusalink/conftest.py +index 391579359b6dd1..8beb67b0ed412d 100644 +--- a/tests/components/prusalink/conftest.py ++++ b/tests/components/prusalink/conftest.py +@@ -42,8 +42,8 @@ def mock_printer_api(hass): + "material": "PLA", + }, + "temperature": { +- "tool0": {"actual": 47.8, "target": 0.0, "display": 0.0, "offset": 0}, +- "bed": {"actual": 41.9, "target": 0.0, "offset": 0}, ++ "tool0": {"actual": 47.8, "target": 210.1, "display": 0.0, "offset": 0}, ++ "bed": {"actual": 41.9, "target": 60.5, "offset": 0}, + }, + "state": { + "text": "Operational", +diff --git a/tests/components/prusalink/test_sensor.py b/tests/components/prusalink/test_sensor.py +index 4f64c3139e157f..6a0944bdf3651f 100644 +--- a/tests/components/prusalink/test_sensor.py ++++ b/tests/components/prusalink/test_sensor.py +@@ -14,7 +14,9 @@ + from homeassistant.const import ( + ATTR_DEVICE_CLASS, + ATTR_UNIT_OF_MEASUREMENT, ++ PERCENTAGE, + Platform, ++ UnitOfLength, + UnitOfTemperature, + ) + from homeassistant.core import HomeAssistant +@@ -63,6 +65,36 @@ async def test_sensors_no_job(hass: HomeAssistant, mock_config_entry, mock_api) + assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE + assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT + ++ state = hass.states.get("sensor.mock_title_heatbed_target_temperature") ++ assert state is not None ++ assert state.state == "60.5" ++ assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfTemperature.CELSIUS ++ assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE ++ assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT ++ ++ state = hass.states.get("sensor.mock_title_nozzle_target_temperature") ++ assert state is not None ++ assert state.state == "210.1" ++ assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfTemperature.CELSIUS ++ assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.TEMPERATURE ++ assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT ++ ++ state = hass.states.get("sensor.mock_title_z_height") ++ assert state is not None ++ assert state.state == "1.8" ++ assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfLength.MILLIMETERS ++ assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.DISTANCE ++ assert state.attributes[ATTR_STATE_CLASS] == SensorStateClass.MEASUREMENT ++ ++ state = hass.states.get("sensor.mock_title_print_speed") ++ assert state is not None ++ assert state.state == "100" ++ assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == PERCENTAGE ++ ++ state = hass.states.get("sensor.mock_title_material") ++ assert state is not None ++ assert state.state == "PLA" ++ + state = hass.states.get("sensor.mock_title_progress") + assert state is not None + assert state.state == "unavailable" +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+3TPU/cQBAG4Kv9K0ZKkxT+usNHlYIqVAQBTSq0Z8+dN7F3zcysxf37rM0JLkiB ++BoSizNPYGu+OX2vW2SbYrrlFN+aL91JEp1U1X6Pn1/m+rJblslhV61VcV5brYrWA6t0SHQkshgAW ++5L28tO615/+o7Gn+giy3te9745qM27d7x2vzPy2Wj/OvipM4/5N1WS6geLsIf/efz79uYB78Bpsk +++QRntdjRCIK0CAMSWxZ0AqMlCaaDeE4sedfHWsI+UI2Q+0Hy1qTjdIY21uXm0GPqd40Clz9uzr9f ++XJ7dnIN4CHxobqRusYFDly35/ikJ3g+ejnd+PQ75DR3SHJKM486I9Y4fOrCQdTvOfrJ38JnwLliK ++L9l6itHFyh6c6REI2Xdh2vclGfbSereCNO6uyQ6S/dG2wRE7P0CaWie4o7kMAwU2nXW/pjxXwc2f ++FA/SLn7vlJSP28bbWHqo5/EHG7yLYTh/bBKLbjs9zob9S8vmP5TRsadpZXoP6Zh89AlSSimllFJK ++KaWUUkoppZRSSimllFIf6TfY9h2tACgAAA== +diff --git 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-001508/tests/test.sh b/tasks/format-code-task-001508/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ce11a9cbbb0aadd77a54eea3209e0601f04b567f --- /dev/null +++ b/tasks/format-code-task-001508/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/components/prusalink/conftest.py +tests/components/prusalink/test_sensor.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-001508/tests/test_command.sh b/tasks/format-code-task-001508/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001508/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001530/environment/Dockerfile b/tasks/format-code-task-001530/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5b457f0eca14ea56e4854d42fc4bdbddaf61dd31 --- /dev/null +++ b/tasks/format-code-task-001530/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:54ba133b38f6328e0b4656e905898931b110f973b3bc0e0494badce5a72e0e25 diff --git a/tasks/format-code-task-001530/environment/setup/files/blocklist b/tasks/format-code-task-001530/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001530/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001530/environment/setup/setup.sh b/tasks/format-code-task-001530/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001530/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001530/tests/test.patch b/tasks/format-code-task-001530/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2c27250412d3371245a8674d3d6422dd81de0677 --- /dev/null +++ b/tasks/format-code-task-001530/tests/test.patch @@ -0,0 +1,40 @@ +diff --git a/tests/utils/test_convert_slow_tokenizer.py b/tests/utils/test_convert_slow_tokenizer.py +index c76fe6f1f91c..edeb06c390c0 100644 +--- a/tests/utils/test_convert_slow_tokenizer.py ++++ b/tests/utils/test_convert_slow_tokenizer.py +@@ -24,10 +24,12 @@ def test_spm_converter_bytefallback_warning(self): + + original_tokenizer_with_bytefallback = FakeOriginalTokenizer(vocab_file=spm_model_file_with_bytefallback) + +- with self.assertRaises(RuntimeError) as cm: ++ with warnings.catch_warnings(record=True) as w: + _ = SpmConverter(original_tokenizer_with_bytefallback) ++ self.assertEqual(len(w), 1) ++ + self.assertIn( + "The sentencepiece tokenizer that you are converting to a fast tokenizer uses the byte fallback option" + " which is not implemented in the fast tokenizers.", +- str(cm.exception), ++ str(w[0].message), + ) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SW4rDIBQG4DxnFW6gXtLaLCfkIlQm0aInDp3V1wRKS6HTl5ZhZv7vQQ9eUPnl ++3WzHoTEuieJdZFZrvfbZfb/WSley2sta1XUhldorWTD9thvdmCO1gbEieE/frXs2/0vxa/5kIjW9 ++n6bWDTweXnfGs/yV3l3zr/K42q35y9dd4bF/nn8/sDX4zgxl9HPoDRPLUwVPy5/orBNtTza1ZMrj ++iQ7ebdlmYrnMm9jSRDGTHePl+7hkAjVx9J8N+Q/j7JcJ/Hhim1T+9FsBAAAAAAAAAAAAAAAAAAAA ++AP6aM8MmY/IAKAAA +diff --git 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-001530/tests/test.sh b/tasks/format-code-task-001530/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..da0e04a0afcd1097fd625516afd01a75aca48394 --- /dev/null +++ b/tasks/format-code-task-001530/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/utils/test_convert_slow_tokenizer.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-001530/tests/test_command.sh b/tasks/format-code-task-001530/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001530/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001531/environment/Dockerfile b/tasks/format-code-task-001531/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..692ae1d79c574d6a4aeba275a6220220f013a397 --- /dev/null +++ b/tasks/format-code-task-001531/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0efd5f8b834f2b1e896cd948b36fe68f812d7d3b45e0044d9677c7f54558f7bd diff --git a/tasks/format-code-task-001531/environment/setup/files/blocklist b/tasks/format-code-task-001531/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001531/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001531/environment/setup/setup.sh b/tasks/format-code-task-001531/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001531/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001531/tests/test.patch b/tasks/format-code-task-001531/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..832e587e0427b0da284b2d9d654b6493bfe53cbc --- /dev/null +++ b/tasks/format-code-task-001531/tests/test.patch @@ -0,0 +1,145 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..a6775215b1 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest tests/test_modeling_utils.py::SlidingWindowInclusiveTester -v"] ++} +diff --git a/tests/test_modeling_utils.py b/tests/test_modeling_utils.py +index d0db5031e8..30163bbb5a 100755 +--- a/tests/test_modeling_utils.py ++++ b/tests/test_modeling_utils.py +@@ -1882,6 +1882,118 @@ class AttentionMaskTester(unittest.TestCase): + self.assertTrue(torch.equal(expanded_mask, result)) + + ++@require_torch ++class SlidingWindowInclusiveTester(unittest.TestCase): ++ """Tests for sliding-window mask semantics. ++ ++ With sliding_window=N, position i must attend to itself and N previous positions ++ (inclusive of self) -- i.e. attended set is {i-N, ..., i} for indices >= 0. ++ """ ++ ++ @staticmethod ++ def _attended_per_row(mask_4d): ++ ++ attended = (mask_4d[0, 0] == 0).to(torch.int32) ++ return attended ++ ++ def test_sliding_window_inclusive_size_2_no_past(self): ++ conv = AttentionMaskConverter(is_causal=True, sliding_window=2) ++ mask_4d = conv.to_causal_4d(1, 6, 6, dtype=torch.float32, device=torch_device) ++ attended = self._attended_per_row(mask_4d).cpu() ++ expected = torch.tensor( ++ [ ++ [1, 0, 0, 0, 0, 0], ++ [1, 1, 0, 0, 0, 0], ++ [1, 1, 1, 0, 0, 0], ++ [0, 1, 1, 1, 0, 0], ++ [0, 0, 1, 1, 1, 0], ++ [0, 0, 0, 1, 1, 1], ++ ], ++ dtype=torch.int32, ++ ) ++ self.assertTrue(torch.equal(attended, expected)) ++ ++ def test_sliding_window_inclusive_size_3_no_past(self): ++ conv = AttentionMaskConverter(is_causal=True, sliding_window=3) ++ mask_4d = conv.to_causal_4d(1, 6, 6, dtype=torch.float32, device=torch_device) ++ attended = self._attended_per_row(mask_4d).cpu() ++ expected = torch.tensor( ++ [ ++ [1, 0, 0, 0, 0, 0], ++ [1, 1, 0, 0, 0, 0], ++ [1, 1, 1, 0, 0, 0], ++ [1, 1, 1, 1, 0, 0], ++ [0, 1, 1, 1, 1, 0], ++ [0, 0, 1, 1, 1, 1], ++ ], ++ dtype=torch.int32, ++ ) ++ self.assertTrue(torch.equal(attended, expected)) ++ ++ def test_sliding_window_inclusive_size_1_no_past(self): ++ ++ conv = AttentionMaskConverter(is_causal=True, sliding_window=1) ++ mask_4d = conv.to_causal_4d(1, 5, 5, dtype=torch.float32, device=torch_device) ++ attended = self._attended_per_row(mask_4d).cpu() ++ expected = torch.tensor( ++ [ ++ [1, 0, 0, 0, 0], ++ [1, 1, 0, 0, 0], ++ [0, 1, 1, 0, 0], ++ [0, 0, 1, 1, 0], ++ [0, 0, 0, 1, 1], ++ ], ++ dtype=torch.int32, ++ ) ++ self.assertTrue(torch.equal(attended, expected)) ++ ++ def test_sliding_window_inclusive_attended_count_per_row(self): ++ ++ sliding_window = 4 ++ seq_len = 10 ++ conv = AttentionMaskConverter(is_causal=True, sliding_window=sliding_window) ++ mask_4d = conv.to_causal_4d(1, seq_len, seq_len, dtype=torch.float32, device=torch_device) ++ attended = self._attended_per_row(mask_4d).cpu() ++ for i in range(seq_len): ++ expected_count = min(sliding_window + 1, i + 1) ++ self.assertEqual(int(attended[i].sum().item()), expected_count, f"row {i} mismatch") ++ ++ def test_sliding_window_inclusive_with_past_kv(self): ++ ++ conv = AttentionMaskConverter(is_causal=True, sliding_window=2) ++ mask_4d = conv.to_causal_4d(1, 4, 7, dtype=torch.float32, device=torch_device) ++ attended = self._attended_per_row(mask_4d).cpu() ++ expected = torch.tensor( ++ [ ++ [0, 1, 1, 1, 0, 0, 0], ++ [0, 0, 1, 1, 1, 0, 0], ++ [0, 0, 0, 1, 1, 1, 0], ++ [0, 0, 0, 0, 1, 1, 1], ++ ], ++ dtype=torch.int32, ++ ) ++ self.assertTrue(torch.equal(attended, expected)) ++ ++ def test_sliding_window_inclusive_via_to_4d(self): ++ ++ conv = AttentionMaskConverter(is_causal=True, sliding_window=2) ++ mask_2d = torch.ones((1, 6), dtype=torch.long, device=torch_device) ++ mask_4d = conv.to_4d(mask_2d, query_length=6, key_value_length=6, dtype=torch.float32) ++ attended = self._attended_per_row(mask_4d).cpu() ++ ++ self.assertEqual(int(attended[5, 3].item()), 1) ++ self.assertEqual(int(attended[5, 4].item()), 1) ++ self.assertEqual(int(attended[5, 5].item()), 1) ++ ++ self.assertEqual(int(attended[5, 0].item()), 0) ++ self.assertEqual(int(attended[5, 1].item()), 0) ++ self.assertEqual(int(attended[5, 2].item()), 0) ++ ++ self.assertEqual(int(attended[2, 0].item()), 1) ++ self.assertEqual(int(attended[2, 1].item()), 1) ++ self.assertEqual(int(attended[2, 2].item()), 1) ++ ++ + @require_torch + class TestAttentionImplementation(unittest.TestCase): + def test_error_no_sdpa_available(self): +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest tests/test_modeling_utils.py::SlidingWindowInclusiveTester -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001531/tests/test.sh b/tasks/format-code-task-001531/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a5bfdfc5c13b0245c6d8676ea7107fab05e95b2c --- /dev/null +++ b/tasks/format-code-task-001531/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_modeling_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-001531/tests/test_command.sh b/tasks/format-code-task-001531/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001531/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001536/environment/Dockerfile b/tasks/format-code-task-001536/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d063edfdb51638ed08ed67ed93ca504b41716543 --- /dev/null +++ b/tasks/format-code-task-001536/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3b220197e877e97c541eba4a17cbf0fb66fba73665ceb7a613f1d79e20bfc191 diff --git a/tasks/format-code-task-001536/environment/setup/files/blocklist b/tasks/format-code-task-001536/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001536/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001536/environment/setup/setup.sh b/tasks/format-code-task-001536/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001536/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001536/tests/test.patch b/tasks/format-code-task-001536/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0f882d8a4f39ac51e07287c6d4757f65844295a9 --- /dev/null +++ b/tasks/format-code-task-001536/tests/test.patch @@ -0,0 +1,215 @@ +diff --git a/core_test.go b/core_test.go +index 5455eedd..e680d95c 100644 +--- a/core_test.go ++++ b/core_test.go +@@ -699,6 +699,183 @@ func TestMatExtractChannel(t *testing.T) { + dst.Close() + } + ++func TestMatFindNonZero(t *testing.T) { ++ src := NewMatWithSize(10, 10, MatTypeCV8U) ++ defer src.Close() ++ src.SetFloatAt(3, 3, 17) ++ src.SetFloatAt(4, 4, 17) ++ ++ dst := NewMat() ++ defer dst.Close() ++ ++ FindNonZero(src, dst) ++ ++ if dst.Empty() { ++ t.Error("TestMatFindNonZero dst should not be empty.") ++ } ++ if dst.Rows() != 2*2 { ++ t.Error("TestMatFindNonZero didn't find all nonzero locations.") ++ } ++} ++ ++func TestMatFlip(t *testing.T) { ++ src := NewMatWithSize(10, 10, MatTypeCV32F) ++ defer src.Close() ++ ++ dst := NewMat() ++ defer dst.Close() ++ ++ Flip(src, dst, 0) ++ ++ if dst.Empty() { ++ t.Error("TestMatFlip dst should not be empty.") ++ } ++ if dst.Rows() != src.Rows() { ++ t.Error("TestMatFlip src and dst size should be same.") ++ } ++} ++ ++func TestMatGemm(t *testing.T) { ++ src1 := NewMatWithSize(3, 4, MatTypeCV32F) ++ defer src1.Close() ++ ++ src2 := NewMatWithSize(4, 3, MatTypeCV32F) ++ defer src2.Close() ++ ++ src3 := NewMat() ++ defer src3.Close() ++ ++ dst := NewMat() ++ defer dst.Close() ++ ++ Gemm(src1, src2, 1, src3, 0, dst, 0) ++ ++ if dst.Empty() { ++ t.Error("Gemm dst should not be empty.") ++ } ++ if dst.Rows() != src1.Rows() { ++ t.Error("Gemm src and dst size should be same.") ++ } ++} ++ ++func TestMatHconcat(t *testing.T) { ++ src := NewMatWithSize(10, 10, MatTypeCV32F) ++ defer src.Close() ++ ++ dst := NewMat() ++ defer dst.Close() ++ ++ Hconcat(src, src, dst) ++ ++ if dst.Empty() { ++ t.Error("TestMatHconcat dst should not be empty.") ++ } ++ if dst.Cols() != 2*src.Cols() { ++ t.Error("TestMatHconcat dst.Cols should be 2 x src.Cols.") ++ } ++} ++ ++func TestMatIdct(t *testing.T) { ++ src := NewMatWithSize(4, 4, MatTypeCV32F) ++ defer src.Close() ++ ++ dst := NewMat() ++ defer dst.Close() ++ ++ Idct(src, dst, 0) ++ if dst.Empty() { ++ t.Error("Idct dst should not be empty.") ++ } ++ if dst.Rows() != src.Rows() { ++ t.Error("Idct src and dst size should be same.") ++ } ++} ++ ++func TestMatIdft(t *testing.T) { ++ src := NewMatWithSize(4, 4, MatTypeCV32F) ++ defer src.Close() ++ ++ dst := NewMat() ++ defer dst.Close() ++ ++ Idft(src, dst, 0, 0) ++ if dst.Empty() { ++ t.Error("Idct dst should not be empty.") ++ } ++ if dst.Rows() != src.Rows() { ++ t.Error("Idct src and dst size should be same.") ++ } ++} ++ ++func TestMatInsertChannel(t *testing.T) { ++ src := NewMatWithSize(4, 4, MatTypeCV8U) ++ defer src.Close() ++ ++ dst := NewMatWithSize(4, 4, MatTypeCV8UC3) ++ defer dst.Close() ++ ++ InsertChannel(src, dst, 1) ++ if dst.Channels() != 3 { ++ t.Error("TestMatInsertChannel dst should change the channel count") ++ } ++} ++ ++func TestMatInvert(t *testing.T) { ++ src := NewMatWithSize(4, 4, MatTypeCV32F) ++ defer src.Close() ++ ++ dst := NewMat() ++ defer dst.Close() ++ ++ Invert(src, dst, 0) ++ if dst.Empty() { ++ t.Error("Invert dst should not be empty.") ++ } ++} ++ ++func TestMatLog(t *testing.T) { ++ src := NewMatWithSize(4, 3, MatTypeCV32F) ++ defer src.Close() ++ ++ dst := NewMat() ++ defer dst.Close() ++ ++ Log(src, dst) ++ if dst.Empty() { ++ t.Error("Log dst should not be empty.") ++ } ++} ++ ++func TestMatMagnitude(t *testing.T) { ++ src1 := NewMatWithSize(4, 4, MatTypeCV32F) ++ defer src1.Close() ++ src2 := NewMatWithSize(4, 4, MatTypeCV32F) ++ defer src2.Close() ++ ++ dst := NewMat() ++ defer dst.Close() ++ ++ Magnitude(src1, src2, dst) ++ if dst.Empty() { ++ t.Error("Magnitude dst should not be empty.") ++ } ++} ++ ++func TestMatMax(t *testing.T) { ++ src1 := NewMatWithSize(4, 4, MatTypeCV32F) ++ defer src1.Close() ++ src2 := NewMatWithSize(4, 4, MatTypeCV32F) ++ defer src2.Close() ++ ++ dst := NewMat() ++ defer dst.Close() ++ ++ Max(src1, src2, dst) ++ if dst.Empty() { ++ t.Error("Max dst should not be empty.") ++ } ++} ++ + func TestMatToImage(t *testing.T) { + mat1 := NewMatWithSize(101, 102, MatTypeCV8UC3) + defer mat1.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,11 @@ ++H4sIAAAAAAAAA+2TQW/aMBTHOedTvNHLpiqEsFJOHDpoWaVUoEKn7jJkbEO8OnZkO1Fb7cPPyQSB ++Sl13aDVNe7+L/d77x372P+6sCiHZkqsyar0VXc+g369Hz9Oxnsf9Xhyf9rtxz+viuD8YtKD/Zh3t ++UVhHDEDLaO1+p3up/o/Safx33Lol1VlGFOvY9PX2eMH/+KQ32PnfPT3x/p+c9uIWdF+vhef5z/0/ ++ehethIpWxKYBZVD/BCvOguAI5txBkcNkOjtbfAb7kEmh7sBqcCkHkeXaOMiJS2GjadkROrqPqhkY ++brUsuQ2yOyYMhDlE1eX5YmQNjXbqQCoI7Xq35zOyelb1c65KYbTKuHKw1gZGEx1Nc65GXwJ+X3cz ++mcZxfDUd3yTnQ71eN+nqBMPt8tv0aDJdjmazi+RsMh+2w8uosCaSmhIZCUVlwXj7QHp7u5WG1rEh ++PT6OHw8UyXgrSPbWkmIFodS+UVr652V4E6Vik24K0SRKwbgWukmIbJMbTQ8SVDNObZPSq++MO05d ++k1pz4grvQ489WbsJmVJ7bRHf5cc9cZ5qtye2TjiaCrXZ20ISpXbHT8bL5PLT9dn112V91+3DC2hX ++/l0XCoiUUNltYW10BtV1LKu4423Z6LoEYQkh1YVywxhC4z9qf3u/8IUr4n5UY3KzqMcrTtTcsTEv ++63DBTTYywnEjSJ2Y+82J+VXTo5kWytk6mnA3zZ3IiBxfLObikX9oP/mHg7/9LBEEQRAEQRAEQRAE ++QRAEQRAEQRAEQRAEQf6Yny2KFfcAKAAA +diff --git 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-001536/tests/test.sh b/tasks/format-code-task-001536/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..887069999571e302ba1b5a97295da8bf5b7249a6 --- /dev/null +++ b/tasks/format-code-task-001536/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' +core_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-001536/tests/test_command.sh b/tasks/format-code-task-001536/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001536/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001537/environment/Dockerfile b/tasks/format-code-task-001537/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b8e5ebb1da34f8962f990a7acd455b44a8bbc2e6 --- /dev/null +++ b/tasks/format-code-task-001537/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c42fbe4776d4642ee65a51a3f5ec5f518e5b274cd72496c9741c3578b8e4e9a4 diff --git a/tasks/format-code-task-001537/environment/setup/files/blocklist b/tasks/format-code-task-001537/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001537/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001537/environment/setup/setup.sh b/tasks/format-code-task-001537/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001537/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001537/tests/test.patch b/tasks/format-code-task-001537/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5ab5c5e3d85cd22953116030280ecd80d57aa5d5 --- /dev/null +++ b/tasks/format-code-task-001537/tests/test.patch @@ -0,0 +1,56 @@ +diff --git a/imgproc_test.go b/imgproc_test.go +index 72ff7143..359ba5c9 100644 +--- a/imgproc_test.go ++++ b/imgproc_test.go +@@ -71,6 +71,23 @@ func TestConvexity(t *testing.T) { + } + } + ++func TestMinEnclosingCircle(t *testing.T) { ++ pts := []image.Point{ ++ image.Pt(0, 2), ++ image.Pt(2, 0), ++ image.Pt(0, -2), ++ image.Pt(-2, 0), ++ image.Pt(1, -1), ++ } ++ x, y, radius := MinEnclosingCircle(pts) ++ const epsilon = 0.001 ++ if math.Abs(float64(radius-2.0)) > epsilon || ++ math.Abs(float64(x-0.0)) > epsilon || ++ math.Abs(float64(y-0.0)) > epsilon { ++ t.Error("Invalid circle returned in MinEnclosingCircle test") ++ } ++} ++ + func TestCvtColor(t *testing.T) { + img := IMRead("images/face-detect.jpg", IMReadColor) + if img.Empty() { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,12 @@ ++H4sIAAAAAAAAA+2UXW/bIBSGc+1fwaLdOq7dOJU25aJK26xatkRbdzVNFgFss9qAAKduf/2Iq9Sk ++68dNu2naeW6Al8PXeYHRuuEVzZjYRIPX4sBxlKZd6bhfdvU4TeIkSY+Oxk6P48nBZIDSV9uRR2Ms ++1ggNtJT2qbjn+v9RRr3/lhmbEVnXWNCRKV9ujWf8Tw6T9M7/Sbr1fzxJxgN08HJbeJz/3H9CUWf8 ++mtEgYK2S2qL58styeTGNpLJRIcN4FI93Xavjiw97HdGai3dvt3I/+jZomzAX1ctxHH9annxbnE5l ++nu/k2XyZzVars8Xx/Ot0GJ5HjdFRJQmuIi5I1VDmVmOCbMZDf8jiZDdi4Y2o+BqF1W28u8ma9S1e ++F0pLsicQSRkxvVTyoiwa3gsbTpm81+SeINc/KbOMWG9V7DZxSHtBldJ6Q3KGbaOZSbyQvMJC9E3q ++N+qqrxvLLSm5KHoJ64Z4s68Lw4raa3PJhVFcM2850u1xb72HTkKVN1GOiZfMXDNmr5WvNDc3114m ++c7OX6azEpuyViguWUWaI5spK7ScLG5Y14kpjpfYOqirp7U0zr0sXa+90xh3OVa79tDHt22isS9rW ++BOo2UpTetKZRTDtzPIeVzSt55YfobS6yGt+3wmpMLvcUiq07jvWms6z1lmsfugymxH5i298ubvuA ++V213y+5eyOrjPJstP5+dz7PuLQ7330ikLt3dFzkvhkFQX1LuHFBo92Ajo4kryGbEZdQGPEff0RsU ++skcCuhr68R7ZkokAOSp3fc3dr/LUsCDnQUCeDikk2s6Ewg0KdSPQ8MK1PnFx6n4HaVy+Z1yTig1R ++SGQj7DRGo+Bvf6oAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8If5BeOoo28AKAAA +diff --git 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-001537/tests/test.sh b/tasks/format-code-task-001537/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..38f2e0f4180aafdf582571d1cd853eb252755c95 --- /dev/null +++ b/tasks/format-code-task-001537/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' +imgproc_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-001537/tests/test_command.sh b/tasks/format-code-task-001537/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001537/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001552/environment/Dockerfile b/tasks/format-code-task-001552/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1b0afd59f4f7f5d2c9cb50701cbb03a2ef3fa225 --- /dev/null +++ b/tasks/format-code-task-001552/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:212a7bc4fb4bdeba7255c0bf50166b30b91b025a7a0d6459bfd7d91981252326 diff --git a/tasks/format-code-task-001552/environment/setup/files/blocklist b/tasks/format-code-task-001552/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001552/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001552/environment/setup/setup.sh b/tasks/format-code-task-001552/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001552/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001552/tests/test.patch b/tasks/format-code-task-001552/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..53e3feb088a5df973b8a1c61ff496710c7ea6839 --- /dev/null +++ b/tasks/format-code-task-001552/tests/test.patch @@ -0,0 +1,107 @@ +diff --git a/ibis/tests/expr/test_relocate.py b/ibis/tests/expr/test_relocate.py +index 6e34967a9..5485e8a90 100644 +--- a/ibis/tests/expr/test_relocate.py ++++ b/ibis/tests/expr/test_relocate.py +@@ -86,3 +86,80 @@ def test_no_arguments(): + t = ibis.table(dict(x="int", y="int", z="int")) + with pytest.raises(exc.IbisInputError, match="At least one selector"): + assert t.relocate() ++ ++ ++def test_positional_string_before_selector_preserves_order(): ++ ++ ++ t = ibis.table( ++ { ++ "species": "string", ++ "island": "string", ++ "bill_length_mm": "float", ++ "bill_depth_mm": "float", ++ "flipper_length_mm": "int", ++ "body_mass_g": "int", ++ "sex": "string", ++ "year": "int", ++ } ++ ) ++ assert t.relocate("year", s.numeric()).columns == [ ++ "year", ++ "bill_length_mm", ++ "bill_depth_mm", ++ "flipper_length_mm", ++ "body_mass_g", ++ "species", ++ "island", ++ "sex", ++ ] ++ ++ ++def test_positional_selector_before_string_preserves_order(): ++ ++ ++ ++ t = ibis.table( ++ { ++ "species": "string", ++ "island": "string", ++ "bill_length_mm": "float", ++ "bill_depth_mm": "float", ++ "flipper_length_mm": "int", ++ "body_mass_g": "int", ++ "sex": "string", ++ "year": "int", ++ } ++ ) ++ assert t.relocate(s.numeric(), "year").columns == [ ++ "bill_length_mm", ++ "bill_depth_mm", ++ "flipper_length_mm", ++ "body_mass_g", ++ "year", ++ "species", ++ "island", ++ "sex", ++ ] ++ ++ ++def test_positional_duplicate_first_occurrence_wins(): ++ ++ ++ t = ibis.table( ++ dict(a="int", b="string", c="int", d="string") ++ ) ++ assert t.relocate("b", s.of_type("string")).columns == ["b", "d", "a", "c"] ++ ++ ++def test_kwarg_duplicate_rename_last_wins(): ++ ++ t = ibis.table(dict(a="int", b="string", c="int", d="string")) ++ assert t.relocate(e="d", f="d").columns == ["f", "a", "b", "c"] ++ ++ ++def test_positional_then_kwarg_rename_of_same_column(): ++ ++ ++ t = ibis.table(dict(x="int", y="int")) ++ assert t.relocate("x", z="x").columns == ["z", "y"] +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..98845d7b5 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest ibis/tests/expr/test_relocate.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 ibis/tests/expr/test_relocate.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001552/tests/test.sh b/tasks/format-code-task-001552/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d02929e7d0ca9b12438770fe8149a53078291f22 --- /dev/null +++ b/tasks/format-code-task-001552/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' +ibis/tests/expr/test_relocate.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-001552/tests/test_command.sh b/tasks/format-code-task-001552/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001552/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001555/environment/Dockerfile b/tasks/format-code-task-001555/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e2f4bf1565f2e8e483e6d0b724c203cf12a30e85 --- /dev/null +++ b/tasks/format-code-task-001555/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4f680d08dd0abe286e717cb184bfbcd03eef9564fcf58c102f0bd060830e0ef7 diff --git a/tasks/format-code-task-001555/environment/setup/files/blocklist b/tasks/format-code-task-001555/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001555/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001555/environment/setup/setup.sh b/tasks/format-code-task-001555/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001555/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001555/tests/test.patch b/tasks/format-code-task-001555/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b4083890d0cf91c8d430c328ac6401681a1e376e --- /dev/null +++ b/tasks/format-code-task-001555/tests/test.patch @@ -0,0 +1,280 @@ +diff --git a/usercase-test-coderl/comm_declarative_message_filter.test.js b/usercase-test-coderl/comm_declarative_message_filter.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/comm_declarative_message_filter.test.js +@@ -0,0 +1,250 @@ ++import { describe, it, before, beforeEach, afterEach } from 'mocha'; ++import { expect } from 'chai'; ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++const directRule = { conditions: [{ field: 'player.name', value: '43Bad' }] }; ++const regexRule = { conditions: [{ field: 'markup[0][1].plain', pattern: /UK\)$/i }] }; ++const matchingDirectMessage = { player: { name: '43Bad', team: 2 } }; ++const nonMatchingDirectMessage = { player: { name: 'Spedd', team: 2 } }; ++const matchingRegexMessage = { ++ player: { name: 'Q77n', team: 1 }, ++ markup: [['PORTAL', { plain: 'Bridge (UK)' }]], ++}; ++const nonMatchingRegexMessage = { ++ player: { name: 'Q77n', team: 1 }, ++ markup: [['PORTAL', { plain: 'Bridge (US)' }]], ++}; ++ ++function filter() { ++ return IITC.comm.declarativeMessageFilter; ++} ++ ++function resetRules() { ++ for (const id of Object.keys(filter().getAllRules())) { ++ filter().removeRule(id); ++ } ++} ++ ++describe('usercase COMM declarative message filter acceptance', () => { ++ let originalWarn; ++ let originalError; ++ ++ before(async () => { ++ globalThis.window.TEAM_TO_CSS = { 1: 'res', 2: 'enl' }; ++ globalThis.window.PLAYER = { nickname: 'local' }; ++ globalThis.window.scrollBottom = () => 0; ++ globalThis.chat = { keepScrollPosition: () => {} }; ++ ++ await import('../core/code/comm.js'); ++ await import('../core/code/comm_declarative_message_filter.js'); ++ }); ++ ++ beforeEach(() => { ++ originalWarn = console.warn; ++ originalError = console.error; ++ resetRules(); ++ }); ++ ++ afterEach(() => { ++ console.warn = originalWarn; ++ console.error = originalError; ++ resetRules(); ++ }); ++ ++ it('retains added direct and regex rules across singleton calls and removes by ID', () => { ++ ++ ++ expect(filter().getRuleById('directComparison')).to.equal(null); ++ expect(filter().getAllRules()).to.deep.equal({}); ++ ++ filter().addRule('directComparison', directRule); ++ expect(filter().getRuleById('directComparison')).to.deep.equal({ conditions: [{ field: 'player.name', value: '43Bad' }] }); ++ expect(Object.keys(filter().getAllRules())).to.deep.equal(['directComparison']); ++ expect(filter().filterMessage(matchingDirectMessage)).to.equal(true); ++ expect(filter().filterMessage(nonMatchingDirectMessage)).to.equal(false); ++ ++ filter().addRule('regexPattern', regexRule); ++ ++ expect(Object.keys(filter().getAllRules()).sort()).to.deep.equal(['directComparison', 'regexPattern']); ++ expect(filter().filterMessage(matchingRegexMessage)).to.equal(true); ++ expect(filter().filterMessage(nonMatchingRegexMessage)).to.equal(false); ++ expect(filter().filterMessage(matchingDirectMessage)).to.equal(true); ++ ++ filter().removeRule('directComparison'); ++ expect(filter().getRuleById('directComparison')).to.equal(null); ++ expect(Object.keys(filter().getAllRules())).to.deep.equal(['regexPattern']); ++ expect(filter().filterMessage(matchingDirectMessage)).to.equal(false); ++ expect(filter().filterMessage(matchingRegexMessage)).to.equal(true); ++ }); ++ ++ it('requires every condition in a rule to match', () => { ++ ++ ++ filter().addRule('bothConditions', { ++ conditions: [ ++ { field: 'player.name', value: '43Bad' }, ++ { field: 'player.team', value: 2 }, ++ ], ++ }); ++ ++ expect(filter().filterMessage({ player: { name: '43Bad', team: 2 } })).to.equal(true); ++ expect(filter().filterMessage({ player: { name: '43Bad', team: 1 } })).to.equal(false); ++ expect(filter().filterMessage({ player: { name: 'Spedd', team: 2 } })).to.equal(false); ++ }); ++ ++ it('supports inverted conditions and invalid condition non-matches', () => { ++ ++ ++ filter().addRule('invertCondition', { conditions: [{ field: 'player.team', value: 1, invert: true }] }); ++ expect(filter().filterMessage({ player: { team: 2 } })).to.equal(true); ++ expect(filter().filterMessage({ player: { team: 1 } })).to.equal(false); ++ ++ resetRules(); ++ filter().addRule('missingField', { conditions: [{ field: 'player.badge', value: 'x' }] }); ++ expect(filter().filterMessage({ player: { name: '43Bad' } })).to.equal(false); ++ ++ resetRules(); ++ filter().addRule('missingComparator', { conditions: [{ field: 'player.name' }] }); ++ expect(filter().filterMessage({ player: { name: '43Bad' } })).to.equal(false); ++ }); ++ ++ it('overwrites an existing ID and logs the observed warning', () => { ++ ++ ++ const warnings = []; ++ console.warn = (message) => warnings.push(message); ++ ++ filter().addRule('sameId', { conditions: [{ field: 'player.name', value: 'first' }] }); ++ filter().addRule('sameId', { conditions: [{ field: 'player.name', value: 'second' }] }); ++ ++ expect(filter().getRuleById('sameId')).to.deep.equal({ conditions: [{ field: 'player.name', value: 'second' }] }); ++ ++ expect(warnings).to.have.lengthOf(1); ++ expect(String(warnings[0]).trim()).to.not.equal(''); ++ expect(filter().filterMessage({ player: { name: 'first' } })).to.equal(false); ++ expect(filter().filterMessage({ player: { name: 'second' } })).to.equal(true); ++ }); ++ ++ it('logs an exact error and leaves state unchanged when removing an unknown ID', () => { ++ ++ ++ const errors = []; ++ console.error = (message) => errors.push(message); ++ ++ filter().removeRule('unknown'); ++ ++ ++ expect(errors).to.have.lengthOf(1); ++ expect(String(errors[0]).trim()).to.not.equal(''); ++ expect(filter().getAllRules()).to.deep.equal({}); ++ }); ++ ++ it('can remove the same rule twice without throwing while reporting the second removal error', () => { ++ ++ ++ const errors = []; ++ console.error = (message) => errors.push(message); ++ ++ filter().addRule('temporary', directRule); ++ expect(filter().getAllRules()).to.deep.equal({ temporary: { conditions: [{ field: 'player.name', value: '43Bad' }] } }); ++ ++ expect(() => filter().removeRule('temporary')).to.not.throw(); ++ expect(filter().getAllRules()).to.deep.equal({}); ++ expect(() => filter().removeRule('temporary')).to.not.throw(); ++ ++ ++ expect(errors).to.have.lengthOf(1); ++ expect(String(errors[0]).trim()).to.not.equal(''); ++ expect(filter().getAllRules()).to.deep.equal({}); ++ }); ++ ++ it('keeps independently named rules from sharing or corrupting each other', () => { ++ ++ ++ filter().addRule('a', { conditions: [{ field: 'player.name', value: '43Bad' }] }); ++ filter().addRule('b', { conditions: [{ field: 'player.name', value: 'Spedd' }] }); ++ filter().removeRule('a'); ++ ++ expect(filter().getRuleById('a')).to.equal(null); ++ expect(filter().getRuleById('b')).to.deep.equal({ conditions: [{ field: 'player.name', value: 'Spedd' }] }); ++ ++ expect(Object.keys(filter().getAllRules()).sort()).to.deep.equal(['b']); ++ expect(filter().filterMessage({ player: { name: '43Bad' } })).to.equal(false); ++ expect(filter().filterMessage({ player: { name: 'Spedd' } })).to.equal(true); ++ }); ++ ++ it('keeps the public rule counter bounded across repeated add/remove cleanup cycles', () => { ++ ++ ++ expect(Object.keys(filter().getAllRules()).length).to.equal(0); ++ ++ for (let i = 0; i < 150; i += 1) { ++ const id = `cycle-${i}`; ++ filter().addRule(id, { conditions: [{ field: 'player.name', value: `agent-${i}` }] }); ++ expect(filter().filterMessage({ player: { name: `agent-${i}` } })).to.equal(true); ++ filter().removeRule(id); ++ expect(Object.keys(filter().getAllRules()).length).to.equal(0); ++ } ++ ++ expect(filter().getAllRules()).to.deep.equal({}); ++ }); ++ ++ it('omits matching parsed COMM rows from rendered chat while keeping non-matches', () => { ++ ++ ++ filter().addRule('hide43Bad', directRule); ++ ++ let htmlValue = null; ++ const dataStore = {}; ++ const fakeElement = { ++ is(selector) { ++ if (selector === ':hidden') return false; ++ if (selector === ':empty') return htmlValue === null; ++ return false; ++ }, ++ html(value) { ++ if (value !== undefined) htmlValue = value; ++ return htmlValue; ++ }, ++ data(key, value) { ++ if (value !== undefined) dataStore[key] = value; ++ return dataStore[key]; ++ }, ++ scrollTop(value) { ++ dataStore.scrollTop = value; ++ }, ++ }; ++ globalThis.$ = (selector) => { ++ ++ expect(String(selector)).to.include('chatall'); ++ return fakeElement; ++ }; ++ ++ const commData = { ++ g1: [1700000000000, false, 'Spedd row', 'Spedd', { player: { name: 'Spedd' } }], ++ g2: [1700000001000, false, '43Bad row', '43Bad', { player: { name: '43Bad' } }], ++ g3: [1700000002000, false, 'Q77n row', 'Q77n', { player: { name: 'Q77n' } }], ++ }; ++ ++ IITC.comm.renderData(commData, 'chatall', false, ['g1', 'g2', 'g3']); ++ ++ ++ expect(htmlValue).to.include('data-guid="g1"'); ++ expect(htmlValue).to.include('Spedd row'); ++ expect(htmlValue).to.include('data-guid="g3"'); ++ expect(htmlValue).to.include('Q77n row'); ++ expect(htmlValue).to.not.include('data-guid="g2"'); ++ expect(htmlValue).to.not.include('43Bad row'); ++ ++ expect(htmlValue).to.be.a('string').and.not.equal(''); ++ }); ++}); +diff --git 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 node_modules/.bin/mocha ]; then ++ echo "Missing local mocha install; node_modules must be preinstalled for offline test execution." >&2 ++ exit 127 ++fi ++ ++exec ./node_modules/.bin/mocha -r test/_mocks.js --exit /workspace/repo/usercase-test-coderl/comm_declarative_message_filter.test.js diff --git a/tasks/format-code-task-001555/tests/test.sh b/tasks/format-code-task-001555/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8e0d87882b2421f922dd7d433e74355fbae7cfe1 --- /dev/null +++ b/tasks/format-code-task-001555/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/comm_declarative_message_filter.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-001555/tests/test_command.sh b/tasks/format-code-task-001555/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001555/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-001563/environment/Dockerfile b/tasks/format-code-task-001563/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..16ba0478628546eb9f19b8460bb847746675f3ab --- /dev/null +++ b/tasks/format-code-task-001563/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6fcbd03b0858045f4fd6d5adf62565d2bb2d29027b29469310459feac73b48dc diff --git a/tasks/format-code-task-001563/environment/setup/files/blocklist b/tasks/format-code-task-001563/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001563/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001563/environment/setup/setup.sh b/tasks/format-code-task-001563/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001563/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001563/tests/test.patch b/tasks/format-code-task-001563/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..cc0fba5d7c80d8bdd7e6ff07ea91eff49e3bd354 --- /dev/null +++ b/tasks/format-code-task-001563/tests/test.patch @@ -0,0 +1,305 @@ +diff --git a/influxql/select_test.go b/influxql/select_test.go +index 091a98b090..c2f7997ab4 100644 +--- a/influxql/select_test.go ++++ b/influxql/select_test.go +@@ -1592,36 +1592,255 @@ func TestSelect_BinaryExpr_NilValues(t *testing.T) { + Name: "nil binary add", + Statement: `SELECT total + value FROM cpu`, + Points: [][]influxql.Point{ +- {&influxql.FloatPoint{Name: "cpu", Time: 0 * Second, Value: 20}}, ++ {&influxql.FloatPoint{Name: "cpu", Time: 0 * Second, Nil: true}}, + {&influxql.FloatPoint{Name: "cpu", Time: 5 * Second, Value: 25}}, +- {&influxql.FloatPoint{Name: "cpu", Time: 9 * Second, Value: 5}}, ++ {&influxql.FloatPoint{Name: "cpu", Time: 9 * Second, Nil: true}}, + }, + }, + { + Name: "nil binary subtract", + Statement: `SELECT total - value FROM cpu`, + Points: [][]influxql.Point{ +- {&influxql.FloatPoint{Name: "cpu", Time: 0 * Second, Value: 20}}, ++ {&influxql.FloatPoint{Name: "cpu", Time: 0 * Second, Nil: true}}, + {&influxql.FloatPoint{Name: "cpu", Time: 5 * Second, Value: -5}}, +- {&influxql.FloatPoint{Name: "cpu", Time: 9 * Second, Value: -5}}, ++ {&influxql.FloatPoint{Name: "cpu", Time: 9 * Second, Nil: true}}, + }, + }, + { + Name: "nil binary multiply", + Statement: `SELECT total * value FROM cpu`, + Points: [][]influxql.Point{ +- {&influxql.FloatPoint{Name: "cpu", Time: 0 * Second, Value: 0}}, ++ {&influxql.FloatPoint{Name: "cpu", Time: 0 * Second, Nil: true}}, + {&influxql.FloatPoint{Name: "cpu", Time: 5 * Second, Value: 150}}, +- {&influxql.FloatPoint{Name: "cpu", Time: 9 * Second, Value: 0}}, ++ {&influxql.FloatPoint{Name: "cpu", Time: 9 * Second, Nil: true}}, + }, + }, + { + Name: "nil binary division", + Statement: `SELECT total / value FROM cpu`, + Points: [][]influxql.Point{ +- {&influxql.FloatPoint{Name: "cpu", Time: 0 * Second, Value: 0}}, ++ {&influxql.FloatPoint{Name: "cpu", Time: 0 * Second, Nil: true}}, + {&influxql.FloatPoint{Name: "cpu", Time: 5 * Second, Value: float64(10) / float64(15)}}, +- {&influxql.FloatPoint{Name: "cpu", Time: 9 * Second, Value: 0}}, ++ {&influxql.FloatPoint{Name: "cpu", Time: 9 * Second, Nil: true}}, ++ }, ++ }, ++ } { ++ itrs, err := influxql.Select(MustParseSelectStatement(test.Statement), &ic, nil) ++ if err != nil { ++ t.Errorf("%s: parse error: %s", test.Name, err) ++ } else if a := Iterators(itrs).ReadAll(); !deep.Equal(a, test.Points) { ++ t.Errorf("%s: unexpected points: %s", test.Name, spew.Sdump(a)) ++ } ++ } ++} ++ ++func TestSelect_BinaryExpr_NilValues_FloatArithmeticAllOps(t *testing.T) { ++ var ic IteratorCreator ++ ic.CreateIteratorFn = func(opt influxql.IteratorOptions) (influxql.Iterator, error) { ++ return &FloatIterator{Points: []influxql.FloatPoint{ ++ {Name: "missing_float_ops", Time: 11 * Second, Value: 14.5, Aux: []interface{}{float64(14.5), nil}}, ++ {Name: "missing_float_ops", Time: 17 * Second, Value: 9, Aux: []interface{}{float64(9), float64(3)}}, ++ {Name: "missing_float_ops", Time: 23 * Second, Value: 2.5, Aux: []interface{}{nil, float64(2.5)}}, ++ }}, nil ++ } ++ ++ for _, test := range []struct { ++ Name string ++ Statement string ++ Points [][]influxql.Point ++ }{ ++ { ++ Name: "float add propagates missing operands", ++ Statement: `SELECT left_f + right_f FROM missing_float_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 11 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 17 * Second, Value: 12}}, ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 23 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "float subtract propagates missing operands", ++ Statement: `SELECT left_f - right_f FROM missing_float_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 11 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 17 * Second, Value: 6}}, ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 23 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "float multiply propagates missing operands", ++ Statement: `SELECT left_f * right_f FROM missing_float_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 11 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 17 * Second, Value: 27}}, ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 23 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "float division propagates missing operands", ++ Statement: `SELECT left_f / right_f FROM missing_float_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 11 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 17 * Second, Value: 3}}, ++ {&influxql.FloatPoint{Name: "missing_float_ops", Time: 23 * Second, Nil: true}}, ++ }, ++ }, ++ } { ++ itrs, err := influxql.Select(MustParseSelectStatement(test.Statement), &ic, nil) ++ if err != nil { ++ t.Errorf("%s: parse error: %s", test.Name, err) ++ } else if a := Iterators(itrs).ReadAll(); !deep.Equal(a, test.Points) { ++ t.Errorf("%s: unexpected points: %s", test.Name, spew.Sdump(a)) ++ } ++ } ++} ++ ++func TestSelect_BinaryExpr_NilValues_IntegerArithmeticAllOps(t *testing.T) { ++ var ic IteratorCreator ++ ic.CreateIteratorFn = func(opt influxql.IteratorOptions) (influxql.Iterator, error) { ++ return &IntegerIterator{Points: []influxql.IntegerPoint{ ++ {Name: "missing_integer_ops", Time: 31 * Second, Value: 21, Aux: []interface{}{int64(21), nil}}, ++ {Name: "missing_integer_ops", Time: 37 * Second, Value: 20, Aux: []interface{}{int64(20), int64(4)}}, ++ {Name: "missing_integer_ops", Time: 43 * Second, Value: 6, Aux: []interface{}{nil, int64(6)}}, ++ }}, nil ++ } ++ ++ for _, test := range []struct { ++ Name string ++ Statement string ++ Points [][]influxql.Point ++ }{ ++ { ++ Name: "integer add propagates missing operands", ++ Statement: `SELECT left_i + right_i FROM missing_integer_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.IntegerPoint{Name: "missing_integer_ops", Time: 31 * Second, Nil: true}}, ++ {&influxql.IntegerPoint{Name: "missing_integer_ops", Time: 37 * Second, Value: 24}}, ++ {&influxql.IntegerPoint{Name: "missing_integer_ops", Time: 43 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "integer subtract propagates missing operands", ++ Statement: `SELECT left_i - right_i FROM missing_integer_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.IntegerPoint{Name: "missing_integer_ops", Time: 31 * Second, Nil: true}}, ++ {&influxql.IntegerPoint{Name: "missing_integer_ops", Time: 37 * Second, Value: 16}}, ++ {&influxql.IntegerPoint{Name: "missing_integer_ops", Time: 43 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "integer multiply propagates missing operands", ++ Statement: `SELECT left_i * right_i FROM missing_integer_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.IntegerPoint{Name: "missing_integer_ops", Time: 31 * Second, Nil: true}}, ++ {&influxql.IntegerPoint{Name: "missing_integer_ops", Time: 37 * Second, Value: 80}}, ++ {&influxql.IntegerPoint{Name: "missing_integer_ops", Time: 43 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "integer division propagates missing operands", ++ Statement: `SELECT left_i / right_i FROM missing_integer_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_integer_ops", Time: 31 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_integer_ops", Time: 37 * Second, Value: 5}}, ++ {&influxql.FloatPoint{Name: "missing_integer_ops", Time: 43 * Second, Nil: true}}, ++ }, ++ }, ++ } { ++ itrs, err := influxql.Select(MustParseSelectStatement(test.Statement), &ic, nil) ++ if err != nil { ++ t.Errorf("%s: parse error: %s", test.Name, err) ++ } else if a := Iterators(itrs).ReadAll(); !deep.Equal(a, test.Points) { ++ t.Errorf("%s: unexpected points: %s", test.Name, spew.Sdump(a)) ++ } ++ } ++} ++ ++func TestSelect_BinaryExpr_NilValues_MixedFloatIntegerArithmeticAllOps(t *testing.T) { ++ var ic IteratorCreator ++ ic.CreateIteratorFn = func(opt influxql.IteratorOptions) (influxql.Iterator, error) { ++ return &FloatIterator{Points: []influxql.FloatPoint{ ++ {Name: "missing_mixed_ops", Time: 53 * Second, Value: 7.5, Aux: []interface{}{float64(7.5), nil}}, ++ {Name: "missing_mixed_ops", Time: 59 * Second, Value: 12, Aux: []interface{}{float64(12), int64(3)}}, ++ {Name: "missing_mixed_ops", Time: 67 * Second, Value: 5, Aux: []interface{}{nil, int64(5)}}, ++ }}, nil ++ } ++ ++ for _, test := range []struct { ++ Name string ++ Statement string ++ Points [][]influxql.Point ++ }{ ++ { ++ Name: "mixed float plus integer propagates missing operands", ++ Statement: `SELECT left_f + right_i FROM missing_mixed_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 53 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 59 * Second, Value: 15}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 67 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "mixed float minus integer propagates missing operands", ++ Statement: `SELECT left_f - right_i FROM missing_mixed_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 53 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 59 * Second, Value: 9}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 67 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "mixed float times integer propagates missing operands", ++ Statement: `SELECT left_f * right_i FROM missing_mixed_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 53 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 59 * Second, Value: 36}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 67 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "mixed float divided by integer propagates missing operands", ++ Statement: `SELECT left_f / right_i FROM missing_mixed_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 53 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 59 * Second, Value: 4}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 67 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "mixed integer plus float propagates missing operands", ++ Statement: `SELECT right_i + left_f FROM missing_mixed_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 53 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 59 * Second, Value: 15}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 67 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "mixed integer minus float propagates missing operands", ++ Statement: `SELECT right_i - left_f FROM missing_mixed_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 53 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 59 * Second, Value: -9}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 67 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "mixed integer times float propagates missing operands", ++ Statement: `SELECT right_i * left_f FROM missing_mixed_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 53 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 59 * Second, Value: 36}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 67 * Second, Nil: true}}, ++ }, ++ }, ++ { ++ Name: "mixed integer divided by float propagates missing operands", ++ Statement: `SELECT right_i / left_f FROM missing_mixed_ops`, ++ Points: [][]influxql.Point{ ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 53 * Second, Nil: true}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 59 * Second, Value: 0.25}}, ++ {&influxql.FloatPoint{Name: "missing_mixed_ops", Time: 67 * Second, Nil: 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,32 @@ ++#!/bin/bash ++set -euo pipefail ++ ++cd /testbed ++ ++ ++export GOPATH=/root/go ++mkdir -p "$GOPATH/src/github.com/influxdata" ++ln -sfn /testbed "$GOPATH/src/github.com/influxdata/influxdb" ++ ++if [ ! -d "$GOPATH/src/github.com/gogo/protobuf" ]; then ++ git clone --depth 1 https://github.com/gogo/protobuf.git "$GOPATH/src/github.com/gogo/protobuf" 2>/dev/null ++fi ++if [ ! -d "$GOPATH/src/github.com/davecgh/go-spew" ]; then ++ git clone --depth 1 https://github.com/davecgh/go-spew.git "$GOPATH/src/github.com/davecgh/go-spew" 2>/dev/null ++fi ++ ++cd "$GOPATH/src/github.com/influxdata/influxdb" ++ ++ ++case "${1:-}" in ++ base) ++ GO111MODULE=off go test ./influxql/ -v -count=1 -timeout 120s -run '^(TestSelect_BinaryExpr_Float|TestSelect_BinaryExpr_Integer|TestSelect_BinaryExpr_Mixed)$' ++ ;; ++ new) ++ GO111MODULE=off go test ./influxql/ -v -count=1 -timeout 120s -run '^(TestSelect_BinaryExpr_NilValues|TestSelect_BinaryExpr_NilValues_FloatArithmeticAllOps|TestSelect_BinaryExpr_NilValues_IntegerArithmeticAllOps|TestSelect_BinaryExpr_NilValues_MixedFloatIntegerArithmeticAllOps)$' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-001563/tests/test.sh b/tasks/format-code-task-001563/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..60e141d04776d81ca3d87fcda37cebf8d7baa1fb --- /dev/null +++ b/tasks/format-code-task-001563/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' +influxql/select_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-001563/tests/test_command.sh b/tasks/format-code-task-001563/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-001563/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-001564/environment/Dockerfile b/tasks/format-code-task-001564/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..86014f5effc5499d308951afb95c1e1a14587edd --- /dev/null +++ b/tasks/format-code-task-001564/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:03892a4974f54bb10f0e1316ccff360811ec162be8558949c15aa898be8ad2ea diff --git a/tasks/format-code-task-001564/environment/setup/files/blocklist b/tasks/format-code-task-001564/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001564/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001564/environment/setup/setup.sh b/tasks/format-code-task-001564/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001564/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001564/tests/test.patch b/tasks/format-code-task-001564/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..91d15bf2f620db291ba60bf0c3cfded3695674a1 --- /dev/null +++ b/tasks/format-code-task-001564/tests/test.patch @@ -0,0 +1,66 @@ +diff --git a/internal/write/service_test.go b/internal/write/service_test.go +index e60a8a3..6e045ad 100644 +--- a/internal/write/service_test.go ++++ b/internal/write/service_test.go +@@ -470,6 +470,39 @@ func TestComputeRetryDelay(t *testing.T) { + assert.EqualValues(t, 125_000, srv.computeRetryDelay(5)) + } + ++ ++ ++ ++func TestComputeRetryDelayOverflow(t *testing.T) { ++ hs := test.NewTestService(t, "http://localhost:8888") ++ opts := write.DefaultOptions() ++ srv := NewService("my-org", "my-bucket", hs, opts) ++ ++ ++ ++ assert.NotPanics(t, func() { ++ assert.EqualValues(t, opts.MaxRetryInterval(), srv.computeRetryDelay(51)) ++ }) ++ ++ ++ ++ assert.NotPanics(t, func() { ++ assert.EqualValues(t, opts.MaxRetryInterval(), srv.computeRetryDelay(64)) ++ }) ++ ++ ++ assert.NotPanics(t, func() { ++ d := srv.computeRetryDelay(100) ++ assert.LessOrEqual(t, d, opts.MaxRetryInterval()) ++ }) ++ ++ ++ assert.NotPanics(t, func() { ++ d := srv.computeRetryDelay(0) ++ assert.True(t, d >= 5_000 && d <= 10_000) ++ }) ++} ++ + func TestErrorCallback(t *testing.T) { + log.Log.SetLogLevel(log.DebugLevel) + hs := test.NewTestService(t, "http://localhost:8086") +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..22f113a +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./internal/write/ -run TestComputeRetryDelayOverflow -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 ./internal/write/ -run TestComputeRetryDelayOverflow -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001564/tests/test.sh b/tasks/format-code-task-001564/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..301ba3ffa1ff3fa5e68b52a93a2f5aac9d960f8a --- /dev/null +++ b/tasks/format-code-task-001564/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/write/service_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-001564/tests/test_command.sh b/tasks/format-code-task-001564/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001564/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001590/environment/Dockerfile b/tasks/format-code-task-001590/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f5ecf2e610801d546ec9ddb8270e5c750d869f5f --- /dev/null +++ b/tasks/format-code-task-001590/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:61adf2685fadb2066045bd90c75f84cadd4ee15f8aa6a2919c78c8caf69ce932 diff --git a/tasks/format-code-task-001590/environment/setup/files/blocklist b/tasks/format-code-task-001590/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001590/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001590/environment/setup/setup.sh b/tasks/format-code-task-001590/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001590/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001590/tests/test.patch b/tasks/format-code-task-001590/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..49e4f36ce5e1ae8392a4778302df0a26ad622b60 --- /dev/null +++ b/tasks/format-code-task-001590/tests/test.patch @@ -0,0 +1,69 @@ +diff --git a/isso/tests/test_config.py b/isso/tests/test_config.py +index 2fd1b4dc1..8a15d1445 100644 +--- a/isso/tests/test_config.py ++++ b/isso/tests/test_config.py +@@ -10,8 +10,8 @@ class TestConfig(unittest.TestCase): + + def test_parser(self): + +- parser = config.IssoParser(allow_no_value=True) +- parser.read_file(io.StringIO(u""" ++ parser = config.IssoParser() ++ parser.read_file(io.StringIO(""" + [foo] + bar = 1h + baz = 12 +@@ -19,10 +19,18 @@ def test_parser(self): + bla = + spam + ham +- asd = fgh""")) ++ asd = fgh ++ password = %s%%foo""")) + + self.assertEqual(parser.getint("foo", "bar"), 3600) + self.assertEqual(parser.getint("foo", "baz"), 12) + self.assertEqual(parser.getlist("foo", "spam"), ['a', 'b', 'cdef']) + self.assertEqual(list(parser.getiter("foo", "bla")), ['spam', 'ham']) + self.assertEqual(list(parser.getiter("foo", "asd")), ['fgh']) ++ ++ # Strings containing '%' should not be python-interpolated ++ self.assertEqual(parser.get("foo", "password"), '%s%%foo') ++ ++ # Section.get() should function the same way as plain IssoParser ++ foosection = parser.section("foo") ++ self.assertEqual(foosection.get("password"), '%s%%foo') +diff --git a/isso/tests/test_utils_hash.py b/isso/tests/test_utils_hash.py +index 122c897f9..feafe69b6 100644 +--- a/isso/tests/test_utils_hash.py ++++ b/isso/tests/test_utils_hash.py +@@ -21,7 +21,7 @@ def test_hash(self): + + self.assertRaises(TypeError, h.hash, "...") + self.assertEqual(h.hash(b"..."), b"...") +- self.assertIsInstance(h.uhash(u"..."), (str, )) ++ self.assertIsInstance(h.uhash("..."), (str, )) + + def test_uhash(self): + h = Hash(b"", func=None) +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+3S326DIBiHYY69CpodV8WKXo7R6iZJhaZgk959mcn+ZMvWkzbL2vc5gfAR+MiP ++tJvNrm8Ge8zEreRRrfUyRl/HZa50oYp8U9dlLXKlKqWE1Dfr6JPZh/YgpTg4F37bd6n+T6Uf+YfB ++h2brpqm1ferH691xKX9V6vf8dVnF/MuqKITMr9fCzx48/6dV1hmbda0fk20vl0/QDX2yP4XR2Y1c ++TzJO46I03rul7N9+in02L+n+9K0yB7PzzRiPfK2uj8lfPxIAAAAAAAAAAAAAAAC4U2cEOl4TACgA ++AA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001590/tests/test.sh b/tasks/format-code-task-001590/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1207856434b4c8e423790867b1ee7bcb357d2791 --- /dev/null +++ b/tasks/format-code-task-001590/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' +isso/tests/test_config.py +isso/tests/test_utils_hash.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-001590/tests/test_command.sh b/tasks/format-code-task-001590/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001590/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001597/environment/Dockerfile b/tasks/format-code-task-001597/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..af0a907e0e45e0562b54866be8b282cfb13c9239 --- /dev/null +++ b/tasks/format-code-task-001597/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f6ae92c0abb8d0d249ec80926b56ff663b6d59c157c805cb00e406b869ed4aa6 diff --git a/tasks/format-code-task-001597/environment/setup/files/blocklist b/tasks/format-code-task-001597/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001597/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001597/environment/setup/setup.sh b/tasks/format-code-task-001597/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001597/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001597/tests/test.patch b/tasks/format-code-task-001597/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9e82d0e0db7bef26256f8edf7c4602ff99f35859 --- /dev/null +++ b/tasks/format-code-task-001597/tests/test.patch @@ -0,0 +1,47 @@ +diff --git a/tests/e2e/tests/pilot/authn_policy_test.go b/tests/e2e/tests/pilot/authn_policy_test.go +index 121b57a99a7a..de42d1d0df0a 100644 +--- a/tests/e2e/tests/pilot/authn_policy_test.go ++++ b/tests/e2e/tests/pilot/authn_policy_test.go +@@ -70,12 +70,6 @@ func TestAuthNPolicy(t *testing.T) { + } + + func TestAuthNJwt(t *testing.T) { +- // V1alpha3 == true implies envoyv2, jwt authn doesn't work for v2 so skip it now. +- // TODO(quanlin): enable test for v2 API after https://github.com/istio/istio/pull/5061 is in. +- if tc.V1alpha3 { +- t.Skipf("Skipping %s: V1alpha3=true", t.Name()) +- } +- + // JWT token used is borrowed from https://github.com/istio/proxy/blob/master/src/envoy/http/jwt_auth/sample/correct_jwt. + // The Token expires in year 2132, issuer is 628645741881-noabiu23f5a8m8ovd8ucv698lj78vv0l@developer.gserviceaccount.com. + // Test will fail if this service account is deleted. +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+2V30/bMBDH++y/4lb2AA9NmkKLxNRNCBgrMIFa2B6mqUodJzFN7ch2Wirtj9/F ++hlIhGHsATRP+vMQ5n+/H95w2mFS8SMZMzMPGa9FGdrtd+0QePu066nbane3ezvYu2qOo195uQPfV ++Klqj0iZWAA0lpfmT33P7/ynB/fwN02ZM5WwWiyTQ+cvleGb+nSjqrOYf9dAv2ulF3Qa0X66Ep3nj ++8994F064CCexzglNwF6CCUsI2YARM1CVcCwBbwdXUsyYMLB5fH6xf/mlhSdYAqWS14waWHCTw5yJ ++RCq0JqzUWwFhN6VUBtyBflgrGGby3hxF0dfzw6uzo75M0zrjkdCVYmByBno5K7iYQioVcG24DLgM ++7QJfgQsoi5iygMymCVfQKuEufKgVDe9OkEJAS6erth73uo3b+RgmbB6KqiiI1eJpXyuPYSVEe3Ag ++ZyUvXNV4lTJUjXVwiRkhrTc248rkYlzKgtPluLYHmdwCI1EwxdMlxrJnVwfw+4O4KIAbXUuJqjJB ++OdNgv1WgUinUvFg61euzcVkWvB5HbGgekEy6aC0KgW1dh1jS7QqLxbagJVGVWelex7htKyPUdTNW ++tP/+E+Ep/ID39zZoCQZt+PmhzioIIIzmEpqf9wdne+AcYxRIgEzh0cyQxhgrcbWzG27wVMLWkzRd ++3HprzUpSTlyug7/IEj6mOeiKUsYSljRXA+zswbASVsRKYEYbw946F6ecZuEMCyxgkXOaO11r75Pv ++pyNQTMsCp4jRbBc0j0WGzXEX0Y4DNq8XUz2+c63rsL0PhGYUr/toystv9iLA5dkI44iUZ1trQ5zj ++HGUlTD/CaT6oCueosPzmJXoOXYYTzHY1HFxpLrJzvDyDw1/1Ln7N+1U9NcOp1e7CanPrra3PMTMX ++1QTNp2xpDSeL2oBvQ5ZiA3mT2D8JdzmIG9GthfzrXzKPx+PxeDwej8fj8Xg8Ho/H4/F4PB6Px+Px ++eN4uvwG2/Vg5ACgAAA== +diff --git 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-001597/tests/test.sh b/tasks/format-code-task-001597/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..ce2debeb2889c274722332946ceebbe8cabf1204 --- /dev/null +++ b/tasks/format-code-task-001597/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/e2e/tests/pilot/authn_policy_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-001597/tests/test_command.sh b/tasks/format-code-task-001597/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001597/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001599/environment/Dockerfile b/tasks/format-code-task-001599/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4fc987a5d44372a022a0e864ae355d310c5e7d31 --- /dev/null +++ b/tasks/format-code-task-001599/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:fa4febe0c1645e93aec01228b3932316f3f38a5f99fd876ec2c636c11bd9b907 diff --git a/tasks/format-code-task-001599/environment/setup/files/blocklist b/tasks/format-code-task-001599/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001599/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001599/environment/setup/setup.sh b/tasks/format-code-task-001599/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001599/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001599/tests/test.patch b/tasks/format-code-task-001599/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..88aa6b91db8421e2f64aade822cb2523a60cebbe --- /dev/null +++ b/tasks/format-code-task-001599/tests/test.patch @@ -0,0 +1,212 @@ +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,190 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++export DVC_NO_ANALYTICS=1 ++export DVC_TEST=true ++export DVC_STUDIO_OFFLINE=true ++export DVC_EXP_AUTO_PUSH=false ++export PYTHONDONTWRITEBYTECODE=1 ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:$PYTHONPATH}" ++ ++( cd /workspace/repo && python -c 'import dvc.cli' ) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++ ++DVC=(python -m dvc) ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++names_from_csv() { ++ tr -d '\r' <"$1" | awk -F, 'NR > 1 && $1 != "" { print $1 }' ++} ++ ++run_ok() { ++ local label="$1" ++ local expected="$2" ++ shift 2 ++ ++ "${DVC[@]}" exp show --no-pager --csv --drop='rev|Created' "$@" \ ++ >"$TMP/$label.out" 2>"$TMP/$label.err" ++ local ec=$? ++ local actual ++ actual="$(names_from_csv "$TMP/$label.out")" ++ ++ [ "$ec" -eq 0 ] || fail "$label exit $ec; want 0; stderr: $(cat "$TMP/$label.err")" ++ ++ ! grep -qi "error" "$TMP/$label.err" || fail "$label stderr reports error: $(cat "$TMP/$label.err")" ++ [ "$actual" = "$expected" ] || fail "$label experiment order: [$actual], want [$expected]" ++} ++ ++run_err() { ++ local label="$1" ++ shift ++ ++ set +e ++ "${DVC[@]}" exp show --no-pager --csv --drop='rev|Created' "$@" \ ++ >"$TMP/$label.out" 2>"$TMP/$label.err" ++ local ec=$? ++ set -e ++ ++ [ "$ec" -ne 0 ] || fail "$label exit 0; want non-zero" ++ ++ ! grep -q "^Experiment," "$TMP/$label.out" || fail "$label produced experiment table on failure: $(cat "$TMP/$label.out")" ++ [ -s "$TMP/$label.err" ] || fail "$label missing stderr" ++} ++ ++setup_repo() { ++ local repo_dir="$1" ++ mkdir -p "$repo_dir" ++ cd "$repo_dir" || exit 1 ++ git init -q ++ git config user.email test@example.com ++ git config user.name "Test User" ++ "${DVC[@]}" init -q || exit 1 ++ ++ cat >params.yaml <<'EOF' ++foo: 10 ++alpha: 100 ++EOF ++ cat >metrics.yaml <<'EOF' ++foo: 10 ++score: 10 ++EOF ++ cat >'metrics:1.json' <<'EOF' ++{"my::metric": 10, "other_metric": 10} ++EOF ++ cat >dvc.yaml <<'EOF' ++metrics: ++ - metrics.yaml ++ - metrics:1.json ++params: ++ - params.yaml ++EOF ++ git add . ++ git commit -q -m baseline ++ ++ cat >params.yaml <<'EOF' ++foo: 3 ++alpha: 300 ++EOF ++ cat >metrics.yaml <<'EOF' ++foo: 1 ++score: 1 ++EOF ++ cat >'metrics:1.json' <<'EOF' ++{"my::metric": 2, "other_metric": 20} ++EOF ++ "${DVC[@]}" exp save -q -n low || exit 1 ++ ++ cat >params.yaml <<'EOF' ++alpha: 900 ++EOF ++ cat >metrics.yaml <<'EOF' ++foo: 5 ++score: 5 ++EOF ++ cat >'metrics:1.json' <<'EOF' ++{"my::metric": 1} ++EOF ++ "${DVC[@]}" exp save -q -n missing_param || exit 1 ++ ++ cat >params.yaml <<'EOF' ++foo: 7 ++alpha: 700 ++EOF ++ cat >metrics.yaml <<'EOF' ++foo: 9 ++score: 9 ++EOF ++ cat >'metrics:1.json' <<'EOF' ++{"my::metric": 3, "other_metric": 10} ++EOF ++ "${DVC[@]}" exp save -q -n high || exit 1 ++} ++ ++WORK="$TMP/work" ++setup_repo "$WORK" ++cd "$WORK" || exit 1 ++ ++ ++ ++ ++run_ok "metric_qualified_asc" $'low\nmissing_param\nhigh' --sort-by=metrics.yaml:foo ++ ++ ++ ++ ++run_ok "param_qualified_missing_last" $'low\nhigh\nmissing_param' --sort-by=params.yaml:foo ++ ++ ++ ++ ++run_ok "param_qualified_desc" $'missing_param\nhigh\nlow' --sort-by=params.yaml:foo --sort-order desc ++ ++ ++ ++ ++run_ok "metric_unqualified_unique" $'low\nmissing_param\nhigh' --sort-by=score ++ ++ ++ ++ ++run_ok "param_unqualified_unique" $'low\nhigh\nmissing_param' --sort-by=alpha ++ ++ ++ ++ ++run_ok "colon_qualified" $'missing_param\nlow\nhigh' '--sort-by=metrics:1.json:my::metric' ++ ++ ++ ++ ++run_ok "leading_colon" $'high\nlow\nmissing_param' '--sort-by=:other_metric' ++ ++ ++ ++ ++run_err "unknown_column" --sort-by=missing ++ ++grep -Eiq "(unknown.*sort column|sort column.*unknown)" "$TMP/unknown_column.err" \ ++ || fail "unknown_column stderr: $(cat "$TMP/unknown_column.err")" ++grep -q "missing" "$TMP/unknown_column.err" \ ++ || fail "unknown_column stderr: $(cat "$TMP/unknown_column.err")" ++ ++ ++ ++ ++run_err "ambiguous_column" --sort-by=foo ++ ++grep -Eiq "(ambiguous.*sort column|sort column.*ambiguous)" "$TMP/ambiguous_column.err" \ ++ || fail "ambiguous_column missing ambiguous error: $(cat "$TMP/ambiguous_column.err")" ++grep -q "foo" "$TMP/ambiguous_column.err" \ ++ || fail "ambiguous_column missing requested name: $(cat "$TMP/ambiguous_column.err")" ++grep -q "metrics.yaml:foo" "$TMP/ambiguous_column.err" \ ++ || fail "ambiguous_column missing metrics match: $(cat "$TMP/ambiguous_column.err")" ++grep -q "params.yaml:foo" "$TMP/ambiguous_column.err" \ ++ || fail "ambiguous_column missing params match: $(cat "$TMP/ambiguous_column.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-001599/tests/test.sh b/tasks/format-code-task-001599/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-001599/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-001599/tests/test_command.sh b/tasks/format-code-task-001599/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001599/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-001702/environment/Dockerfile b/tasks/format-code-task-001702/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..366feb026e7217b97f525e563ef06247849395e2 --- /dev/null +++ b/tasks/format-code-task-001702/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6a0e3bcb3029b735e5804ce0f7e5657f7d23afaf1c961c47016bee3f8668db39 diff --git a/tasks/format-code-task-001702/environment/setup/files/blocklist b/tasks/format-code-task-001702/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001702/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001702/environment/setup/setup.sh b/tasks/format-code-task-001702/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001702/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001702/tests/test.patch b/tasks/format-code-task-001702/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ce3b20d5a56aa10e6b30d5d85a8fc7e186e50fe3 --- /dev/null +++ b/tasks/format-code-task-001702/tests/test.patch @@ -0,0 +1,196 @@ +diff --git a/test/request/codespec-trusted-proxy-policy.js b/test/request/codespec-trusted-proxy-policy.js +new file mode 100644 +index 0000000..0ef50e4 +--- /dev/null ++++ b/test/request/codespec-trusted-proxy-policy.js +@@ -0,0 +1,171 @@ ++'use strict'; ++ ++var request = require('../context').request; ++var supertest = require('supertest'); ++var koa = require('../..'); ++ ++function forwardedRequest(value) { ++ var req = request(); ++ req.socket.remoteAddress = '10.0.0.3'; ++ if (value != null) req.header['x-forwarded-for'] = value; ++ return req; ++} ++ ++describe('codespec trusted proxy policy', function(){ ++ it('stops at the first untrusted hop and keeps that boundary address', function(){ ++ var req = forwardedRequest('198.51.100.7, 203.0.113.9, 10.0.0.2'); ++ ++ req.app.proxy = function(address, hop) { ++ if (hop === 0) return address === '10.0.0.3'; ++ if (hop === 1) return address === '10.0.0.2'; ++ return false; ++ }; ++ ++ req.ips.should.eql(['203.0.113.9', '10.0.0.2']); ++ req.ip.should.equal('203.0.113.9'); ++ }); ++ ++ it('numbers hops from the socket and re-evaluates each accepted hop', function(){ ++ var req = forwardedRequest('198.51.100.7, 10.0.0.2'); ++ ++ req.app.proxy = function(address, hop) { ++ return hop === 0; ++ }; ++ ++ req.ips.should.eql(['10.0.0.2']); ++ req.ip.should.equal('10.0.0.2'); ++ }); ++ ++ it('trims entries, drops empty entries, and preserves wire order when all hops are trusted', function(){ ++ var req = forwardedRequest(' , 198.51.100.7 ,, 10.0.0.2, '); ++ req.app.proxy = function() { return true; }; ++ ++ req.ips.should.eql(['198.51.100.7', '10.0.0.2']); ++ req.ip.should.equal('198.51.100.7'); ++ }); ++ ++ it('ignores every forwarded field when the direct peer is untrusted', function(){ ++ var req = forwardedRequest('198.51.100.7, 10.0.0.2'); ++ req.header.host = 'origin.internal:3000'; ++ req.header['x-forwarded-host'] = 'public.example:8443, proxy.internal'; ++ req.header['x-forwarded-proto'] = 'https, http'; ++ req.app.proxy = function(address, hop) { ++ return address === '10.0.0.99' && hop === 0; ++ }; ++ ++ req.ips.should.eql([]); ++ req.ip.should.equal('10.0.0.3'); ++ req.host.should.equal('origin.internal:3000'); ++ req.hostname.should.equal('origin.internal'); ++ req.protocol.should.equal('http'); ++ req.secure.should.equal(false); ++ req.origin.should.equal('http://origin.internal:3000'); ++ }); ++ ++ it('uses the first forwarded host and protocol when the direct peer is trusted', function(){ ++ var req = forwardedRequest(); ++ req.header.host = 'origin.internal:3000'; ++ req.header['x-forwarded-host'] = 'public.example:8443, proxy.internal'; ++ req.header['x-forwarded-proto'] = 'https, http'; ++ req.app.proxy = function(address, hop) { ++ return address === '10.0.0.3' && hop === 0; ++ }; ++ ++ req.host.should.equal('public.example:8443'); ++ req.hostname.should.equal('public.example'); ++ req.protocol.should.equal('https'); ++ req.secure.should.equal(true); ++ req.origin.should.equal('https://public.example:8443'); ++ }); ++ ++ it('falls back to http when a trusted peer sends no usable protocol', function(){ ++ var req = forwardedRequest(); ++ req.header['x-forwarded-proto'] = ''; ++ req.app.proxy = function() { return true; }; ++ ++ req.protocol.should.equal('http'); ++ req.secure.should.equal(false); ++ }); ++ ++ it('always reports an encrypted socket as https', function(){ ++ var req = forwardedRequest(); ++ req.socket.encrypted = true; ++ req.header['x-forwarded-proto'] = 'http'; ++ req.app.proxy = function() { return false; }; ++ ++ req.protocol.should.equal('https'); ++ req.secure.should.equal(true); ++ }); ++ ++ it('does not authorize forwarded fields without a direct peer address', function(){ ++ var req = forwardedRequest('198.51.100.7'); ++ req.socket.remoteAddress = null; ++ req.header.host = 'origin.internal'; ++ req.header['x-forwarded-host'] = 'public.example'; ++ req.header['x-forwarded-proto'] = 'https'; ++ req.app.proxy = function() { return true; }; ++ ++ req.ips.should.eql([]); ++ req.ip.should.equal(''); ++ req.host.should.equal('origin.internal'); ++ req.protocol.should.equal('http'); ++ }); ++ ++ it('preserves the legacy true and false modes', function(){ ++ var trusted = forwardedRequest(' , 198.51.100.7 ,, 10.0.0.2, '); ++ trusted.header.host = 'origin.internal'; ++ trusted.header['x-forwarded-host'] = 'public.example, proxy.internal'; ++ trusted.header['x-forwarded-proto'] = 'https, http'; ++ trusted.app.proxy = true; ++ ++ trusted.ips.should.eql(['198.51.100.7', '10.0.0.2']); ++ trusted.ip.should.equal('198.51.100.7'); ++ trusted.host.should.equal('public.example'); ++ trusted.protocol.should.equal('https'); ++ ++ var untrusted = forwardedRequest('198.51.100.7, 10.0.0.2'); ++ untrusted.header.host = 'origin.internal'; ++ untrusted.header['x-forwarded-host'] = 'public.example'; ++ untrusted.header['x-forwarded-proto'] = 'https'; ++ untrusted.app.proxy = false; ++ ++ untrusted.ips.should.eql([]); ++ untrusted.ip.should.equal('10.0.0.3'); ++ untrusted.host.should.equal('origin.internal'); ++ untrusted.protocol.should.equal('http'); ++ }); ++ ++ it('applies hop-limited trust through application contexts', function(done){ ++ var app = koa(); ++ app.proxy = function(address, hop) { return hop === 0; }; ++ ++ app.use(function *(){ ++ this.body = { ++ ip: this.ip, ++ ips: this.ips, ++ host: this.host, ++ protocol: this.protocol, ++ hostname: this.hostname, ++ origin: this.origin, ++ secure: this.secure ++ }; ++ }); ++ ++ supertest(app.listen()) ++ .get('/') ++ .set('Host', 'origin.internal') ++ .set('X-Forwarded-For', '198.51.100.7, 203.0.113.9') ++ .set('X-Forwarded-Host', 'public.example') ++ .set('X-Forwarded-Proto', 'https') ++ .expect(200) ++ .expect({ ++ ip: '203.0.113.9', ++ ips: ['203.0.113.9'], ++ host: 'public.example', ++ protocol: 'https', ++ hostname: 'public.example', ++ origin: 'https://public.example', ++ secure: true ++ }, done); ++ }); ++}); +diff --git 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 @@ ++#!/bin/bash ++set -euo pipefail ++ ++ ++NODE_ENV=test node --harmony ./node_modules/.bin/_mocha \ ++ --require should \ ++ --require should-http \ ++ test/request/codespec-trusted-proxy-policy.js \ ++ test/request/ip.js \ ++ test/request/ips.js \ ++ test/request/protocol.js \ ++ test/request/host.js \ ++ test/request/hostname.js \ ++ --bail diff --git a/tasks/format-code-task-001702/tests/test.sh b/tasks/format-code-task-001702/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..315bdca5701c3b33d46108c4f634ffcc90d91976 --- /dev/null +++ b/tasks/format-code-task-001702/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/request/codespec-trusted-proxy-policy.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-001702/tests/test_command.sh b/tasks/format-code-task-001702/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001702/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001703/environment/Dockerfile b/tasks/format-code-task-001703/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fdb6d8cb71a62234f55c683feecbe7df4a8b5f3a --- /dev/null +++ b/tasks/format-code-task-001703/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1d005edab251e5cb03b3917795715e510943367a8b15259b11452783ee21e0f7 diff --git a/tasks/format-code-task-001703/environment/setup/files/blocklist b/tasks/format-code-task-001703/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001703/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001703/environment/setup/setup.sh b/tasks/format-code-task-001703/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001703/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001703/tests/test.patch b/tasks/format-code-task-001703/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c4a52b7cce173cc49d92fa927e35cb09559c4316 --- /dev/null +++ b/tasks/format-code-task-001703/tests/test.patch @@ -0,0 +1,271 @@ +diff --git a/test/security.js b/test/security.js +new file mode 100644 +index 0000000..af845c3 +--- /dev/null ++++ b/test/security.js +@@ -0,0 +1,243 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++'use strict'; ++ ++const fs = require('fs'); ++const http = require('http'); ++const koaBody = require('../index'); ++const request = require('supertest'); ++const should = require('should'); ++const Koa = require('koa'); ++const Router = require('koa-router'); ++ ++function summarizeFiles(filesObj) { ++ const out = {}; ++ if (!filesObj) return out; ++ for (const k of Object.keys(filesObj)) { ++ const f = filesObj[k]; ++ if (Array.isArray(f)) { ++ out[k] = f.map(file => ({ name: file.name, path: file.path })); ++ } else if (f && typeof f === 'object') { ++ out[k] = { name: f.name, path: f.path }; ++ } ++ } ++ return out; ++} ++ ++function unlinkAll(filesSummary) { ++ if (!filesSummary) return; ++ for (const k of Object.keys(filesSummary)) { ++ const v = filesSummary[k]; ++ if (Array.isArray(v)) { ++ v.forEach(f => { try { fs.unlinkSync(f.path); } catch (_) {} }); ++ } else if (v && v.path) { ++ try { fs.unlinkSync(v.path); } catch (_) {} ++ } ++ } ++} ++ ++describe('koa-body security: files separated from body', () => { ++ let app; ++ let router; ++ ++ beforeEach((done) => { ++ app = new Koa(); ++ router = Router() ++ .post('/inspect', (ctx) => { ++ const body = ctx.request.body; ++ const reqBody = ctx.req.body; ++ ctx.status = 200; ++ ctx.body = { ++ ++ requestBody: body, ++ requestBodyType: typeof body, ++ requestBodyHasFilesKey: !!(body && typeof body === 'object' && Object.prototype.hasOwnProperty.call(body, 'files')), ++ requestBodyHasFieldsKey: !!(body && typeof body === 'object' && Object.prototype.hasOwnProperty.call(body, 'fields')), ++ ++ requestFilesIsSet: ctx.request.files !== undefined, ++ requestFiles: summarizeFiles(ctx.request.files), ++ ++ reqBody: reqBody, ++ reqBodyType: typeof reqBody, ++ reqBodyHasFilesKey: !!(reqBody && typeof reqBody === 'object' && Object.prototype.hasOwnProperty.call(reqBody, 'files')), ++ reqBodyHasFieldsKey: !!(reqBody && typeof reqBody === 'object' && Object.prototype.hasOwnProperty.call(reqBody, 'fields')), ++ reqFilesIsSet: ctx.req.files !== undefined, ++ reqFiles: summarizeFiles(ctx.req.files), ++ }; ++ }); ++ done(); ++ }); ++ ++ ++ ++ ++ ++ ++ it('multipart with file: ctx.request.body holds fields directly; files go on ctx.request.files', (done) => { ++ app.use(koaBody({ ++ multipart: true, ++ formidable: { uploadDir: __dirname + '/temp' } ++ })); ++ app.use(router.routes()); ++ ++ request(http.createServer(app.callback())) ++ .post('/inspect') ++ .type('multipart/form-data') ++ .field('name', 'daryl') ++ .field('followers', '30') ++ .attach('upload', 'package.json') ++ .expect(200) ++ .end((err, res) => { ++ if (err) return done(err); ++ ++ res.body.requestBody.should.have.property('name', 'daryl'); ++ res.body.requestBody.should.have.property('followers', '30'); ++ ++ res.body.requestBodyHasFilesKey.should.be.exactly(false); ++ res.body.requestBodyHasFieldsKey.should.be.exactly(false); ++ ++ res.body.requestFilesIsSet.should.be.exactly(true); ++ res.body.requestFiles.should.have.property('upload'); ++ res.body.requestFiles.upload.name.should.equal('package.json'); ++ unlinkAll(res.body.requestFiles); ++ done(); ++ }); ++ }); ++ ++ ++ ++ ++ ++ ++ it('JSON attack: ctx.request.files is NOT set when body is JSON containing a "files" key', (done) => { ++ app.use(koaBody({ multipart: true })); ++ app.use(router.routes()); ++ ++ request(http.createServer(app.callback())) ++ .post('/inspect') ++ .type('application/json') ++ .send({ files: { uploads: [{ path: '/etc/passwd' }] }, other: 'x' }) ++ .expect(200) ++ .end((err, res) => { ++ if (err) return done(err); ++ ++ res.body.requestFilesIsSet.should.be.exactly(false); ++ ++ res.body.requestBody.should.have.property('other', 'x'); ++ res.body.requestBody.should.have.property('files'); ++ res.body.requestBody.files.should.have.property('uploads'); ++ res.body.requestBody.files.uploads.should.be.an.Array().and.have.lengthOf(1); ++ res.body.requestBody.files.uploads[0].should.have.property('path', '/etc/passwd'); ++ done(); ++ }); ++ }); ++ ++ ++ ++ ++ it('urlencoded request: ctx.request.body has parsed fields and ctx.request.files is NOT set', (done) => { ++ app.use(koaBody({ multipart: true })); ++ app.use(router.routes()); ++ ++ request(http.createServer(app.callback())) ++ .post('/inspect') ++ .type('application/x-www-form-urlencoded') ++ .send({ name: 'urluser', followers: '99' }) ++ .expect(200) ++ .end((err, res) => { ++ if (err) return done(err); ++ res.body.requestBody.should.have.property('name', 'urluser'); ++ res.body.requestBody.should.have.property('followers', '99'); ++ res.body.requestFilesIsSet.should.be.exactly(false); ++ done(); ++ }); ++ }); ++ ++ ++ ++ ++ ++ ++ it('patchNode + multipart: ctx.req.body holds fields directly; ctx.req.files holds files', (done) => { ++ app.use(koaBody({ ++ multipart: true, ++ patchNode: true, ++ formidable: { uploadDir: __dirname + '/temp' } ++ })); ++ app.use(router.routes()); ++ ++ request(http.createServer(app.callback())) ++ .post('/inspect') ++ .type('multipart/form-data') ++ .field('name', 'daryl') ++ .attach('upload', 'package.json') ++ .expect(200) ++ .end((err, res) => { ++ if (err) return done(err); ++ res.body.reqBody.should.have.property('name', 'daryl'); ++ res.body.reqBodyHasFilesKey.should.be.exactly(false); ++ res.body.reqBodyHasFieldsKey.should.be.exactly(false); ++ res.body.reqFilesIsSet.should.be.exactly(true); ++ res.body.reqFiles.should.have.property('upload'); ++ res.body.reqFiles.upload.name.should.equal('package.json'); ++ unlinkAll(res.body.reqFiles); ++ done(); ++ }); ++ }); ++ ++ ++ ++ ++ ++ ++ it('multipart disabled: JSON with "files" key never sets ctx.request.files', (done) => { ++ app.use(koaBody({ multipart: false })); ++ app.use(router.routes()); ++ ++ request(http.createServer(app.callback())) ++ .post('/inspect') ++ .type('application/json') ++ .send({ files: { uploads: [{ path: '/etc/shadow' }] } }) ++ .expect(200) ++ .end((err, res) => { ++ if (err) return done(err); ++ res.body.requestFilesIsSet.should.be.exactly(false); ++ ++ res.body.requestBody.should.have.property('files'); ++ res.body.requestBody.files.uploads[0].should.have.property('path', '/etc/shadow'); ++ done(); ++ }); ++ }); ++ ++ ++ ++ ++ ++ it('multipart with fields only: fields top-level on body, no "files" key on body', (done) => { ++ app.use(koaBody({ multipart: true })); ++ app.use(router.routes()); ++ ++ request(http.createServer(app.callback())) ++ .post('/inspect') ++ .type('multipart/form-data') ++ .field('name', 'onlyfields') ++ .field('followers', '7') ++ .expect(200) ++ .end((err, res) => { ++ if (err) return done(err); ++ res.body.requestBody.should.have.property('name', 'onlyfields'); ++ res.body.requestBody.should.have.property('followers', '7'); ++ res.body.requestBodyHasFilesKey.should.be.exactly(false); ++ res.body.requestBodyHasFieldsKey.should.be.exactly(false); ++ done(); ++ }); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..5c5b08b +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/mocha test/security.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_modules/.bin/mocha test/security.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001703/tests/test.sh b/tasks/format-code-task-001703/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..23ef12ebcd3ce52f9c4b978a0e5985863ce17dc3 --- /dev/null +++ b/tasks/format-code-task-001703/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/security.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-001703/tests/test_command.sh b/tasks/format-code-task-001703/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001703/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001705/environment/Dockerfile b/tasks/format-code-task-001705/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f99eb964c16ebf08d5767d3546c22d4e989015c1 --- /dev/null +++ b/tasks/format-code-task-001705/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5d7faa1d516b71494220255fc2954ffdb68350fd1e438c56c5a1fd00260108cf diff --git a/tasks/format-code-task-001705/environment/setup/files/blocklist b/tasks/format-code-task-001705/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001705/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001705/environment/setup/setup.sh b/tasks/format-code-task-001705/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001705/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001705/tests/test.patch b/tasks/format-code-task-001705/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ef30bf9bdb118980d3f5d911e06b478b8530d84a --- /dev/null +++ b/tasks/format-code-task-001705/tests/test.patch @@ -0,0 +1,305 @@ +diff --git a/apis/extension/node_allocatable_amplification_test.go b/apis/extension/node_allocatable_amplification_test.go +new file mode 100644 +index 00000000..d16f14fa +--- /dev/null ++++ b/apis/extension/node_allocatable_amplification_test.go +@@ -0,0 +1,274 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++package extension ++ ++import ( ++ "testing" ++ ++ "github.com/stretchr/testify/assert" ++ corev1 "k8s.io/api/core/v1" ++ "k8s.io/apimachinery/pkg/api/resource" ++ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ++) ++ ++func mustValue(s string) int64 { ++ q := resource.MustParse(s) ++ return q.Value() ++} ++ ++func newAmplifyTestNode(annotations map[string]string, allocatable corev1.ResourceList) *corev1.Node { ++ return &corev1.Node{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "test-node", ++ Annotations: annotations, ++ }, ++ Status: corev1.NodeStatus{ ++ Allocatable: allocatable, ++ }, ++ } ++} ++ ++func TestAmplifyNodeAllocatable_AmplifiesCPUAndMemory(t *testing.T) { ++ node := newAmplifyTestNode( ++ map[string]string{ ++ AnnotationNodeResourceAmplificationRatio: `{"cpu":1.5,"memory":2}`, ++ }, ++ corev1.ResourceList{ ++ corev1.ResourceCPU: resource.MustParse("4"), ++ corev1.ResourceMemory: resource.MustParse("2Gi"), ++ }, ++ ) ++ ++ err := AmplifyNodeAllocatable(node) ++ assert.NoError(t, err) ++ ++ gotCPU := node.Status.Allocatable[corev1.ResourceCPU] ++ gotMem := node.Status.Allocatable[corev1.ResourceMemory] ++ assert.Equal(t, int64(6000), gotCPU.MilliValue(), "cpu should be amplified by 1.5") ++ assert.Equal(t, mustValue("4Gi"), gotMem.Value(), "memory should be amplified by 2") ++ ++ ++ raw, err := GetNodeRawAllocatable(node.Annotations) ++ assert.NoError(t, err) ++ assert.NotNil(t, raw) ++ rawCPU := raw[corev1.ResourceCPU] ++ rawMem := raw[corev1.ResourceMemory] ++ assert.Equal(t, int64(4000), rawCPU.MilliValue()) ++ assert.Equal(t, mustValue("2Gi"), rawMem.Value()) ++} ++ ++func TestAmplifyNodeAllocatable_Idempotent(t *testing.T) { ++ node := newAmplifyTestNode( ++ map[string]string{ ++ AnnotationNodeResourceAmplificationRatio: `{"cpu":1.5,"memory":2}`, ++ }, ++ corev1.ResourceList{ ++ corev1.ResourceCPU: resource.MustParse("4"), ++ corev1.ResourceMemory: resource.MustParse("2Gi"), ++ }, ++ ) ++ ++ assert.NoError(t, AmplifyNodeAllocatable(node)) ++ assert.NoError(t, AmplifyNodeAllocatable(node)) ++ assert.NoError(t, AmplifyNodeAllocatable(node)) ++ ++ gotCPU := node.Status.Allocatable[corev1.ResourceCPU] ++ gotMem := node.Status.Allocatable[corev1.ResourceMemory] ++ ++ assert.Equal(t, int64(6000), gotCPU.MilliValue()) ++ assert.Equal(t, mustValue("4Gi"), gotMem.Value()) ++} ++ ++func TestAmplifyNodeAllocatable_StoredRawIsTheBaseline(t *testing.T) { ++ ++ ++ node := newAmplifyTestNode( ++ map[string]string{ ++ AnnotationNodeResourceAmplificationRatio: `{"cpu":1.5}`, ++ AnnotationNodeRawAllocatable: `{"cpu":"4"}`, ++ }, ++ corev1.ResourceList{ ++ corev1.ResourceCPU: resource.MustParse("9"), ++ }, ++ ) ++ ++ err := AmplifyNodeAllocatable(node) ++ assert.NoError(t, err) ++ ++ gotCPU := node.Status.Allocatable[corev1.ResourceCPU] ++ assert.Equal(t, int64(6000), gotCPU.MilliValue(), "should amplify the stored raw baseline 4 by 1.5") ++ ++ ++ raw, err := GetNodeRawAllocatable(node.Annotations) ++ assert.NoError(t, err) ++ rawCPU := raw[corev1.ResourceCPU] ++ assert.Equal(t, int64(4000), rawCPU.MilliValue()) ++} ++ ++func TestAmplifyNodeAllocatable_RatioLessOrEqualOneUnchanged(t *testing.T) { ++ node := newAmplifyTestNode( ++ map[string]string{ ++ AnnotationNodeResourceAmplificationRatio: `{"cpu":1,"memory":0.5}`, ++ }, ++ corev1.ResourceList{ ++ corev1.ResourceCPU: resource.MustParse("4"), ++ corev1.ResourceMemory: resource.MustParse("2Gi"), ++ }, ++ ) ++ ++ err := AmplifyNodeAllocatable(node) ++ assert.NoError(t, err) ++ ++ gotCPU := node.Status.Allocatable[corev1.ResourceCPU] ++ gotMem := node.Status.Allocatable[corev1.ResourceMemory] ++ assert.Equal(t, int64(4000), gotCPU.MilliValue(), "ratio == 1 leaves cpu unchanged") ++ assert.Equal(t, mustValue("2Gi"), gotMem.Value(), "ratio < 1 leaves memory unchanged") ++} ++ ++func TestAmplifyNodeAllocatable_OnlyCPUAndMemoryAmplified(t *testing.T) { ++ node := newAmplifyTestNode( ++ map[string]string{ ++ AnnotationNodeResourceAmplificationRatio: `{"cpu":2,"nvidia.com/gpu":2}`, ++ }, ++ corev1.ResourceList{ ++ corev1.ResourceCPU: resource.MustParse("4"), ++ corev1.ResourceName("nvidia.com/gpu"): resource.MustParse("4"), ++ }, ++ ) ++ ++ err := AmplifyNodeAllocatable(node) ++ assert.NoError(t, err) ++ ++ gotCPU := node.Status.Allocatable[corev1.ResourceCPU] ++ gotGPU := node.Status.Allocatable[corev1.ResourceName("nvidia.com/gpu")] ++ assert.Equal(t, int64(8000), gotCPU.MilliValue(), "cpu amplified by 2") ++ assert.Equal(t, int64(4), gotGPU.Value(), "gpu must not be amplified") ++} ++ ++func TestAmplifyNodeAllocatable_MissingBaselineResourceUnchanged(t *testing.T) { ++ ++ node := newAmplifyTestNode( ++ map[string]string{ ++ AnnotationNodeResourceAmplificationRatio: `{"cpu":2,"memory":2}`, ++ }, ++ corev1.ResourceList{ ++ corev1.ResourceMemory: resource.MustParse("2Gi"), ++ }, ++ ) ++ ++ err := AmplifyNodeAllocatable(node) ++ assert.NoError(t, err) ++ ++ gotMem := node.Status.Allocatable[corev1.ResourceMemory] ++ assert.Equal(t, mustValue("4Gi"), gotMem.Value(), "memory amplified by 2") ++ _, hasCPU := node.Status.Allocatable[corev1.ResourceCPU] ++ assert.False(t, hasCPU, "cpu must not be introduced when it has no baseline") ++} ++ ++func TestAmplifyNodeAllocatable_DisabledRemovesRawAndKeepsAllocatable(t *testing.T) { ++ node := newAmplifyTestNode( ++ map[string]string{ ++ AnnotationNodeRawAllocatable: `{"cpu":"4"}`, ++ "other": "keep-me", ++ }, ++ corev1.ResourceList{ ++ corev1.ResourceCPU: resource.MustParse("6"), ++ }, ++ ) ++ ++ err := AmplifyNodeAllocatable(node) ++ assert.NoError(t, err) ++ ++ ++ gotCPU := node.Status.Allocatable[corev1.ResourceCPU] ++ assert.Equal(t, int64(6000), gotCPU.MilliValue()) ++ ++ ++ raw, err := GetNodeRawAllocatable(node.Annotations) ++ assert.NoError(t, err) ++ assert.Nil(t, raw) ++ ++ ++ assert.Equal(t, "keep-me", node.Annotations["other"]) ++} ++ ++func TestAmplifyNodeAllocatable_DisabledEmptyValue(t *testing.T) { ++ node := newAmplifyTestNode( ++ map[string]string{ ++ AnnotationNodeResourceAmplificationRatio: "", ++ AnnotationNodeRawAllocatable: `{"cpu":"4"}`, ++ }, ++ corev1.ResourceList{ ++ corev1.ResourceCPU: resource.MustParse("6"), ++ }, ++ ) ++ ++ err := AmplifyNodeAllocatable(node) ++ assert.NoError(t, err) ++ ++ gotCPU := node.Status.Allocatable[corev1.ResourceCPU] ++ assert.Equal(t, int64(6000), gotCPU.MilliValue()) ++ raw, err := GetNodeRawAllocatable(node.Annotations) ++ assert.NoError(t, err) ++ assert.Nil(t, raw) ++} ++ ++func TestAmplifyNodeAllocatable_NilAllocatable(t *testing.T) { ++ node := newAmplifyTestNode( ++ map[string]string{ ++ AnnotationNodeResourceAmplificationRatio: `{"cpu":1.5}`, ++ }, ++ nil, ++ ) ++ ++ err := AmplifyNodeAllocatable(node) ++ assert.NoError(t, err) ++ assert.Nil(t, node.Status.Allocatable) ++ ++ raw, err := GetNodeRawAllocatable(node.Annotations) ++ assert.NoError(t, err) ++ assert.Nil(t, raw) ++} ++ ++func TestAmplifyNodeAllocatable_MalformedRatioErrors(t *testing.T) { ++ node := newAmplifyTestNode( ++ map[string]string{ ++ AnnotationNodeResourceAmplificationRatio: "not-json", ++ }, ++ corev1.ResourceList{ ++ corev1.ResourceCPU: resource.MustParse("4"), ++ }, ++ ) ++ ++ err := AmplifyNodeAllocatable(node) ++ assert.Error(t, err) ++} ++ ++func TestAmplifyNodeAllocatable_MalformedRawBaselineErrors(t *testing.T) { ++ node := newAmplifyTestNode( ++ map[string]string{ ++ AnnotationNodeResourceAmplificationRatio: `{"cpu":1.5}`, ++ AnnotationNodeRawAllocatable: "not-json", ++ }, ++ corev1.ResourceList{ ++ corev1.ResourceCPU: resource.MustParse("4"), ++ }, ++ ) ++ ++ err := AmplifyNodeAllocatable(node) ++ assert.Error(t, err) ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++go test -count=1 ./apis/extension/ ++ ++ ++go test -count=1 -run 'TestAmplifyNodeAllocatable' ./apis/extension/ diff --git a/tasks/format-code-task-001705/tests/test.sh b/tasks/format-code-task-001705/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..524cf2dbeb010500ad72281831d4fb7e429359be --- /dev/null +++ b/tasks/format-code-task-001705/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' +apis/extension/node_allocatable_amplification_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-001705/tests/test_command.sh b/tasks/format-code-task-001705/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001705/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001751/environment/Dockerfile b/tasks/format-code-task-001751/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8842f5c04f7342581ba2e401cc345f6b8c5aa7c1 --- /dev/null +++ b/tasks/format-code-task-001751/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:70d011d13ed05515ad7e1df8972c5f62181f035cceb321c86535b24a576c11a5 diff --git a/tasks/format-code-task-001751/environment/setup/files/blocklist b/tasks/format-code-task-001751/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001751/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001751/environment/setup/setup.sh b/tasks/format-code-task-001751/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001751/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001751/tests/test.patch b/tasks/format-code-task-001751/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..d3724a227e87c4b24150dcda922c9c8613a4a3d1 --- /dev/null +++ b/tasks/format-code-task-001751/tests/test.patch @@ -0,0 +1,40 @@ +diff --git a/pkg/engine/context/imageutils_test.go b/pkg/engine/context/imageutils_test.go +index e88a3e811514..a599fe80c0a2 100644 +--- a/pkg/engine/context/imageutils_test.go ++++ b/pkg/engine/context/imageutils_test.go +@@ -17,12 +17,12 @@ func Test_extractImageInfo(t *testing.T) { + { + raw: []byte(`{"apiVersion": "v1","kind": "Pod","metadata": {"name": "myapp"},"spec": {"initContainers": [{"name": "init","image": "index.docker.io/busybox:v1.2.3"}],"containers": [{"name": "nginx","image": "nginx:latest"}]}}`), + initContainers: []*containerImage{{Name: "init", Image: imageInfo{Registry: "index.docker.io", Name: "busybox", Tag: "v1.2.3"}}}, +- containers: []*containerImage{{Name: "nginx", Image: imageInfo{Name: "nginx", Tag: "latest"}}}, ++ containers: []*containerImage{{Name: "nginx", Image: imageInfo{Registry: "docker.io", Name: "nginx", Tag: "latest"}}}, + }, + { + raw: []byte(`{"apiVersion": "apps/v1","kind": "Deployment","metadata": {"name": "myapp"},"spec": {"selector": {"matchLabels": {"app": "myapp"}},"template": {"metadata": {"labels": {"app": "myapp"}},"spec": {"initContainers": [{"name": "init","image": "fictional.registry.example:10443/imagename:tag@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"}],"containers": [{"name": "myapp","image": "fictional.registry.example:10443/imagename"}]}}}}`), + initContainers: []*containerImage{{Name: "init", Image: imageInfo{Registry: "fictional.registry.example:10443", Name: "imagename", Tag: "tag", Digest: "sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"}}}, +- containers: []*containerImage{{Name: "myapp", Image: imageInfo{Registry: "fictional.registry.example:10443", Name: "imagename"}}}}, ++ containers: []*containerImage{{Name: "myapp", Image: imageInfo{Registry: "fictional.registry.example:10443", Name: "imagename", Tag: "latest"}}}}, + { + raw: []byte(`{"apiVersion": "batch/v1beta1","kind": "CronJob","metadata": {"name": "hello"},"spec": {"schedule": "*/1 * * * *","jobTemplate": {"spec": {"template": {"spec": {"containers": [{"name": "hello","image": "b.gcr.io/test.example.com/my-app:test.example.com"}]}}}}}}`), + containers: []*containerImage{{Name: "hello", Image: imageInfo{Registry: "b.gcr.io", Name: "test.example.com/my-app", Tag: "test.example.com"}}}, +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SsQ7CIBAG4M59ijPOFrHFPoO7e0NbrI0WDNDGxxe7aEzURWPU/2PggEuA3CVl ++3+7rQumBRe8yD3Ihxjm4nceYiwUPQ6R52Odc5HlE4m0vutI7Ly1RZI3xj/KenX+p5FJ/r5wvKtN1 ++UteJ277ujmf152l2qX8W8ni25GlE89c94b4/r/90wnpnWdlqFnqASum2cVXT2AylquPG0DmkhB12 ++TUhpWq1YZbRXR89oZntN63PfhKWVlV91slErvTE0G+JP/w0AAAAAAAAAAAAAAAAAAAAA4NedAOQs ++d6AAKAAA +diff --git 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-001751/tests/test.sh b/tasks/format-code-task-001751/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d8998aa951ae48e3f74c87ce693663d896f3a299 --- /dev/null +++ b/tasks/format-code-task-001751/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/engine/context/imageutils_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-001751/tests/test_command.sh b/tasks/format-code-task-001751/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001751/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001756/environment/Dockerfile b/tasks/format-code-task-001756/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e6d0f025cba1db4d9217ac455b19a67ab171b9c6 --- /dev/null +++ b/tasks/format-code-task-001756/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8966c22c51dc01f521c66eed9bec492e42d0376186df307bf04a383b142eef10 diff --git a/tasks/format-code-task-001756/environment/setup/files/blocklist b/tasks/format-code-task-001756/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001756/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001756/environment/setup/setup.sh b/tasks/format-code-task-001756/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001756/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001756/tests/test.patch b/tasks/format-code-task-001756/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c86f096f3156b87349f9ca0e102303cba476939b --- /dev/null +++ b/tasks/format-code-task-001756/tests/test.patch @@ -0,0 +1,58 @@ +diff --git a/tests/Queue/QueueRedisQueueTest.php b/tests/Queue/QueueRedisQueueTest.php +index 0ec421bda65c..8967d7b3f0ef 100644 +--- a/tests/Queue/QueueRedisQueueTest.php ++++ b/tests/Queue/QueueRedisQueueTest.php +@@ -44,6 +44,27 @@ public function testPushProperlyPushesJobOntoRedisWithCustomPayloadHook() + Queue::createPayloadUsing(null); + } + ++ public function testPushProperlyPushesJobOntoRedisWithTwoCustomPayloadHook() ++ { ++ $queue = $this->getMockBuilder(RedisQueue::class)->setMethods(['getRandomId'])->setConstructorArgs([$redis = m::mock(Factory::class), 'default'])->getMock(); ++ $queue->expects($this->once())->method('getRandomId')->will($this->returnValue('foo')); ++ $redis->shouldReceive('connection')->once()->andReturn($redis); ++ $redis->shouldReceive('rpush')->once()->with('queues:default', json_encode(['displayName' => 'foo', 'job' => 'foo', 'maxTries' => null, 'timeout' => null, 'data' => ['data'], 'custom' => 'taylor', 'bar' => 'foo', 'id' => 'foo', 'attempts' => 0])); ++ ++ Queue::createPayloadUsing(function ($connection, $queue, $payload) { ++ return ['custom' => 'taylor']; ++ }); ++ ++ Queue::createPayloadUsing(function ($connection, $queue, $payload) { ++ return ['bar' => 'foo']; ++ }); ++ ++ $id = $queue->push('foo', ['data']); ++ $this->assertEquals('foo', $id); ++ ++ Queue::createPayloadUsing(null); ++ } ++ + public function testDelayedPushProperlyPushesJobOntoRedis() + { + $queue = $this->getMockBuilder(RedisQueue::class)->setMethods(['availableAt', 'getRandomId'])->setConstructorArgs([$redis = m::mock(Factory::class), 'default'])->getMock(); +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+3TS4+bMBAA4Jz5FVNFandVAQHCpqe99NLetqveV8YM4MaxXT8S5d/XQNL0oXYv ++u6razncIBoxnxuNkTRCyfUC1zxfPZRVt6nq6Rj9ep3FRl0VZVlVRVItVUdSbcgH1s2X0jeA8swAL ++q7X/3bzH3v+lskv/PTr/wPVux1SbueHpYjzS/6JY1+f+l5tq7P/6prhZwOrpUvi1/7z/yxd5I1Te ++MDckvIXpEDTYJskS3mrViT5YhHgojHZowWsY4umQCBJ7xo9gGN+yHsEhD1b4I7B2L5y2Al3y9Ss+ ++LQRp2kvdMAlGS8GP2WVq1kjNt9Ax6RDK27zFfa6ClD8twaTUh9TI0Avlsu1R4pbF9inp8mBa5jEd ++UJoxURu+XynW817FVksJLRpULSoeI0NwQvXgjs7jDu7e3cHVm6y6hoPwAxjJfKftDix+diB6pW3c ++mSXETziCHxCM1Z+Qe4g59OjdtMAmK15DEzwc8FWMZoOCcVPdvCaD8Q/nTzPXlwrFKbs0VToVyqNl ++3Aut4gNjsUObtsL5eDfnkZ6TS6fkytuXxVjj/RgtJjYnNAWGTsR+zXWeosLVGDY+bqGzegdOBxsr ++Yh5ybXxuBrNZXyeX8XRE4gj2ceO0Pd8GJeYQLv8QMOD8e48x0Wn0Mb7K4rzkTx9yQgghhBBCCCGE ++EEIIIYQQQgghhJB/2BfltJRPACgAAA== +diff --git 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-001756/tests/test.sh b/tasks/format-code-task-001756/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1a5f142b48bcc626c1acac50f294636fdd7c2160 --- /dev/null +++ b/tasks/format-code-task-001756/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/Queue/QueueRedisQueueTest.php +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001756/tests/test_command.sh b/tasks/format-code-task-001756/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001756/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001758/environment/Dockerfile b/tasks/format-code-task-001758/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..413a6e84d86bbf9e9115369f6c8aef5ecdf204ac --- /dev/null +++ b/tasks/format-code-task-001758/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0921f836de95a95b10aac166066c0bf767e206343773753533a08a95784ae476 diff --git a/tasks/format-code-task-001758/environment/setup/files/blocklist b/tasks/format-code-task-001758/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001758/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001758/environment/setup/setup.sh b/tasks/format-code-task-001758/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001758/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001758/tests/test.patch b/tasks/format-code-task-001758/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5a3a0d9a106c3328adb4c7d38aeb58749395c2af --- /dev/null +++ b/tasks/format-code-task-001758/tests/test.patch @@ -0,0 +1,62 @@ +diff --git a/tests/Support/SupportStrTest.php b/tests/Support/SupportStrTest.php +index fbf5eeff6d0d..af0523b935fd 100755 +--- a/tests/Support/SupportStrTest.php ++++ b/tests/Support/SupportStrTest.php +@@ -425,6 +425,15 @@ public function testWrap() + $this->assertEquals('foo-bar-baz', Str::wrap('-bar-', 'foo', 'baz')); + } + ++ public function testUnwrap() ++ { ++ $this->assertEquals('value', Str::unwrap('"value"', '"')); ++ $this->assertEquals('value', Str::unwrap('"value', '"')); ++ $this->assertEquals('value', Str::unwrap('value"', '"')); ++ $this->assertEquals('bar', Str::unwrap('foo-bar-baz', 'foo-', '-baz')); ++ $this->assertEquals('some: "json"', Str::unwrap('{some: "json"}', '{', '}')); ++ } ++ + public function testIs() + { + $this->assertTrue(Str::is('/', '/')); +diff --git a/tests/Support/SupportStringableTest.php b/tests/Support/SupportStringableTest.php +index 5cf433fa4973..5192a62cc002 100644 +--- a/tests/Support/SupportStringableTest.php ++++ b/tests/Support/SupportStringableTest.php +@@ -1177,6 +1177,13 @@ public function testWrap() + $this->assertEquals('"value"', $this->stringable('value')->wrap('"')); + } + ++ public function testUnwrap() ++ { ++ $this->assertEquals('value', $this->stringable('"value"')->unwrap('"')); ++ $this->assertEquals('bar', $this->stringable('foo-bar-baz')->unwrap('foo-', '-baz')); ++ $this->assertEquals('some: "json"', $this->stringable('{some: "json"}')->unwrap('{', '}')); ++ } ++ + public function testToHtmlString() + { + $this->assertEquals( +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+3SzWrcMBAA4D37KaYESntYW/J2HXJoLyWHHFqX3dBjFtmaxAJZUiXZ7aEP34lL ++SCn5uSSU0PkwSFjDSJpR2U3G6gO6uVo9F0GOt9tlJH+Py1xua1nXm03TUJyUjWhWsH22E/1hSllF ++gFX0Pj8U99j6C1Xe9j9jyofej6NyukzD0+3xWP8bUd/2n+ZCvmvE8QrE0x3hfv95/49eVZ1xVafS ++UPQalkfQoS6KIzhzVBprQWNAp9H1BhO8+dh++tLuT3eHXdueH76e7vZn7WdwiBo1ZA8Rk7czwowx ++Ge+g9+7Smj5Twg7zd0QHXVSuH0Buyh9Abw2simpGW4Xox5ATpfg2mWjcFRhrp9E4lbHqvbXYZ0qZ ++4EKKUvy8kLIUb4s7D/SeIk5O6KP9x+ATRpiCpjywXju/Ni5jVEs2qD+8ltfX3U0O8oBAz+EKM1wX ++Ai6NxVSU1UwF8HGpVBjC5Mzv9VTtpxB8zDfjPsdz+l9S0L0BdC/VWbyJK/71C2CMMcYYY4wxxhhj ++jDHGGGOMMcYYYy/ZL8nq4msAKAAA +diff --git 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-001758/tests/test.sh b/tasks/format-code-task-001758/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4c6f7799de145ae7b2a6b6a7ba6b5ca469046d46 --- /dev/null +++ b/tasks/format-code-task-001758/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/Support/SupportStrTest.php +tests/Support/SupportStringableTest.php +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-001758/tests/test_command.sh b/tasks/format-code-task-001758/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001758/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001760/environment/Dockerfile b/tasks/format-code-task-001760/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bbf36c79e04e5623bdfe29ae7921181dadc1bdbc --- /dev/null +++ b/tasks/format-code-task-001760/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:44ab2c584ebe5f75167ca029d0286c6924950614099d85ae68ca7b330b826894 diff --git a/tasks/format-code-task-001760/environment/setup/files/blocklist b/tasks/format-code-task-001760/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001760/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001760/environment/setup/setup.sh b/tasks/format-code-task-001760/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001760/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001760/tests/test.patch b/tasks/format-code-task-001760/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8af0e25be7706991068b99382562fd38c52217b2 --- /dev/null +++ b/tasks/format-code-task-001760/tests/test.patch @@ -0,0 +1,293 @@ +diff --git a/usercase-test-coderl/fixtures/grammars/ab.lark b/usercase-test-coderl/fixtures/grammars/ab.lark +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/grammars/ab.lark +@@ -0,0 +1,10 @@ ++startab: expr ++ ++expr: A B ++ | A expr B ++ ++A: "a" ++B: "b" ++ ++%import common.WS ++%ignore WS +diff --git a/usercase-test-coderl/fixtures/grammars/rule_only.lark b/usercase-test-coderl/fixtures/grammars/rule_only.lark +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/grammars/rule_only.lark +@@ -0,0 +1,2 @@ ++start: item ++item: "a" +diff --git a/usercase-test-coderl/fixtures/grammars/term_only.lark b/usercase-test-coderl/fixtures/grammars/term_only.lark +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/grammars/term_only.lark +@@ -0,0 +1,2 @@ ++start: ITEM ++ITEM: "a" +diff --git a/usercase-test-coderl/fixtures/usercase_anchor.py b/usercase-test-coderl/fixtures/usercase_anchor.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/usercase_anchor.py +@@ -0,0 +1,2 @@ ++ ++ +diff --git a/usercase-test-coderl/test_extend_directive.py b/usercase-test-coderl/test_extend_directive.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_extend_directive.py +@@ -0,0 +1,228 @@ ++import gc ++ ++import pytest ++ ++from lark import GrammarError, Lark ++ ++ ++FIXTURES = "/workspace/repo/usercase-test-coderl/fixtures" ++SOURCE_PATH = f"{FIXTURES}/usercase_anchor.py" ++ ++ ++def test_imported_rule_extend_adds_alternative_inside_existing_rule(): ++ ++ ++ ++ ++ parser = Lark( ++ """ ++ %import .grammars.ab (startab, A, B, expr) ++ %extend expr: B A ++ """, ++ start="startab", ++ source_path=SOURCE_PATH, ++ ) ++ ++ ++ assert parser.parse("abab") is not None ++ ++ ++def test_multiple_rule_extends_accumulate_all_rule_alternatives(): ++ ++ ++ ++ ++ parser = Lark( ++ """ ++ start: x+ ++ x: "a" ++ %extend x: "b" ++ %extend x: "c" ++ """ ++ ) ++ ++ ++ assert parser.parse("a") is not None ++ assert parser.parse("b") is not None ++ assert parser.parse("c") is not None ++ assert parser.parse("abcba") is not None ++ ++ ++def test_terminal_extend_changes_matching_where_terminal_is_used(): ++ ++ ++ ++ ++ parser = Lark( ++ """ ++ %import .grammars.ab (startab, A, B, expr) ++ %extend A: "c" ++ """, ++ start="startab", ++ source_path=SOURCE_PATH, ++ ) ++ ++ ++ assert parser.parse("acbb") is not None ++ ++ ++def test_extending_undefined_symbol_fails_during_construction(): ++ ++ ++ ++ ++ with pytest.raises(GrammarError) as excinfo: ++ Lark( ++ """ ++ %extend missing: "b" ++ start: "a" ++ """ ++ ) ++ ++ ++ assert isinstance(excinfo.value, GrammarError) ++ ++ ++def test_extending_rule_as_terminal_fails_during_construction(): ++ ++ ++ ++ ++ with pytest.raises(GrammarError) as excinfo: ++ Lark( ++ """ ++ %import .grammars.rule_only.item -> ITEM ++ start: ITEM ++ %extend ITEM: "b" ++ """, ++ source_path=SOURCE_PATH, ++ ) ++ ++ ++ assert isinstance(excinfo.value, GrammarError) ++ ++ ++def test_extending_terminal_as_rule_fails_during_construction(): ++ ++ ++ ++ ++ with pytest.raises(GrammarError) as excinfo: ++ Lark( ++ """ ++ %import .grammars.term_only.ITEM -> item ++ start: item ++ %extend item: "b" ++ """, ++ source_path=SOURCE_PATH, ++ ) ++ ++ ++ assert isinstance(excinfo.value, GrammarError) ++ ++ ++def test_extending_template_with_different_parameter_list_fails_during_construction(): ++ ++ ++ ++ ++ with pytest.raises(GrammarError) as excinfo: ++ Lark( ++ """ ++ start: wrap{"a"} ++ wrap{x}: x ++ %extend wrap{x, y}: x y ++ """ ++ ) ++ ++ ++ assert isinstance(excinfo.value, GrammarError) ++ ++ ++def test_extending_declared_abstract_symbol_fails_during_construction(): ++ ++ ++ ++ ++ with pytest.raises(GrammarError) as excinfo: ++ Lark( ++ """ ++ start: A ++ %declare A ++ %extend A: "a" ++ """ ++ ) ++ ++ ++ assert isinstance(excinfo.value, GrammarError) ++ ++ ++def test_two_lark_instances_keep_extended_grammar_state_independent(): ++ ++ ++ ++ ++ parser_a = Lark( ++ """ ++ start: x+ ++ x: "a" ++ %extend x: "b" ++ """ ++ ) ++ parser_b = Lark( ++ """ ++ start: y+ ++ y: "c" ++ %extend y: "d" ++ """ ++ ) ++ ++ ++ assert parser_a.parse("abba") is not None ++ assert parser_b.parse("cddc") is not None ++ ++ ++def test_repeated_public_construction_parse_and_cleanup_accepts_extended_rule(): ++ ++ ++ ++ ++ grammar = """ ++ %import .grammars.ab (startab, A, B, expr) ++ %extend expr: B A ++ """ ++ ++ for _ in range(100): ++ parser = Lark(grammar, start="startab", source_path=SOURCE_PATH) ++ ++ assert parser.parse("abab") is not None ++ del parser ++ gc.collect() ++ ++ ++def test_reference_cleanup_path_is_idempotent_for_constructed_parser(): ++ ++ ++ ++ ++ parser = Lark( ++ """ ++ start: x ++ x: "a" ++ %extend x: "b" ++ """ ++ ) ++ ++ assert parser.parse("b") is not None ++ del parser ++ gc.collect() ++ parser = Lark( ++ """ ++ start: x ++ x: "a" ++ %extend x: "b" ++ """ ++ ) ++ ++ assert parser.parse("b") is not None ++ 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,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PIP_NO_INDEX=1 ++ ++exec /opt/coderl-stage4a-venv/bin/python -m pytest /workspace/repo/usercase-test-coderl/test_extend_directive.py -v diff --git a/tasks/format-code-task-001760/tests/test.sh b/tasks/format-code-task-001760/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..75dfbddb4cc7ec600a85af9f796458c89ee630b5 --- /dev/null +++ b/tasks/format-code-task-001760/tests/test.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/grammars/ab.lark +usercase-test-coderl/fixtures/grammars/rule_only.lark +usercase-test-coderl/fixtures/grammars/term_only.lark +usercase-test-coderl/fixtures/usercase_anchor.py +usercase-test-coderl/test_extend_directive.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-001760/tests/test_command.sh b/tasks/format-code-task-001760/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001760/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-001767/environment/Dockerfile b/tasks/format-code-task-001767/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8223a2944022fcd76e14378c71561e71b8e614e3 --- /dev/null +++ b/tasks/format-code-task-001767/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4b17085254e7342b71c16f99c027f90ed54f4eb777bf5c7b3ffa7aaa81d6510d diff --git a/tasks/format-code-task-001767/environment/setup/files/blocklist b/tasks/format-code-task-001767/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001767/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001767/environment/setup/setup.sh b/tasks/format-code-task-001767/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001767/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001767/tests/test.patch b/tasks/format-code-task-001767/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9c7026256afeaec4c470410433ea23fd61eab078 --- /dev/null +++ b/tasks/format-code-task-001767/tests/test.patch @@ -0,0 +1,473 @@ +diff --git a/usercase-test-coderl/dump_import_test.go b/usercase-test-coderl/dump_import_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/dump_import_test.go +@@ -0,0 +1,440 @@ ++package usercase_test_coderl ++ ++import ( ++ "bytes" ++ "encoding/binary" ++ "encoding/hex" ++ "errors" ++ "fmt" ++ "io" ++ "os" ++ "path/filepath" ++ "sync" ++ "testing" ++ "time" ++ ++ "github.com/ledisdb/ledisdb/config" ++ "github.com/ledisdb/ledisdb/ledis" ++ "github.com/siddontang/go/snappy" ++) ++ ++type dumpRecord struct { ++ keyHex string ++ valueHex string ++} ++ ++type parsedDump struct { ++ commitID uint64 ++ records []dumpRecord ++} ++ ++func TestDumpWritesConcreteStreamToAnyWriter(t *testing.T) { ++ ++ ++ root := t.TempDir() ++ src := openLedis(t, filepath.Join(root, "src")) ++ defer src.Close() ++ db := selectDB(t, src, 0) ++ mustSet(t, db, "alpha", "one") ++ mustSet(t, db, "beta", "two") ++ if n, err := db.HSet([]byte("hash"), []byte("field"), []byte("h-value")); err != nil { ++ t.Fatalf("HSet failed: %v", err) ++ } else if n != 1 { ++ t.Fatalf("HSet new-field count = %d, want 1", n) ++ } ++ ++ var buf bytes.Buffer ++ if err := src.Dump(&buf); err != nil { ++ t.Fatalf("Dump failed: %v", err) ++ } ++ ++ if got := buf.Len(); got <= 8 { ++ t.Fatalf("dump byte length = %d, want more than 8-byte header", got) ++ } ++ ++ parsed := parseDumpStream(t, buf.Bytes()) ++ want := []dumpRecord{ ++ {keyHex: "0001616c706861", valueHex: "6f6e65"}, ++ {keyHex: "000162657461", valueHex: "74776f"}, ++ {keyHex: "00020004686173683a6669656c64", valueHex: "682d76616c7565"}, ++ {keyHex: "000368617368", valueHex: "0100000000000000"}, ++ } ++ ++ if !recordsEqual(parsed.records, want) { ++ t.Fatalf("parsed records = %#v, want %#v", parsed.records, want) ++ } ++} ++ ++func TestDumpFileAndLoadDumpFileRoundTripIntoSeparateLedis(t *testing.T) { ++ ++ ++ root := t.TempDir() ++ src := openLedis(t, filepath.Join(root, "src")) ++ defer src.Close() ++ srcDB := selectDB(t, src, 0) ++ mustSet(t, srcDB, "alpha", "one") ++ mustSet(t, srcDB, "beta", "two") ++ if _, err := srcDB.HSet([]byte("hash"), []byte("field"), []byte("h-value")); err != nil { ++ t.Fatalf("HSet failed: %v", err) ++ } ++ ++ dumpPath := filepath.Join(root, "ledis.dump") ++ if err := src.DumpFile(dumpPath); err != nil { ++ t.Fatalf("DumpFile failed: %v", err) ++ } ++ ++ if info, err := os.Stat(dumpPath); err != nil { ++ t.Fatalf("dump file stat failed: %v", err) ++ } else if info.Size() <= 8 { ++ t.Fatalf("dump file size = %d, want more than 8-byte header", info.Size()) ++ } ++ dumpBytes, err := os.ReadFile(dumpPath) ++ if err != nil { ++ t.Fatalf("read dump file failed: %v", err) ++ } ++ parsed := parseDumpStream(t, dumpBytes) ++ ++ dst := openLedis(t, filepath.Join(root, "dst")) ++ defer dst.Close() ++ dstDB := selectDB(t, dst, 0) ++ mustSet(t, dstDB, "stale", "old") ++ ++ head, err := dst.LoadDumpFile(dumpPath) ++ if err != nil { ++ t.Fatalf("LoadDumpFile failed: %v", err) ++ } ++ ++ if head.CommitID != parsed.commitID { ++ t.Fatalf("loaded CommitID = %d, want stream CommitID %d", head.CommitID, parsed.commitID) ++ } ++ assertStringValue(t, dstDB, "alpha", "one") ++ assertStringValue(t, dstDB, "beta", "two") ++ assertMissingValue(t, dstDB, "stale") ++ assertHashStringValue(t, dstDB, "hash", "field", "h-value") ++} ++ ++func TestLoadDumpReadsAnyReaderAndClearsBeforeApplying(t *testing.T) { ++ ++ ++ root := t.TempDir() ++ src := openLedis(t, filepath.Join(root, "src")) ++ defer src.Close() ++ srcDB := selectDB(t, src, 0) ++ mustSet(t, srcDB, "alpha", "one") ++ mustSet(t, srcDB, "beta", "two") ++ ++ var buf bytes.Buffer ++ if err := src.Dump(&buf); err != nil { ++ t.Fatalf("Dump failed: %v", err) ++ } ++ dumpBytes := append([]byte(nil), buf.Bytes()...) ++ wantCommitID := uint64(0x0102030405060708) ++ binary.BigEndian.PutUint64(dumpBytes[:8], wantCommitID) ++ ++ dst := openLedis(t, filepath.Join(root, "dst")) ++ defer dst.Close() ++ dstDB := selectDB(t, dst, 0) ++ mustSet(t, dstDB, "stale", "old") ++ ++ head, err := dst.LoadDump(bytes.NewReader(dumpBytes)) ++ if err != nil { ++ t.Fatalf("LoadDump failed: %v", err) ++ } ++ ++ if head.CommitID != wantCommitID { ++ t.Fatalf("loaded CommitID = %d, want stream CommitID %d", head.CommitID, wantCommitID) ++ } ++ assertStringValue(t, dstDB, "alpha", "one") ++ assertStringValue(t, dstDB, "beta", "two") ++ assertMissingValue(t, dstDB, "stale") ++} ++ ++func TestDumpIsPointInTimeWhenWritesStartAfterDumpStarts(t *testing.T) { ++ ++ ++ root := t.TempDir() ++ src := openLedis(t, filepath.Join(root, "src")) ++ defer src.Close() ++ srcDB := selectDB(t, src, 0) ++ for i := 0; i < 300; i++ { ++ mustSet(t, srcDB, fmt.Sprintf("m%03d", i), fmt.Sprintf("value-%03d-abcdefghijklmnopqrstuvwxyz", i)) ++ } ++ ++ w := newGatedWriter() ++ dumpDone := make(chan error, 1) ++ go func() { ++ dumpDone <- src.Dump(w) ++ }() ++ select { ++ case <-w.started: ++ case <-time.After(5 * time.Second): ++ t.Fatal("Dump did not start writing within 5s") ++ } ++ ++ setDone := make(chan error, 1) ++ go func() { ++ setDone <- srcDB.Set([]byte("zz-after-start"), []byte("after-start")) ++ }() ++ time.Sleep(20 * time.Millisecond) ++ w.release() ++ ++ if err := <-setDone; err != nil { ++ t.Fatalf("post-start Set failed: %v", err) ++ } ++ if err := <-dumpDone; err != nil { ++ t.Fatalf("Dump failed: %v", err) ++ } ++ ++ dst := openLedis(t, filepath.Join(root, "dst")) ++ defer dst.Close() ++ dstDB := selectDB(t, dst, 0) ++ if _, err := dst.LoadDump(bytes.NewReader(w.bytes())); err != nil { ++ t.Fatalf("LoadDump failed: %v", err) ++ } ++ assertStringValue(t, srcDB, "zz-after-start", "after-start") ++ assertMissingValue(t, dstDB, "zz-after-start") ++ if keys, err := dstDB.Scan(ledis.KV, nil, 1000, true, ""); err != nil { ++ t.Fatalf("Scan failed: %v", err) ++ } else if len(keys) != 300 { ++ t.Fatalf("loaded KV key count = %d, want 300", len(keys)) ++ } ++} ++ ++func TestLoadDumpRejectsUnreadableMalformedTruncatedAndBadSnappyInputs(t *testing.T) { ++ ++ ++ root := t.TempDir() ++ l := openLedis(t, filepath.Join(root, "dst")) ++ defer l.Close() ++ ++ ++ if _, err := l.LoadDumpFile(filepath.Join(root, "missing.dump")); err == nil { ++ t.Fatal("LoadDumpFile missing path error = nil, want error") ++ } ++ ++ ++ if _, err := l.LoadDump(bytes.NewReader([]byte{1, 2, 3})); err == nil { ++ t.Fatal("short header error = nil, want error") ++ } ++ ++ badSnappyKey := make([]byte, 13) ++ binary.BigEndian.PutUint64(badSnappyKey[:8], 0) ++ binary.BigEndian.PutUint16(badSnappyKey[8:10], 3) ++ copy(badSnappyKey[10:], []byte{0xff, 0xff, 0xff}) ++ ++ if _, err := l.LoadDump(bytes.NewReader(badSnappyKey)); err == nil { ++ t.Fatal("bad snappy error = nil, want error") ++ } ++ ++ truncatedRecord := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 7, 24} ++ ++ if _, err := l.LoadDump(bytes.NewReader(truncatedRecord)); err == nil { ++ t.Fatal("truncated record error = nil, want error") ++ } ++} ++ ++func TestTwoLedisInstancesKeepIndependentStateUntilExplicitLoad(t *testing.T) { ++ ++ ++ root := t.TempDir() ++ a := openLedis(t, filepath.Join(root, "a")) ++ defer a.Close() ++ b := openLedis(t, filepath.Join(root, "b")) ++ defer b.Close() ++ aDB := selectDB(t, a, 0) ++ bDB := selectDB(t, b, 0) ++ ++ mustSet(t, aDB, "alpha", "one") ++ mustSet(t, aDB, "beta", "two") ++ ++ assertStringValue(t, aDB, "alpha", "one") ++ assertStringValue(t, aDB, "beta", "two") ++ assertMissingValue(t, bDB, "alpha") ++ assertMissingValue(t, bDB, "beta") ++} ++ ++func TestOpenUseCloseCyclesDumpAndLoadRepeatedly(t *testing.T) { ++ ++ ++ ++ root := t.TempDir() ++ ++ for i := 0; i < 3; i++ { ++ src := openLedis(t, filepath.Join(root, fmt.Sprintf("src-%03d", i))) ++ srcDB := selectDB(t, src, 0) ++ mustSet(t, srcDB, "alpha", "one") ++ dumpPath := filepath.Join(root, fmt.Sprintf("cycle-%03d.dump", i)) ++ if err := src.DumpFile(dumpPath); err != nil { ++ t.Fatalf("cycle %d DumpFile failed: %v", i, err) ++ } ++ ++ dst := openLedis(t, filepath.Join(root, fmt.Sprintf("dst-%03d", i))) ++ dstDB := selectDB(t, dst, 0) ++ head, err := dst.LoadDumpFile(dumpPath) ++ if err != nil { ++ t.Fatalf("cycle %d LoadDumpFile failed: %v", i, err) ++ } ++ ++ if head == nil { ++ t.Fatalf("cycle %d LoadDumpFile returned nil DumpHead", i) ++ } ++ assertStringValue(t, dstDB, "alpha", "one") ++ src.Close() ++ dst.Close() ++ } ++} ++ ++type gatedWriter struct { ++ started chan struct{} ++ gate chan struct{} ++ once sync.Once ++ buf bytes.Buffer ++} ++ ++func newGatedWriter() *gatedWriter { ++ return &gatedWriter{started: make(chan struct{}), gate: make(chan struct{})} ++} ++ ++func (w *gatedWriter) Write(p []byte) (int, error) { ++ w.once.Do(func() { ++ close(w.started) ++ <-w.gate ++ }) ++ return w.buf.Write(p) ++} ++ ++func (w *gatedWriter) release() { ++ close(w.gate) ++} ++ ++func (w *gatedWriter) bytes() []byte { ++ return w.buf.Bytes() ++} ++ ++func openLedis(t *testing.T, dir string) *ledis.Ledis { ++ t.Helper() ++ cfg := config.NewConfigDefault() ++ cfg.DataDir = dir ++ if err := os.RemoveAll(dir); err != nil { ++ t.Fatalf("RemoveAll(%q) failed: %v", dir, err) ++ } ++ l, err := ledis.Open(cfg) ++ if err != nil { ++ t.Fatalf("ledis.Open(%q) failed: %v", dir, err) ++ } ++ return l ++} ++ ++func selectDB(t *testing.T, l *ledis.Ledis, index int) *ledis.DB { ++ t.Helper() ++ db, err := l.Select(index) ++ if err != nil { ++ t.Fatalf("Select(%d) failed: %v", index, err) ++ } ++ return db ++} ++ ++func mustSet(t *testing.T, db *ledis.DB, key string, value string) { ++ t.Helper() ++ if err := db.Set([]byte(key), []byte(value)); err != nil { ++ t.Fatalf("Set(%q, %q) failed: %v", key, value, err) ++ } ++} ++ ++func assertStringValue(t *testing.T, db *ledis.DB, key string, want string) { ++ t.Helper() ++ got, err := db.Get([]byte(key)) ++ if err != nil { ++ t.Fatalf("Get(%q) failed: %v", key, err) ++ } ++ if got == nil { ++ t.Fatalf("Get(%q) = nil, want %q", key, want) ++ } ++ if string(got) != want { ++ t.Fatalf("Get(%q) = %q, want %q", key, string(got), want) ++ } ++} ++ ++func assertMissingValue(t *testing.T, db *ledis.DB, key string) { ++ t.Helper() ++ got, err := db.Get([]byte(key)) ++ if err != nil { ++ t.Fatalf("Get(%q) failed: %v", key, err) ++ } ++ if got != nil { ++ t.Fatalf("Get(%q) = %q, want nil", key, string(got)) ++ } ++} ++ ++func assertHashStringValue(t *testing.T, db *ledis.DB, key string, field string, want string) { ++ t.Helper() ++ got, err := db.HGet([]byte(key), []byte(field)) ++ if err != nil { ++ t.Fatalf("HGet(%q, %q) failed: %v", key, field, err) ++ } ++ if string(got) != want { ++ t.Fatalf("HGet(%q, %q) = %q, want %q", key, field, string(got), want) ++ } ++} ++ ++func parseDumpStream(t *testing.T, data []byte) parsedDump { ++ t.Helper() ++ r := bytes.NewReader(data) ++ var out parsedDump ++ if err := binary.Read(r, binary.BigEndian, &out.commitID); err != nil { ++ t.Fatalf("read dump header failed: %v", err) ++ } ++ for { ++ var keyLen uint16 ++ if err := binary.Read(r, binary.BigEndian, &keyLen); err != nil { ++ if errors.Is(err, io.EOF) { ++ break ++ } ++ t.Fatalf("read key length failed: %v", err) ++ } ++ keyCompressed := make([]byte, keyLen) ++ if _, err := io.ReadFull(r, keyCompressed); err != nil { ++ t.Fatalf("read compressed key failed: %v", err) ++ } ++ key, err := snappy.Decode(nil, keyCompressed) ++ if err != nil { ++ t.Fatalf("decode key failed: %v", err) ++ } ++ ++ var valueLen uint32 ++ if err := binary.Read(r, binary.BigEndian, &valueLen); err != nil { ++ t.Fatalf("read value length failed: %v", err) ++ } ++ valueCompressed := make([]byte, valueLen) ++ if _, err := io.ReadFull(r, valueCompressed); err != nil { ++ t.Fatalf("read compressed value failed: %v", err) ++ } ++ value, err := snappy.Decode(nil, valueCompressed) ++ if err != nil { ++ t.Fatalf("decode value failed: %v", err) ++ } ++ out.records = append(out.records, dumpRecord{ ++ keyHex: hex.EncodeToString(key), ++ valueHex: hex.EncodeToString(value), ++ }) ++ } ++ return out ++} ++ ++func recordsEqual(a []dumpRecord, b []dumpRecord) bool { ++ if len(a) != len(b) { ++ return false ++ } ++ ++ counts := make(map[dumpRecord]int, len(a)) ++ for _, record := range a { ++ counts[record]++ ++ } ++ for _, record := range b { ++ if counts[record] == 0 { ++ return false ++ } ++ counts[record]-- ++ } ++ return true ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,23 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export GO111MODULE=on ++export GOPROXY=off ++export GOSUMDB=off ++export GONOSUMDB='*' ++export GONOPROXY='*' ++export GOVCS='*:off' ++export GOTOOLCHAIN=local ++unset GOFLAGS ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++exec go test -mod=vendor -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001767/tests/test.sh b/tasks/format-code-task-001767/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..772de0c042b5f577028dc7771a2440aa67ff2d1f --- /dev/null +++ b/tasks/format-code-task-001767/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/dump_import_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-001767/tests/test_command.sh b/tasks/format-code-task-001767/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001767/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-001769/environment/Dockerfile b/tasks/format-code-task-001769/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d23c85f1c533f6e30cf26215600ad25b35e55ffc --- /dev/null +++ b/tasks/format-code-task-001769/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3cb858ba711883f7f931503d5da6eb3053886d48b8a0299ab91a6643cccddf16 diff --git a/tasks/format-code-task-001769/environment/setup/files/blocklist b/tasks/format-code-task-001769/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001769/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001769/environment/setup/setup.sh b/tasks/format-code-task-001769/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001769/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001769/tests/test.patch b/tasks/format-code-task-001769/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3b86243b7d994aa9a49df22f10e5a66fed8e6c78 --- /dev/null +++ b/tasks/format-code-task-001769/tests/test.patch @@ -0,0 +1,301 @@ +diff --git a/usercase-test-coderl/test_source_position_point_source.py b/usercase-test-coderl/test_source_position_point_source.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_source_position_point_source.py +@@ -0,0 +1,272 @@ ++ ++ ++import numpy as np ++import pytest ++ ++from lenstronomy.LensModel.lens_model import LensModel ++from lenstronomy.PointSource.point_source import PointSource ++ ++ ++KWARGS_LENS = [{"theta_E": 1, "center_x": 0, "center_y": 0}] ++ ++ ++def _sis_lens_model(): ++ return LensModel(lens_model_list=["SIS"]) ++ ++ ++def _source_position_point_source(*, fixed_magnification=False): ++ return PointSource( ++ point_source_type_list=["SOURCE_POSITION"], ++ lens_model=_sis_lens_model(), ++ fixed_magnification_list=[fixed_magnification], ++ magnification_limit=None, ++ kwargs_lens_eqn_solver=None, ++ redshift_list=None, ++ ) ++ ++ ++def _first_component_xy(position_tuple): ++ return position_tuple[0][0], position_tuple[1][0] ++ ++ ++def _assert_two_sis_images_for_source(x_image, y_image, ra_source=0.1, dec_source=0.0): ++ ++ assert len(x_image) == 2 ++ assert len(y_image) == 2 ++ order = np.argsort(np.asarray(x_image)) ++ expected_x = [ra_source - 1.0, ra_source + 1.0] ++ np.testing.assert_allclose(np.asarray(x_image)[order], expected_x, atol=1e-5) ++ np.testing.assert_allclose(np.asarray(y_image)[order], [0.0, 0.0], atol=1e-5) ++ ++ ray_x, ray_y = _sis_lens_model().ray_shooting(x_image, y_image, KWARGS_LENS) ++ np.testing.assert_allclose(ray_x, [ra_source, ra_source], atol=1e-5) ++ np.testing.assert_allclose(ray_y, [dec_source, dec_source], atol=1e-5) ++ ++ ++def test_source_position_session_solves_images_and_uses_explicit_point_amp(): ++ ++ ++ ++ kwargs_ps = [{"ra_source": 0.1, "dec_source": 0.0, "point_amp": [2, 1]}] ++ point_source = _source_position_point_source(fixed_magnification=False) ++ ++ assert point_source.point_source_type_list == ["SOURCE_POSITION"] ++ ++ x_source_list, y_source_list = point_source.source_position(kwargs_ps, KWARGS_LENS) ++ np.testing.assert_allclose([float(x_source_list[0])], [0.1], atol=0.0, rtol=0.0) ++ np.testing.assert_allclose([float(y_source_list[0])], [0.0], atol=0.0, rtol=0.0) ++ ++ x_image, y_image = _first_component_xy( ++ point_source.image_position(kwargs_ps, KWARGS_LENS) ++ ) ++ _assert_two_sis_images_for_source(x_image, y_image) ++ ++ image_amp = point_source.image_amplitude(kwargs_ps, KWARGS_LENS) ++ np.testing.assert_array_equal(image_amp[0], np.array([2, 1])) ++ ++ source_amp = point_source.source_amplitude(kwargs_ps, KWARGS_LENS) ++ ++ assert len(source_amp) == 1 ++ assert np.isfinite(float(source_amp[0])) ++ ++ ra_array, dec_array, amp_array = point_source.point_source_list( ++ kwargs_ps, KWARGS_LENS ++ ) ++ _assert_two_sis_images_for_source(ra_array, dec_array) ++ np.testing.assert_array_equal(amp_array, np.array([2, 1])) ++ ++ ++def test_scalar_point_amp_expands_to_each_solved_image(): ++ ++ ++ ++ kwargs_ps = [{"ra_source": 0.1, "dec_source": 0.0, "point_amp": 3.0}] ++ point_source = _source_position_point_source(fixed_magnification=False) ++ ++ image_amp = point_source.image_amplitude(kwargs_ps, KWARGS_LENS) ++ np.testing.assert_allclose(image_amp[0], [3.0, 3.0], atol=0.0, rtol=0.0) ++ ++ source_amp = point_source.source_amplitude(kwargs_ps, KWARGS_LENS) ++ ++ assert len(source_amp) == 1 ++ assert np.isfinite(float(source_amp[0])) ++ ++ ra_array, dec_array, amp_array = point_source.point_source_list( ++ kwargs_ps, KWARGS_LENS ++ ) ++ _assert_two_sis_images_for_source(ra_array, dec_array) ++ np.testing.assert_allclose(amp_array, [3.0, 3.0], atol=0.0, rtol=0.0) ++ ++ ++def test_fixed_magnification_uses_source_amp_and_absolute_sis_magnification(): ++ ++ ++ ++ kwargs_ps = [{"ra_source": 0.1, "dec_source": 0.0, "source_amp": 3.0}] ++ point_source = _source_position_point_source(fixed_magnification=True) ++ ++ x_image, y_image = _first_component_xy( ++ point_source.image_position(kwargs_ps, KWARGS_LENS) ++ ) ++ _assert_two_sis_images_for_source(x_image, y_image) ++ ++ image_amp = point_source.image_amplitude(kwargs_ps, KWARGS_LENS) ++ expected_amp = 3.0 * np.abs( ++ _sis_lens_model().magnification(x_image, y_image, KWARGS_LENS) ++ ) ++ ++ np.testing.assert_allclose(image_amp[0], expected_amp, atol=1e-5, rtol=0.0) ++ ++ source_amp = point_source.source_amplitude(kwargs_ps, KWARGS_LENS) ++ np.testing.assert_allclose([float(source_amp[0])], [3.0], atol=0.0, rtol=0.0) ++ ++ ra_array, dec_array, amp_array = point_source.point_source_list( ++ kwargs_ps, KWARGS_LENS ++ ) ++ _assert_two_sis_images_for_source(ra_array, dec_array) ++ expected_flat_amp = 3.0 * np.abs( ++ _sis_lens_model().magnification(ra_array, dec_array, KWARGS_LENS) ++ ) ++ ++ np.testing.assert_allclose(amp_array, expected_flat_amp, atol=1e-5, rtol=0.0) ++ ++ ++def test_mag_pert_multiplies_and_trims_to_solved_image_count(): ++ ++ ++ ++ kwargs_ps = [ ++ { ++ "ra_source": 0.1, ++ "dec_source": 0.0, ++ "source_amp": 3.0, ++ ++ ++ "mag_pert": [1.0, 0.5], ++ } ++ ] ++ point_source = _source_position_point_source(fixed_magnification=True) ++ x_image, y_image = _first_component_xy( ++ point_source.image_position(kwargs_ps, KWARGS_LENS) ++ ) ++ ++ image_amp = point_source.image_amplitude(kwargs_ps, KWARGS_LENS) ++ expected_amp = ( ++ 3.0 ++ * np.abs(_sis_lens_model().magnification(x_image, y_image, KWARGS_LENS)) ++ * np.asarray(kwargs_ps[0]["mag_pert"]) ++ ) ++ ++ np.testing.assert_allclose(image_amp[0], expected_amp, atol=1e-5, rtol=0.0) ++ ++ ra_array, dec_array, amp_array = point_source.point_source_list( ++ kwargs_ps, KWARGS_LENS ++ ) ++ _assert_two_sis_images_for_source(ra_array, dec_array) ++ expected_flat_amp = ( ++ 3.0 ++ * np.abs(_sis_lens_model().magnification(ra_array, dec_array, KWARGS_LENS)) ++ * np.asarray(kwargs_ps[0]["mag_pert"]) ++ ) ++ ++ np.testing.assert_allclose(amp_array, expected_flat_amp, atol=1e-5, rtol=0.0) ++ ++ ++def test_missing_source_plane_coordinates_raise_key_error_from_needed_call(): ++ ++ ++ ++ missing_ra = [{"dec_source": 0.0, "point_amp": [2, 1]}] ++ missing_dec = [{"ra_source": 0.1, "point_amp": [2, 1]}] ++ point_source = _source_position_point_source(fixed_magnification=False) ++ ++ ++ with pytest.raises(KeyError): ++ point_source.image_position(missing_ra, KWARGS_LENS) ++ ++ ++ with pytest.raises(KeyError): ++ point_source.image_position(missing_dec, KWARGS_LENS) ++ ++ ++def test_same_instance_uses_current_point_amp_values(): ++ ++ ++ ++ ++ first_kwargs_ps = [{"ra_source": 0.1, "dec_source": 0.0, "point_amp": [2, 1]}] ++ second_kwargs_ps = [{"ra_source": 0.1, "dec_source": 0.0, "point_amp": [4, 5]}] ++ point_source = _source_position_point_source(fixed_magnification=False) ++ ++ x_source_list, y_source_list = point_source.source_position( ++ first_kwargs_ps, KWARGS_LENS ++ ) ++ np.testing.assert_allclose([float(x_source_list[0])], [0.1], atol=0.0, rtol=0.0) ++ np.testing.assert_allclose([float(y_source_list[0])], [0.0], atol=0.0, rtol=0.0) ++ ++ x_recomputed_list, y_recomputed_list = point_source.source_position( ++ second_kwargs_ps, KWARGS_LENS ++ ) ++ np.testing.assert_allclose( ++ [float(x_recomputed_list[0])], [0.1], atol=0.0, rtol=0.0 ++ ) ++ np.testing.assert_allclose( ++ [float(y_recomputed_list[0])], [0.0], atol=0.0, rtol=0.0 ++ ) ++ x_image, y_image = _first_component_xy( ++ point_source.image_position(second_kwargs_ps, KWARGS_LENS) ++ ) ++ _assert_two_sis_images_for_source(x_image, y_image) ++ image_amp = point_source.image_amplitude(second_kwargs_ps, KWARGS_LENS) ++ np.testing.assert_array_equal(image_amp[0], np.array([4, 5])) ++ ++ ++def test_two_instances_keep_independent_source_state(): ++ ++ ++ ++ ++ first_kwargs_ps = [{"ra_source": 0.1, "dec_source": 0.0, "point_amp": [2, 1]}] ++ second_kwargs_ps = [{"ra_source": 0.1, "dec_source": 0.0, "point_amp": [4, 5]}] ++ point_source_a = _source_position_point_source(fixed_magnification=False) ++ point_source_b = _source_position_point_source(fixed_magnification=False) ++ ++ a_x_source, a_y_source = point_source_a.source_position( ++ first_kwargs_ps, KWARGS_LENS ++ ) ++ b_x_source, b_y_source = point_source_b.source_position( ++ second_kwargs_ps, KWARGS_LENS ++ ) ++ np.testing.assert_allclose([float(a_x_source[0])], [0.1], atol=0.0, rtol=0.0) ++ np.testing.assert_allclose([float(a_y_source[0])], [0.0], atol=0.0, rtol=0.0) ++ np.testing.assert_allclose([float(b_x_source[0])], [0.1], atol=0.0, rtol=0.0) ++ np.testing.assert_allclose([float(b_y_source[0])], [0.0], atol=0.0, rtol=0.0) ++ ++ a_x_image, a_y_image = _first_component_xy( ++ point_source_a.image_position(first_kwargs_ps, KWARGS_LENS) ++ ) ++ b_x_image, b_y_image = _first_component_xy( ++ point_source_b.image_position(second_kwargs_ps, KWARGS_LENS) ++ ) ++ _assert_two_sis_images_for_source(a_x_image, a_y_image, ra_source=0.1) ++ _assert_two_sis_images_for_source(b_x_image, b_y_image, ra_source=0.1) ++ a_image_amp = point_source_a.image_amplitude(first_kwargs_ps, KWARGS_LENS) ++ b_image_amp = point_source_b.image_amplitude(second_kwargs_ps, KWARGS_LENS) ++ np.testing.assert_array_equal(a_image_amp[0], np.array([2, 1])) ++ np.testing.assert_array_equal(b_image_amp[0], np.array([4, 5])) ++ ++ ++def test_repeated_source_position_sessions_support_varied_point_amp_values(): ++ ++ ++ ++ ++ for index in range(5): ++ point_amp = np.array([index + 2, index + 3]) ++ point_source = _source_position_point_source(fixed_magnification=False) ++ ra_array, dec_array, amp_array = point_source.point_source_list( ++ [{"ra_source": 0.1, "dec_source": 0.0, "point_amp": point_amp}], ++ KWARGS_LENS, ++ ) ++ _assert_two_sis_images_for_source(ra_array, dec_array) ++ np.testing.assert_array_equal(amp_array, point_amp) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:${PYTHONPATH}}" ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_source_position_point_source.py -v diff --git a/tasks/format-code-task-001769/tests/test.sh b/tasks/format-code-task-001769/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bc37b95211afcbe459b1bc432f2b5014a8452472 --- /dev/null +++ b/tasks/format-code-task-001769/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_source_position_point_source.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-001769/tests/test_command.sh b/tasks/format-code-task-001769/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001769/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-001793/environment/Dockerfile b/tasks/format-code-task-001793/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4630c29a5cc85869db1cdfc6e454ea32abd9e456 --- /dev/null +++ b/tasks/format-code-task-001793/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:57c9318f609fb4e841d54458ca00acc383268e318c1041d351dd4c72ffd34d8d diff --git a/tasks/format-code-task-001793/environment/setup/files/blocklist b/tasks/format-code-task-001793/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001793/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001793/environment/setup/setup.sh b/tasks/format-code-task-001793/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001793/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001793/tests/test.patch b/tasks/format-code-task-001793/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0738d6f7b0d72f90e571e36703a587395272b55a --- /dev/null +++ b/tasks/format-code-task-001793/tests/test.patch @@ -0,0 +1,384 @@ +diff --git a/usercase-test-coderl/fixtures/acceptance_plugins/__init__.py b/usercase-test-coderl/fixtures/acceptance_plugins/__init__.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/acceptance_plugins/__init__.py +@@ -0,0 +1,1 @@ ++ +diff --git a/usercase-test-coderl/fixtures/acceptance_plugins/cleanup_vendor.py b/usercase-test-coderl/fixtures/acceptance_plugins/cleanup_vendor.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/acceptance_plugins/cleanup_vendor.py +@@ -0,0 +1,14 @@ ++class cleanup_vendor(object): ++ supports = frozenset(["call"]) ++ cleanup_calls = 0 ++ ++ def __init__(self, config): ++ pass ++ ++ def send(self, message): ++ return 501 ++ ++ def cleanup(self): ++ type(self).cleanup_calls += 1 ++ ++ +diff --git a/usercase-test-coderl/fixtures/acceptance_plugins/failing_vendor.py b/usercase-test-coderl/fixtures/acceptance_plugins/failing_vendor.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/acceptance_plugins/failing_vendor.py +@@ -0,0 +1,11 @@ ++class failing_vendor(object): ++ supports = frozenset(["call"]) ++ attempts = 0 ++ ++ def __init__(self, config): ++ pass ++ ++ def send(self, message): ++ type(self).attempts += 1 ++ raise ValueError("planned vendor failure") ++ +diff --git a/usercase-test-coderl/fixtures/acceptance_plugins/flaky_retry_a.py b/usercase-test-coderl/fixtures/acceptance_plugins/flaky_retry_a.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/acceptance_plugins/flaky_retry_a.py +@@ -0,0 +1,18 @@ ++from acceptance_plugins import retry_log ++ ++ ++class flaky_retry_a(object): ++ supports = frozenset(["call"]) ++ ++ def __init__(self, config): ++ self._calls = 0 ++ ++ def send(self, message): ++ self._calls += 1 ++ if self._calls == 1: ++ retry_log.events.append("fail") ++ raise RuntimeError("flaky_retry_a planned failure") ++ retry_log.events.append("success") ++ return 77 ++ ++ +diff --git a/usercase-test-coderl/fixtures/acceptance_plugins/flaky_retry_b.py b/usercase-test-coderl/fixtures/acceptance_plugins/flaky_retry_b.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/acceptance_plugins/flaky_retry_b.py +@@ -0,0 +1,18 @@ ++from acceptance_plugins import retry_log ++ ++ ++class flaky_retry_b(object): ++ supports = frozenset(["call"]) ++ ++ def __init__(self, config): ++ self._calls = 0 ++ ++ def send(self, message): ++ self._calls += 1 ++ if self._calls == 1: ++ retry_log.events.append("fail") ++ raise RuntimeError("flaky_retry_b planned failure") ++ retry_log.events.append("success") ++ return 77 ++ ++ +diff --git a/usercase-test-coderl/fixtures/acceptance_plugins/multi_mode_vendor.py b/usercase-test-coderl/fixtures/acceptance_plugins/multi_mode_vendor.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/acceptance_plugins/multi_mode_vendor.py +@@ -0,0 +1,10 @@ ++class multi_mode_vendor(object): ++ supports = frozenset(["call", "sms"]) ++ ++ def __init__(self, config): ++ self._returns = dict(config.get("returns", {})) ++ ++ def send(self, message): ++ return self._returns[message["mode"]] ++ ++ +diff --git a/usercase-test-coderl/fixtures/acceptance_plugins/no_cleanup_vendor.py b/usercase-test-coderl/fixtures/acceptance_plugins/no_cleanup_vendor.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/acceptance_plugins/no_cleanup_vendor.py +@@ -0,0 +1,10 @@ ++class no_cleanup_vendor(object): ++ supports = frozenset(["call"]) ++ ++ def __init__(self, config): ++ pass ++ ++ def send(self, message): ++ return 601 ++ ++ +diff --git a/usercase-test-coderl/fixtures/acceptance_plugins/retry_log.py b/usercase-test-coderl/fixtures/acceptance_plugins/retry_log.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/acceptance_plugins/retry_log.py +@@ -0,0 +1,3 @@ ++events = [] ++ ++ +diff --git a/usercase-test-coderl/fixtures/acceptance_plugins/stateful_counter_vendor.py b/usercase-test-coderl/fixtures/acceptance_plugins/stateful_counter_vendor.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/acceptance_plugins/stateful_counter_vendor.py +@@ -0,0 +1,25 @@ ++class stateful_counter_vendor(object): ++ supports = frozenset(["call"]) ++ construct_calls = 0 ++ cleanup_calls = 0 ++ active_instances = 0 ++ send_values = [] ++ ++ def __init__(self, config): ++ type(self).construct_calls += 1 ++ type(self).active_instances += 1 ++ self._next_value = 300 ++ self._cleaned = False ++ ++ def send(self, message): ++ self._next_value += 1 ++ type(self).send_values.append(self._next_value) ++ return self._next_value ++ ++ def cleanup(self): ++ type(self).cleanup_calls += 1 ++ if not self._cleaned: ++ type(self).active_instances -= 1 ++ self._cleaned = True ++ ++ +diff --git a/usercase-test-coderl/test_vendor_manager_stateful.py b/usercase-test-coderl/test_vendor_manager_stateful.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_vendor_manager_stateful.py +@@ -0,0 +1,199 @@ ++import sys ++ ++import pytest ++ ++ ++FIXTURES = "/workspace/repo/usercase-test-coderl/fixtures" ++if FIXTURES not in sys.path: ++ sys.path.insert(0, FIXTURES) ++ ++from iris.vendors import IrisVendorException, IrisVendorManager ++from acceptance_plugins import retry_log ++from acceptance_plugins.cleanup_vendor import cleanup_vendor ++from acceptance_plugins.failing_vendor import failing_vendor ++from acceptance_plugins.stateful_counter_vendor import stateful_counter_vendor ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++def reset_stateful_counter_vendor(): ++ stateful_counter_vendor.construct_calls = 0 ++ stateful_counter_vendor.cleanup_calls = 0 ++ stateful_counter_vendor.active_instances = 0 ++ stateful_counter_vendor.send_values = [] ++ ++ ++def test_dummy_default_application_wrapper_and_unknown_application_fallback(): ++ ++ ++ ++ ++ manager = IrisVendorManager([{"type": "iris_dummy"}], ["dummy_app"]) ++ ++ assert manager.send_message({"mode": "call"}) == 1 ++ assert manager.send_message({"application": "dummy app", "mode": "call"}) == 2 ++ assert manager.send_message({"application": "unknown app", "mode": "call"}) == 1 ++ ++ ++def test_single_vendor_instance_is_built_once_and_retained_across_sends(): ++ ++ ++ ++ ++ reset_stateful_counter_vendor() ++ manager = IrisVendorManager( ++ [{"type": "acceptance_plugins.stateful_counter_vendor"}], [] ++ ) ++ ++ assert stateful_counter_vendor.construct_calls == 1 ++ assert stateful_counter_vendor.active_instances == 1 ++ assert stateful_counter_vendor.cleanup_calls == 0 ++ assert stateful_counter_vendor.send_values == [] ++ ++ assert manager.send_message({"mode": "call"}) == 301 ++ assert manager.send_message({"mode": "call"}) == 302 ++ assert stateful_counter_vendor.construct_calls == 1 ++ assert stateful_counter_vendor.active_instances == 1 ++ assert stateful_counter_vendor.cleanup_calls == 0 ++ assert stateful_counter_vendor.send_values == [301, 302] ++ ++ manager.cleanup() ++ ++ ++def test_vendor_is_registered_for_each_supported_mode(): ++ ++ ++ ++ ++ manager = IrisVendorManager( ++ [ ++ { ++ "type": "acceptance_plugins.multi_mode_vendor", ++ "returns": {"call": 401, "sms": 402}, ++ } ++ ], ++ [], ++ ) ++ ++ assert manager.send_message({"mode": "call"}) == 401 ++ assert manager.send_message({"mode": "sms"}) == 402 ++ ++ ++def test_failed_vendor_send_retries_next_vendor_before_returning_success(): ++ ++ ++ ++ ++ retry_log.events[:] = [] ++ manager = IrisVendorManager( ++ [ ++ {"type": "acceptance_plugins.flaky_retry_a"}, ++ {"type": "acceptance_plugins.flaky_retry_b"}, ++ ], ++ [], ++ ) ++ ++ assert manager.send_message({"mode": "call"}) == 77 ++ assert retry_log.events.count("fail") == 2 ++ assert retry_log.events.count("success") == 1 ++ assert len(retry_log.events) == 3 ++ ++ ++def test_exhausted_delivery_attempts_raise_specific_vendor_exception(): ++ ++ ++ ++ ++ failing_vendor.attempts = 0 ++ manager = IrisVendorManager([{"type": "acceptance_plugins.failing_vendor"}], []) ++ ++ with pytest.raises(IrisVendorException) as exc_info: ++ manager.send_message({"mode": "call"}) ++ ++ ++ assert str(exc_info.value).strip() ++ assert "call" in str(exc_info.value).lower() ++ ++ assert failing_vendor.attempts >= 1 ++ ++ ++def test_cleanup_calls_available_vendor_cleanup_and_ignores_missing_cleanup_twice(): ++ ++ ++ ++ ++ cleanup_vendor.cleanup_calls = 0 ++ manager = IrisVendorManager( ++ [ ++ {"type": "acceptance_plugins.cleanup_vendor"}, ++ {"type": "acceptance_plugins.no_cleanup_vendor"}, ++ ], ++ [], ++ ) ++ ++ assert cleanup_vendor.cleanup_calls == 0 ++ manager.cleanup() ++ assert cleanup_vendor.cleanup_calls == 1 ++ manager.cleanup() ++ ++ assert cleanup_vendor.cleanup_calls >= 1 ++ ++ ++def test_two_managers_keep_independent_vendor_state(): ++ ++ ++ ++ ++ reset_stateful_counter_vendor() ++ first = IrisVendorManager( ++ [{"type": "acceptance_plugins.stateful_counter_vendor"}], [] ++ ) ++ second = IrisVendorManager( ++ [{"type": "acceptance_plugins.stateful_counter_vendor"}], [] ++ ) ++ ++ assert first.send_message({"mode": "call"}) == 301 ++ assert first.send_message({"mode": "call"}) == 302 ++ assert second.send_message({"mode": "call"}) == 301 ++ assert stateful_counter_vendor.construct_calls == 2 ++ assert stateful_counter_vendor.active_instances == 2 ++ assert stateful_counter_vendor.send_values == [301, 302, 301] ++ ++ first.cleanup() ++ second.cleanup() ++ assert stateful_counter_vendor.active_instances == 0 ++ assert stateful_counter_vendor.cleanup_calls == 2 ++ ++ ++def test_construct_use_cleanup_cycles_do_not_leave_vendor_instances_active(): ++ ++ ++ ++ ++ reset_stateful_counter_vendor() ++ ++ for _ in range(125): ++ manager = IrisVendorManager( ++ [{"type": "acceptance_plugins.stateful_counter_vendor"}], [] ++ ) ++ assert manager.send_message({"mode": "call"}) == 301 ++ manager.cleanup() ++ ++ assert stateful_counter_vendor.construct_calls == 125 ++ assert stateful_counter_vendor.cleanup_calls == 125 ++ assert stateful_counter_vendor.active_instances == 0 ++ assert len(stateful_counter_vendor.send_values) == 125 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++ ++cd /workspace/repo ++ ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PYTHONPATH="/workspace/repo/src:/workspace/repo/usercase-test-coderl/fixtures${PYTHONPATH:+:$PYTHONPATH}" ++exec python -m pytest /workspace/repo/usercase-test-coderl/test_vendor_manager_stateful.py -v diff --git a/tasks/format-code-task-001793/tests/test.sh b/tasks/format-code-task-001793/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3294c41f7a65fde59ff57e78f0b7e491656dc16c --- /dev/null +++ b/tasks/format-code-task-001793/tests/test.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/acceptance_plugins/__init__.py +usercase-test-coderl/fixtures/acceptance_plugins/cleanup_vendor.py +usercase-test-coderl/fixtures/acceptance_plugins/failing_vendor.py +usercase-test-coderl/fixtures/acceptance_plugins/flaky_retry_a.py +usercase-test-coderl/fixtures/acceptance_plugins/flaky_retry_b.py +usercase-test-coderl/fixtures/acceptance_plugins/multi_mode_vendor.py +usercase-test-coderl/fixtures/acceptance_plugins/no_cleanup_vendor.py +usercase-test-coderl/fixtures/acceptance_plugins/retry_log.py +usercase-test-coderl/fixtures/acceptance_plugins/stateful_counter_vendor.py +usercase-test-coderl/test_vendor_manager_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-001793/tests/test_command.sh b/tasks/format-code-task-001793/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001793/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-001794/environment/Dockerfile b/tasks/format-code-task-001794/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ae6cc2f6d2cdc91bc9fe1ebdd06a08ebd79b18a4 --- /dev/null +++ b/tasks/format-code-task-001794/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bfb126fd9adeb47213a5d4f271163f4e600b76ba0b60710abb0767c1c96aa862 diff --git a/tasks/format-code-task-001794/environment/setup/files/blocklist b/tasks/format-code-task-001794/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001794/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001794/environment/setup/setup.sh b/tasks/format-code-task-001794/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001794/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001794/tests/test.patch b/tasks/format-code-task-001794/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9d9edd285dc708b219424f9825b3553bbf2c05e --- /dev/null +++ b/tasks/format-code-task-001794/tests/test.patch @@ -0,0 +1,107 @@ +diff --git a/cli/cmd/install-cni-plugin_test.go b/cli/cmd/install-cni-plugin_test.go +index a6066460c93c3..45ca139b3f37b 100644 +--- a/cli/cmd/install-cni-plugin_test.go ++++ b/cli/cmd/install-cni-plugin_test.go +@@ -14,7 +14,7 @@ func TestRenderCNIPlugin(t *testing.T) { + + image := cniPluginImage{ + name: "my-docker-registry.io/awesome/cni-plugin-test-image", +- version: "v1.0.0", ++ version: "v1.1.0", + pullPolicy: nil, + } + fullyConfiguredOptions := &cniPluginOptions{ +diff --git a/cli/cmd/install_cni_helm_test.go b/cli/cmd/install_cni_helm_test.go +index ad3b19ab11713..ce25611978d66 100644 +--- a/cli/cmd/install_cni_helm_test.go ++++ b/cli/cmd/install_cni_helm_test.go +@@ -35,7 +35,7 @@ func TestRenderCniHelm(t *testing.T) { + "logLevel": "debug", + "image": { + "name": "cr.l5d.io/linkerd/cni-plugin", +- "version": "v1.0.0" ++ "version": "v1.1.0" + }, + "proxyUID": 1111, + "destCNINetDir": "/etc/cni/net.d-test", +diff --git a/cni-plugin/test/install-cni_test.go b/cni-plugin/test/install-cni_test.go +index ad940a617a017..424159b7f185d 100644 +--- a/cni-plugin/test/install-cni_test.go ++++ b/cni-plugin/test/install-cni_test.go +@@ -147,7 +147,7 @@ func populateK8sCreds(wd string, tempK8sSvcAcctDir string, t *testing.T) { + + // startDocker starts a test Docker container and runs the install-cni.sh script. + func startDocker(testNum int, wd string, testWorkRootDir string, tempCNINetDir string, tempCNIBinDir string, tempK8sSvcAcctDir string, t *testing.T) string { +- dockerImage := env("HUB", "cr.l5d.io/linkerd") + "/cni-plugin:" + env("CNI_PLUGIN_VERSION", "v1.0.0") ++ dockerImage := env("HUB", "cr.l5d.io/linkerd") + "/cni-plugin:" + env("CNI_PLUGIN_VERSION", "v1.1.0") + errFileName := testWorkRootDir + "/docker_run_stderr" + + // Build arguments list by picking whatever is necessary from the environment. +diff --git a/pkg/healthcheck/healthcheck_test.go b/pkg/healthcheck/healthcheck_test.go +index 5abc15dc39ce8..25e0e8c0b89e3 100644 +--- a/pkg/healthcheck/healthcheck_test.go ++++ b/pkg/healthcheck/healthcheck_test.go +@@ -1763,7 +1763,7 @@ data: + global: | + {"linkerdNamespace":"linkerd","cniEnabled":false,"version":"install-control-plane-version","identityContext":{"trustDomain":"cluster.local","trustAnchorsPem":"fake-trust-anchors-pem","issuanceLifetime":"86400s","clockSkewAllowance":"20s"}} + proxy: | +- {"proxyImage":{"imageName":"cr.l5d.io/linkerd/proxy","pullPolicy":"IfNotPresent"},"proxyInitImage":{"imageName":"cr.l5d.io/linkerd/proxy-init","pullPolicy":"IfNotPresent"},"controlPort":{"port":4190},"ignoreInboundPorts":[],"ignoreOutboundPorts":[],"inboundPort":{"port":4143},"adminPort":{"port":4191},"outboundPort":{"port":4140},"resource":{"requestCpu":"","requestMemory":"","limitCpu":"","limitMemory":""},"proxyUid":"2102","logLevel":{"level":"warn,linkerd=info"},"disableExternalProfiles":true,"proxyVersion":"install-proxy-version","proxy_init_image_version":"v2.2.0","debugImage":{"imageName":"cr.l5d.io/linkerd/debug","pullPolicy":"IfNotPresent"},"debugImageVersion":"install-debug-version"} ++ {"proxyImage":{"imageName":"cr.l5d.io/linkerd/proxy","pullPolicy":"IfNotPresent"},"proxyInitImage":{"imageName":"cr.l5d.io/linkerd/proxy-init","pullPolicy":"IfNotPresent"},"controlPort":{"port":4190},"ignoreInboundPorts":[],"ignoreOutboundPorts":[],"inboundPort":{"port":4143},"adminPort":{"port":4191},"outboundPort":{"port":4140},"resource":{"requestCpu":"","requestMemory":"","limitCpu":"","limitMemory":""},"proxyUid":"2102","logLevel":{"level":"warn,linkerd=info"},"disableExternalProfiles":true,"proxyVersion":"install-proxy-version","proxy_init_image_version":"v2.2.1","debugImage":{"imageName":"cr.l5d.io/linkerd/debug","pullPolicy":"IfNotPresent"},"debugImageVersion":"install-debug-version"} + install: | + {"cliVersion":"dev-undefined","flags":[]} + values: | +@@ -1916,7 +1916,7 @@ data: + global: | + {"linkerdNamespace":"linkerd","cniEnabled":false,"version":"install-control-plane-version","identityContext":{"trustDomain":"cluster.local","trustAnchorsPem":"fake-trust-anchors-pem","issuanceLifetime":"86400s","clockSkewAllowance":"20s"}} + proxy: | +- {"proxyImage":{"imageName":"cr.l5d.io/linkerd/proxy","pullPolicy":"IfNotPresent"},"proxyInitImage":{"imageName":"cr.l5d.io/linkerd/proxy-init","pullPolicy":"IfNotPresent"},"controlPort":{"port":4190},"ignoreInboundPorts":[],"ignoreOutboundPorts":[],"inboundPort":{"port":4143},"adminPort":{"port":4191},"outboundPort":{"port":4140},"resource":{"requestCpu":"","requestMemory":"","limitCpu":"","limitMemory":""},"proxyUid":"2102","logLevel":{"level":"warn,linkerd=info"},"disableExternalProfiles":true,"proxyVersion":"install-proxy-version","proxy_init_image_version":"v2.2.0","debugImage":{"imageName":"cr.l5d.io/linkerd/debug","pullPolicy":"IfNotPresent"},"debugImageVersion":"install-debug-version"} ++ {"proxyImage":{"imageName":"cr.l5d.io/linkerd/proxy","pullPolicy":"IfNotPresent"},"proxyInitImage":{"imageName":"cr.l5d.io/linkerd/proxy-init","pullPolicy":"IfNotPresent"},"controlPort":{"port":4190},"ignoreInboundPorts":[],"ignoreOutboundPorts":[],"inboundPort":{"port":4143},"adminPort":{"port":4191},"outboundPort":{"port":4140},"resource":{"requestCpu":"","requestMemory":"","limitCpu":"","limitMemory":""},"proxyUid":"2102","logLevel":{"level":"warn,linkerd=info"},"disableExternalProfiles":true,"proxyVersion":"install-proxy-version","proxy_init_image_version":"v2.2.1","debugImage":{"imageName":"cr.l5d.io/linkerd/debug","pullPolicy":"IfNotPresent"},"debugImageVersion":"install-debug-version"} + install: | + {"cliVersion":"dev-undefined","flags":[]} + values: | +@@ -2422,7 +2422,7 @@ spec: + serviceAccountName: linkerd-cni + containers: + - name: install-cni +- image: cr.l5d.io/linkerd/cni-plugin:v1.0.0 ++ image: cr.l5d.io/linkerd/cni-plugin:v1.1.0 + env: + - name: DEST_CNI_NET_DIR + valueFrom: +diff --git a/test/integration/multicluster/install_test.go b/test/integration/multicluster/install_test.go +index c7d40bf809f0a..fe69f500e408c 100644 +--- a/test/integration/multicluster/install_test.go ++++ b/test/integration/multicluster/install_test.go +@@ -110,7 +110,7 @@ func TestInstall(t *testing.T) { + "install", + "--controller-log-level", "debug", + "--set", "proxyInit.image.name=ghcr.io/linkerd/proxy-init", +- "--set", "proxyInit.image.version=v2.2.0", ++ "--set", "proxyInit.image.version=v2.2.1", + "--set", fmt.Sprintf("proxy.image.version=%s", TestHelper.GetVersion()), + "--set", "heartbeatSchedule=1 2 3 4 5", + "--identity-trust-anchors-file", rootPath, +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+2SX2vbMBTF/exPcUlhbFD/URInJdCnjLG+lFH2bhL5xhaRpSJL3R724Sc7aaZk ++W/PSUkrv78VGV9I5516laydkVaJ6yKKXIvfMi2L4ek6/wz8rxozNWDEvJlHu//J5BMWLOQpwnV0Z ++gMhobZ/ad67+Rkn/zN9iZ0uu23alqrRrnk/jzPwZm7DD/Gfzfv7T2TiPIH8+C//nnc+fVzAMfo1V ++HHdoIcE4voA7p8A2CAX47tR+ud8DGyGxW/R1Bh9gvAAuRcbbCpa3N3AvXS0U+McDX1G2w4kOPgrl ++GyxlwpVIdlvKvpLW+hL2tdLXysafeax8imu9U0yzvUQGifGeRt/96h2qCo3X/Dbc9ytYU6LXHkHy ++AAnXTtlr1tudeKsHfS9rsTYrK7TaqYQmDx4gAfwpfIQcfgjbaGfhs+ZbNKG5w6VDE7NT3ekCGlxJ ++2/AG+XYvFqz8K/D9ts6CLWHwL2h5s3TGoLJLrTaidrsYfwUuFtA6aQWX/n2jeez0cdynom6vOtgf ++DrwNIYP2ZaHIcfrXftgEQRAEQRAEQRAEQRAEQRAEQRAEQRAEQRDvhN98qKGIACgAAA== +diff --git 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-001794/tests/test.sh b/tasks/format-code-task-001794/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fa9a90e56efbd690a81efb573c7d633699cf2c74 --- /dev/null +++ b/tasks/format-code-task-001794/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' +cli/cmd/install-cni-plugin_test.go +cli/cmd/install_cni_helm_test.go +cni-plugin/test/install-cni_test.go +pkg/healthcheck/healthcheck_test.go +test/integration/multicluster/install_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-001794/tests/test_command.sh b/tasks/format-code-task-001794/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001794/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001903/environment/Dockerfile b/tasks/format-code-task-001903/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..32dfb23d130948df81a69bc91fd88bdbc3c4e0ec --- /dev/null +++ b/tasks/format-code-task-001903/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e213da8df5f6a0dcd9f11e8b6dbc27ead7b58bef763b593942dbd4458d399f20 diff --git a/tasks/format-code-task-001903/environment/setup/files/blocklist b/tasks/format-code-task-001903/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001903/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001903/environment/setup/setup.sh b/tasks/format-code-task-001903/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001903/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001903/tests/test.patch b/tasks/format-code-task-001903/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0532acf5804e971d8a5ffca69f30fb860c10c877 --- /dev/null +++ b/tasks/format-code-task-001903/tests/test.patch @@ -0,0 +1,642 @@ +diff --git a/usercase-test-coderl/a2a_client_test.go b/usercase-test-coderl/a2a_client_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/a2a_client_test.go +@@ -0,0 +1,605 @@ ++package usercase_test_coderl ++ ++import ( ++ "bytes" ++ "context" ++ "encoding/json" ++ "errors" ++ "fmt" ++ "io" ++ "mime" ++ "net/http" ++ "net/http/httptest" ++ "os" ++ "runtime" ++ "slices" ++ "strings" ++ "sync" ++ "testing" ++ "time" ++ ++ "go-micro.dev/v6/gateway/a2a" ++) ++ ++ ++ ++ ++ ++ ++ ++ ++type roundTripFunc func(*http.Request) (*http.Response, error) ++ ++func (f roundTripFunc) RoundTrip(r *http.Request) (*http.Response, error) { ++ return f(r) ++} ++ ++func TestWithHTTPClientNilAndNonNilArePerInstance(t *testing.T) { ++ ++ ++ ++ ++ ctx := context.Background() ++ requests := 0 ++ transport := roundTripFunc(func(r *http.Request) (*http.Response, error) { ++ requests++ ++ if r.Method != http.MethodGet { ++ t.Fatalf("method = %q, want %q", r.Method, http.MethodGet) ++ } ++ if r.URL.String() != "http://agent.example/rpc/.well-known/agent.json" { ++ t.Fatalf("url = %q, want %q", r.URL.String(), "http://agent.example/rpc/.well-known/agent.json") ++ } ++ return jsonResponse(200, `{"name":"alpha","url":"http://agent.example/rpc","version":"1.0.0","protocolVersion":"0.3.0","capabilities":{"streaming":false,"pushNotifications":false},"defaultInputModes":["text/plain"],"defaultOutputModes":["text/plain"],"skills":[{"id":"chat","name":"Chat"}]}`), nil ++ }) ++ ++ client := a2a.NewClient("http://agent.example/rpc") ++ chained := client.WithHTTPClient(&http.Client{Transport: transport}) ++ if (chained == client) != true { ++ t.Fatalf("WithHTTPClient(non-nil) returned same pointer = %t, want %t", chained == client, true) ++ } ++ chainedAgain := client.WithHTTPClient(nil) ++ if (chainedAgain == client) != true { ++ t.Fatalf("WithHTTPClient(nil) returned same pointer = %t, want %t", chainedAgain == client, true) ++ } ++ ++ card, err := client.Card(ctx) ++ if err != nil { ++ t.Fatalf("Card error = %v, want nil", err) ++ } ++ if requests != 1 { ++ t.Fatalf("transport requests = %d, want %d", requests, 1) ++ } ++ if card.Name != "alpha" { ++ t.Fatalf("card name = %q, want %q", card.Name, "alpha") ++ } ++ if card.URL != "http://agent.example/rpc" { ++ t.Fatalf("card url = %q, want %q", card.URL, "http://agent.example/rpc") ++ } ++ if card.ProtocolVersion != "0.3.0" { ++ t.Fatalf("card protocolVersion = %q, want %q", card.ProtocolVersion, "0.3.0") ++ } ++} ++ ++func TestCardFetchesWellKnownAgentJSONAndReportsStatus(t *testing.T) { ++ ++ ++ ++ ++ var paths []string ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ paths = append(paths, r.Method+" "+r.URL.Path) ++ switch r.URL.Path { ++ case "/missing/.well-known/agent.json": ++ http.Error(w, "not found", http.StatusNotFound) ++ default: ++ writeJSON(w, 200, a2a.AgentCard{ ++ Name: "echo", ++ Description: "card fixture", ++ URL: serverURLFromRequest(r), ++ Version: "1.0.0", ++ ProtocolVersion: "0.3.0", ++ Capabilities: a2a.Capabilities{Streaming: false, PushNotifications: false}, ++ DefaultInputModes: []string{"text/plain"}, ++ DefaultOutputModes: []string{"text/plain"}, ++ Skills: []a2a.Skill{{ID: "chat", Name: "Chat", Tags: []string{"ops"}}}, ++ }) ++ } ++ })) ++ defer server.Close() ++ ++ card, err := a2a.NewClient(server.URL).Card(context.Background()) ++ if err != nil { ++ t.Fatalf("Card error = %v, want nil", err) ++ } ++ if card.Name != "echo" { ++ t.Fatalf("card name = %q, want %q", card.Name, "echo") ++ } ++ if card.Description != "card fixture" { ++ t.Fatalf("card description = %q, want %q", card.Description, "card fixture") ++ } ++ if card.URL != server.URL { ++ t.Fatalf("card url = %q, want %q", card.URL, server.URL) ++ } ++ if card.DefaultInputModes[0] != "text/plain" { ++ t.Fatalf("card defaultInputModes[0] = %q, want %q", card.DefaultInputModes[0], "text/plain") ++ } ++ if card.Skills[0].Tags[0] != "ops" { ++ t.Fatalf("card skill tag = %q, want %q", card.Skills[0].Tags[0], "ops") ++ } ++ ++ _, err = a2a.NewClient(server.URL + "/missing").Card(context.Background()) ++ if err == nil { ++ t.Fatalf("Card 404 error = nil, want %q", "agent card: status 404") ++ } ++ ++ if !strings.Contains(err.Error(), "agent card") || !strings.Contains(err.Error(), "404") { ++ t.Fatalf("Card 404 error = %q, want agent card context and status 404", err.Error()) ++ } ++ ++ if !slices.Contains(paths, "GET /.well-known/agent.json") || !slices.Contains(paths, "GET /missing/.well-known/agent.json") { ++ t.Fatalf("card request paths = %q, want both well-known agent card fetches", strings.Join(paths, ",")) ++ } ++} ++ ++func TestSendPostsUserTextAndReturnsMessageTextParts(t *testing.T) { ++ ++ ++ ++ ++ var captured normalizedSendRequest ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ if r.Method != http.MethodPost { ++ t.Fatalf("method = %q, want %q", r.Method, http.MethodPost) ++ } ++ if r.URL.Path != "/" { ++ t.Fatalf("path = %q, want %q", r.URL.Path, "/") ++ } ++ contentType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) ++ if err != nil || contentType != "application/json" { ++ ++ t.Fatalf("content-type = %q, want JSON media type", r.Header.Get("Content-Type")) ++ } ++ captured = decodeSendRequest(t, r.Body) ++ writeRPCResult(w, map[string]any{ ++ "kind": "message", ++ "role": "agent", ++ "parts": []map[string]string{ ++ {"kind": "text", "text": "hel"}, ++ {"kind": "text", "text": "lo"}, ++ }, ++ }) ++ })) ++ defer server.Close() ++ ++ text, err := a2a.NewClient(server.URL).Send(context.Background(), "hi") ++ if err != nil { ++ t.Fatalf("Send error = %v, want nil", err) ++ } ++ if text != "hello" { ++ t.Fatalf("Send text = %q, want %q", text, "hello") ++ } ++ want := normalizedSendRequest{ ++ JSONRPC: "2.0", ++ Method: "message/send", ++ MessageRole: "user", ++ MessageKind: "message", ++ PartKind: "text", ++ PartText: "hi", ++ } ++ if captured != want { ++ t.Fatalf("normalized request = %+v, want %+v", captured, want) ++ } ++} ++ ++func TestSendReturnsCompletedTaskArtifactText(t *testing.T) { ++ ++ ++ ++ ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ req := decodeRPCRequest(t, r.Body) ++ if req.Method != "message/send" { ++ t.Fatalf("method = %q, want %q", req.Method, "message/send") ++ } ++ writeRPCResult(w, completedTask("task-completed", "po", "ng")) ++ })) ++ defer server.Close() ++ ++ text, err := a2a.NewClient(server.URL).Send(context.Background(), "ping") ++ if err != nil { ++ t.Fatalf("Send error = %v, want nil", err) ++ } ++ if text != "pong" { ++ t.Fatalf("Send text = %q, want %q", text, "pong") ++ } ++} ++ ++func TestSendPollsPendingTaskUntilCompleted(t *testing.T) { ++ ++ ++ ++ ++ var mu sync.Mutex ++ var methods []string ++ var getID string ++ var sendAt, getAt time.Time ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ req := decodeRPCRequest(t, r.Body) ++ mu.Lock() ++ methods = append(methods, req.Method) ++ switch req.Method { ++ case "message/send": ++ sendAt = time.Now() ++ mu.Unlock() ++ writeRPCResult(w, map[string]any{ ++ "kind": "task", ++ "id": "task-pending", ++ "contextId": "ctx-pending", ++ "status": map[string]string{ ++ "state": "working", ++ "timestamp": "2026-06-29T00:00:00Z", ++ }, ++ }) ++ case "tasks/get": ++ getAt = time.Now() ++ getID = taskGetID(t, req.Params) ++ mu.Unlock() ++ writeRPCResult(w, completedTask("task-pending", "done")) ++ default: ++ mu.Unlock() ++ t.Fatalf("method = %q, want %q or %q", req.Method, "message/send", "tasks/get") ++ } ++ })) ++ defer server.Close() ++ ++ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) ++ defer cancel() ++ text, err := a2a.NewClient(server.URL).Send(ctx, "wait") ++ if err != nil { ++ t.Fatalf("Send error = %v, want nil", err) ++ } ++ if text != "done" { ++ t.Fatalf("Send text = %q, want %q", text, "done") ++ } ++ if strings.Join(methods, ",") != "message/send,tasks/get" { ++ t.Fatalf("methods = %q, want %q", strings.Join(methods, ","), "message/send,tasks/get") ++ } ++ if getID != "task-pending" { ++ t.Fatalf("tasks/get id = %q, want %q", getID, "task-pending") ++ } ++ delay := getAt.Sub(sendAt) ++ ++ if delay < 200*time.Millisecond || delay > 750*time.Millisecond { ++ t.Fatalf("poll delay = %s, want about 300ms", delay) ++ } ++} ++ ++func TestSendTerminalFailureStatesReturnSpecificErrors(t *testing.T) { ++ ++ ++ ++ ++ cases := []struct { ++ state string ++ want string ++ }{ ++ {state: "failed", want: "remote task task-failed ended in state \"failed\""}, ++ {state: "canceled", want: "remote task task-canceled ended in state \"canceled\""}, ++ {state: "rejected", want: "remote task task-rejected ended in state \"rejected\""}, ++ } ++ for _, tc := range cases { ++ t.Run(tc.state, func(t *testing.T) { ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ writeRPCResult(w, terminalTask("task-"+tc.state, tc.state)) ++ })) ++ defer server.Close() ++ ++ text, err := a2a.NewClient(server.URL).Send(context.Background(), "stop") ++ if text != "" { ++ t.Fatalf("Send text = %q, want %q", text, "") ++ } ++ if err == nil { ++ t.Fatalf("Send error = nil, want %q", tc.want) ++ } ++ ++ if !strings.Contains(err.Error(), "task-"+tc.state) || !strings.Contains(err.Error(), tc.state) { ++ t.Fatalf("Send error = %q, want task id and terminal state %q", err.Error(), tc.state) ++ } ++ }) ++ } ++} ++ ++func TestSendJSONRPCErrorIncludesMethodMessageAndCode(t *testing.T) { ++ ++ ++ ++ ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ req := decodeRPCRequest(t, r.Body) ++ writeJSON(w, 200, map[string]any{ ++ "jsonrpc": "2.0", ++ "id": req.ID, ++ "error": map[string]any{ ++ "code": -32602, ++ "message": "bad request", ++ }, ++ }) ++ })) ++ defer server.Close() ++ ++ text, err := a2a.NewClient(server.URL).Send(context.Background(), "bad") ++ if text != "" { ++ t.Fatalf("Send text = %q, want %q", text, "") ++ } ++ if err == nil { ++ t.Fatalf("Send error = nil, want %q", "a2a message/send: bad request (-32602)") ++ } ++ ++ if !strings.Contains(err.Error(), "message/send") || !strings.Contains(err.Error(), "bad request") || !strings.Contains(err.Error(), "-32602") { ++ t.Fatalf("Send error = %q, want method, remote message, and numeric code", err.Error()) ++ } ++} ++ ++func TestSendStopsPollingWhenContextIsDone(t *testing.T) { ++ ++ ++ ++ ++ var methods []string ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ req := decodeRPCRequest(t, r.Body) ++ methods = append(methods, req.Method) ++ writeRPCResult(w, map[string]any{ ++ "kind": "task", ++ "id": "task-timeout", ++ "contextId": "ctx-timeout", ++ "status": map[string]string{ ++ "state": "working", ++ "timestamp": "2026-06-29T00:00:00Z", ++ }, ++ }) ++ })) ++ defer server.Close() ++ ++ ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond) ++ defer cancel() ++ text, err := a2a.NewClient(server.URL).Send(ctx, "wait") ++ if text != "" { ++ t.Fatalf("Send text = %q, want %q", text, "") ++ } ++ if (errors.Is(err, context.DeadlineExceeded)) != true { ++ t.Fatalf("errors.Is(deadline exceeded) = %t, want %t (err %v)", errors.Is(err, context.DeadlineExceeded), true, err) ++ } ++ if strings.Join(methods, ",") != "message/send" { ++ t.Fatalf("methods = %q, want %q", strings.Join(methods, ","), "message/send") ++ } ++} ++ ++func TestTwoClientsKeepIndependentURLsAndTransports(t *testing.T) { ++ ++ ++ ++ ++ aRequests := 0 ++ aTransport := roundTripFunc(func(r *http.Request) (*http.Response, error) { ++ aRequests++ ++ if r.URL.String() != "http://alpha.invalid/rpc/.well-known/agent.json" { ++ t.Fatalf("client A url = %q, want %q", r.URL.String(), "http://alpha.invalid/rpc/.well-known/agent.json") ++ } ++ return jsonResponse(200, `{"name":"alpha","url":"http://alpha.invalid/rpc","version":"1.0.0","protocolVersion":"0.3.0","capabilities":{"streaming":false,"pushNotifications":false},"defaultInputModes":["text/plain"],"defaultOutputModes":["text/plain"],"skills":[{"id":"chat","name":"Chat"}]}`), nil ++ }) ++ bRequests := 0 ++ bServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ bRequests++ ++ if r.URL.Path != "/.well-known/agent.json" { ++ t.Fatalf("client B path = %q, want %q", r.URL.Path, "/.well-known/agent.json") ++ } ++ writeJSON(w, 200, a2a.AgentCard{ ++ Name: "bravo", ++ URL: bServerURL(r), ++ Version: "1.0.0", ++ ProtocolVersion: "0.3.0", ++ Capabilities: a2a.Capabilities{Streaming: false, PushNotifications: false}, ++ DefaultInputModes: []string{"text/plain"}, ++ DefaultOutputModes: []string{"text/plain"}, ++ Skills: []a2a.Skill{{ID: "chat", Name: "Chat"}}, ++ }) ++ })) ++ defer bServer.Close() ++ ++ aClient := a2a.NewClient("http://alpha.invalid/rpc").WithHTTPClient(&http.Client{Transport: aTransport}) ++ bClient := a2a.NewClient(bServer.URL) ++ ++ aCard, err := aClient.Card(context.Background()) ++ if err != nil { ++ t.Fatalf("client A Card error = %v, want nil", err) ++ } ++ bCard, err := bClient.Card(context.Background()) ++ if err != nil { ++ t.Fatalf("client B Card error = %v, want nil", err) ++ } ++ if aCard.Name != "alpha" { ++ t.Fatalf("client A card name = %q, want %q", aCard.Name, "alpha") ++ } ++ if bCard.Name != "bravo" { ++ t.Fatalf("client B card name = %q, want %q", bCard.Name, "bravo") ++ } ++ if aRequests != 1 { ++ t.Fatalf("client A transport requests = %d, want %d", aRequests, 1) ++ } ++ if bRequests != 1 { ++ t.Fatalf("client B server requests = %d, want %d", bRequests, 1) ++ } ++} ++ ++func TestRepeatedConstructUseCyclesKeepFDsAndGoroutinesBounded(t *testing.T) { ++ ++ ++ ++ ++ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ++ writeRPCResult(w, completedTask("task-leak", "ok")) ++ })) ++ defer server.Close() ++ ++ runtime.GC() ++ time.Sleep(50 * time.Millisecond) ++ baseFDs := openFDs(t) ++ baseGoroutines := runtime.NumGoroutine() ++ ++ for i := 0; i < 120; i++ { ++ text, err := a2a.NewClient(server.URL).Send(context.Background(), "cycle") ++ if err != nil { ++ t.Fatalf("cycle %d Send error = %v, want nil", i, err) ++ } ++ if text != "ok" { ++ t.Fatalf("cycle %d Send text = %q, want %q", i, text, "ok") ++ } ++ } ++ ++ runtime.GC() ++ time.Sleep(200 * time.Millisecond) ++ afterFDs := openFDs(t) ++ afterGoroutines := runtime.NumGoroutine() ++ ++ if (afterFDs-baseFDs <= 40) != true { ++ t.Fatalf("fd delta <= 40 = %t, want %t (before %d after %d)", afterFDs-baseFDs <= 40, true, baseFDs, afterFDs) ++ } ++ ++ if (afterGoroutines-baseGoroutines <= 60) != true { ++ t.Fatalf("goroutine delta <= 60 = %t, want %t (before %d after %d)", afterGoroutines-baseGoroutines <= 60, true, baseGoroutines, afterGoroutines) ++ } ++} ++ ++type rpcRequest struct { ++ JSONRPC string `json:"jsonrpc"` ++ ID json.RawMessage `json:"id"` ++ Method string `json:"method"` ++ Params json.RawMessage `json:"params"` ++} ++ ++type normalizedSendRequest struct { ++ JSONRPC string ++ Method string ++ MessageRole string ++ MessageKind string ++ PartKind string ++ PartText string ++} ++ ++func decodeSendRequest(t *testing.T, body io.Reader) normalizedSendRequest { ++ t.Helper() ++ req := decodeRPCRequest(t, body) ++ var params struct { ++ Message struct { ++ Role string `json:"role"` ++ Kind string `json:"kind"` ++ Parts []struct { ++ Kind string `json:"kind"` ++ Text string `json:"text"` ++ } `json:"parts"` ++ } `json:"message"` ++ } ++ if err := json.Unmarshal(req.Params, ¶ms); err != nil { ++ t.Fatalf("decode params: %v", err) ++ } ++ return normalizedSendRequest{ ++ JSONRPC: req.JSONRPC, ++ Method: req.Method, ++ MessageRole: params.Message.Role, ++ MessageKind: params.Message.Kind, ++ PartKind: params.Message.Parts[0].Kind, ++ PartText: params.Message.Parts[0].Text, ++ } ++} ++ ++func decodeRPCRequest(t *testing.T, body io.Reader) rpcRequest { ++ t.Helper() ++ var req rpcRequest ++ if err := json.NewDecoder(body).Decode(&req); err != nil { ++ t.Fatalf("decode rpc request: %v", err) ++ } ++ return req ++} ++ ++func taskGetID(t *testing.T, raw json.RawMessage) string { ++ t.Helper() ++ var params struct { ++ ID string `json:"id"` ++ } ++ if err := json.Unmarshal(raw, ¶ms); err != nil { ++ t.Fatalf("decode tasks/get params: %v", err) ++ } ++ return params.ID ++} ++ ++func completedTask(id string, parts ...string) map[string]any { ++ textParts := make([]map[string]string, 0, len(parts)) ++ for _, part := range parts { ++ textParts = append(textParts, map[string]string{"kind": "text", "text": part}) ++ } ++ return map[string]any{ ++ "kind": "task", ++ "id": id, ++ "contextId": "ctx-" + id, ++ "status": map[string]string{ ++ "state": "completed", ++ "timestamp": "2026-06-29T00:00:00Z", ++ }, ++ "artifacts": []map[string]any{{ ++ "artifactId": "artifact-" + id, ++ "parts": textParts, ++ }}, ++ } ++} ++ ++func terminalTask(id, state string) map[string]any { ++ return map[string]any{ ++ "kind": "task", ++ "id": id, ++ "contextId": "ctx-" + id, ++ "status": map[string]string{ ++ "state": state, ++ "timestamp": "2026-06-29T00:00:00Z", ++ }, ++ } ++} ++ ++func writeRPCResult(w http.ResponseWriter, result any) { ++ writeJSON(w, 200, map[string]any{ ++ "jsonrpc": "2.0", ++ "id": "response-id", ++ "result": result, ++ }) ++} ++ ++func writeJSON(w http.ResponseWriter, status int, v any) { ++ w.Header().Set("Content-Type", "application/json") ++ w.WriteHeader(status) ++ _ = json.NewEncoder(w).Encode(v) ++} ++ ++func jsonResponse(status int, body string) *http.Response { ++ return &http.Response{ ++ StatusCode: status, ++ Header: make(http.Header), ++ Body: io.NopCloser(bytes.NewBufferString(body)), ++ } ++} ++ ++func openFDs(t *testing.T) int { ++ t.Helper() ++ entries, err := os.ReadDir("/proc/self/fd") ++ if err != nil { ++ t.Fatalf("read /proc/self/fd: %v", err) ++ } ++ return len(entries) ++} ++ ++func serverURLFromRequest(r *http.Request) string { ++ return fmt.Sprintf("http://%s", r.Host) ++} ++ ++func bServerURL(r *http.Request) string { ++ return fmt.Sprintf("http://%s", r.Host) ++} +diff --git 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 GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++export GOVCS='*:off' ++export GOFLAGS="${GOFLAGS:-} -mod=readonly" ++ ++GO124=/root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.1.linux-amd64/bin/go ++if [ ! -x "$GO124" ]; then ++ echo "cached Go 1.24.1 toolchain missing at $GO124" >&2 ++ exit 1 ++fi ++ ++exec "$GO124" test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-001903/tests/test.sh b/tasks/format-code-task-001903/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6816d95a13770544045bd3a0cf5b34dba7907ca5 --- /dev/null +++ b/tasks/format-code-task-001903/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/a2a_client_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-001903/tests/test_command.sh b/tasks/format-code-task-001903/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001903/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-001904/environment/Dockerfile b/tasks/format-code-task-001904/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..85ba77dfcea6ee08ad42346aadb3254a0805ff80 --- /dev/null +++ b/tasks/format-code-task-001904/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:08444e600fa56a1316fa03cc1f12a763d798ae4936b862cd47bd8a1ef88e2d21 diff --git a/tasks/format-code-task-001904/environment/setup/files/blocklist b/tasks/format-code-task-001904/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001904/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001904/environment/setup/setup.sh b/tasks/format-code-task-001904/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001904/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001904/tests/test.patch b/tasks/format-code-task-001904/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1878c0fd17505c155cf238fabeecc9c38cc19652 --- /dev/null +++ b/tasks/format-code-task-001904/tests/test.patch @@ -0,0 +1,456 @@ +diff --git a/usercase-test-coderl/query_helpers.test.js b/usercase-test-coderl/query_helpers.test.js +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/query_helpers.test.js +@@ -0,0 +1,425 @@ ++ ++ ++const assert = require('node:assert/strict') ++const { execFileSync } = require('node:child_process') ++const fs = require('node:fs') ++const os = require('node:os') ++const path = require('node:path') ++const http = require('node:http') ++const https = require('node:https') ++const net = require('node:net') ++const tls = require('node:tls') ++const test = require('node:test') ++ ++const mql = require('@microlink/mql') ++ ++const clonePlain = value => JSON.parse(JSON.stringify(value)) ++ ++const assertApiUrl = (actual, expectedBaseUrl, expectedParams) => { ++ const parsed = new URL(actual) ++ assert.equal(`${parsed.origin}${parsed.pathname}`, expectedBaseUrl) ++ assert.deepStrictEqual( ++ [...parsed.searchParams.keys()].sort(), ++ Object.keys(expectedParams).sort() ++ ) ++ for (const [key, value] of Object.entries(expectedParams)) { ++ assert.equal(parsed.searchParams.get(key), value) ++ } ++} ++ ++const listEntries = root => { ++ const entries = [] ++ const visit = dir => { ++ for (const dirent of fs.readdirSync(dir, { withFileTypes: true })) { ++ const fullPath = path.join(dir, dirent.name) ++ const relative = path.relative(root, fullPath) ++ entries.push(`${dirent.isDirectory() ? 'dir' : 'file'}:${relative}`) ++ if (dirent.isDirectory()) visit(fullPath) ++ } ++ } ++ visit(root) ++ return entries.sort() ++} ++ ++test('commonjs default export exposes query helpers', () => { ++ ++ ++ assert.equal(typeof mql.getApiUrl, 'function') ++ assert.equal(typeof mql.mapRules, 'function') ++ assert.deepStrictEqual(mql.getApiUrl('https://kikobeats.com'), [ ++ 'https://api.microlink.io/?url=https%3A%2F%2Fkikobeats.com', ++ { responseType: 'json', headers: {} } ++ ]) ++ assert.deepStrictEqual( ++ mql.mapRules({ ++ avatar: { ++ type: 'image', ++ selectors: { selector: '#avatar' } ++ } ++ }), ++ { ++ 'data.avatar.type': 'image', ++ 'data.avatar.selectors.selector': '#avatar' ++ } ++ ) ++}) ++ ++test('esm entry exposes named query helpers', async () => { ++ ++ ++ const { getApiUrl, mapRules } = await import('@microlink/mql') ++ assert.equal(typeof getApiUrl, 'function') ++ assert.equal(typeof mapRules, 'function') ++ const [apiUrl, fetchOptions] = getApiUrl('https://kikobeats.com', { ++ overlay: { browser: 'dark' } ++ }) ++ ++ assertApiUrl(apiUrl, 'https://api.microlink.io/', { ++ url: 'https://kikobeats.com', ++ 'overlay.browser': 'dark' ++ }) ++ assert.deepStrictEqual(fetchOptions, { responseType: 'json', headers: {} }) ++ assert.deepStrictEqual( ++ mapRules({ ++ avatar: { ++ type: 'image', ++ selectors: { selector: '#avatar' } ++ } ++ }), ++ { ++ 'data.avatar.type': 'image', ++ 'data.avatar.selectors.selector': '#avatar' ++ } ++ ) ++}) ++ ++test('getApiUrl builds the free endpoint request by default', () => { ++ ++ ++ assert.deepStrictEqual(mql.getApiUrl('https://kikobeats.com'), [ ++ 'https://api.microlink.io/?url=https%3A%2F%2Fkikobeats.com', ++ { responseType: 'json', headers: {} } ++ ]) ++}) ++ ++test('getApiUrl switches to the pro endpoint and api key header', () => { ++ ++ ++ assert.deepStrictEqual(mql.getApiUrl('https://kikobeats.com', { apiKey: 'foobar' }), [ ++ 'https://pro.microlink.io/?url=https%3A%2F%2Fkikobeats.com', ++ { responseType: 'json', headers: { 'x-api-key': 'foobar' } } ++ ]) ++}) ++ ++test('getApiUrl uses an explicit endpoint instead of default selection', () => { ++ ++ ++ const [apiUrl, fetchOptions] = mql.getApiUrl('https://kikobeats.com', { ++ apiKey: 'foobar', ++ endpoint: 'https://edge.example.test/mql/' ++ }) ++ ++ assertApiUrl(apiUrl, 'https://edge.example.test/mql/', { ++ url: 'https://kikobeats.com' ++ }) ++ assert.deepStrictEqual(fetchOptions, { ++ responseType: 'json', ++ headers: { 'x-api-key': 'foobar' } ++ }) ++}) ++ ++test('getApiUrl carries got options and merges request headers', () => { ++ ++ ++ assert.deepStrictEqual( ++ mql.getApiUrl( ++ 'https://kikobeats.com', ++ { apiKey: 'foobar' }, ++ { headers: { accept: 'application/json' }, timeout: 15000, retry: 0 } ++ ), ++ [ ++ 'https://pro.microlink.io/?url=https%3A%2F%2Fkikobeats.com', ++ { ++ timeout: 15000, ++ retry: 0, ++ responseType: 'json', ++ headers: { accept: 'application/json', 'x-api-key': 'foobar' } ++ } ++ ] ++ ) ++}) ++ ++test('getApiUrl flattens nested option objects into dotted query parameters', () => { ++ ++ ++ const [apiUrl, fetchOptions] = mql.getApiUrl('https://kikobeats.com', { ++ overlay: { browser: 'dark' } ++ }) ++ ++ assertApiUrl(apiUrl, 'https://api.microlink.io/', { ++ url: 'https://kikobeats.com', ++ 'overlay.browser': 'dark' ++ }) ++ assert.deepStrictEqual(fetchOptions, { responseType: 'json', headers: {} }) ++}) ++ ++test('getApiUrl changes responseType when stream is truthy', () => { ++ ++ ++ const [apiUrl, fetchOptions] = mql.getApiUrl( ++ 'https://kikobeats.com', ++ { stream: 1 }, ++ { responseType: 'text', headers: { accept: 'text/plain' } } ++ ) ++ const parsed = new URL(apiUrl) ++ ++ assert.equal(`${parsed.origin}${parsed.pathname}`, 'https://api.microlink.io/') ++ assert.equal(parsed.searchParams.get('url'), 'https://kikobeats.com') ++ assert.deepStrictEqual(fetchOptions, { ++ responseType: 'arrayBuffer', ++ headers: { accept: 'text/plain' } ++ }) ++}) ++ ++test('getApiUrl encodes target URLs that already contain query strings', () => { ++ ++ ++ assert.deepStrictEqual(mql.getApiUrl('https://example.com/path?x=1&y=two'), [ ++ 'https://api.microlink.io/?url=https%3A%2F%2Fexample.com%2Fpath%3Fx%3D1%26y%3Dtwo', ++ { responseType: 'json', headers: {} } ++ ]) ++}) ++ ++test('getApiUrl includes flattened data rules in query parameters', () => { ++ ++ ++ const [apiUrl, fetchOptions] = mql.getApiUrl('https://kikobeats.com', { ++ data: { ++ avatar: { ++ type: 'image', ++ selectors: { selector: '#avatar' } ++ } ++ } ++ }) ++ ++ assertApiUrl(apiUrl, 'https://api.microlink.io/', { ++ url: 'https://kikobeats.com', ++ 'data.avatar.type': 'image', ++ 'data.avatar.selectors.selector': '#avatar' ++ }) ++ assert.deepStrictEqual(fetchOptions, { responseType: 'json', headers: {} }) ++}) ++ ++test('mapRules flattens object selectors and prefixes data keys', () => { ++ ++ ++ assert.deepStrictEqual( ++ mql.mapRules({ ++ avatar: { ++ type: 'image', ++ selectors: { selector: '#avatar' } ++ } ++ }), ++ { ++ 'data.avatar.type': 'image', ++ 'data.avatar.selectors.selector': '#avatar' ++ } ++ ) ++}) ++ ++test('mapRules flattens array selectors and stringifies numeric leaves', () => { ++ ++ ++ assert.deepStrictEqual( ++ mql.mapRules({ ++ article: { ++ type: 'text', ++ selectors: [ ++ { selector: 'h1', attr: 'text' }, ++ { selector: '.lead', attr: 'text' } ++ ], ++ wait: 250 ++ } ++ }), ++ { ++ 'data.article.type': 'text', ++ 'data.article.selectors.0.selector': 'h1', ++ 'data.article.selectors.0.attr': 'text', ++ 'data.article.selectors.1.selector': '.lead', ++ 'data.article.selectors.1.attr': 'text', ++ 'data.article.wait': '250' ++ } ++ ) ++}) ++ ++test('mapRules returns undefined for missing and non-object rules', () => { ++ ++ ++ assert.equal(mql.mapRules(), undefined) ++ assert.equal(mql.mapRules(false), undefined) ++ assert.equal(mql.mapRules('false'), undefined) ++}) ++ ++test('mapRules returns an empty object for empty object and array inputs', () => { ++ ++ ++ assert.deepStrictEqual(mql.mapRules({}), {}) ++ assert.deepStrictEqual(mql.mapRules([]), {}) ++}) ++ ++test('getApiUrl accepts an empty opts object', () => { ++ ++ ++ ++ assert.deepStrictEqual(mql.getApiUrl('https://kikobeats.com', {}), [ ++ 'https://api.microlink.io/?url=https%3A%2F%2Fkikobeats.com', ++ { responseType: 'json', headers: {} } ++ ]) ++}) ++ ++test('query helpers are referentially transparent for repeated calls', () => { ++ const getArgs = [ ++ 'https://kikobeats.com', ++ { overlay: { browser: 'dark' }, data: { avatar: { type: 'image' } } }, ++ { headers: { accept: 'application/json' }, timeout: 5000 } ++ ] ++ const rules = { ++ avatar: { ++ type: 'image', ++ selectors: { selector: '#avatar' } ++ } ++ } ++ assert.deepStrictEqual(mql.getApiUrl(...getArgs), mql.getApiUrl(...getArgs)) ++ assert.deepStrictEqual(mql.mapRules(rules), mql.mapRules(rules)) ++}) ++ ++test('query helpers do not mutate caller-owned input objects', () => { ++ const opts = { ++ apiKey: 'foobar', ++ overlay: { browser: 'dark' }, ++ data: { ++ avatar: { ++ type: 'image', ++ selectors: [{ selector: '#avatar', attr: 'src' }] ++ } ++ } ++ } ++ const gotOpts = { ++ headers: { accept: 'application/json' }, ++ timeout: 15000 ++ } ++ const rules = { ++ avatar: { ++ type: 'image', ++ selectors: [{ selector: '#avatar', attr: 'src' }] ++ } ++ } ++ const originalOpts = clonePlain(opts) ++ const originalGotOpts = clonePlain(gotOpts) ++ const originalRules = clonePlain(rules) ++ ++ mql.getApiUrl('https://kikobeats.com', opts, gotOpts) ++ mql.mapRules(rules) ++ ++ assert.deepStrictEqual(opts, originalOpts) ++ assert.deepStrictEqual(gotOpts, originalGotOpts) ++ assert.deepStrictEqual(rules, originalRules) ++}) ++ ++test('query helpers return the same values in a fresh process', () => { ++ const inProcess = { ++ getApiUrl: mql.getApiUrl('https://kikobeats.com', { ++ overlay: { browser: 'dark' }, ++ data: { avatar: { type: 'image' } } ++ }), ++ mapRules: mql.mapRules({ ++ avatar: { ++ type: 'image', ++ selectors: { selector: '#avatar' } ++ } ++ }) ++ } ++ const script = ` ++ const mql = require('@microlink/mql') ++ const out = { ++ getApiUrl: mql.getApiUrl('https://kikobeats.com', { ++ overlay: { browser: 'dark' }, ++ data: { avatar: { type: 'image' } } ++ }), ++ mapRules: mql.mapRules({ ++ avatar: { ++ type: 'image', ++ selectors: { selector: '#avatar' } ++ } ++ }) ++ } ++ process.stdout.write(JSON.stringify(out)) ++ ` ++ const freshProcess = JSON.parse( ++ execFileSync(process.execPath, ['-e', script], { ++ cwd: '/workspace/repo', ++ encoding: 'utf8' ++ }) ++ ) ++ ++ assert.deepStrictEqual(freshProcess, inProcess) ++}) ++ ++test('query helpers do not touch cwd files or network APIs', () => { ++ const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'mql-query-helpers-')) ++ const originalCwd = process.cwd() ++ const before = listEntries(tmpDir) ++ const blocked = () => { ++ throw new Error('network access is not declared for query helpers') ++ } ++ const originals = { ++ netConnect: net.connect, ++ socketConnect: net.Socket.prototype.connect, ++ tlsConnect: tls.connect, ++ httpRequest: http.request, ++ httpsRequest: https.request, ++ fetch: globalThis.fetch ++ } ++ ++ try { ++ process.chdir(tmpDir) ++ net.connect = blocked ++ net.Socket.prototype.connect = blocked ++ tls.connect = blocked ++ http.request = blocked ++ https.request = blocked ++ globalThis.fetch = blocked ++ ++ const [apiUrl, fetchOptions] = mql.getApiUrl('https://kikobeats.com', { ++ overlay: { browser: 'dark' } ++ }) ++ ++ assertApiUrl(apiUrl, 'https://api.microlink.io/', { ++ url: 'https://kikobeats.com', ++ 'overlay.browser': 'dark' ++ }) ++ assert.deepStrictEqual(fetchOptions, { responseType: 'json', headers: {} }) ++ assert.deepStrictEqual( ++ mql.mapRules({ ++ avatar: { ++ type: 'image', ++ selectors: { selector: '#avatar' } ++ } ++ }), ++ { ++ 'data.avatar.type': 'image', ++ 'data.avatar.selectors.selector': '#avatar' ++ } ++ ) ++ assert.deepStrictEqual(listEntries(tmpDir), before) ++ } finally { ++ net.connect = originals.netConnect ++ net.Socket.prototype.connect = originals.socketConnect ++ tls.connect = originals.tlsConnect ++ http.request = originals.httpRequest ++ https.request = originals.httpsRequest ++ globalThis.fetch = originals.fetch ++ process.chdir(originalCwd) ++ fs.rmSync(tmpDir, { recursive: true, force: true }) ++ } ++}) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/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 COREPACK_ENABLE_NETWORK=0 ++export npm_config_offline=true ++export npm_config_audit=false ++export npm_config_fund=false ++test -x /workspace/repo/node_modules/.bin/rollup ++rm -rf /workspace/repo/dist/index.js ++/workspace/repo/node_modules/.bin/rollup -c /workspace/repo/rollup.config.js --bundleConfigAsCjs >/dev/null ++exec node --no-warnings --test /workspace/repo/usercase-test-coderl/query_helpers.test.js diff --git a/tasks/format-code-task-001904/tests/test.sh b/tasks/format-code-task-001904/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7b12693806308ff78fd2556ebb79ac6f65005ff3 --- /dev/null +++ b/tasks/format-code-task-001904/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/query_helpers.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-001904/tests/test_command.sh b/tasks/format-code-task-001904/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001904/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-001932/environment/Dockerfile b/tasks/format-code-task-001932/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..35fcc2102d74946eea0e93889a81fe3c0ebbdae1 --- /dev/null +++ b/tasks/format-code-task-001932/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f29c4deb8a49987ddc136722b662f842654d57c0fbcdc1b3fae5c3fcef62e63c diff --git a/tasks/format-code-task-001932/environment/setup/files/blocklist b/tasks/format-code-task-001932/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001932/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001932/environment/setup/setup.sh b/tasks/format-code-task-001932/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001932/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001932/tests/test.patch b/tasks/format-code-task-001932/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..a2e8c33a760b4345de3ed6146490c3de77317e4a --- /dev/null +++ b/tasks/format-code-task-001932/tests/test.patch @@ -0,0 +1,127 @@ +diff --git a/test/compress/hoist_props.js b/test/compress/hoist_props.js +index b055ae7b..3ba63e03 100644 +--- a/test/compress/hoist_props.js ++++ b/test/compress/hoist_props.js +@@ -886,3 +886,100 @@ issue_3411: { + } + expect_stdout: "PASS" + } ++ ++issue_3457_1: { ++ options = { ++ hoist_props: true, ++ reduce_vars: true, ++ unused: true, ++ } ++ input: { ++ function xxx(module) { ++ function fun() { ++ console.log(MODE.BlockStatement === "a"); ++ } ++ var MODE = { ++ BlockStatement: "BlockStatement", ++ }; ++ module.exports = fun; ++ } ++ var m = {}; ++ xxx(m); ++ m.exports(); ++ } ++ expect: { ++ function xxx(module) { ++ var MODE_BlockStatement = "BlockStatement"; ++ module.exports = function() { ++ console.log("a" === MODE_BlockStatement); ++ }; ++ } ++ var m = {}; ++ xxx(m); ++ m.exports(); ++ } ++ expect_stdout: "false" ++} ++ ++issue_3457_2: { ++ options = { ++ hoist_props: true, ++ reduce_vars: true, ++ unused: true, ++ } ++ input: { ++ function xxx(module) { ++ function fun() { ++ console.log(MODE.BlockStatement); ++ } ++ var MODE = { ++ BlockStatement: "OK", ++ }; ++ module.exports = fun; ++ } ++ var m = {}; ++ xxx(m); ++ m.exports(); ++ } ++ expect: { ++ function xxx(module) { ++ var MODE_BlockStatement = "OK"; ++ module.exports = function() { ++ console.log(MODE_BlockStatement); ++ }; ++ } ++ var m = {}; ++ xxx(m); ++ m.exports(); ++ } ++ expect_stdout: "OK" ++} ++ ++issue_3457_3: { ++ options = { ++ hoist_props: true, ++ reduce_vars: true, ++ unused: true, ++ } ++ input: { ++ function xxx() { ++ var MODE = { ++ key: "value", ++ }; ++ return function() { ++ return MODE.key; ++ }; ++ } ++ console.log(xxx()()); ++ } ++ expect: { ++ function xxx() { ++ var MODE_key = "value"; ++ return function() { ++ return MODE_key; ++ }; ++ } ++ console.log(xxx()()); ++ } ++ expect_stdout: "value" ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..cf4dd2b0 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["node test/compress.js hoist_props.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 test/compress.js hoist_props.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001932/tests/test.sh b/tasks/format-code-task-001932/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c1862705456199a8f8cf807e6f1679cccd9fd39d --- /dev/null +++ b/tasks/format-code-task-001932/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/compress/hoist_props.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-001932/tests/test_command.sh b/tasks/format-code-task-001932/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001932/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001935/environment/Dockerfile b/tasks/format-code-task-001935/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..8277ac7971e2adccb5f37d90b433e3fe0e477359 --- /dev/null +++ b/tasks/format-code-task-001935/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:33f1553849c7c89323589656cde1bd4301e903280a5cb92481d4114b01e6ee40 diff --git a/tasks/format-code-task-001935/environment/setup/files/blocklist b/tasks/format-code-task-001935/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001935/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001935/environment/setup/setup.sh b/tasks/format-code-task-001935/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001935/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001935/tests/test.patch b/tasks/format-code-task-001935/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..64cb7ae96b7cff44eb96cc050ea09f52b9260d12 --- /dev/null +++ b/tasks/format-code-task-001935/tests/test.patch @@ -0,0 +1,155 @@ +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,129 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++( cd /workspace/repo && make build ) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN=/workspace/repo/build/bin/csvq ++ ++TMP=$(mktemp -d); trap 'rm -rf "$TMP"' EXIT ++REPO="$TMP/data" ++mkdir -p "$REPO" ++cd "$TMP" || exit 1 ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++assert_file_eq() { ++ label=$1 ++ file=$2 ++ expected=$3 ++ actual=$(cat "$file") ++ [ "$actual" = "$expected" ] || fail "$label: $actual" ++} ++ ++assert_empty_file() { ++ label=$1 ++ file=$2 ++ [ ! -s "$file" ] || fail "$label: $(cat "$file")" ++} ++ ++assert_file_contains() { ++ label=$1 ++ file=$2 ++ needle=$3 ++ actual=$(cat "$file") ++ case "$actual" in ++ *"$needle"*) ;; ++ *) fail "$label: expected to contain [$needle], got [$actual]" ;; ++ esac ++} ++ ++printf 'name:Alice\tage:30\nname:Bob\tage:41\n' > "$REPO/people.ltsv" ++printf 'f1:value1\tf2:value2\tf3:value3\nf1:value4\tf2:value5\tf4:value6\n' > "$REPO/table6.ltsv" ++printf 'name:' > "$REPO/sjis.ltsv" ++printf '\x93\x8c\x8b\x9e' >> "$REPO/sjis.ltsv" ++printf '\tage:40\n' >> "$REPO/sjis.ltsv" ++ ++ ++ ++ ++"$BIN" --format CSV --repository "$REPO" \ ++ "select name, age from ltsv(people)" >out 2>err; ec=$? ++EXPECTED='name,age ++Alice,30 ++Bob,41' ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++assert_file_eq "F1 stdout" out "$EXPECTED" ++assert_empty_file "F1 stderr" err ++ ++ ++ ++ ++"$BIN" --format CSV --repository "$REPO" \ ++ "select f1, f2, f3 is null as f3_null, f3 = '' as f3_empty, f4 is null as f4_null, f4 = '' as f4_empty from ltsv(table6)" >out 2>err; ec=$? ++EXPECTED='f1,f2,f3_null,f3_empty,f4_null,f4_empty ++value1,value2,false,false,true, ++value4,value5,true,,false,false' ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++assert_file_eq "F2 stdout" out "$EXPECTED" ++assert_empty_file "F2 stderr" err ++ ++ ++ ++ ++"$BIN" --format CSV --repository "$REPO" \ ++ "select f1, f2, f3 is null as f3_null, f3 = '' as f3_empty, f4 is null as f4_null, f4 = '' as f4_empty from ltsv(table6, 'utf8', true)" >out 2>err; ec=$? ++EXPECTED='f1,f2,f3_null,f3_empty,f4_null,f4_empty ++value1,value2,false,false,false,true ++value4,value5,false,true,false,false' ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++assert_file_eq "F3 stdout" out "$EXPECTED" ++assert_empty_file "F3 stderr" err ++ ++ ++ ++ ++"$BIN" --format CSV --repository "$REPO" \ ++ "select name, age from ltsv(sjis, 'sjis')" >out 2>err; ec=$? ++EXPECTED_HEX='6e616d652c6167650ae69db1e4baac2c34300a' ++ACTUAL_HEX=$(od -An -tx1 -v out | tr -d ' \n') ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++[ "$ACTUAL_HEX" = "$EXPECTED_HEX" ] || fail "F4 stdout hex: $ACTUAL_HEX" ++assert_empty_file "F4 stderr" err ++ ++ ++ ++ ++"$BIN" --format CSV --import-format LTSV --repository "$REPO" \ ++ "select name from people" >out 2>err; ec=$? ++EXPECTED='name ++Alice ++Bob' ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++assert_file_eq "F5 stdout" out "$EXPECTED" ++assert_empty_file "F5 stderr" err ++ ++ ++ ++ ++"$BIN" --format CSV --repository "$REPO" \ ++ "select name from ltsv(people, 'utf8', true, false)" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F6 exit $ec; want non-zero" ++assert_file_eq "F6 stdout" out '' ++ ++assert_file_contains "F6 stderr mentions ltsv" err 'ltsv' ++assert_file_contains "F6 stderr mentions arguments" err 'arguments' ++ ++ ++ ++ ++"$BIN" --format CSV --import-format LTSV --repository "$REPO" \ ++ "select name from ghost" >out 2>err; ec=$? ++[ "$ec" -ne 0 ] || fail "F7 exit $ec; want non-zero" ++assert_file_eq "F7 stdout" out '' ++ ++assert_file_contains "F7 stderr mentions ghost" err 'ghost' ++assert_file_contains "F7 stderr mentions file" err 'file' ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,16 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++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-001935/tests/test.sh b/tasks/format-code-task-001935/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-001935/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-001935/tests/test_command.sh b/tasks/format-code-task-001935/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001935/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-001950/environment/Dockerfile b/tasks/format-code-task-001950/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..73def31698428e8ef886bf96486d83bb39845456 --- /dev/null +++ b/tasks/format-code-task-001950/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:9909aa39d446b0176ffb12e74e48f3b105cd064a8d4e04be6e505b2b1b6132ba diff --git a/tasks/format-code-task-001950/environment/setup/files/blocklist b/tasks/format-code-task-001950/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001950/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001950/environment/setup/setup.sh b/tasks/format-code-task-001950/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001950/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001950/tests/test.patch b/tasks/format-code-task-001950/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1a76562ec4c1e8258f64decad3577ab79e73cd01 --- /dev/null +++ b/tasks/format-code-task-001950/tests/test.patch @@ -0,0 +1,137 @@ +diff --git a/mne/io/egi/tests/test_egi.py b/mne/io/egi/tests/test_egi.py +index f30aa4267..e6d745f9c 100644 +--- a/mne/io/egi/tests/test_egi.py ++++ b/mne/io/egi/tests/test_egi.py +@@ -148,6 +148,110 @@ def test_io_egi_pns_mff(): + assert_array_equal(mat_data, raw_data) + + ++@requires_testing_data ++def test_io_egi_mff_crop_then_load_data(): ++ """Test that lazy MFF read + crop + load_data does not crash and is correct. ++ ++ Regression test for issue where reading raw MFF without preload, ++ then cropping, then calling load_data() (or any access that triggers ++ _read_segment_file across block boundaries) raised IndexError. ++ """ ++ egi_fname_mff = op.join(data_path(), 'EGI', 'test_egi.mff') ++ ++ ++ raw_full = read_raw_egi(egi_fname_mff, include=None, preload=True, ++ verbose='error') ++ raw_full.crop(tmin=2.5) ++ ++ ++ raw_lazy = read_raw_egi(egi_fname_mff, include=None, preload=False, ++ verbose='error') ++ raw_lazy.crop(tmin=2.5) ++ raw_lazy.load_data() ++ ++ ++ ++ ++ assert_allclose(raw_lazy._data, raw_full._data) ++ ++ ++@requires_testing_data ++def test_io_egi_mff_crop_then_find_events(): ++ """Test that find_events works correctly after lazy MFF read + crop. ++ ++ Exact reproduction of the issue snippet. ++ """ ++ egi_fname_mff = op.join(data_path(), 'EGI', 'test_egi.mff') ++ ++ ++ raw_full = read_raw_egi(egi_fname_mff, include=None, preload=True, ++ verbose='error') ++ raw_full.crop(tmin=2.5) ++ events_full = find_events(raw_full, stim_channel='STI 014') ++ ++ ++ raw_lazy = read_raw_egi(egi_fname_mff, include=None, preload=False, ++ verbose='error') ++ raw_lazy.crop(tmin=2.5) ++ events_lazy = find_events(raw_lazy, stim_channel='STI 014') ++ ++ assert_array_equal(events_lazy, events_full) ++ ++ ++@requires_testing_data ++def test_io_egi_mff_crop_event_channel_correct(): ++ """After crop on lazy MFF, event channel data must reflect cropped range. ++ ++ Catches a bug where events were indexed from absolute zero rather than ++ from the crop start, producing event channel values from the wrong time. ++ """ ++ egi_fname_mff = op.join(data_path(), 'EGI', 'test_egi.mff') ++ ++ raw_full = read_raw_egi(egi_fname_mff, include=None, preload=True, ++ verbose='error') ++ raw_full.crop(tmin=2.5) ++ ++ raw_lazy = read_raw_egi(egi_fname_mff, include=None, preload=False, ++ verbose='error') ++ raw_lazy.crop(tmin=2.5) ++ ++ ++ ++ sti_idx = raw_lazy.ch_names.index('STI 014') ++ data_lazy, _ = raw_lazy[sti_idx, :] ++ data_full, _ = raw_full[sti_idx, :] ++ assert_array_equal(data_lazy, data_full) ++ ++ ++ n_eeg = sum(1 for n in raw_lazy.ch_names if n.startswith('E')) ++ data_lazy_ev, _ = raw_lazy[n_eeg:, :] ++ data_full_ev, _ = raw_full[n_eeg:, :] ++ assert_array_equal(data_lazy_ev, data_full_ev) ++ ++ ++@requires_testing_data ++def test_io_egi_mff_crop_eeg_data_correct(): ++ """After crop on lazy MFF, EEG data must match preloaded+cropped EEG data. ++ ++ Catches a regression in the offset_samples handling in the EEG read path ++ where samples in blocks after the first were incorrectly skipped. ++ """ ++ egi_fname_mff = op.join(data_path(), 'EGI', 'test_egi.mff') ++ ++ raw_full = read_raw_egi(egi_fname_mff, include=None, preload=True, ++ verbose='error') ++ raw_full.crop(tmin=2.5) ++ ++ raw_lazy = read_raw_egi(egi_fname_mff, include=None, preload=False, ++ verbose='error') ++ raw_lazy.crop(tmin=2.5) ++ ++ eeg_picks = pick_types(raw_lazy.info, eeg=True) ++ data_lazy, _ = raw_lazy[eeg_picks, :] ++ data_full, _ = raw_full[eeg_picks, :] ++ assert_allclose(data_lazy, data_full) ++ ++ + @requires_testing_data + def test_io_egi_pns_mff_bug(): + """Test importing EGI MFF with PNS data (BUG).""" +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..cb2552131 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest mne/io/egi/tests/test_egi.py::test_io_egi_mff_crop_then_load_data mne/io/egi/tests/test_egi.py::test_io_egi_mff_crop_then_find_events mne/io/egi/tests/test_egi.py::test_io_egi_mff_crop_event_channel_correct mne/io/egi/tests/test_egi.py::test_io_egi_mff_crop_eeg_data_correct -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 mne/io/egi/tests/test_egi.py::test_io_egi_mff_crop_then_load_data mne/io/egi/tests/test_egi.py::test_io_egi_mff_crop_then_find_events mne/io/egi/tests/test_egi.py::test_io_egi_mff_crop_event_channel_correct mne/io/egi/tests/test_egi.py::test_io_egi_mff_crop_eeg_data_correct -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-001950/tests/test.sh b/tasks/format-code-task-001950/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a5e11dfddc8fdd86c89c7db7e6e0e3fd3e54fef7 --- /dev/null +++ b/tasks/format-code-task-001950/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' +mne/io/egi/tests/test_egi.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-001950/tests/test_command.sh b/tasks/format-code-task-001950/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001950/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001951/environment/Dockerfile b/tasks/format-code-task-001951/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3f04b383d192ab3d74cfe8253a659c46d0e3bfeb --- /dev/null +++ b/tasks/format-code-task-001951/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:20c802bfd18205b50bb4108e2274cc06578dc81cb1946ab9a21bd6dc3e8194a4 diff --git a/tasks/format-code-task-001951/environment/setup/files/blocklist b/tasks/format-code-task-001951/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001951/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001951/environment/setup/setup.sh b/tasks/format-code-task-001951/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001951/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001951/tests/test.patch b/tasks/format-code-task-001951/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e552d3316c6dd2f1a6a60ecdc7e0a04f620981e5 --- /dev/null +++ b/tasks/format-code-task-001951/tests/test.patch @@ -0,0 +1,86 @@ +diff --git a/frontend/dockerfile/instructions/bflag_test.go b/frontend/dockerfile/instructions/bflag_test.go +index 0e880e619066..f7c180d8e7da 100644 +--- a/frontend/dockerfile/instructions/bflag_test.go ++++ b/frontend/dockerfile/instructions/bflag_test.go +@@ -1,6 +1,8 @@ + package instructions + + import ( ++ "sort" ++ "strings" + "testing" + ) + +@@ -184,4 +186,30 @@ func TestBuilderFlags(t *testing.T) { + if !flBool1.IsTrue() { + t.Fatalf("Test %s, bool1 should be true", bf.Args) + } ++ ++ ++ ++ bf = NewBFlags() ++ _ = bf.AddBool("bool1", false) ++ _ = bf.AddBool("bool2", false) ++ _ = bf.AddBool("bool3", false) ++ _ = bf.AddBool("bool4", true) ++ _ = bf.AddBool("bool5", true) ++ _ = bf.AddString("str1", "") ++ _ = bf.AddString("str2", "") ++ _ = bf.AddString("str3", "def3") ++ _ = bf.AddString("str4", "def4") ++ ++ bf.Args = []string{`--bool2=false`, `--bool3`, `--bool4=true`, `--bool5`, `--str2= `, `--str3=def3`, `--str4=my-val`} ++ ++ if err = bf.Parse(); err != nil { ++ t.Fatalf("Test %q was supposed to work: %s", bf.Args, err) ++ } ++ used := bf.Used() ++ sort.Strings(used) ++ expected = "bool2, bool3, bool4, bool5, str2, str3, str4" ++ actual := strings.Join(used, ", ") ++ if actual != expected { ++ t.Fatalf("Test %s, expected '%s', got '%s'", bf.Args, expected, actual) ++ } + } +diff --git a/frontend/dockerfile/instructions/parse_test.go b/frontend/dockerfile/instructions/parse_test.go +index ed543effd2fa..b059654c6cce 100644 +--- a/frontend/dockerfile/instructions/parse_test.go ++++ b/frontend/dockerfile/instructions/parse_test.go +@@ -226,3 +226,16 @@ func TestErrorCases(t *testing.T) { + require.Contains(t, err.Error(), c.expectedError) + } + } ++ ++func TestRunCmdFlagsUsed(t *testing.T) { ++ dockerfile := "RUN --mount=type=tmpfs,target=/foo/ echo hello" ++ r := strings.NewReader(dockerfile) ++ ast, err := parser.Parse(r) ++ require.NoError(t, err) ++ ++ n := ast.AST.Children[0] ++ c, err := ParseInstruction(n) ++ require.NoError(t, err) ++ require.IsType(t, c, &RunCommand{}) ++ require.Equal(t, []string{"mount"}, c.(*RunCommand).FlagsUsed) ++} +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+3ST0/DIBgGcM77FG92bylsrCcvmvgBjJ6XDths1kLCn5388NIe1JjoLluM+vwu ++wAsEyEO9y/1gttadOLuWpmiVmtviczv3hZJCSqnWrWSNEJtmxUhd7UYf5Ji6QMSC9+m7defmf6n6 ++Pf9kY9pqP46dM3V8vtwZ5/Ivab/lv2pLXaw3QjBqLneFr/3z/LWhOfidNYuDp6lL1Ykq7bNLN4Jq ++vg/eJesMN14fbdj3g+W9iylknXrvIqcqZEfLx7L1dvpMNtwP3SG+TIWH7O5GM4+fojXLxU+/FwAA ++AAAAAAAAAAAAAAAAAADgL3kFJFNMxQAoAAA= +diff --git 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-001951/tests/test.sh b/tasks/format-code-task-001951/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0c15887578bb9cf6e3de980da9c96e6a381a58f5 --- /dev/null +++ b/tasks/format-code-task-001951/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' +frontend/dockerfile/instructions/bflag_test.go +frontend/dockerfile/instructions/parse_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-001951/tests/test_command.sh b/tasks/format-code-task-001951/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001951/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001956/environment/Dockerfile b/tasks/format-code-task-001956/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..15f4541f0f5bca148e61adee98d54866ec7fb4a5 --- /dev/null +++ b/tasks/format-code-task-001956/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:518b1375249c01c6d12de2747cc7c91a6f9b0559a0bddf4d2b0bfaef81e5a0e4 diff --git a/tasks/format-code-task-001956/environment/setup/files/blocklist b/tasks/format-code-task-001956/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001956/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001956/environment/setup/setup.sh b/tasks/format-code-task-001956/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001956/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001956/tests/test.patch b/tasks/format-code-task-001956/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0df6053a29b8ce7d0c0fab4e1cde29d8c19631e2 --- /dev/null +++ b/tasks/format-code-task-001956/tests/test.patch @@ -0,0 +1,224 @@ +diff --git a/packages/create-module-federation/__tests__/renderTemplate.spec.ts b/packages/create-module-federation/__tests__/renderTemplate.spec.ts +new file mode 100644 +index 000000000..b400c6081 +--- /dev/null ++++ b/packages/create-module-federation/__tests__/renderTemplate.spec.ts +@@ -0,0 +1,183 @@ ++import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync } from 'fs'; ++import { tmpdir } from 'os'; ++import path from 'path'; ++import { renderProject } from '../src'; ++ ++function makeTmp(prefix: string): string { ++ return mkdtempSync(path.join(tmpdir(), prefix)); ++} ++ ++function write(root: string, rel: string, content: string): void { ++ const full = path.join(root, rel); ++ mkdirSync(path.dirname(full), { recursive: true }); ++ writeFileSync(full, content); ++} ++ ++function read(root: string, rel: string): string { ++ return readFileSync(path.join(root, rel), 'utf-8'); ++} ++ ++describe('renderProject', () => { ++ let templateDir: string; ++ let targetDir: string; ++ ++ beforeEach(() => { ++ templateDir = makeTmp('cmf-tpl-'); ++ targetDir = path.join(makeTmp('cmf-out-'), 'project'); ++ }); ++ ++ it('copies a nested directory tree into the target preserving structure', async () => { ++ write(templateDir, 'src/index.ts', 'console.log(1);'); ++ write(templateDir, 'src/routes/page.tsx', 'export default 1;'); ++ write(templateDir, 'README.md', '# hello'); ++ ++ const result = await renderProject({ templateDir, targetDir }); ++ ++ expect(read(targetDir, 'src/index.ts')).toBe('console.log(1);'); ++ expect(read(targetDir, 'src/routes/page.tsx')).toBe('export default 1;'); ++ expect(read(targetDir, 'README.md')).toBe('# hello'); ++ expect([...result.written].sort()).toEqual( ++ ['README.md', 'src/index.ts', 'src/routes/page.tsx'].sort(), ++ ); ++ expect(result.skipped).toEqual([]); ++ }); ++ ++ it('creates the target directory when it does not exist', async () => { ++ write(templateDir, 'a.txt', 'a'); ++ expect(existsSync(targetDir)).toBe(false); ++ ++ await renderProject({ templateDir, targetDir }); ++ ++ expect(existsSync(targetDir)).toBe(true); ++ expect(read(targetDir, 'a.txt')).toBe('a'); ++ }); ++ ++ it('includes dotfiles, hidden directories and empty files', async () => { ++ write(templateDir, '.gitignore', 'node_modules\n'); ++ write(templateDir, '.npmrc', 'registry=x\n'); ++ write(templateDir, '.vscode/settings.json', '{}'); ++ write(templateDir, 'public/.gitkeep', ''); ++ ++ const result = await renderProject({ templateDir, targetDir }); ++ ++ expect(read(targetDir, '.gitignore')).toBe('node_modules\n'); ++ expect(read(targetDir, '.npmrc')).toBe('registry=x\n'); ++ expect(read(targetDir, '.vscode/settings.json')).toBe('{}'); ++ expect(read(targetDir, 'public/.gitkeep')).toBe(''); ++ expect([...result.written].sort()).toEqual( ++ ['.gitignore', '.npmrc', '.vscode/settings.json', 'public/.gitkeep'].sort(), ++ ); ++ }); ++ ++ it('renders .handlebars templates and strips only the final .handlebars segment', async () => { ++ write(templateDir, 'package.json.handlebars', '{ "name": "{{ name }}" }'); ++ write( ++ templateDir, ++ 'module-federation.config.ts.handlebars', ++ 'export const name = "{{name}}";', ++ ); ++ write(templateDir, 'foo.handlebars', 'value={{ value }}'); ++ ++ const result = await renderProject({ ++ templateDir, ++ targetDir, ++ data: { name: 'mf_app', value: 'v' }, ++ }); ++ ++ expect(read(targetDir, 'package.json')).toBe('{ "name": "mf_app" }'); ++ expect(read(targetDir, 'module-federation.config.ts')).toBe( ++ 'export const name = "mf_app";', ++ ); ++ expect(read(targetDir, 'foo')).toBe('value=v'); ++ expect(existsSync(path.join(targetDir, 'package.json.handlebars'))).toBe(false); ++ expect([...result.written].sort()).toEqual( ++ ['foo', 'module-federation.config.ts', 'package.json'].sort(), ++ ); ++ }); ++ ++ it('tolerates whitespace inside braces, repeats, and dot-path / non-string values', async () => { ++ write( ++ templateDir, ++ 't.txt.handlebars', ++ '{{name}}-{{ name }}-{{ name }}|{{ meta.role }}|{{ port }}|{{ flag }}', ++ ); ++ ++ await renderProject({ ++ templateDir, ++ targetDir, ++ data: { name: 'app', meta: { role: 'provider' }, port: 3001, flag: false }, ++ }); ++ ++ expect(read(targetDir, 't.txt')).toBe('app-app-app|provider|3001|false'); ++ }); ++ ++ it('does not interpret placeholder-looking text in non-template files', async () => { ++ write(templateDir, 'raw.txt', 'literal {{ name }} stays'); ++ ++ await renderProject({ templateDir, targetDir, data: { name: 'app' } }); ++ ++ expect(read(targetDir, 'raw.txt')).toBe('literal {{ name }} stays'); ++ }); ++ ++ it('rejects when a template placeholder cannot be resolved, naming the expression', async () => { ++ write(templateDir, 'a.txt.handlebars', 'hello {{ missingKey }}'); ++ ++ await expect( ++ renderProject({ templateDir, targetDir, data: { name: 'app' } }), ++ ).rejects.toThrow(/missingKey/); ++ }); ++ ++ it('rejects when data is omitted but a template has placeholders', async () => { ++ write(templateDir, 'a.txt.handlebars', 'hi {{ name }}'); ++ ++ await expect(renderProject({ templateDir, targetDir })).rejects.toThrow(/name/); ++ }); ++ ++ it('rejects when a nested dot path cannot be resolved, naming the path', async () => { ++ write(templateDir, 'a.txt.handlebars', '{{ meta.unknown }}'); ++ ++ await expect( ++ renderProject({ templateDir, targetDir, data: { meta: { role: 'p' } } }), ++ ).rejects.toThrow(/meta\.unknown/); ++ }); ++ ++ it('skips existing files by default and reports them in skipped', async () => { ++ write(templateDir, 'package.json.handlebars', '{ "name": "{{ name }}" }'); ++ write(templateDir, 'new.txt', 'fresh'); ++ write(targetDir, 'package.json', 'OLD'); ++ ++ const result = await renderProject({ ++ templateDir, ++ targetDir, ++ data: { name: 'mf_app' }, ++ }); ++ ++ expect(read(targetDir, 'package.json')).toBe('OLD'); ++ expect(read(targetDir, 'new.txt')).toBe('fresh'); ++ expect(result.skipped).toEqual(['package.json']); ++ expect([...result.written].sort()).toEqual(['new.txt'].sort()); ++ }); ++ ++ it('overwrites existing files when override is set and reports them in written', async () => { ++ write(templateDir, 'package.json.handlebars', '{ "name": "{{ name }}" }'); ++ write(targetDir, 'package.json', 'OLD'); ++ ++ const result = await renderProject({ ++ templateDir, ++ targetDir, ++ data: { name: 'mf_app' }, ++ override: true, ++ }); ++ ++ expect(read(targetDir, 'package.json')).toBe('{ "name": "mf_app" }'); ++ expect(result.skipped).toEqual([]); ++ expect([...result.written].sort()).toEqual(['package.json'].sort()); ++ }); ++ ++ it('returns empty lists for an empty template directory and still creates the target', async () => { ++ const result = await renderProject({ templateDir, targetDir }); ++ ++ expect(result).toEqual({ written: [], skipped: [] }); ++ expect(existsSync(targetDir)).toBe(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,30 @@ ++#!/usr/bin/env bash ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++CMF_CONFIG="$(mktemp /tmp/cmf-jest.XXXXXX.js)" ++trap 'rm -f "$CMF_CONFIG"' EXIT ++cat > "$CMF_CONFIG" <<'EOF' ++const swc = require.resolve('@swc/jest', { paths: ['/testbed/node_modules'] }); ++module.exports = { ++ rootDir: '/testbed/packages/create-module-federation', ++ testEnvironment: 'node', ++ transform: { '^.+\\.(t|j)sx?$': [swc, { jsc: { parser: { syntax: 'typescript' } } }] }, ++ testMatch: ['/__tests__/**/*.spec.ts'], ++ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'], ++}; ++EOF ++ ++ ++npx jest --config packages/sdk/jest.config.js ++ ++ ++npx jest --config "$CMF_CONFIG" diff --git a/tasks/format-code-task-001956/tests/test.sh b/tasks/format-code-task-001956/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..5d076c3ee9ad893d41bc054ea56d6431ee050abd --- /dev/null +++ b/tasks/format-code-task-001956/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' +packages/create-module-federation/__tests__/renderTemplate.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-001956/tests/test_command.sh b/tasks/format-code-task-001956/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001956/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-001957/environment/Dockerfile b/tasks/format-code-task-001957/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6f5b87408b9cad43f0a9b48958f79235b5943b10 --- /dev/null +++ b/tasks/format-code-task-001957/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:41b4a048973bffa695c418eb1575d630d7571f3f71f7466c4aeb27cba79931d2 diff --git a/tasks/format-code-task-001957/environment/setup/files/blocklist b/tasks/format-code-task-001957/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001957/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001957/environment/setup/setup.sh b/tasks/format-code-task-001957/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001957/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001957/tests/test.sh b/tasks/format-code-task-001957/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..1c4ee19e5f78d9531ac5d2d144c72d96268db3a4 --- /dev/null +++ b/tasks/format-code-task-001957/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/facet_mounting_helpers.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-001957/tests/test_command.sh b/tasks/format-code-task-001957/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001957/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-001968/environment/Dockerfile b/tasks/format-code-task-001968/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..fc91c65993c25bec4c0056822e834639ca47fff8 --- /dev/null +++ b/tasks/format-code-task-001968/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a39be93019f84de710aae24d5721fcbb9ea4e8fb5991b517cd9a0dab8bb81292 diff --git a/tasks/format-code-task-001968/environment/setup/files/blocklist b/tasks/format-code-task-001968/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001968/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001968/environment/setup/setup.sh b/tasks/format-code-task-001968/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-001968/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-001968/tests/test.patch b/tasks/format-code-task-001968/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..bbff0eb88a36eac312b79d7e41d9b24ceeec0e4d --- /dev/null +++ b/tasks/format-code-task-001968/tests/test.patch @@ -0,0 +1,229 @@ +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,201 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++ ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++command -v script >/dev/null 2>&1 || fail "script(1) is required for interactive prompts" ++ ++( cd /workspace/repo/mini-star && ../node_modules/.bin/tsc -p ./tsconfig.build.json ) \ ++ || fail "build" ++BIN="node /workspace/repo/mini-star/lib/cli/index.js" ++ ++TMP=$(mktemp -d) ++REPO_CFG="/workspace/repo/.ministarrc.json" ++REPO_CFG_BACKUP="$TMP/repo.ministarrc.backup" ++REPO_CFG_HAD=0 ++if [ -e "$REPO_CFG" ]; then ++ cp "$REPO_CFG" "$REPO_CFG_BACKUP" || fail "backup existing repo config" ++ REPO_CFG_HAD=1 ++fi ++cleanup() { ++ if [ "$REPO_CFG_HAD" -eq 1 ]; then ++ mv "$REPO_CFG_BACKUP" "$REPO_CFG" ++ else ++ rm -f "$REPO_CFG" ++ fi ++ rm -rf "$TMP" ++} ++trap cleanup EXIT ++ ++run_pty() { ++ local cwd="$1" ++ local input_script="$2" ++ local command="$3" ++ local out_file="$4" ++ local err_file="$5" ++ local script_err="$out_file.script.err" ++ ++ ( ++ cd "$cwd" || exit 125 ++ eval "$input_script" ++ ) | script -q -e -c "cd '$cwd' && $command 2> '$err_file'" /dev/null >"$out_file" 2>"$script_err" ++ local ec=$? ++ [ ! -s "$script_err" ] || fail "script wrapper stderr: $(cat "$script_err")" ++ return "$ec" ++} ++ ++clean_out() { ++ perl -pe 's/\e\[[0-9;?]*[ -\/]*[@-~]//g; s/\r//g' "$1" ++} ++ ++ ++assert_file_contains() { ++ local file="$1" ++ local expected="$2" ++ [ -f "$file" ] || fail "missing file $file" ++ grep -Fq "$expected" "$file" || fail "content mismatch for $file: $(cat "$file")" ++} ++ ++assert_package_spec() { ++ local file="$1" ++ local expected_name="$2" ++ local expected_main="$3" ++ local expected_author="${4-__localb_absent__}" ++ local expected_license="${5-__localb_absent__}" ++ [ -f "$file" ] || fail "missing file $file" ++ ++ node -e ' ++ const fs = require("fs"); ++ const pkg = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); ++ const [expectedName, expectedMain, expectedAuthor, expectedLicense] = process.argv.slice(2); ++ function check(cond, msg) { ++ if (!cond) { ++ console.error(msg, JSON.stringify(pkg)); ++ process.exit(1); ++ } ++ } ++ check(pkg.name === expectedName, "name mismatch"); ++ check(pkg.main === expectedMain, "main mismatch"); ++ check(pkg.version === "0.0.0", "version mismatch"); ++ check(pkg.private === true, "private mismatch"); ++ check(pkg.dependencies && typeof pkg.dependencies === "object" && !Array.isArray(pkg.dependencies) && Object.keys(pkg.dependencies).length === 0, "dependencies mismatch"); ++ if (expectedAuthor !== "__localb_absent__") check(pkg.author === expectedAuthor, "author mismatch"); ++ if (expectedLicense !== "__localb_absent__") check(pkg.license === expectedLicense, "license mismatch"); ++ ' "$file" "$expected_name" "$expected_main" "$expected_author" "$expected_license" \ ++ || fail "package metadata mismatch for $file" ++} ++ ++assert_tsconfig_spec() { ++ local file="$1" ++ [ -f "$file" ] || fail "missing file $file" ++ ++ node -e ' ++ const fs = require("fs"); ++ const cfg = JSON.parse(fs.readFileSync(process.argv[1], "utf8")); ++ if (cfg.extends !== "../../tsconfig.json" || !cfg.compilerOptions || cfg.compilerOptions.rootDir !== "./src") { ++ console.error(JSON.stringify(cfg)); ++ process.exit(1); ++ } ++ ' "$file" || fail "tsconfig mismatch for $file" ++} ++ ++ ++ ++ ++F1="$TMP/f1" ++mkdir -p "$F1" ++cat >"$F1/.ministarrc.json" <"$CLEAN_F1" ++grep -Fq "Require Plugin Name!" "$CLEAN_F1" || fail "F1 missing empty-name validation" ++ ++grep -Fq "Language" "$CLEAN_F1" || fail "F1 missing Language prompt" ++ ++grep -Fq "Ensure to create plugin: [valid] ?" "$CLEAN_F1" || fail "F1 missing declined confirmation prompt" ++! grep -Fq "create completed" "$CLEAN_F1" || fail "F1 printed completion despite decline" ++[ ! -e "$F1/root/plugins/valid" ] || fail "F1 created plugin files despite decline" ++ ++ ++ ++ ++F2="$TMP/f2" ++mkdir -p "$F2" ++cat >"$F2/.ministarrc.json" <"$CLEAN_F2" ++ ++grep -Fq "Plugin Name" "$CLEAN_F2" || fail "F2 missing Plugin Name prompt" ++grep -Fq "Language" "$CLEAN_F2" || fail "F2 missing Language prompt" ++ ++grep -Fq "Ensure to create plugin: [demo] ?" "$CLEAN_F2" || fail "F2 missing accepted confirmation prompt" ++grep -Fxq "Plugin [demo] create completed: $F2/root/plugins/demo/src/index.js" "$CLEAN_F2" || fail "F2 missing exact completion line" ++assert_package_spec "$F2/root/plugins/demo/package.json" "@acme/demo" "src/index.js" "Ada" "Apache-2.0" ++assert_file_contains "$F2/root/plugins/demo/src/index.js" 'console.log("Hello World!")' ++[ ! -e "$F2/root/plugins/demo/tsconfig.json" ] || fail "F2 wrote tsconfig for JavaScript plugin" ++ ++ ++ ++ ++F3="$TMP/f3" ++mkdir -p "$F3" ++cat >"$F3/.ministarrc.json" <"$CLEAN_F3" ++ ++grep -Fq "Language" "$CLEAN_F3" || fail "F3 missing Language prompt" ++grep -Fxq "Plugin [typed] create completed: $F3/root/plugins/typed/src/index.ts" "$CLEAN_F3" || fail "F3 missing exact completion line" ++assert_package_spec "$F3/root/plugins/typed/package.json" "@team/typed" "src/index.ts" ++assert_file_contains "$F3/root/plugins/typed/src/index.ts" 'console.log("Hello World!")' ++assert_tsconfig_spec "$F3/root/plugins/typed/tsconfig.json" ++ ++ ++ ++ ++F4="$TMP/f4" ++mkdir -p "$F4/root/plugins/demo" ++printf 'keep me' >"$F4/root/plugins/demo/sentinel.txt" ++cat >"$F4/.ministarrc.json" <"$REPO_CFG" <"$CLEAN_F5" ++ ++grep -Fq "Plugin Name" "$CLEAN_F5" || fail "F5 missing Plugin Name prompt through npm shortcut" ++grep -Fq "Language" "$CLEAN_F5" || fail "F5 missing Language prompt through npm shortcut" ++grep -Fxq "Plugin [via-npm] create completed: $F5/root/plugins/via-npm/src/index.js" "$CLEAN_F5" || fail "F5 missing exact completion line" ++assert_package_spec "$F5/root/plugins/via-npm/package.json" "@shortcut/via-npm" "src/index.js" ++assert_file_contains "$F5/root/plugins/via-npm/src/index.js" 'console.log("Hello World!")' ++ ++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 NPM_CONFIG_OFFLINE=true ++export NPM_CONFIG_AUDIT=false ++export NPM_CONFIG_FUND=false ++export NPM_CONFIG_UPDATE_NOTIFIER=false ++export COREPACK_ENABLE_NETWORK=0 ++set -e ++cd /workspace/repo ++exec bash /workspace/repo/usercase-test-coderl/usecase.sh diff --git a/tasks/format-code-task-001968/tests/test.sh b/tasks/format-code-task-001968/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-001968/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-001968/tests/test_command.sh b/tasks/format-code-task-001968/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-001968/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-001969/environment/Dockerfile b/tasks/format-code-task-001969/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ac83a482038243c124e7d342e8ed0517575ea479 --- /dev/null +++ b/tasks/format-code-task-001969/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:14ecd6994010e6d39181e720ef76c7872b8baff30db2b1b61e960d9b3a607660 diff --git a/tasks/format-code-task-001969/environment/setup/files/blocklist b/tasks/format-code-task-001969/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-001969/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-001969/environment/setup/setup.sh b/tasks/format-code-task-001969/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-001969/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-001969/tests/test.patch b/tasks/format-code-task-001969/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9716590aecc714ffbaca74552b15df89eb7e723e --- /dev/null +++ b/tasks/format-code-task-001969/tests/test.patch @@ -0,0 +1,105 @@ +diff --git a/Specs/Browser/Browser.js b/Specs/Browser/Browser.js +index 94b59005e..111df39de 100644 +--- a/Specs/Browser/Browser.js ++++ b/Specs/Browser/Browser.js +@@ -78,18 +78,33 @@ describe('Browser', function(){ + + it('should think it is executed in a browser', function(){ + var isPhantomJS = !!navigator.userAgent.match(/phantomjs/i); +- expect(isPhantomJS || Browser.ie || Browser.safari || Browser.chrome || Browser.firefox || Browser.opera).toEqual(true); ++ if (!isPhantomJS) expect(['ie', 'safari', 'chrome', 'firefox', 'opera']).toContain(Browser.name); + }); + ++ ++ it('should assign a Browser[Browser.name] property for all browsers, except IE v11 or higher', function(){ ++ if (Browser.name != 'ie' || Browser.version < 11){ ++ var isPhantomJS = !!navigator.userAgent.match(/phantomjs/i); ++ expect(isPhantomJS || Browser.ie || Browser.safari || Browser.chrome || Browser.firefox || Browser.opera).toEqual(true); ++ } ++ }); ++ ++ it('should not assign a Browser[Browser.name] property for IE v11 or higher', function(){ ++ if (Browser.name == 'ie' && Browser.version >= 11){ ++ expect(Browser.ie || Browser.safari || Browser.chrome || Browser.firefox || Browser.opera).toBeUndefined(); ++ } ++ }); ++ ++ + it('should assume the IE version is emulated by the documentMode (X-UA-Compatible)', function(){ +- if (Browser.ie && document.documentMode) expect(Browser.version).toEqual(document.documentMode); ++ if (Browser.name == 'ie' && document.documentMode) expect(Browser.version).toEqual(document.documentMode); + }); + + }); + +-describe('Browser.parse', function(){ ++describe('Browser.parseUA', function(){ + +- var parse = Browser.parse; ++ var parse = Browser.parseUA; + var userAgents = { + ie6: { + desc: 'Internet Explorer 6', +@@ -215,7 +230,7 @@ describe('Browser.parse', function(){ + + var testUA = function(ua){ + return function(){ +- var browser = parse(ua.string.toLowerCase(), ''); ++ var browser = parse(ua.string, ''); + Object.forEach(ua.expect, runExpects, browser); + } + } +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,38 @@ ++H4sIAAAAAAAAA+0Za3PbNtKf9SuQ6QdSY5sUZUvOybGvjePepU2ajJ253k0u41IkKMGmAB4Ayva1 ++/u/dBcCHHn6kl95N54QPIgks9oV9YRWMS5anF5TPw63fa/RgHAwG5glj+Wneo0G/1x8O+/sHw61e ++FA2jvS0y+N04ao1S6VgSsiWF0A/BPbb+Bx1Bc/6y5BdjKa4VlReaKq2CS/VFaOABD/f37zn/KIp6 ++/eb8I4CLBgf9wRbpfRHqj4z/8/P/6llYKhmOGQ/BBggXKe105qCRTJEjIum/Siap72XK6x6a+SLW ++0/YKfldr352/eve2vRiKQoeIc7ffC3M2Nu8XM5GWOVXhpUrFzOsGZpvFoGTyiklA4YVogmOaeoed ++ThiSl2imZAI2qoGF5CqeUElEqYtSE5YB35rEuaRxektSwWkH5vxnmQroDQNLPr/liY+cBpeCcd9S ++2SHeDA5ViFztxnkO1u51u13yc4c0AiRT9I5CioQqWAZ0NDHIPF7cOHaSnMa8ZmoEqJoPVdBEeTvk ++Z5JcpyNSEVY6ZWJEPManVDLtkTvQ4J0R9AxkIHpKiRKlTCiJeUoQC8kY6MwoqeL6BJQJqgIpUfBv ++Yf3JcsJcqbPn1cEhgadjO3dCeS9ttGi9LiOvJbqM1YxxShIha9F2iZa3JBdJnKPEnExyMY5zw5GD ++fw/U0RA/wqGs4aRtTsiF27WLVPAbTG7dtPu2zC5gfthifyOJzqfDtkwnqIIjwss8P+xkQhIfFxlM ++9Q7h8WJB9iCnfKKnsLC9bW0TLXvRsNvwH9knZ8Nkid7ywS7tah0a7h0D7BW+3oFdGmdqYbMEEsGV ++yGlApRTSX9CA8cdMlDwNyFnJR4QXM8I4hFpwjt1dLnZVPKekveXrviXtfA3l035Uu8UJ8KPBG4gJ ++GgRiFZOCzyj4X5xoxickVuRkKsWMGl0jEOiYXtug5Hsvnr16d/LhH+9PyVTP8uMX7hc0cvwitI+x ++SG/hwz0MALouMFXKHLx1qnUxCkNjsFOh9OhPzw+GoYcWBIHgPJGs0Arg0piD74tS5bdmsZBUU55+ ++EC/p35gqY8ClZUk76PSG2WvGU3EN/ALXgf2wrvNuDspl4Jc8nrNJrIUMSvCybyYotxbgO+KK5OyK ++OtHJXtR5N76kiQ5SmuHpSlFQqW99izWo8eBxV5ickPM4Lymw/1b8m+V5HA6CHvH/HkWH5A3j5Q25 ++eT68GO53yTdFkdMf6fh7psPB3kGwNyT+93/98PbNjmXlLzS5El3HUbgXBb0gGg56weCAnMdZLJnb ++ZXQDRpSxSSnjcU6tWnD2GoJiM2MU9WSxijzW4FWzJanaMnweZTyIN2I5hjEO+jfG2HFMUCDlt73E ++ZS6IvfXWawbZM4b8UgipIYPpaawhGwC0gklV5loRwZ1BLCD+yc9KDpYuuG/dzy1WmI8qGmc2dwXI ++pb84ZxwMDQ5Tfb0hmFB9yud+vermX3PgMIuTNbhZtVQR2EGUKDAhdUQr3CGBqlZQViHKCvGxAv3U ++kKpBm0UbjhrRLy5qtqzmjiDPFrFSFFJtb4dkMcQ6+6qFRrdzkyWoekQ+Qswz+dm+YtkwguVcUXJn ++JAGRgjhNz9xh+ZZl3PLKwlYHYk+ukule/gLDxfb2oQPDsGq3BhAZdQkCHEHlYyXwGnT3I7SgDcY7 ++QpH9VcTPEHHKFJr201Bb5TWoH4ZEjQZFqaZ+gxlMAVLcD/EMVOW4qSZ22kCG0OkNqBV4BXWqBnxl ++KZjFReMIGW1LggMibSk5mMEMcghUYHBINHDveKoN5F2307zW+nvkAI25ODkhJq+TjFiN1wvuACoa ++dzvt1Pwb7QhNFYwdI9ThI6ACMggk3XNnXxVXC9OOs47VRMu/HK5TEy3AGyAZdyFM/NQOim+F+ICl ++ZQdruVZcMkGrXakaBVQ1Qy4mvldthTQWpxRKhaqIRM0eeWS7wtWeh1mI7NUMiKFAc+uA3RJWECSJ ++dTL119ctp/gwLGAVsVQpj4BWbUAP1SdGF1i2O/JNzb5WMVXB/Znc1UifzNcpXFhKXZday8y0jtjc ++bQDUfyJPFhy5cjiezNN7AVUgpolEzKCUQNO395r45seYabC1aNDr9WzRfA0zNDXFsfk2qQdUCDOK ++6tfuayU52l3bgAoR2Vj7oDv98ku16fio4qTyRLzhyZpUxYHzaGQKb6z3YDcORQiKLWFnleUt3rY3 ++VJW3dFEGFHQawxnUkuF0ExuMLgAB6gEW1mUQ8mfi/bPsH0R7HhkRfwWszgcIuIswFvzAqwPiAoeE ++oJsZouCE5sPgRLeswpt7rkjWqRNeky/s1aYRaWHTt1WebphpbV1RTrZDWDsZrGHcZ/ATdZH3rpnI ++6qjdbTJDti7rrJJbyjxL5CzBbNEbVpLNei1X8t51VjQpXcI36revO4aSdEybBftaLZiaw8ybt/os ++mqtGkORCUd+RXfDZGu8x6YGRRGAiva67Fe6ga8HH/7qDtRn/yWj1f7HhdgEheRbDtV1NvxyNR/r/ ++UW/Q9H/3DrD/uz/s9zf93//GSFJSdVo7na/Ia9ejgSiA122S0oLylPKEwQXVZxOOV9/30xguv7Pv ++zokyPY/6TtXtLPZ5LPyuhVKkfxymdB5i46tNy3Z0bO8vvyU+9o7gyoh3ZNLuvmHDI54Llpqre84S ++vUxwYnF93d+/l1a7SWUaOUgR6zZZcg5lG7bIFIEiJJPAVKWahS7gspTru1nLHNgGNlJyzeH0ng7v ++ZzSWl2mclXy1BjV/5ZA5q1pn23UtiEI1Ij7yT9Amzm/GZmzGZmzGZmzGZmzGZvzhx68pQTKoACgA ++AA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-001969/tests/test.sh b/tasks/format-code-task-001969/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0eea1eb48fe08bface34b3f845a56f632d433218 --- /dev/null +++ b/tasks/format-code-task-001969/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' +Specs/Browser/Browser.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-001969/tests/test_command.sh b/tasks/format-code-task-001969/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-001969/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002111/environment/Dockerfile b/tasks/format-code-task-002111/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..adfaff31fe9b6b25fb6a34b247d9a35431635ee3 --- /dev/null +++ b/tasks/format-code-task-002111/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e4074f73fef8fa404580364ec1ea9de83969a117844bff7f6826fa215f653c2b diff --git a/tasks/format-code-task-002111/environment/setup/files/blocklist b/tasks/format-code-task-002111/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002111/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002111/environment/setup/setup.sh b/tasks/format-code-task-002111/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002111/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002111/tests/test.patch b/tasks/format-code-task-002111/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e6d5dd126bf72349638d76b4dafa0d68f21c94a5 --- /dev/null +++ b/tasks/format-code-task-002111/tests/test.patch @@ -0,0 +1,311 @@ +diff --git a/runtime/coverage_test.go b/runtime/coverage_test.go +index 951aa16033..8a5e780e0b 100644 +--- a/runtime/coverage_test.go ++++ b/runtime/coverage_test.go +@@ -621,6 +621,117 @@ func TestCoverageReportWithAddressLocation(t *testing.T) { + require.JSONEq(t, expected, string(actual)) + } + ++func TestCoverageReportWithLocationMappings(t *testing.T) { ++ ++ t.Parallel() ++ ++ script := []byte(` ++ pub fun answer(): Int { ++ var i = 0 ++ while i < 42 { ++ i = i + 1 ++ } ++ return i ++ } ++ `) ++ ++ program, err := parser.ParseProgram(nil, script, parser.Config{}) ++ require.NoError(t, err) ++ ++ locationMappings := map[string]string{ ++ "Answer": "cadence/scripts/answer.cdc", ++ } ++ coverageReport := NewCoverageReport() ++ coverageReport.WithLocationMappings(locationMappings) ++ ++ t.Run("with AddressLocation", func(t *testing.T) { ++ location := common.AddressLocation{ ++ Address: common.MustBytesToAddress([]byte{1, 2}), ++ Name: "Answer", ++ } ++ coverageReport.InspectProgram(location, program) ++ ++ actual, err := json.Marshal(coverageReport) ++ require.NoError(t, err) ++ ++ expected := ` ++ { ++ "coverage": { ++ "cadence/scripts/answer.cdc": { ++ "line_hits": { ++ "3": 0, ++ "4": 0, ++ "5": 0, ++ "7": 0 ++ }, ++ "missed_lines": [3, 4, 5, 7], ++ "statements": 4, ++ "percentage": "0.0%" ++ } ++ }, ++ "excluded_locations": [] ++ } ++ ` ++ require.JSONEq(t, expected, string(actual)) ++ }) ++ ++ t.Run("with StringLocation", func(t *testing.T) { ++ location := common.StringLocation("Answer") ++ coverageReport.InspectProgram(location, program) ++ ++ actual, err := json.Marshal(coverageReport) ++ require.NoError(t, err) ++ ++ expected := ` ++ { ++ "coverage": { ++ "cadence/scripts/answer.cdc": { ++ "line_hits": { ++ "3": 0, ++ "4": 0, ++ "5": 0, ++ "7": 0 ++ }, ++ "missed_lines": [3, 4, 5, 7], ++ "statements": 4, ++ "percentage": "0.0%" ++ } ++ }, ++ "excluded_locations": [] ++ } ++ ` ++ require.JSONEq(t, expected, string(actual)) ++ }) ++ ++ t.Run("with IdentifierLocation", func(t *testing.T) { ++ location := common.IdentifierLocation("Answer") ++ coverageReport.InspectProgram(location, program) ++ ++ actual, err := json.Marshal(coverageReport) ++ require.NoError(t, err) ++ ++ expected := ` ++ { ++ "coverage": { ++ "cadence/scripts/answer.cdc": { ++ "line_hits": { ++ "3": 0, ++ "4": 0, ++ "5": 0, ++ "7": 0 ++ }, ++ "missed_lines": [3, 4, 5, 7], ++ "statements": 4, ++ "percentage": "0.0%" ++ } ++ }, ++ "excluded_locations": [] ++ } ++ ` ++ require.JSONEq(t, expected, string(actual)) ++ }) ++} ++ + func TestCoverageReportReset(t *testing.T) { + + t.Parallel() +@@ -1790,43 +1901,114 @@ func TestCoverageReportLCOVFormat(t *testing.T) { + } + `) + +- coverageReport := NewCoverageReport() +- scriptlocation := common.ScriptLocation{} +- coverageReport.ExcludeLocation(scriptlocation) +- +- runtimeInterface := &testRuntimeInterface{ +- getCode: func(location Location) (bytes []byte, err error) { +- switch location { +- case common.StringLocation("IntegerTraits"): +- return integerTraits, nil +- default: +- return nil, fmt.Errorf("unknown import location: %s", location) +- } +- }, +- } +- +- runtime := newTestInterpreterRuntime() +- runtime.defaultConfig.CoverageReport = coverageReport +- +- value, err := runtime.ExecuteScript( +- Script{ +- Source: script, +- }, +- Context{ +- Interface: runtimeInterface, +- Location: scriptlocation, +- CoverageReport: coverageReport, +- }, +- ) +- require.NoError(t, err) ++ t.Run("without location mappings", func(t *testing.T) { ++ coverageReport := NewCoverageReport() ++ scriptlocation := common.ScriptLocation{} ++ coverageReport.ExcludeLocation(scriptlocation) ++ ++ runtimeInterface := &testRuntimeInterface{ ++ getCode: func(location Location) (bytes []byte, err error) { ++ switch location { ++ case common.StringLocation("IntegerTraits"): ++ return integerTraits, nil ++ default: ++ return nil, fmt.Errorf("unknown import location: %s", location) ++ } ++ }, ++ } ++ ++ runtime := newTestInterpreterRuntime() ++ runtime.defaultConfig.CoverageReport = coverageReport ++ ++ value, err := runtime.ExecuteScript( ++ Script{ ++ Source: script, ++ }, ++ Context{ ++ Interface: runtimeInterface, ++ Location: scriptlocation, ++ CoverageReport: coverageReport, ++ }, ++ ) ++ require.NoError(t, err) ++ ++ assert.Equal(t, cadence.NewInt(42), value) ++ ++ actual, err := coverageReport.MarshalLCOV() ++ require.NoError(t, err) ++ ++ expected := `TN: ++SF:S.IntegerTraits ++DA:9,1 ++DA:13,10 ++DA:14,1 ++DA:15,9 ++DA:16,1 ++DA:17,8 ++DA:18,1 ++DA:19,7 ++DA:20,1 ++DA:21,6 ++DA:22,1 ++DA:25,5 ++DA:26,4 ++DA:29,1 ++LF:14 ++LH:14 ++end_of_record ++` + +- assert.Equal(t, cadence.NewInt(42), value) ++ require.Equal(t, expected, string(actual)) + +- actual, err := coverageReport.MarshalLCOV() +- require.NoError(t, err) ++ assert.Equal( ++ t, ++ "Coverage: 100.0% of statements", ++ coverageReport.String(), ++ ) ++ }) + +- expected := `TN: +-SF:S.IntegerTraits ++ t.Run("with location mappings", func(t *testing.T) { ++ locationMappings := map[string]string{ ++ "IntegerTraits": "cadence/contracts/IntegerTraits.cdc", ++ } ++ coverageReport := NewCoverageReport() ++ coverageReport.WithLocationMappings(locationMappings) ++ scriptlocation := common.ScriptLocation{} ++ coverageReport.ExcludeLocation(scriptlocation) ++ ++ runtimeInterface := &testRuntimeInterface{ ++ getCode: func(location Location) (bytes []byte, err error) { ++ switch location { ++ case common.StringLocation("IntegerTraits"): ++ return integerTraits, nil ++ default: ++ return nil, fmt.Errorf("unknown import location: %s", location) ++ } ++ }, ++ } ++ ++ runtime := newTestInterpreterRuntime() ++ runtime.defaultConfig.CoverageReport = coverageReport ++ ++ value, err := runtime.ExecuteScript( ++ Script{ ++ Source: script, ++ }, ++ Context{ ++ Interface: runtimeInterface, ++ Location: scriptlocation, ++ CoverageReport: coverageReport, ++ }, ++ ) ++ require.NoError(t, err) ++ ++ assert.Equal(t, cadence.NewInt(42), value) ++ ++ actual, err := coverageReport.MarshalLCOV() ++ require.NoError(t, err) ++ ++ expected := `TN: ++SF:cadence/contracts/IntegerTraits.cdc + DA:9,1 + DA:13,10 + DA:14,1 +@@ -1845,11 +2027,13 @@ LF:14 + LH:14 + end_of_record + ` +- require.Equal(t, expected, string(actual)) ++ require.Equal(t, expected, string(actual)) ++ ++ assert.Equal( ++ t, ++ "Coverage: 100.0% of statements", ++ coverageReport.String(), ++ ) ++ }) + +- assert.Equal( +- t, +- "Coverage: 100.0% of statements", +- coverageReport.String(), +- ) + } +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+3RQWrDMBCFYa1zirmAbY1dqauueoXug2OLNFBbYMs5fxVvUgJpNgml5P82M2gE ++GvHK3XL46rdhPFbmUWz26txas8u69upqVeebpvHGqnrrjbiHbfTDMqd2EjFTjOm3e7fm/1R5zj+F ++OW27OAzt2Jfz5/3euJW/6jn/2jc5/xevasTeb4Xrnjz/rpc1+F3oN/sop1bKalrGdBhCJUXu5CMf ++vsdjmNp9kKKLefimUpxuxCWJ1nbe/PU/AAAAAAAAAAAAAAAAgGf0DeeYFq8AKAAA +diff --git 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-002111/tests/test.sh b/tasks/format-code-task-002111/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6d45b3fd19d9ade09f6abb47a1226f9cb061cf51 --- /dev/null +++ b/tasks/format-code-task-002111/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' +runtime/coverage_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-002111/tests/test_command.sh b/tasks/format-code-task-002111/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002111/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002120/environment/Dockerfile b/tasks/format-code-task-002120/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9b23ac5c79e3287127ccdaea285d8b9a2565a110 --- /dev/null +++ b/tasks/format-code-task-002120/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2eeb4bcbcaebea33b7a31afc498c5d8753f5c330872e4c1d5ad532c6e2f25459 diff --git a/tasks/format-code-task-002120/environment/setup/files/blocklist b/tasks/format-code-task-002120/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002120/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002120/environment/setup/setup.sh b/tasks/format-code-task-002120/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002120/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002120/tests/test.patch b/tasks/format-code-task-002120/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..3d25966518fc17b86e81ddb783853bb98093bad4 --- /dev/null +++ b/tasks/format-code-task-002120/tests/test.patch @@ -0,0 +1,575 @@ +diff --git a/exporter/splunkhecexporter/client_test.go b/exporter/splunkhecexporter/client_test.go +index 25d9be1e29..7e699ce5d8 100644 +--- a/exporter/splunkhecexporter/client_test.go ++++ b/exporter/splunkhecexporter/client_test.go +@@ -14,8 +14,10 @@ + package splunkhecexporter + + import ( ++ "bytes" + "compress/gzip" + "context" ++ "encoding/json" + "errors" + "fmt" + "io/ioutil" +@@ -23,6 +25,7 @@ import ( + "net" + "net/http" + "net/url" ++ "strings" + "sync" + "testing" + "time" +@@ -720,3 +723,291 @@ func TestSubLogs(t *testing.T) { + // The name of the sole log record should be 1_1_2. + assert.Equal(t, "1_1_2", got.ResourceLogs().At(0).InstrumentationLibraryLogs().At(0).Logs().At(0).Name()) + } ++ ++ ++ ++func captureSplunkEvents(t *testing.T, c *client, logs pdata.Logs) []*splunk.Event { ++ t.Helper() ++ var captured []byte ++ send := func(_ context.Context, buf *bytes.Buffer) error { ++ captured = append(captured, buf.Bytes()...) ++ return nil ++ } ++ err := c.pushLogDataInBatches(context.Background(), logs, send) ++ require.NoError(t, err) ++ ++ events := []*splunk.Event{} ++ for _, part := range strings.Split(string(captured), "\r\n\r\n") { ++ part = strings.TrimSpace(part) ++ if part == "" { ++ continue ++ } ++ dec := json.NewDecoder(strings.NewReader(part)) ++ for { ++ var ev splunk.Event ++ if err := dec.Decode(&ev); err != nil { ++ break ++ } ++ events = append(events, &ev) ++ } ++ } ++ return events ++} ++ ++func newResourceLogsWithAttrs(resourceAttrs map[string]interface{}, logAttrs map[string]interface{}) pdata.Logs { ++ logs := pdata.NewLogs() ++ logs.ResourceLogs().Resize(1) ++ rl := logs.ResourceLogs().At(0) ++ for k, v := range resourceAttrs { ++ switch val := v.(type) { ++ case string: ++ rl.Resource().Attributes().InsertString(k, val) ++ case int: ++ rl.Resource().Attributes().InsertInt(k, int64(val)) ++ case float64: ++ rl.Resource().Attributes().InsertDouble(k, val) ++ case bool: ++ rl.Resource().Attributes().InsertBool(k, val) ++ } ++ } ++ rl.InstrumentationLibraryLogs().Resize(1) ++ ill := rl.InstrumentationLibraryLogs().At(0) ++ logRecord := pdata.NewLogRecord() ++ logRecord.Body().SetStringVal("mylog") ++ logRecord.SetTimestamp(pdata.Timestamp(123)) ++ for k, v := range logAttrs { ++ switch val := v.(type) { ++ case string: ++ logRecord.Attributes().InsertString(k, val) ++ } ++ } ++ ill.Logs().Append(logRecord) ++ return logs ++} ++ ++func newTestClient(cfg *Config) *client { ++ return &client{ ++ zippers: sync.Pool{New: func() interface{} { ++ return gzip.NewWriter(nil) ++ }}, ++ config: cfg, ++ logger: zap.NewNop(), ++ } ++} ++ ++ ++func Test_pushLogData_ResourceAttributes_AppearInFields(t *testing.T) { ++ cfg := NewFactory().CreateDefaultConfig().(*Config) ++ cfg.Source = "default-source" ++ cfg.SourceType = "default-sourcetype" ++ c := newTestClient(cfg) ++ ++ resAttrs := map[string]interface{}{ ++ "k8spoduid": "eda0a956-99ec-49cb-a954-d733e2f881dd", ++ "k8s.pod.name": "loggen-zjklf", ++ "k8s.namespace.name": "default", ++ } ++ logs := newResourceLogsWithAttrs(resAttrs, map[string]interface{}{ ++ "stream": "stdout", ++ }) ++ ++ events := captureSplunkEvents(t, c, logs) ++ require.Len(t, events, 1) ++ ev := events[0] ++ ++ assert.Equal(t, "eda0a956-99ec-49cb-a954-d733e2f881dd", ev.Fields["k8spoduid"]) ++ assert.Equal(t, "loggen-zjklf", ev.Fields["k8s.pod.name"]) ++ assert.Equal(t, "default", ev.Fields["k8s.namespace.name"]) ++ ++ assert.Equal(t, "stdout", ev.Fields["stream"]) ++} ++ ++ ++func Test_pushLogData_ResourceHostName_SetsHost(t *testing.T) { ++ cfg := NewFactory().CreateDefaultConfig().(*Config) ++ c := newTestClient(cfg) ++ ++ logs := newResourceLogsWithAttrs( ++ map[string]interface{}{conventions.AttributeHostName: "myhost-from-resource"}, ++ map[string]interface{}{}, ++ ) ++ ++ events := captureSplunkEvents(t, c, logs) ++ require.Len(t, events, 1) ++ assert.Equal(t, "myhost-from-resource", events[0].Host) ++ assert.Equal(t, "myhost-from-resource", events[0].Fields[conventions.AttributeHostName]) ++} ++ ++ ++func Test_pushLogData_ResourceServiceName_SetsSource(t *testing.T) { ++ cfg := NewFactory().CreateDefaultConfig().(*Config) ++ cfg.Source = "config-source" ++ c := newTestClient(cfg) ++ ++ logs := newResourceLogsWithAttrs( ++ map[string]interface{}{conventions.AttributeServiceName: "service-from-resource"}, ++ map[string]interface{}{}, ++ ) ++ ++ events := captureSplunkEvents(t, c, logs) ++ require.Len(t, events, 1) ++ assert.Equal(t, "service-from-resource", events[0].Source) ++ assert.Equal(t, "service-from-resource", events[0].Fields[conventions.AttributeServiceName]) ++} ++ ++ ++func Test_pushLogData_ResourceSourcetype_SetsSourceType(t *testing.T) { ++ cfg := NewFactory().CreateDefaultConfig().(*Config) ++ cfg.SourceType = "config-sourcetype" ++ c := newTestClient(cfg) ++ ++ logs := newResourceLogsWithAttrs( ++ map[string]interface{}{splunk.SourcetypeLabel: "sourcetype-from-resource"}, ++ map[string]interface{}{}, ++ ) ++ ++ events := captureSplunkEvents(t, c, logs) ++ require.Len(t, events, 1) ++ assert.Equal(t, "sourcetype-from-resource", events[0].SourceType) ++} ++ ++ ++func Test_pushLogData_ResourceIndex_SetsIndex(t *testing.T) { ++ cfg := NewFactory().CreateDefaultConfig().(*Config) ++ cfg.Index = "config-index" ++ c := newTestClient(cfg) ++ ++ logs := newResourceLogsWithAttrs( ++ map[string]interface{}{splunk.IndexLabel: "index-from-resource"}, ++ map[string]interface{}{}, ++ ) ++ ++ events := captureSplunkEvents(t, c, logs) ++ require.Len(t, events, 1) ++ assert.Equal(t, "index-from-resource", events[0].Index) ++} ++ ++ ++func Test_pushLogData_ResourceSourcetypeAndIndex_NotInFields(t *testing.T) { ++ cfg := NewFactory().CreateDefaultConfig().(*Config) ++ c := newTestClient(cfg) ++ ++ logs := newResourceLogsWithAttrs( ++ map[string]interface{}{ ++ splunk.SourcetypeLabel: "res-sourcetype", ++ splunk.IndexLabel: "res-index", ++ }, ++ map[string]interface{}{}, ++ ) ++ ++ events := captureSplunkEvents(t, c, logs) ++ require.Len(t, events, 1) ++ ev := events[0] ++ assert.Equal(t, "res-sourcetype", ev.SourceType) ++ assert.Equal(t, "res-index", ev.Index) ++ _, hasSourcetypeField := ev.Fields[splunk.SourcetypeLabel] ++ assert.False(t, hasSourcetypeField, "splunk.sourcetype label must not appear inside Fields map") ++ _, hasIndexField := ev.Fields[splunk.IndexLabel] ++ assert.False(t, hasIndexField, "splunk.index label must not appear inside Fields map") ++} ++ ++ ++func Test_pushLogData_LogRecordHostName_OverridesResource(t *testing.T) { ++ cfg := NewFactory().CreateDefaultConfig().(*Config) ++ c := newTestClient(cfg) ++ ++ logs := newResourceLogsWithAttrs( ++ map[string]interface{}{conventions.AttributeHostName: "res-host"}, ++ map[string]interface{}{conventions.AttributeHostName: "log-host"}, ++ ) ++ ++ events := captureSplunkEvents(t, c, logs) ++ require.Len(t, events, 1) ++ assert.Equal(t, "log-host", events[0].Host) ++ assert.Equal(t, "log-host", events[0].Fields[conventions.AttributeHostName]) ++} ++ ++ ++func Test_pushLogData_LogRecordAttributes_StillWork(t *testing.T) { ++ cfg := NewFactory().CreateDefaultConfig().(*Config) ++ c := newTestClient(cfg) ++ ++ logs := newResourceLogsWithAttrs( ++ map[string]interface{}{}, ++ map[string]interface{}{ ++ "run_id": "0", ++ "stream": "stdout", ++ "k8s.container.name": "loggen", ++ }, ++ ) ++ ++ events := captureSplunkEvents(t, c, logs) ++ require.Len(t, events, 1) ++ ev := events[0] ++ assert.Equal(t, "0", ev.Fields["run_id"]) ++ assert.Equal(t, "stdout", ev.Fields["stream"]) ++ assert.Equal(t, "loggen", ev.Fields["k8s.container.name"]) ++} ++ ++ ++func Test_pushLogData_NoHost_DefaultsToUnknown(t *testing.T) { ++ cfg := NewFactory().CreateDefaultConfig().(*Config) ++ cfg.Source = "default-source" ++ cfg.SourceType = "default-sourcetype" ++ c := newTestClient(cfg) ++ ++ logs := newResourceLogsWithAttrs( ++ map[string]interface{}{"k8spoduid": "abc"}, ++ map[string]interface{}{}, ++ ) ++ ++ events := captureSplunkEvents(t, c, logs) ++ require.Len(t, events, 1) ++ ev := events[0] ++ assert.Equal(t, "unknown", ev.Host) ++ assert.Equal(t, "default-source", ev.Source) ++ assert.Equal(t, "default-sourcetype", ev.SourceType) ++ assert.Equal(t, "abc", ev.Fields["k8spoduid"]) ++} ++ ++ ++func Test_pushLogData_IssueReproScenario(t *testing.T) { ++ cfg := NewFactory().CreateDefaultConfig().(*Config) ++ c := newTestClient(cfg) ++ ++ resAttrs := map[string]interface{}{ ++ "k8spoduid": "eda0a956-99ec-49cb-a954-d733e2f881dd", ++ "k8s.pod.annotations.splunk.com/index": "test", ++ "k8s.pod.name": "loggen-zjklf", ++ "k8s.namespace.name": "default", ++ "k8s.pod.startTime": "2021-03-20 00:03:32 +0000 UTC", ++ "k8s.pod.uid": "eda0a956-99ec-49cb-a954-d733e2f881dd", ++ "k8s.node.name": "ip-192-168-82-91.us-west-1.compute.internal", ++ "k8s.pod.labels.hello": "loggen", ++ "k8s.pod.labels.app": "loggen", ++ } ++ logAttrs := map[string]interface{}{ ++ "k8s.pod.uid": "eda0a956-99ec-49cb-a954-d733e2f881dd", ++ "run_id": "0", ++ "stream": "stdout", ++ "k8s.container.name": "loggen", ++ "k8s.namespace.name": "default", ++ "k8s.pod.name": "loggen-zjklf", ++ } ++ logs := newResourceLogsWithAttrs(resAttrs, logAttrs) ++ ++ events := captureSplunkEvents(t, c, logs) ++ require.Len(t, events, 1) ++ ev := events[0] ++ ++ assert.Equal(t, "ip-192-168-82-91.us-west-1.compute.internal", ev.Fields["k8s.node.name"]) ++ assert.Equal(t, "loggen", ev.Fields["k8s.pod.labels.hello"]) ++ assert.Equal(t, "loggen", ev.Fields["k8s.pod.labels.app"]) ++ assert.Equal(t, "test", ev.Fields["k8s.pod.annotations.splunk.com/index"]) ++ assert.Equal(t, "2021-03-20 00:03:32 +0000 UTC", ev.Fields["k8s.pod.startTime"]) ++ assert.Equal(t, "eda0a956-99ec-49cb-a954-d733e2f881dd", ev.Fields["k8spoduid"]) ++ ++ assert.Equal(t, "0", ev.Fields["run_id"]) ++ assert.Equal(t, "stdout", ev.Fields["stream"]) ++ assert.Equal(t, "loggen", ev.Fields["k8s.container.name"]) ++} +diff --git a/exporter/splunkhecexporter/logdata_to_splunk_test.go b/exporter/splunkhecexporter/logdata_to_splunk_test.go +index 640cf23ee6..77c9b194b4 100644 +--- a/exporter/splunkhecexporter/logdata_to_splunk_test.go ++++ b/exporter/splunkhecexporter/logdata_to_splunk_test.go +@@ -15,9 +15,16 @@ + package splunkhecexporter + + import ( ++ "bytes" ++ "compress/gzip" ++ "context" ++ "encoding/json" ++ "strings" ++ "sync" + "testing" + + "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/consumer/pdata" + "go.opentelemetry.io/collector/translator/conventions" + "go.uber.org/zap" +@@ -25,8 +32,46 @@ import ( + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk" + ) + ++ ++ ++func runLogRecordThroughClient(t *testing.T, lr pdata.LogRecord, cfg *Config) *splunk.Event { ++ t.Helper() ++ c := &client{ ++ zippers: sync.Pool{New: func() interface{} { ++ return gzip.NewWriter(nil) ++ }}, ++ config: cfg, ++ logger: zap.NewNop(), ++ } ++ ++ logs := pdata.NewLogs() ++ logs.ResourceLogs().Resize(1) ++ rl := logs.ResourceLogs().At(0) ++ rl.InstrumentationLibraryLogs().Resize(1) ++ rl.InstrumentationLibraryLogs().At(0).Logs().Append(lr) ++ ++ var captured []byte ++ send := func(_ context.Context, buf *bytes.Buffer) error { ++ captured = append(captured, buf.Bytes()...) ++ return nil ++ } ++ err := c.pushLogDataInBatches(context.Background(), logs, send) ++ require.NoError(t, err) ++ ++ for _, part := range strings.Split(string(captured), "\r\n\r\n") { ++ part = strings.TrimSpace(part) ++ if part == "" { ++ continue ++ } ++ var ev splunk.Event ++ if err := json.NewDecoder(strings.NewReader(part)).Decode(&ev); err == nil { ++ return &ev ++ } ++ } ++ return nil ++} ++ + func Test_mapLogRecordToSplunkEvent(t *testing.T) { +- logger := zap.NewNop() + ts := pdata.Timestamp(123) + + tests := []struct { +@@ -99,22 +144,6 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { + commonLogSplunkEvent("mylog", ts, map[string]interface{}{"custom": "custom"}, "unknown", "source", "sourcetype"), + }, + }, +- { +- name: "log_is_empty", +- logRecordFn: func() pdata.LogRecord { +- logRecord := pdata.NewLogRecord() +- return logRecord +- }, +- configDataFn: func() *Config { +- return &Config{ +- Source: "source", +- SourceType: "sourcetype", +- } +- }, +- wantSplunkEvents: []*splunk.Event{ +- commonLogSplunkEvent(nil, 0, map[string]interface{}{}, "unknown", "source", "sourcetype"), +- }, +- }, + { + name: "with double body", + logRecordFn: func() pdata.LogRecord { +@@ -156,7 +185,8 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { + } + }, + wantSplunkEvents: []*splunk.Event{ +- commonLogSplunkEvent(int64(42), ts, map[string]interface{}{"custom": "custom", "service.name": "myapp", "host.name": "myhost"}, "myhost", "myapp", "myapp-type"), ++ ++ commonLogSplunkEvent(float64(42), ts, map[string]interface{}{"custom": "custom", "service.name": "myapp", "host.name": "myhost"}, "myhost", "myapp", "myapp-type"), + }, + }, + { +@@ -181,103 +211,23 @@ func Test_mapLogRecordToSplunkEvent(t *testing.T) { + commonLogSplunkEvent(true, ts, map[string]interface{}{"custom": "custom", "service.name": "myapp", "host.name": "myhost"}, "myhost", "myapp", "myapp-type"), + }, + }, +- { +- name: "with map body", +- logRecordFn: func() pdata.LogRecord { +- logRecord := pdata.NewLogRecord() +- attVal := pdata.NewAttributeValueMap() +- attMap := attVal.MapVal() +- attMap.InsertDouble("23", 45) +- attMap.InsertString("foo", "bar") +- attVal.CopyTo(logRecord.Body()) +- logRecord.Attributes().InsertString(conventions.AttributeServiceName, "myapp") +- logRecord.Attributes().InsertString(splunk.SourcetypeLabel, "myapp-type") +- logRecord.Attributes().InsertString(conventions.AttributeHostName, "myhost") +- logRecord.Attributes().InsertString("custom", "custom") +- logRecord.SetTimestamp(ts) +- return logRecord +- }, +- configDataFn: func() *Config { +- return &Config{ +- Source: "source", +- SourceType: "sourcetype", +- } +- }, +- wantSplunkEvents: []*splunk.Event{ +- commonLogSplunkEvent(map[string]interface{}{"23": float64(45), "foo": "bar"}, ts, +- map[string]interface{}{"custom": "custom", "service.name": "myapp", "host.name": "myhost"}, +- "myhost", "myapp", "myapp-type"), +- }, +- }, +- { +- name: "with nil body", +- logRecordFn: func() pdata.LogRecord { +- logRecord := pdata.NewLogRecord() +- logRecord.Attributes().InsertString(conventions.AttributeServiceName, "myapp") +- logRecord.Attributes().InsertString(splunk.SourcetypeLabel, "myapp-type") +- logRecord.Attributes().InsertString(conventions.AttributeHostName, "myhost") +- logRecord.Attributes().InsertString("custom", "custom") +- logRecord.SetTimestamp(ts) +- return logRecord +- }, +- configDataFn: func() *Config { +- return &Config{ +- Source: "source", +- SourceType: "sourcetype", +- } +- }, +- wantSplunkEvents: []*splunk.Event{ +- commonLogSplunkEvent(nil, ts, map[string]interface{}{"custom": "custom", "service.name": "myapp", "host.name": "myhost"}, +- "myhost", "myapp", "myapp-type"), +- }, +- }, +- { +- name: "with array body", +- logRecordFn: func() pdata.LogRecord { +- logRecord := pdata.NewLogRecord() +- attVal := pdata.NewAttributeValueArray() +- attArray := attVal.ArrayVal() +- attArray.Append(pdata.NewAttributeValueString("foo")) +- attVal.CopyTo(logRecord.Body()) +- logRecord.Attributes().InsertString(conventions.AttributeServiceName, "myapp") +- logRecord.Attributes().InsertString(splunk.SourcetypeLabel, "myapp-type") +- logRecord.Attributes().InsertString(conventions.AttributeHostName, "myhost") +- logRecord.Attributes().InsertString("custom", "custom") +- logRecord.SetTimestamp(ts) +- return logRecord +- }, +- configDataFn: func() *Config { +- return &Config{ +- Source: "source", +- SourceType: "sourcetype", +- } +- }, +- wantSplunkEvents: []*splunk.Event{ +- commonLogSplunkEvent([]interface{}{"foo"}, ts, map[string]interface{}{"custom": "custom", "service.name": "myapp", "host.name": "myhost"}, +- "myhost", "myapp", "myapp-type"), +- }, +- }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + for _, want := range tt.wantSplunkEvents { +- got := mapLogRecordToSplunkEvent(tt.logRecordFn(), tt.configDataFn(), logger) +- assert.EqualValues(t, want, got) ++ got := runLogRecordThroughClient(t, tt.logRecordFn(), tt.configDataFn()) ++ require.NotNil(t, got) ++ assert.EqualValues(t, want.Host, got.Host) ++ assert.EqualValues(t, want.Source, got.Source) ++ assert.EqualValues(t, want.SourceType, got.SourceType) ++ assert.EqualValues(t, want.Index, got.Index) ++ assert.EqualValues(t, want.Event, got.Event) ++ assert.EqualValues(t, want.Fields, got.Fields) + } + }) + } + } + +-func makeLog(record pdata.LogRecord) pdata.Logs { +- logs := pdata.NewLogs() +- logs.ResourceLogs().Resize(1) +- rl := logs.ResourceLogs().At(0) +- rl.InstrumentationLibraryLogs().Resize(1) +- ill := rl.InstrumentationLibraryLogs().At(0) +- ill.Logs().Append(record) +- return logs +-} +- + func commonLogSplunkEvent( + event interface{}, + ts pdata.Timestamp, +@@ -296,15 +246,14 @@ func commonLogSplunkEvent( + } + } + +-func Test_emptyLogRecord(t *testing.T) { +- event := mapLogRecordToSplunkEvent(pdata.NewLogRecord(), &Config{}, zap.NewNop()) +- assert.Nil(t, event.Time) +- assert.Equal(t, event.Host, "unknown") +- assert.Zero(t, event.Source) +- assert.Zero(t, event.SourceType) +- assert.Zero(t, event.Index) +- assert.Nil(t, event.Event) +- assert.Empty(t, event.Fields) ++func makeLog(record pdata.LogRecord) pdata.Logs { ++ logs := pdata.NewLogs() ++ logs.ResourceLogs().Resize(1) ++ rl := logs.ResourceLogs().At(0) ++ rl.InstrumentationLibraryLogs().Resize(1) ++ ill := rl.InstrumentationLibraryLogs().At(0) ++ ill.Logs().Append(record) ++ return logs + } + + func Test_nanoTimestampToEpochMilliseconds(t *testing.T) { +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..6d6a5ce581 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd exporter/splunkhecexporter && go test -run 'Test_pushLogData_Resource|Test_pushLogData_LogRecord|Test_pushLogData_NoHost|Test_pushLogData_IssueRepro|Test_mapLogRecordToSplunkEvent|Test_nanoTimestampToEpochMilliseconds' ."] ++} +diff --git 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 exporter/splunkhecexporter && go test -run 'Test_pushLogData_Resource|Test_pushLogData_LogRecord|Test_pushLogData_NoHost|Test_pushLogData_IssueRepro|Test_mapLogRecordToSplunkEvent|Test_nanoTimestampToEpochMilliseconds' . ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002120/tests/test.sh b/tasks/format-code-task-002120/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f039e0b7edb981c6bad73e5dce87142572ff9a35 --- /dev/null +++ b/tasks/format-code-task-002120/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' +exporter/splunkhecexporter/client_test.go +exporter/splunkhecexporter/logdata_to_splunk_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-002120/tests/test_command.sh b/tasks/format-code-task-002120/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002120/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002127/environment/Dockerfile b/tasks/format-code-task-002127/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..69a81bd8e69dcaef28eadc5a4b27b76f27342464 --- /dev/null +++ b/tasks/format-code-task-002127/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ca910281ffcbe73ea3004a511784e1e03e76778deff70198f550a7c9b985170b diff --git a/tasks/format-code-task-002127/environment/setup/files/blocklist b/tasks/format-code-task-002127/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002127/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002127/environment/setup/setup.sh b/tasks/format-code-task-002127/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002127/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002127/tests/test.patch b/tasks/format-code-task-002127/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5d7fa9f99d464458ba0cc696e4954640720c46d6 --- /dev/null +++ b/tasks/format-code-task-002127/tests/test.patch @@ -0,0 +1,418 @@ +diff --git a/usercase-test-coderl/test_aws_xray_lambda_propagator.py b/usercase-test-coderl/test_aws_xray_lambda_propagator.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_aws_xray_lambda_propagator.py +@@ -0,0 +1,380 @@ ++ ++ ++ ++ ++ ++ ++import copy ++import importlib ++import json ++import subprocess ++import sys ++import textwrap ++import tomllib ++from pathlib import Path ++ ++from opentelemetry import trace ++from opentelemetry.context import Context ++from opentelemetry.propagators import aws as aws_propagators ++from opentelemetry.propagators.aws import AwsXRayLambdaPropagator ++from opentelemetry.propagators.textmap import default_getter ++from opentelemetry.trace import ( ++ NonRecordingSpan, ++ SpanContext, ++ TraceFlags, ++ TraceState, ++ set_span_in_context, ++) ++ ++ ++TRACE_HEADER_KEY = "X-Amzn-Trace-Id" ++ENV_KEY = "_X_AMZN_TRACE_ID" ++AWS_XRAY_PACKAGE_ROOT = ( ++ Path(__file__).resolve().parents[1] / "propagator" / "opentelemetry-propagator-aws-xray" ++) ++ ++ ++def _context_summary(context): ++ span_context = trace.get_current_span(context).get_span_context() ++ return { ++ "trace_id": span_context.trace_id, ++ "span_id": span_context.span_id, ++ "is_remote": span_context.is_remote, ++ "trace_flags": int(span_context.trace_flags), ++ "trace_state": list(span_context.trace_state.items()), ++ "is_valid": span_context.is_valid, ++ } ++ ++ ++def _valid_context(trace_id=1, span_id=2): ++ span_context = SpanContext( ++ trace_id, ++ span_id, ++ is_remote=False, ++ trace_flags=TraceFlags(0), ++ trace_state=TraceState(), ++ ) ++ return set_span_in_context(NonRecordingSpan(span_context), context=Context()) ++ ++ ++def test_extract_uses_supplied_xray_carrier(monkeypatch): ++ ++ ++ ++ monkeypatch.delenv(ENV_KEY, raising=False) ++ carrier = { ++ TRACE_HEADER_KEY: ( ++ "Root=1-00000002-aaaaaaaaaaaaaaaaaaaaaaaa;" ++ "Parent=1111111111111111;Sampled=0" ++ ) ++ } ++ ++ actual = _context_summary(AwsXRayLambdaPropagator().extract(carrier)) ++ ++ assert actual == { ++ "trace_id": 211275100038038233582783867562, ++ "span_id": 1229782938247303441, ++ "is_remote": True, ++ "trace_flags": 0, ++ "trace_state": [], ++ "is_valid": True, ++ } ++ ++ ++def test_extract_keeps_valid_current_context_without_lambda_fallback(monkeypatch): ++ ++ ++ ++ monkeypatch.setenv( ++ ENV_KEY, ++ "Root=1-00000001-d188f8fa79d48a391a778fa6;" ++ "Parent=53995c3f42cd8ad8;Sampled=1;Foo=Bar", ++ ) ++ ++ actual = _context_summary( ++ AwsXRayLambdaPropagator().extract({}, context=_valid_context()) ++ ) ++ ++ assert actual == { ++ "trace_id": 1, ++ "span_id": 2, ++ "is_remote": False, ++ "trace_flags": 0, ++ "trace_state": [], ++ "is_valid": True, ++ } ++ ++ ++def test_extract_falls_back_to_lambda_environment_for_invalid_context(monkeypatch): ++ ++ ++ ++ monkeypatch.setenv( ++ ENV_KEY, ++ "Root=1-00000001-d188f8fa79d48a391a778fa6;" ++ "Parent=53995c3f42cd8ad8;Sampled=1;Foo=Bar", ++ ) ++ ++ actual = _context_summary(AwsXRayLambdaPropagator().extract({})) ++ ++ assert actual == { ++ "trace_id": 144076119245745610175697883046, ++ "span_id": 6023947403358210776, ++ "is_remote": True, ++ "trace_flags": 1, ++ "trace_state": [], ++ "is_valid": True, ++ } ++ ++ ++def test_extract_leaves_default_context_invalid_when_no_header_exists(monkeypatch): ++ ++ ++ ++ monkeypatch.delenv(ENV_KEY, raising=False) ++ ++ actual = _context_summary(AwsXRayLambdaPropagator().extract({})) ++ ++ assert actual == { ++ "trace_id": 0, ++ "span_id": 0, ++ "is_remote": False, ++ "trace_flags": 0, ++ "trace_state": [], ++ "is_valid": False, ++ } ++ ++ ++def test_extract_leaves_context_invalid_when_environment_header_is_malformed(monkeypatch): ++ ++ ++ ++ monkeypatch.setenv( ++ ENV_KEY, ++ "Root=1-bad;Parent=53995c3f42cd8ad8;Sampled=1", ++ ) ++ ++ actual = _context_summary(AwsXRayLambdaPropagator().extract({})) ++ ++ assert actual == { ++ "trace_id": 0, ++ "span_id": 0, ++ "is_remote": False, ++ "trace_flags": 0, ++ "trace_state": [], ++ "is_valid": False, ++ } ++ ++ ++def test_extract_uses_supplied_getter_for_carrier_lookup(monkeypatch): ++ ++ ++ ++ monkeypatch.setenv( ++ ENV_KEY, ++ "Root=1-00000001-d188f8fa79d48a391a778fa6;" ++ "Parent=53995c3f42cd8ad8;Sampled=0", ++ ) ++ ++ class LowercaseGetter: ++ def get(self, carrier, key): ++ if key.lower() in carrier: ++ return [carrier[key.lower()]] ++ return [] ++ ++ carrier = { ++ "x-amzn-trace-id": ( ++ "Root=1-00000003-bbbbbbbbbbbbbbbbbbbbbbbb;" ++ "Parent=2222222222222222;Sampled=1" ++ ) ++ } ++ ++ actual = _context_summary( ++ AwsXRayLambdaPropagator().extract(carrier, getter=LowercaseGetter()) ++ ) ++ ++ assert actual == { ++ "trace_id": 295785140053253527015897414587, ++ "span_id": 2459565876494606882, ++ "is_remote": True, ++ "trace_flags": 1, ++ "trace_state": [], ++ "is_valid": True, ++ } ++ ++ ++def test_lambda_propagator_is_publicly_exported_from_aws_package(): ++ ++ ++ ++ ++ assert aws_propagators.AwsXRayLambdaPropagator is AwsXRayLambdaPropagator ++ assert AwsXRayLambdaPropagator.__name__ == "AwsXRayLambdaPropagator" ++ ++ ++def test_lambda_propagator_is_registered_as_xray_lambda_entry_point(): ++ ++ ++ ++ ++ ++ pyproject = AWS_XRAY_PACKAGE_ROOT / "pyproject.toml" ++ metadata = tomllib.loads(pyproject.read_text()) ++ entry_points = metadata["project"]["entry-points"]["opentelemetry_propagator"] ++ entry_value = entry_points["xray-lambda"] ++ ++ module_name, object_name = entry_value.split(":", 1) ++ ++ assert getattr(importlib.import_module(module_name), object_name) is AwsXRayLambdaPropagator ++ ++ ++def test_extract_accepts_documented_default_getter(monkeypatch): ++ ++ monkeypatch.delenv(ENV_KEY, raising=False) ++ ++ actual = _context_summary( ++ AwsXRayLambdaPropagator().extract({}, getter=default_getter) ++ ) ++ ++ assert actual == { ++ "trace_id": 0, ++ "span_id": 0, ++ "is_remote": False, ++ "trace_flags": 0, ++ "trace_state": [], ++ "is_valid": False, ++ } ++ ++ ++def test_extract_is_referentially_transparent_for_same_inputs(monkeypatch): ++ monkeypatch.setenv( ++ ENV_KEY, ++ "Root=1-00000001-d188f8fa79d48a391a778fa6;" ++ "Parent=53995c3f42cd8ad8;Sampled=1;Foo=Bar", ++ ) ++ carrier = {} ++ context = Context() ++ ++ first = _context_summary( ++ AwsXRayLambdaPropagator().extract( ++ carrier, context=context, getter=default_getter ++ ) ++ ) ++ second = _context_summary( ++ AwsXRayLambdaPropagator().extract( ++ carrier, context=context, getter=default_getter ++ ) ++ ) ++ ++ assert first == second ++ assert second == { ++ "trace_id": 144076119245745610175697883046, ++ "span_id": 6023947403358210776, ++ "is_remote": True, ++ "trace_flags": 1, ++ "trace_state": [], ++ "is_valid": True, ++ } ++ ++ ++def test_extract_does_not_mutate_carrier(monkeypatch): ++ monkeypatch.delenv(ENV_KEY, raising=False) ++ carrier = { ++ TRACE_HEADER_KEY: ( ++ "Root=1-00000002-aaaaaaaaaaaaaaaaaaaaaaaa;" ++ "Parent=1111111111111111;Sampled=0" ++ ), ++ "other": ["unchanged", {"nested": "value"}], ++ } ++ before = copy.deepcopy(carrier) ++ ++ actual = _context_summary(AwsXRayLambdaPropagator().extract(carrier)) ++ ++ assert carrier == before ++ assert actual == { ++ "trace_id": 211275100038038233582783867562, ++ "span_id": 1229782938247303441, ++ "is_remote": True, ++ "trace_flags": 0, ++ "trace_state": [], ++ "is_valid": True, ++ } ++ ++ ++def test_extract_matches_fresh_process_result_for_same_inputs(monkeypatch): ++ monkeypatch.setenv( ++ ENV_KEY, ++ "Root=1-00000001-d188f8fa79d48a391a778fa6;" ++ "Parent=53995c3f42cd8ad8;Sampled=1;Foo=Bar", ++ ) ++ expected = { ++ "trace_id": 144076119245745610175697883046, ++ "span_id": 6023947403358210776, ++ "is_remote": True, ++ "trace_flags": 1, ++ "trace_state": [], ++ "is_valid": True, ++ } ++ ++ in_process = _context_summary(AwsXRayLambdaPropagator().extract({})) ++ script = textwrap.dedent( ++ """ ++ import json ++ import os ++ from opentelemetry import trace ++ from opentelemetry.propagators.aws import AwsXRayLambdaPropagator ++ ++ os.environ["_X_AMZN_TRACE_ID"] = ( ++ "Root=1-00000001-d188f8fa79d48a391a778fa6;" ++ "Parent=53995c3f42cd8ad8;Sampled=1;Foo=Bar" ++ ) ++ ctx = AwsXRayLambdaPropagator().extract({}) ++ sc = trace.get_current_span(ctx).get_span_context() ++ print(json.dumps({ ++ "trace_id": sc.trace_id, ++ "span_id": sc.span_id, ++ "is_remote": sc.is_remote, ++ "trace_flags": int(sc.trace_flags), ++ "trace_state": list(sc.trace_state.items()), ++ "is_valid": sc.is_valid, ++ }, 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 == expected ++ assert fresh_process == expected ++ assert fresh_process == in_process ++ ++ ++def test_extract_preserves_specified_inputs_and_result_stability(monkeypatch): ++ ++ ++ monkeypatch.setenv( ++ ENV_KEY, ++ "Root=1-00000001-d188f8fa79d48a391a778fa6;" ++ "Parent=53995c3f42cd8ad8;Sampled=1;Foo=Bar", ++ ) ++ carrier = {} ++ before = copy.deepcopy(carrier) ++ ++ actual = _context_summary(AwsXRayLambdaPropagator().extract(carrier)) ++ repeated = _context_summary(AwsXRayLambdaPropagator().extract(carrier)) ++ ++ assert carrier == before ++ assert repeated == actual ++ assert actual == { ++ "trace_id": 144076119245745610175697883046, ++ "span_id": 6023947403358210776, ++ "is_remote": True, ++ "trace_flags": 1, ++ "trace_state": [], ++ "is_valid": 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,28 @@ ++#!/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 ++ ++VENV=/workspace/.venv-stage3 ++ ++if [ ! -x "$VENV/bin/python" ]; then ++ echo "local offline venv is missing: $VENV" >&2 ++ exit 1 ++fi ++ ++export PIP_NO_INDEX=1 ++export PIP_DISABLE_PIP_VERSION_CHECK=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++cd /workspace/repo ++exec "$VENV/bin/python" -m pytest /workspace/repo/usercase-test-coderl/test_aws_xray_lambda_propagator.py -v diff --git a/tasks/format-code-task-002127/tests/test.sh b/tasks/format-code-task-002127/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4195e88ec611bef549ef6f683b8d8e042a0c640c --- /dev/null +++ b/tasks/format-code-task-002127/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_aws_xray_lambda_propagator.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-002127/tests/test_command.sh b/tasks/format-code-task-002127/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002127/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-002129/environment/Dockerfile b/tasks/format-code-task-002129/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..484805f8fe97c78f31710038d104f50e18bf0fa7 --- /dev/null +++ b/tasks/format-code-task-002129/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d5fd7521d19e2055a8bd4d29557974e82c0921b9c3a558c1c1f54511a6a1c5e0 diff --git a/tasks/format-code-task-002129/environment/setup/files/blocklist b/tasks/format-code-task-002129/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002129/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002129/environment/setup/setup.sh b/tasks/format-code-task-002129/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002129/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002129/tests/test.patch b/tasks/format-code-task-002129/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..26ce6526fad3ea48f66dc89fc21214b265335dd3 --- /dev/null +++ b/tasks/format-code-task-002129/tests/test.patch @@ -0,0 +1,34 @@ +diff --git a/packages/eslint-plugin-lit-a11y/tests/lib/rules/no-redundant-role.js b/packages/eslint-plugin-lit-a11y/tests/lib/rules/no-redundant-role.js +index 0b3a586fb..5faa8b32e 100644 +--- a/packages/eslint-plugin-lit-a11y/tests/lib/rules/no-redundant-role.js ++++ b/packages/eslint-plugin-lit-a11y/tests/lib/rules/no-redundant-role.js +@@ -22,6 +22,8 @@ const ruleTester = new RuleTester({ + }); + ruleTester.run('no-redundant-role', rule, { + valid: [ ++ { code: 'html`
`' }, ++ { code: 'html`

foo

`' }, + { code: 'html``' }, + { code: 'html`
`' }, + { code: 'html``' }, +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+3RsW7DIBAGYM95CqZu2AYVZ+urRBhODi0GC3DUvH2ph7aq1GZJVEX9vwUEh+7E ++346r8/ZA4dQ1t9JXe6W2tfq+bnuhpBCDFP0gm14ItVcNUzeb6Is1F50Ya1KM5be6S/d3qv3Mv1Au ++BxPnWQfb5uP1elzKX8qP/Gvde/6Pg+gb1l9vhJ/98/yNZVvwI9ldWGbmQv0P7xnnniZtznwhStzS ++kuuRm0JMxLNJbimZyacHUR+9sjmao2aLNi96otxR9i4Uvvh1coF7V7gW4ry1yZ13Y5dWX8tC5Ins ++GqyuxSl6ap/z7q//AwAAAAAAAAAAAAAAAAAAAADgnrwBWqPkcwAoAAA= +diff --git 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-002129/tests/test.sh b/tasks/format-code-task-002129/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..235c588d56b8381749a9896509aceaf955211d7a --- /dev/null +++ b/tasks/format-code-task-002129/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/eslint-plugin-lit-a11y/tests/lib/rules/no-redundant-role.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-002129/tests/test_command.sh b/tasks/format-code-task-002129/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002129/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002173/environment/Dockerfile b/tasks/format-code-task-002173/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b5c044bba567e4d404c7f1317dd9660560cd07ed --- /dev/null +++ b/tasks/format-code-task-002173/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7e95ccc0471d3a34d2f9dff50c9c52216241ee45187e0c6e76861b40fe403394 diff --git a/tasks/format-code-task-002173/environment/setup/files/blocklist b/tasks/format-code-task-002173/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002173/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002173/environment/setup/setup.sh b/tasks/format-code-task-002173/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002173/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002173/tests/test.patch b/tasks/format-code-task-002173/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..943c0acf927c4f5a44d6563319185b7747c1fffb --- /dev/null +++ b/tasks/format-code-task-002173/tests/test.patch @@ -0,0 +1,64 @@ +diff --git a/x/concentrated-liquidity/swaps_test.go b/x/concentrated-liquidity/swaps_test.go +index f59e3049730..3204af9ec58 100644 +--- a/x/concentrated-liquidity/swaps_test.go ++++ b/x/concentrated-liquidity/swaps_test.go +@@ -1602,6 +1602,38 @@ func (s *KeeperTestSuite) TestComputeAndSwapOutAmtGivenIn() { + } + } + ++func (s *KeeperTestSuite) TestSwapOutAmtGivenIn_NoPositions() { ++ s.SetupTest() ++ ++ pool := s.PrepareConcentratedPool() ++ ++ ++ _, _, _, _, _, err := s.App.ConcentratedLiquidityKeeper.SwapOutAmtGivenIn( ++ s.Ctx, s.TestAccs[0], pool, ++ DefaultCoin0, DefaultCoin1.Denom, ++ sdk.ZeroDec(), sdk.ZeroDec(), ++ ) ++ ++ s.Require().Error(err) ++ s.Require().ErrorIs(err, types.NoSpotPriceWhenNoLiquidityError{PoolId: pool.GetId()}) ++} ++ ++func (s *KeeperTestSuite) TestSwapInAmtGivenOut_NoPositions() { ++ s.SetupTest() ++ ++ pool := s.PrepareConcentratedPool() ++ ++ ++ _, _, _, _, _, err := s.App.ConcentratedLiquidityKeeper.SwapInAmtGivenOut( ++ s.Ctx, s.TestAccs[0], pool, ++ DefaultCoin0, DefaultCoin1.Denom, ++ sdk.ZeroDec(), sdk.ZeroDec(), ++ ) ++ ++ s.Require().Error(err) ++ s.Require().ErrorIs(err, types.NoSpotPriceWhenNoLiquidityError{PoolId: pool.GetId()}) ++} ++ + func (s *KeeperTestSuite) TestSwapOutAmtGivenIn_TickUpdates() { + tests := make(map[string]SwapTest) + for name, test := range swapOutGivenInCases { +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+3RQUvDMBgG4J73Kz52b5uky3by4EmGoILeS9cEDazJbL9UBX+8XUEdgttlY4jv ++c8kLyUdC3mwV3dqU1vd5cipisNB6XAc/1zFLrYRaKKmLWSKknAuVkD7Zi3bEjquWKGlD4H3nDu3/ ++Udl3/2w7LuvQNJU3Wfd0vDsO9a8W+qv/YshCzuZKJySO94Tf/fP+a0Nj8StrJo+BtpGy/DWvg6+t ++57Zia9K1e47OOH7LKW2jp+nDcOza2o1tt+k+Orb5mF6qzW3ky4avXG/90pc34S50jl3w3fu+qaX/ ++HBrmd6emlPaU1iF6vpCUsmtsiEyFEN3k3J8HAAAAAAAAAAAAAAAAAAAAAHBmH5LRWKgAKAAA +diff --git 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-002173/tests/test.sh b/tasks/format-code-task-002173/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c00e5f61968a9fdef49366ce8f083bfd0dd99079 --- /dev/null +++ b/tasks/format-code-task-002173/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' +x/concentrated-liquidity/swaps_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-002173/tests/test_command.sh b/tasks/format-code-task-002173/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002173/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002174/environment/Dockerfile b/tasks/format-code-task-002174/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b96f3e8f2586bef0af6ab75f44c11d68fa1794ab --- /dev/null +++ b/tasks/format-code-task-002174/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b1f08a35ecd4423cc001e61bd218f76f8d186b1c3dfa493b12f41117e669a531 diff --git a/tasks/format-code-task-002174/environment/setup/files/blocklist b/tasks/format-code-task-002174/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002174/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002174/environment/setup/setup.sh b/tasks/format-code-task-002174/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002174/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002174/tests/test.patch b/tasks/format-code-task-002174/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b5b73c6836977770298e175699955e9402b54b5c --- /dev/null +++ b/tasks/format-code-task-002174/tests/test.patch @@ -0,0 +1,895 @@ +diff --git a/simapp/sim_test.go b/simapp/sim_test.go +index ce58c336eef..f5ddbb04900 100644 +--- a/simapp/sim_test.go ++++ b/simapp/sim_test.go +@@ -13,7 +13,7 @@ import ( + "github.com/cosmos/cosmos-sdk/store" + simulation2 "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" +- "github.com/osmosis-labs/osmosis/app" ++ "github.com/osmosis-labs/osmosis/v3/app" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + dbm "github.com/tendermint/tm-db" +diff --git a/store/tree_test.go b/store/tree_test.go +index 5b601d1af92..d8fdc1310e1 100644 +--- a/store/tree_test.go ++++ b/store/tree_test.go +@@ -12,10 +12,10 @@ import ( + + dbm "github.com/tendermint/tm-db" + +- sdk "github.com/cosmos/cosmos-sdk/types" + iavlstore "github.com/cosmos/cosmos-sdk/store/iavl" ++ sdk "github.com/cosmos/cosmos-sdk/types" + +- "github.com/osmosis-labs/osmosis/store" ++ "github.com/osmosis-labs/osmosis/v3/store" + ) + + type TreeTestSuite struct { +diff --git a/v043_temp/address/store_key_test.go b/v043_temp/address/store_key_test.go +index 974d4145b4d..3c4fdb39653 100644 +--- a/v043_temp/address/store_key_test.go ++++ b/v043_temp/address/store_key_test.go +@@ -5,7 +5,7 @@ import ( + + "github.com/stretchr/testify/suite" + +- "github.com/osmosis-labs/osmosis/v043_temp/address" ++ "github.com/osmosis-labs/osmosis/v3/v043_temp/address" + ) + + func TestStoreKeySuite(t *testing.T) { +diff --git a/x/claim/client/cli/cli_test.go b/x/claim/client/cli/cli_test.go +index 9276623376d..5184e432cf8 100644 +--- a/x/claim/client/cli/cli_test.go ++++ b/x/claim/client/cli/cli_test.go +@@ -17,11 +17,11 @@ import ( + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +- "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/app/params" +- "github.com/osmosis-labs/osmosis/x/claim/client/cli" +- "github.com/osmosis-labs/osmosis/x/claim/types" +- claimtypes "github.com/osmosis-labs/osmosis/x/claim/types" ++ "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/app/params" ++ "github.com/osmosis-labs/osmosis/v3/x/claim/types" ++ claimtypes "github.com/osmosis-labs/osmosis/v3/x/claim/types" ++ "github.com/osmosis-labs/osmosis/v3/x/claim/client/cli" + "github.com/stretchr/testify/suite" + tmcli "github.com/tendermint/tendermint/libs/cli" + dbm "github.com/tendermint/tm-db" +diff --git a/x/claim/keeper/claim_test.go b/x/claim/keeper/claim_test.go +index 7d656c6de64..9e73e4cb018 100644 +--- a/x/claim/keeper/claim_test.go ++++ b/x/claim/keeper/claim_test.go +@@ -8,7 +8,7 @@ import ( + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" +- "github.com/osmosis-labs/osmosis/x/claim/types" ++ "github.com/osmosis-labs/osmosis/v3/x/claim/types" + ) + + func (suite *KeeperTestSuite) TestHookOfUnclaimableAccount() { +diff --git a/x/claim/keeper/keeper_test.go b/x/claim/keeper/keeper_test.go +index 9e0754cc7c7..e1cdf0d55c3 100644 +--- a/x/claim/keeper/keeper_test.go ++++ b/x/claim/keeper/keeper_test.go +@@ -5,8 +5,8 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/claim/types" ++ "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/claim/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + ) +diff --git a/x/epochs/abci_test.go b/x/epochs/abci_test.go +index ef92abae669..61e66c93dc4 100644 +--- a/x/epochs/abci_test.go ++++ b/x/epochs/abci_test.go +@@ -5,9 +5,9 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- simapp "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/epochs" +- "github.com/osmosis-labs/osmosis/x/epochs/types" ++ simapp "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/epochs" ++ "github.com/osmosis-labs/osmosis/v3/x/epochs/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + ) +diff --git a/x/epochs/client/cli/cli_test.go b/x/epochs/client/cli/cli_test.go +index acc2c0d7e95..2ba46172d6a 100644 +--- a/x/epochs/client/cli/cli_test.go ++++ b/x/epochs/client/cli/cli_test.go +@@ -6,9 +6,9 @@ import ( + + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/cosmos-sdk/testutil/network" +- "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/epochs/client/cli" +- "github.com/osmosis-labs/osmosis/x/epochs/types" ++ "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/epochs/client/cli" ++ "github.com/osmosis-labs/osmosis/v3/x/epochs/types" + ) + + type IntegrationTestSuite struct { +diff --git a/x/epochs/genesis_test.go b/x/epochs/genesis_test.go +index 050b6ec21d0..94f90c017a6 100644 +--- a/x/epochs/genesis_test.go ++++ b/x/epochs/genesis_test.go +@@ -4,9 +4,9 @@ import ( + "testing" + "time" + +- simapp "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/epochs" +- "github.com/osmosis-labs/osmosis/x/epochs/types" ++ simapp "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/epochs" ++ "github.com/osmosis-labs/osmosis/v3/x/epochs/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + ) +diff --git a/x/epochs/keeper/epoch_test.go b/x/epochs/keeper/epoch_test.go +index 24e3bec55d8..c649f056bf4 100644 +--- a/x/epochs/keeper/epoch_test.go ++++ b/x/epochs/keeper/epoch_test.go +@@ -3,7 +3,7 @@ package keeper_test + import ( + "time" + +- "github.com/osmosis-labs/osmosis/x/epochs/types" ++ "github.com/osmosis-labs/osmosis/v3/x/epochs/types" + ) + + func (suite *KeeperTestSuite) TestEpochLifeCycle() { +diff --git a/x/epochs/keeper/grpc_query_test.go b/x/epochs/keeper/grpc_query_test.go +index ea63545ba1a..d40fccde289 100644 +--- a/x/epochs/keeper/grpc_query_test.go ++++ b/x/epochs/keeper/grpc_query_test.go +@@ -4,7 +4,7 @@ import ( + gocontext "context" + "time" + +- "github.com/osmosis-labs/osmosis/x/epochs/types" ++ "github.com/osmosis-labs/osmosis/v3/x/epochs/types" + ) + + func (suite *KeeperTestSuite) TestQueryEpochInfos() { +diff --git a/x/epochs/keeper/keeper_test.go b/x/epochs/keeper/keeper_test.go +index 8078200a28a..9d77e53bc14 100644 +--- a/x/epochs/keeper/keeper_test.go ++++ b/x/epochs/keeper/keeper_test.go +@@ -5,8 +5,8 @@ import ( + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/epochs/types" ++ "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/epochs/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + ) +diff --git a/x/gamm/client/cli/cli_test.go b/x/gamm/client/cli/cli_test.go +index 974532e24b3..2bedac1dbba 100644 +--- a/x/gamm/client/cli/cli_test.go ++++ b/x/gamm/client/cli/cli_test.go +@@ -15,10 +15,10 @@ import ( + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" +- "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/gamm/client/cli" +- gammtestutil "github.com/osmosis-labs/osmosis/x/gamm/client/testutil" +- "github.com/osmosis-labs/osmosis/x/gamm/types" ++ "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/gamm/client/cli" ++ gammtestutil "github.com/osmosis-labs/osmosis/v3/x/gamm/client/testutil" ++ "github.com/osmosis-labs/osmosis/v3/x/gamm/types" + + tmcli "github.com/tendermint/tendermint/libs/cli" + ) +diff --git a/x/gamm/client/testutil/test_helpers.go b/x/gamm/client/testutil/test_helpers.go +index a11828acca3..c38b63d1af7 100644 +--- a/x/gamm/client/testutil/test_helpers.go ++++ b/x/gamm/client/testutil/test_helpers.go +@@ -9,7 +9,7 @@ import ( + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" +- gammcli "github.com/osmosis-labs/osmosis/x/gamm/client/cli" ++ gammcli "github.com/osmosis-labs/osmosis/v3/x/gamm/client/cli" + ) + + // commonArgs is args for CLI test commands +diff --git a/x/gamm/genesis_test.go b/x/gamm/genesis_test.go +index eac860593ee..11338f348f7 100644 +--- a/x/gamm/genesis_test.go ++++ b/x/gamm/genesis_test.go +@@ -5,9 +5,9 @@ import ( + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +- simapp "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/gamm" +- "github.com/osmosis-labs/osmosis/x/gamm/types" ++ simapp "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/gamm" ++ "github.com/osmosis-labs/osmosis/v3/x/gamm/types" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" +diff --git a/x/gamm/keeper/grpc_query_test.go b/x/gamm/keeper/grpc_query_test.go +index 23720a96be7..a90de8c5e77 100644 +--- a/x/gamm/keeper/grpc_query_test.go ++++ b/x/gamm/keeper/grpc_query_test.go +@@ -7,7 +7,7 @@ import ( + + "github.com/cosmos/cosmos-sdk/types/query" + +- "github.com/osmosis-labs/osmosis/x/gamm/types" ++ "github.com/osmosis-labs/osmosis/v3/x/gamm/types" + ) + + func (suite *KeeperTestSuite) TestQueryPool() { +diff --git a/x/gamm/keeper/keeper_test.go b/x/gamm/keeper/keeper_test.go +index 087382cda4b..6d647af0eff 100644 +--- a/x/gamm/keeper/keeper_test.go ++++ b/x/gamm/keeper/keeper_test.go +@@ -11,9 +11,9 @@ import ( + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + +- "github.com/osmosis-labs/osmosis/app" ++ "github.com/osmosis-labs/osmosis/v3/app" + +- "github.com/osmosis-labs/osmosis/x/gamm/types" ++ "github.com/osmosis-labs/osmosis/v3/x/gamm/types" + ) + + type KeeperTestSuite struct { +diff --git a/x/gamm/keeper/multihop_test.go b/x/gamm/keeper/multihop_test.go +index 93bee46d7d5..11841471f80 100644 +--- a/x/gamm/keeper/multihop_test.go ++++ b/x/gamm/keeper/multihop_test.go +@@ -3,7 +3,7 @@ package keeper_test + import ( + sdk "github.com/cosmos/cosmos-sdk/types" + +- "github.com/osmosis-labs/osmosis/x/gamm/types" ++ "github.com/osmosis-labs/osmosis/v3/x/gamm/types" + ) + + func (suite *KeeperTestSuite) TestSimpleMultihopSwapExactAmountIn() { +diff --git a/x/gamm/keeper/pool_service_test.go b/x/gamm/keeper/pool_service_test.go +index c5a523fa89b..e360d793f80 100644 +--- a/x/gamm/keeper/pool_service_test.go ++++ b/x/gamm/keeper/pool_service_test.go +@@ -5,7 +5,7 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/x/gamm/types" ++ "github.com/osmosis-labs/osmosis/v3/x/gamm/types" + ) + + var ( +diff --git a/x/gamm/keeper/swap_test.go b/x/gamm/keeper/swap_test.go +index aa3a4423d36..0499a2ad9f4 100644 +--- a/x/gamm/keeper/swap_test.go ++++ b/x/gamm/keeper/swap_test.go +@@ -5,7 +5,7 @@ import ( + + sdk "github.com/cosmos/cosmos-sdk/types" + +- "github.com/osmosis-labs/osmosis/x/gamm/types" ++ "github.com/osmosis-labs/osmosis/v3/x/gamm/types" + ) + + func (suite *KeeperTestSuite) TestSimpleSwapExactAmountIn() { +diff --git a/x/gamm/types/marshal_test.go b/x/gamm/types/marshal_test.go +index 87b1de781fa..d5b3c92fbec 100644 +--- a/x/gamm/types/marshal_test.go ++++ b/x/gamm/types/marshal_test.go +@@ -11,7 +11,7 @@ import ( + yaml "gopkg.in/yaml.v2" + + sdk "github.com/cosmos/cosmos-sdk/types" +- appParams "github.com/osmosis-labs/osmosis/app/params" ++ appParams "github.com/osmosis-labs/osmosis/v3/app/params" + ) + + var ymlAssetTest = []PoolAsset{ +diff --git a/x/gamm/types/msgs_test.go b/x/gamm/types/msgs_test.go +index 597bf61f36a..c075df8ab1e 100644 +--- a/x/gamm/types/msgs_test.go ++++ b/x/gamm/types/msgs_test.go +@@ -9,7 +9,7 @@ import ( + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + sdk "github.com/cosmos/cosmos-sdk/types" + +- appParams "github.com/osmosis-labs/osmosis/app/params" ++ appParams "github.com/osmosis-labs/osmosis/v3/app/params" + ) + + func TestMsgCreatePool(t *testing.T) { +diff --git a/x/incentives/abci_test.go b/x/incentives/abci_test.go +index d3aca34872e..5cf8f3771cb 100644 +--- a/x/incentives/abci_test.go ++++ b/x/incentives/abci_test.go +@@ -5,8 +5,8 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- simapp "github.com/osmosis-labs/osmosis/app" +- lockuptypes "github.com/osmosis-labs/osmosis/x/lockup/types" ++ simapp "github.com/osmosis-labs/osmosis/v3/app" ++ lockuptypes "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +diff --git a/x/incentives/client/cli/cli_test.go b/x/incentives/client/cli/cli_test.go +index 10b00dddb7d..6fb1f818c4a 100644 +--- a/x/incentives/client/cli/cli_test.go ++++ b/x/incentives/client/cli/cli_test.go +@@ -8,9 +8,9 @@ import ( + + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/cosmos-sdk/testutil/network" +- "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/incentives/client/cli" +- "github.com/osmosis-labs/osmosis/x/incentives/types" ++ "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/incentives/client/cli" ++ "github.com/osmosis-labs/osmosis/v3/x/incentives/types" + ) + + type IntegrationTestSuite struct { +diff --git a/x/incentives/genesis_test.go b/x/incentives/genesis_test.go +index fd21caef692..62b12bac34e 100644 +--- a/x/incentives/genesis_test.go ++++ b/x/incentives/genesis_test.go +@@ -5,10 +5,10 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- simapp "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/incentives" +- "github.com/osmosis-labs/osmosis/x/incentives/types" +- lockuptypes "github.com/osmosis-labs/osmosis/x/lockup/types" ++ simapp "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/incentives" ++ "github.com/osmosis-labs/osmosis/v3/x/incentives/types" ++ lockuptypes "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + ) +diff --git a/x/incentives/keeper/bench_test.go b/x/incentives/keeper/bench_test.go +index af65b22cdbd..fed747c44e5 100644 +--- a/x/incentives/keeper/bench_test.go ++++ b/x/incentives/keeper/bench_test.go +@@ -9,8 +9,8 @@ import ( + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +- "github.com/osmosis-labs/osmosis/app" +- lockuptypes "github.com/osmosis-labs/osmosis/x/lockup/types" ++ "github.com/osmosis-labs/osmosis/v3/app" ++ lockuptypes "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + "github.com/tendermint/tendermint/crypto/secp256k1" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + ) +diff --git a/x/incentives/keeper/gauge_test.go b/x/incentives/keeper/gauge_test.go +index b0140ba184f..07a040562e3 100644 +--- a/x/incentives/keeper/gauge_test.go ++++ b/x/incentives/keeper/gauge_test.go +@@ -4,8 +4,8 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/x/incentives/types" +- lockuptypes "github.com/osmosis-labs/osmosis/x/lockup/types" ++ "github.com/osmosis-labs/osmosis/v3/x/incentives/types" ++ lockuptypes "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + ) + + func (suite *KeeperTestSuite) TestInvalidDurationGaugeCreationValidation() { +diff --git a/x/incentives/keeper/grpc_query_test.go b/x/incentives/keeper/grpc_query_test.go +index b3f5fa7ba6e..1b7491d4f3d 100644 +--- a/x/incentives/keeper/grpc_query_test.go ++++ b/x/incentives/keeper/grpc_query_test.go +@@ -4,9 +4,9 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/x/incentives/types" +- lockuptypes "github.com/osmosis-labs/osmosis/x/lockup/types" +- pooltypes "github.com/osmosis-labs/osmosis/x/pool-incentives/types" ++ "github.com/osmosis-labs/osmosis/v3/x/incentives/types" ++ lockuptypes "github.com/osmosis-labs/osmosis/v3/x/lockup/types" ++ pooltypes "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/types" + ) + + func (suite *KeeperTestSuite) TestGRPCGaugeByID() { +diff --git a/x/incentives/keeper/keeper_test.go b/x/incentives/keeper/keeper_test.go +index f56e2d2e275..e3836f74682 100644 +--- a/x/incentives/keeper/keeper_test.go ++++ b/x/incentives/keeper/keeper_test.go +@@ -5,7 +5,7 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/app" ++ "github.com/osmosis-labs/osmosis/v3/app" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + ) +diff --git a/x/incentives/keeper/suite_test.go b/x/incentives/keeper/suite_test.go +index 66a5780f24d..2e9dcc1fd6d 100644 +--- a/x/incentives/keeper/suite_test.go ++++ b/x/incentives/keeper/suite_test.go +@@ -4,8 +4,8 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/x/incentives/types" +- lockuptypes "github.com/osmosis-labs/osmosis/x/lockup/types" ++ "github.com/osmosis-labs/osmosis/v3/x/incentives/types" ++ lockuptypes "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + ) + + func (suite *KeeperTestSuite) CreateGauge(isPerpetual bool, addr sdk.AccAddress, coins sdk.Coins, distrTo lockuptypes.QueryCondition, startTime time.Time, numEpoch uint64) (uint64, *types.Gauge) { +diff --git a/x/incentives/keeper/utils_test.go b/x/incentives/keeper/utils_test.go +index 816bd35d658..f885f70b7e5 100644 +--- a/x/incentives/keeper/utils_test.go ++++ b/x/incentives/keeper/utils_test.go +@@ -6,7 +6,7 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/x/incentives/types" ++ "github.com/osmosis-labs/osmosis/v3/x/incentives/types" + "github.com/stretchr/testify/require" + ) + +diff --git a/x/incentives/types/msgs_test.go b/x/incentives/types/msgs_test.go +index 6c7d42b68fe..93ffb0f98bb 100644 +--- a/x/incentives/types/msgs_test.go ++++ b/x/incentives/types/msgs_test.go +@@ -5,7 +5,7 @@ import ( + time "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- lockuptypes "github.com/osmosis-labs/osmosis/x/lockup/types" ++ lockuptypes "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" + ) +diff --git a/x/lockup/client/cli/cli_test.go b/x/lockup/client/cli/cli_test.go +index a03cbbc0a05..01125c3814b 100644 +--- a/x/lockup/client/cli/cli_test.go ++++ b/x/lockup/client/cli/cli_test.go +@@ -16,10 +16,10 @@ import ( + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" +- "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/lockup/client/cli" +- lockuptestutil "github.com/osmosis-labs/osmosis/x/lockup/client/testutil" +- "github.com/osmosis-labs/osmosis/x/lockup/types" ++ "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/lockup/client/cli" ++ lockuptestutil "github.com/osmosis-labs/osmosis/v3/x/lockup/client/testutil" ++ "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + ) + + type IntegrationTestSuite struct { +diff --git a/x/lockup/client/testutil/test_helpers.go b/x/lockup/client/testutil/test_helpers.go +index f4e9ac03e79..39e595a29f8 100644 +--- a/x/lockup/client/testutil/test_helpers.go ++++ b/x/lockup/client/testutil/test_helpers.go +@@ -8,7 +8,7 @@ import ( + "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" +- lockupcli "github.com/osmosis-labs/osmosis/x/lockup/client/cli" ++ lockupcli "github.com/osmosis-labs/osmosis/v3/x/lockup/client/cli" + ) + + // commonArgs is args for CLI test commands +diff --git a/x/lockup/keeper/admin_keeper_test.go b/x/lockup/keeper/admin_keeper_test.go +index 45329336b43..615f5207450 100644 +--- a/x/lockup/keeper/admin_keeper_test.go ++++ b/x/lockup/keeper/admin_keeper_test.go +@@ -4,8 +4,8 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/x/lockup/keeper" +- "github.com/osmosis-labs/osmosis/x/lockup/types" ++ "github.com/osmosis-labs/osmosis/v3/x/lockup/keeper" ++ "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + ) + + func (suite *KeeperTestSuite) TestRelock() { +diff --git a/x/lockup/keeper/grpc_query_test.go b/x/lockup/keeper/grpc_query_test.go +index 47b8cb4c241..ea536c3b37e 100644 +--- a/x/lockup/keeper/grpc_query_test.go ++++ b/x/lockup/keeper/grpc_query_test.go +@@ -4,7 +4,7 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/x/lockup/types" ++ "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + ) + + func (suite *KeeperTestSuite) LockTokens(addr sdk.AccAddress, coins sdk.Coins, duration time.Duration) { +diff --git a/x/lockup/keeper/keeper_test.go b/x/lockup/keeper/keeper_test.go +index f56e2d2e275..e3836f74682 100644 +--- a/x/lockup/keeper/keeper_test.go ++++ b/x/lockup/keeper/keeper_test.go +@@ -5,7 +5,7 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/app" ++ "github.com/osmosis-labs/osmosis/v3/app" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + ) +diff --git a/x/lockup/keeper/lock_test.go b/x/lockup/keeper/lock_test.go +index 6bec84f949b..58600cee7d9 100644 +--- a/x/lockup/keeper/lock_test.go ++++ b/x/lockup/keeper/lock_test.go +@@ -4,7 +4,7 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/x/lockup/types" ++ "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + ) + + func (suite *KeeperTestSuite) TestBeginUnlocking() { // test for all unlockable coins +diff --git a/x/lockup/keeper/utils_test.go b/x/lockup/keeper/utils_test.go +index d208bcc2d47..db64b77893d 100644 +--- a/x/lockup/keeper/utils_test.go ++++ b/x/lockup/keeper/utils_test.go +@@ -6,7 +6,7 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/x/lockup/types" ++ "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + "github.com/stretchr/testify/require" + ) + +diff --git a/x/mint/client/cli/cli_test.go b/x/mint/client/cli/cli_test.go +index 154fdaf4748..104035484e0 100644 +--- a/x/mint/client/cli/cli_test.go ++++ b/x/mint/client/cli/cli_test.go +@@ -1,4 +1,4 @@ +-// +build norace ++//go:build norace + + package cli_test + +@@ -13,8 +13,8 @@ import ( + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/cosmos-sdk/testutil/network" +- "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/mint/client/cli" ++ "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/client/cli" + ) + + type IntegrationTestSuite struct { +diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go +index e8a84b0b0bd..1eda8932b7c 100644 +--- a/x/mint/keeper/grpc_query_test.go ++++ b/x/mint/keeper/grpc_query_test.go +@@ -9,8 +9,8 @@ import ( + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" +- simapp "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/mint/types" ++ simapp "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/types" + ) + + type MintTestSuite struct { +diff --git a/x/mint/keeper/hooks_test.go b/x/mint/keeper/hooks_test.go +index d5245517df6..97760840d8c 100644 +--- a/x/mint/keeper/hooks_test.go ++++ b/x/mint/keeper/hooks_test.go +@@ -5,9 +5,9 @@ import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" +- simapp "github.com/osmosis-labs/osmosis/app" +- lockuptypes "github.com/osmosis-labs/osmosis/x/lockup/types" +- "github.com/osmosis-labs/osmosis/x/mint/types" ++ simapp "github.com/osmosis-labs/osmosis/v3/app" ++ lockuptypes "github.com/osmosis-labs/osmosis/v3/x/lockup/types" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/types" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +diff --git a/x/mint/keeper/integration_test.go b/x/mint/keeper/integration_test.go +index 6858d1e1a88..0becd89197d 100644 +--- a/x/mint/keeper/integration_test.go ++++ b/x/mint/keeper/integration_test.go +@@ -4,8 +4,8 @@ import ( + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + sdk "github.com/cosmos/cosmos-sdk/types" +- simapp "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/mint/types" ++ simapp "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/types" + ) + + // returns context and an app with updated mint keeper +diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go +index f88b2cca6ee..52f162c0376 100644 +--- a/x/mint/keeper/keeper_test.go ++++ b/x/mint/keeper/keeper_test.go +@@ -7,10 +7,10 @@ import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/distribution" +- "github.com/osmosis-labs/osmosis/app" +- lockuptypes "github.com/osmosis-labs/osmosis/x/lockup/types" +- "github.com/osmosis-labs/osmosis/x/mint/types" +- poolincentivestypes "github.com/osmosis-labs/osmosis/x/pool-incentives/types" ++ "github.com/osmosis-labs/osmosis/v3/app" ++ lockuptypes "github.com/osmosis-labs/osmosis/v3/x/lockup/types" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/types" ++ poolincentivestypes "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/types" + "github.com/stretchr/testify/suite" + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +diff --git a/x/mint/keeper/querier_test.go b/x/mint/keeper/querier_test.go +index 3bbfc0f73ad..a718fd3758d 100644 +--- a/x/mint/keeper/querier_test.go ++++ b/x/mint/keeper/querier_test.go +@@ -8,8 +8,8 @@ import ( + "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" +- keep "github.com/osmosis-labs/osmosis/x/mint/keeper" +- "github.com/osmosis-labs/osmosis/x/mint/types" ++ keep "github.com/osmosis-labs/osmosis/v3/x/mint/keeper" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/types" + + abci "github.com/tendermint/tendermint/abci/types" + ) +diff --git a/x/mint/module_test.go b/x/mint/module_test.go +index c4396bd79fc..19b1ce65578 100644 +--- a/x/mint/module_test.go ++++ b/x/mint/module_test.go +@@ -8,8 +8,8 @@ import ( + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +- simapp "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/mint/types" ++ simapp "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/types" + ) + + func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { +diff --git a/x/mint/simulation/decoder_test.go b/x/mint/simulation/decoder_test.go +index 2226bf9a531..5e4dbc5bf67 100644 +--- a/x/mint/simulation/decoder_test.go ++++ b/x/mint/simulation/decoder_test.go +@@ -8,9 +8,9 @@ import ( + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" +- simapp "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/mint/simulation" +- "github.com/osmosis-labs/osmosis/x/mint/types" ++ simapp "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/simulation" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/types" + ) + + func TestDecodeStore(t *testing.T) { +diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go +index 582f84f8504..930cfe07fab 100644 +--- a/x/mint/simulation/genesis_test.go ++++ b/x/mint/simulation/genesis_test.go +@@ -11,8 +11,8 @@ import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +- "github.com/osmosis-labs/osmosis/x/mint/simulation" +- "github.com/osmosis-labs/osmosis/x/mint/types" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/simulation" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/types" + ) + + // TestRandomizedGenState tests the normal scenario of applying RandomizedGenState. +diff --git a/x/mint/simulation/params_test.go b/x/mint/simulation/params_test.go +index a1f81d4ed7a..2a33562ce57 100644 +--- a/x/mint/simulation/params_test.go ++++ b/x/mint/simulation/params_test.go +@@ -6,7 +6,7 @@ import ( + + "github.com/stretchr/testify/require" + +- "github.com/osmosis-labs/osmosis/x/mint/simulation" ++ "github.com/osmosis-labs/osmosis/v3/x/mint/simulation" + ) + + func TestParamChanges(t *testing.T) { +diff --git a/x/pool-incentives/client/cli/cli_test.go b/x/pool-incentives/client/cli/cli_test.go +index 7a200184981..39b22c33cb1 100644 +--- a/x/pool-incentives/client/cli/cli_test.go ++++ b/x/pool-incentives/client/cli/cli_test.go +@@ -6,9 +6,9 @@ import ( + + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/cosmos-sdk/testutil/network" +- "github.com/osmosis-labs/osmosis/app" +- "github.com/osmosis-labs/osmosis/x/pool-incentives/client/cli" +- "github.com/osmosis-labs/osmosis/x/pool-incentives/types" ++ "github.com/osmosis-labs/osmosis/v3/app" ++ "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/client/cli" ++ "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/types" + ) + + type IntegrationTestSuite struct { +diff --git a/x/pool-incentives/keeper/distr_test.go b/x/pool-incentives/keeper/distr_test.go +index 0031c1c49c4..6d02048d8b0 100644 +--- a/x/pool-incentives/keeper/distr_test.go ++++ b/x/pool-incentives/keeper/distr_test.go +@@ -5,8 +5,8 @@ import ( + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/distribution" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" +- minttypes "github.com/osmosis-labs/osmosis/x/mint/types" +- "github.com/osmosis-labs/osmosis/x/pool-incentives/types" ++ minttypes "github.com/osmosis-labs/osmosis/v3/x/mint/types" ++ "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/types" + abci "github.com/tendermint/tendermint/abci/types" + ) + +diff --git a/x/pool-incentives/keeper/grpc_query_test.go b/x/pool-incentives/keeper/grpc_query_test.go +index 1507fd1e6f6..99bf8d319be 100644 +--- a/x/pool-incentives/keeper/grpc_query_test.go ++++ b/x/pool-incentives/keeper/grpc_query_test.go +@@ -4,10 +4,10 @@ import ( + "context" + "time" + +- lockuptypes "github.com/osmosis-labs/osmosis/x/lockup/types" ++ lockuptypes "github.com/osmosis-labs/osmosis/v3/x/lockup/types" + + sdk "github.com/cosmos/cosmos-sdk/types" +- "github.com/osmosis-labs/osmosis/x/pool-incentives/types" ++ "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/types" + ) + + var isPerpetual = true +diff --git a/x/pool-incentives/keeper/keeper_test.go b/x/pool-incentives/keeper/keeper_test.go +index d32789e8412..25ff91ca696 100644 +--- a/x/pool-incentives/keeper/keeper_test.go ++++ b/x/pool-incentives/keeper/keeper_test.go +@@ -12,10 +12,10 @@ import ( + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + +- "github.com/osmosis-labs/osmosis/app" ++ "github.com/osmosis-labs/osmosis/v3/app" + +- gammtypes "github.com/osmosis-labs/osmosis/x/gamm/types" +- "github.com/osmosis-labs/osmosis/x/pool-incentives/types" ++ gammtypes "github.com/osmosis-labs/osmosis/v3/x/gamm/types" ++ "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/types" + ) + + type KeeperTestSuite struct { +diff --git a/x/pool-incentives/types/genesis_test.go b/x/pool-incentives/types/genesis_test.go +index 8d38d4cc4da..85ac089be9f 100644 +--- a/x/pool-incentives/types/genesis_test.go ++++ b/x/pool-incentives/types/genesis_test.go +@@ -6,7 +6,7 @@ import ( + + sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/gogo/protobuf/proto" +- "github.com/osmosis-labs/osmosis/x/pool-incentives/types" ++ "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/types" + "github.com/stretchr/testify/require" + ) + +diff --git a/x/pool-incentives/types/gov_test.go b/x/pool-incentives/types/gov_test.go +index 15c7fdf7f02..fa7253e83af 100644 +--- a/x/pool-incentives/types/gov_test.go ++++ b/x/pool-incentives/types/gov_test.go +@@ -5,7 +5,7 @@ import ( + + sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/gogo/protobuf/proto" +- "github.com/osmosis-labs/osmosis/x/pool-incentives/types" ++ "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/types" + "github.com/stretchr/testify/require" + ) + +diff --git a/x/pool-incentives/types/incentives_test.go b/x/pool-incentives/types/incentives_test.go +index 7577bba2737..7635b504f7a 100644 +--- a/x/pool-incentives/types/incentives_test.go ++++ b/x/pool-incentives/types/incentives_test.go +@@ -6,7 +6,7 @@ import ( + + sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/gogo/protobuf/proto" +- "github.com/osmosis-labs/osmosis/x/pool-incentives/types" ++ "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/types" + "github.com/stretchr/testify/require" + ) + +diff --git a/x/pool-incentives/types/query_test.go b/x/pool-incentives/types/query_test.go +index 09546a03f1b..2decbd5a427 100644 +--- a/x/pool-incentives/types/query_test.go ++++ b/x/pool-incentives/types/query_test.go +@@ -5,7 +5,7 @@ import ( + "time" + + proto "github.com/gogo/protobuf/proto" +- "github.com/osmosis-labs/osmosis/x/pool-incentives/types" ++ "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/types" + "github.com/stretchr/testify/require" + ) + +diff --git a/x/pool-incentives/types/record_test.go b/x/pool-incentives/types/record_test.go +index 94ef5bf73f0..57a38caf13a 100644 +--- a/x/pool-incentives/types/record_test.go ++++ b/x/pool-incentives/types/record_test.go +@@ -7,7 +7,7 @@ import ( + + sdk "github.com/cosmos/cosmos-sdk/types" + +- "github.com/osmosis-labs/osmosis/x/pool-incentives/types" ++ "github.com/osmosis-labs/osmosis/v3/x/pool-incentives/types" + ) + + func TestDistrRecord(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,7 @@ ++H4sIAAAAAAAAA+3T3W6DIBgGYI+9CpYdT/Bv3sySBpW0pCJEsNnufta1qaV0PWmzLXufAxFf+gFi ++k3qUXbsS/Y5Gj8ImVVnO7cRv5/u0zNKMFew1zyKWpmVVRKR82IoWRuv4QEg0aO2+G3cr/6OS0/k7 ++Yd2q0Urxvk3s5n5z3Dj/NCuqw/nnVZmn0/kXrxmLCLvfEq775+f//ERr2dOa203ctGT+CGrRxvFa ++k/09eYsJSaiVihtDjz2nB3Hs7FiRr5xQhvK2HYS1x+CdNh2XarpK0bt94ydbIYwYTk+F0c3GXvRD ++BQ6RX2HNVXjCZbDf1+hk56XnvWBl92HEYn2yb6Z6cnflWWgdi9ifYRF583S62Y4mWO88utzZIffn ++UnIafd4LVZ+D4G+nD2LsuJO6PwVG6+7lxv79MX5xP/96E/FP/00AAAAAAAAAAAAAAAAAAAAAfq1P ++d6JDGgAoAAA= +diff --git 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-002174/tests/test.sh b/tasks/format-code-task-002174/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..75dc1dfc454054f29b437f185b2791da3f32fdf6 --- /dev/null +++ b/tasks/format-code-task-002174/tests/test.sh @@ -0,0 +1,96 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +simapp/sim_test.go +store/tree_test.go +v043_temp/address/store_key_test.go +x/claim/client/cli/cli_test.go +x/claim/keeper/claim_test.go +x/claim/keeper/keeper_test.go +x/epochs/abci_test.go +x/epochs/client/cli/cli_test.go +x/epochs/genesis_test.go +x/epochs/keeper/epoch_test.go +x/epochs/keeper/grpc_query_test.go +x/epochs/keeper/keeper_test.go +x/gamm/client/cli/cli_test.go +x/gamm/client/testutil/test_helpers.go +x/gamm/genesis_test.go +x/gamm/keeper/grpc_query_test.go +x/gamm/keeper/keeper_test.go +x/gamm/keeper/multihop_test.go +x/gamm/keeper/pool_service_test.go +x/gamm/keeper/swap_test.go +x/gamm/types/marshal_test.go +x/gamm/types/msgs_test.go +x/incentives/abci_test.go +x/incentives/client/cli/cli_test.go +x/incentives/genesis_test.go +x/incentives/keeper/bench_test.go +x/incentives/keeper/gauge_test.go +x/incentives/keeper/grpc_query_test.go +x/incentives/keeper/keeper_test.go +x/incentives/keeper/suite_test.go +x/incentives/keeper/utils_test.go +x/incentives/types/msgs_test.go +x/lockup/client/cli/cli_test.go +x/lockup/client/testutil/test_helpers.go +x/lockup/keeper/admin_keeper_test.go +x/lockup/keeper/grpc_query_test.go +x/lockup/keeper/keeper_test.go +x/lockup/keeper/lock_test.go +x/lockup/keeper/utils_test.go +x/mint/client/cli/cli_test.go +x/mint/keeper/grpc_query_test.go +x/mint/keeper/hooks_test.go +x/mint/keeper/integration_test.go +x/mint/keeper/keeper_test.go +x/mint/keeper/querier_test.go +x/mint/module_test.go +x/mint/simulation/decoder_test.go +x/mint/simulation/genesis_test.go +x/mint/simulation/params_test.go +x/pool-incentives/client/cli/cli_test.go +x/pool-incentives/keeper/distr_test.go +x/pool-incentives/keeper/grpc_query_test.go +x/pool-incentives/keeper/keeper_test.go +x/pool-incentives/types/genesis_test.go +x/pool-incentives/types/gov_test.go +x/pool-incentives/types/incentives_test.go +x/pool-incentives/types/query_test.go +x/pool-incentives/types/record_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-002174/tests/test_command.sh b/tasks/format-code-task-002174/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002174/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002175/environment/Dockerfile b/tasks/format-code-task-002175/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..c95e5f789d031a6e4ab005937a1921e6d8a4f38e --- /dev/null +++ b/tasks/format-code-task-002175/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:74b4265e4281369269e0a399f4d794b0c6f17f0219b37c6af3290eea408fb705 diff --git a/tasks/format-code-task-002175/environment/setup/files/blocklist b/tasks/format-code-task-002175/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002175/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002175/environment/setup/setup.sh b/tasks/format-code-task-002175/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002175/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002175/tests/test.patch b/tasks/format-code-task-002175/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..27da3a1c0510f28062287e3c8fe464ef6be5df18 --- /dev/null +++ b/tasks/format-code-task-002175/tests/test.patch @@ -0,0 +1,86 @@ +diff --git a/osmomath/decimal_test.go b/osmomath/decimal_test.go +index 35bb28e8b05..545947feaac 100644 +--- a/osmomath/decimal_test.go ++++ b/osmomath/decimal_test.go +@@ -1501,3 +1501,61 @@ func (s *decimalTestSuite) TestPower() { + }) + } + } ++ ++func (s *decimalTestSuite) TestQuoRoundUp_MutativeAndNonMutative() { ++ tests := []struct { ++ d1, d2, expQuoRoundUpMut osmomath.BigDec ++ }{ ++ {osmomath.NewBigDec(0), osmomath.NewBigDec(0), osmomath.NewBigDec(0)}, ++ {osmomath.NewBigDec(1), osmomath.NewBigDec(0), osmomath.NewBigDec(0)}, ++ {osmomath.NewBigDec(0), osmomath.NewBigDec(1), osmomath.NewBigDec(0)}, ++ {osmomath.NewBigDec(0), osmomath.NewBigDec(-1), osmomath.NewBigDec(0)}, ++ {osmomath.NewBigDec(-1), osmomath.NewBigDec(0), osmomath.NewBigDec(0)}, ++ ++ {osmomath.NewBigDec(1), osmomath.NewBigDec(1), osmomath.NewBigDec(1)}, ++ {osmomath.NewBigDec(-1), osmomath.NewBigDec(-1), osmomath.NewBigDec(1)}, ++ {osmomath.NewBigDec(1), osmomath.NewBigDec(-1), osmomath.NewBigDec(-1)}, ++ {osmomath.NewBigDec(-1), osmomath.NewBigDec(1), osmomath.NewBigDec(-1)}, ++ ++ { ++ osmomath.NewBigDec(3), osmomath.NewBigDec(7), osmomath.MustNewBigDecFromStr("0.428571428571428571428571428571428572"), ++ }, ++ { ++ osmomath.NewBigDec(2), osmomath.NewBigDec(4), osmomath.NewBigDecWithPrec(5, 1), ++ }, ++ ++ {osmomath.NewBigDec(100), osmomath.NewBigDec(100), osmomath.NewBigDec(1)}, ++ ++ { ++ osmomath.NewBigDecWithPrec(15, 1), osmomath.NewBigDecWithPrec(15, 1), osmomath.NewBigDec(1), ++ }, ++ { ++ osmomath.NewBigDecWithPrec(3333, 4), osmomath.NewBigDecWithPrec(333, 4), osmomath.MustNewBigDecFromStr("10.009009009009009009009009009009009010"), ++ }, ++ } ++ ++ for tcIndex, tc := range tests { ++ tc := tc ++ ++ if tc.d2.IsZero() { ++ s.Require().Panics(func() { tc.d1.QuoRoundUpMut(tc.d2) }) ++ } else { ++ ++ copy := tc.d1.Clone() ++ ++ nonMutResult := copy.QuoRoundUp(tc.d2) ++ ++ ++ s.Require().Equal(tc.expQuoRoundUpMut, nonMutResult, "exp %v, res %v, tc %d", tc.expQuoRoundUpMut.String(), tc.d1.String(), tcIndex) ++ ++ ++ s.Require().Equal(tc.d1, copy, "exp %v, res %v, tc %d", tc.expQuoRoundUpMut.String(), tc.d1.String(), tcIndex) ++ ++ ++ tc.d1.QuoRoundUpMut(tc.d2) ++ ++ ++ s.Require().True(tc.expQuoRoundUpMut.Equal(tc.d1), "exp %v, res %v, tc %d", tc.expQuoRoundUpMut.String(), tc.d1.String(), tcIndex) ++ } ++ } ++} +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+3RwYrCMBCA4Zx9ijl5a9qJRk/6KlLbogvbBtq0z28tiLKwelFE/L/LBBLIwG/3 ++/c9vuauaITWvko3W3k9z9HdOZ/VOnS4XzjmTqfr1woh/2UY3+i7mrYhpQ4j33j26/1D22j9WXdwV ++oa7zprTd8Xl/POw/xr70z9xq7L9cqRrJnrfC/768f1HKFH5flbNDkPNRkkGSIvRN3Kgkbd+IFZuG ++rg51Ho+ptVbcdq6zd68OAAAAAAAAAAAAAAAAfL0TQ16argAoAAA= +diff --git 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-002175/tests/test.sh b/tasks/format-code-task-002175/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b9bd747ee02aae46a424437c70c45290d850e99f --- /dev/null +++ b/tasks/format-code-task-002175/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' +osmomath/decimal_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-002175/tests/test_command.sh b/tasks/format-code-task-002175/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002175/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002180/environment/Dockerfile b/tasks/format-code-task-002180/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9f9f0d29a38175989788f8251a7be2442bc6bb6d --- /dev/null +++ b/tasks/format-code-task-002180/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a67fcf51e51a802b1c79f44836619b5edc1569b3cb7c69c9ea980524618dbb7c diff --git a/tasks/format-code-task-002180/environment/setup/files/blocklist b/tasks/format-code-task-002180/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002180/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002180/environment/setup/setup.sh b/tasks/format-code-task-002180/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002180/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002180/tests/test.patch b/tasks/format-code-task-002180/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..107d190d53c118161ca3a5607b7f7a2843f5a126 --- /dev/null +++ b/tasks/format-code-task-002180/tests/test.patch @@ -0,0 +1,147 @@ +diff --git a/engine/api/workflow_test.go b/engine/api/workflow_test.go +index 1a179e8117..ee4a596c7f 100644 +--- a/engine/api/workflow_test.go ++++ b/engine/api/workflow_test.go +@@ -376,6 +376,63 @@ func Test_putWorkflowHandler(t *testing.T) { + + assert.NotEmpty(t, payload["git.branch"], "git.branch should not be empty") + } ++func Test_postWorkflowHandlerWithError(t *testing.T) { ++ ++ api, db, router, end := newTestAPI(t) ++ defer end() ++ ++ ++ u, pass := assets.InsertAdminUser(api.mustDB()) ++ ++ key := sdk.RandomString(10) ++ proj := assets.InsertTestProject(t, db, api.Cache, key, key, u) ++ ++ ++ pip := sdk.Pipeline{ ++ Name: "pipeline1", ++ ProjectID: proj.ID, ++ Type: sdk.BuildPipeline, ++ } ++ test.NoError(t, pipeline.InsertPipeline(api.mustDB(), api.Cache, proj, &pip, nil)) ++ ++ ++ vars := map[string]string{ ++ "permProjectKey": proj.Key, ++ } ++ uri := router.GetRoute("POST", api.postWorkflowHandler, vars) ++ test.NotEmpty(t, uri) ++ ++ var workflow = &sdk.Workflow{ ++ Name: "Name", ++ Description: "Description", ++ WorkflowData: &sdk.WorkflowData{ ++ Node: sdk.Node{ ++ Type: sdk.NodeTypePipeline, ++ Context: &sdk.NodeContext{ ++ PipelineID: pip.ID, ++ }, ++ Triggers: []sdk.NodeTrigger{{ ++ ChildNode: sdk.Node{ ++ Type: sdk.NodeTypePipeline, ++ Context: &sdk.NodeContext{ ++ PipelineID: pip.ID, ++ DefaultPayload: map[string]interface{}{ ++ "test": "content", ++ }, ++ }, ++ }, ++ }}, ++ }, ++ }, ++ } ++ ++ req := assets.NewAuthentifiedRequest(t, u, pass, "POST", uri, &workflow) ++ ++ ++ w := httptest.NewRecorder() ++ router.Mux.ServeHTTP(w, req) ++ assert.Equal(t, 400, w.Code) ++} + + func Test_postWorkflowRollbackHandler(t *testing.T) { + // Init database +diff --git a/sdk/exportentities/workflow_test.go b/sdk/exportentities/workflow_test.go +index b9cd9ddd74..aed0f80108 100644 +--- a/sdk/exportentities/workflow_test.go ++++ b/sdk/exportentities/workflow_test.go +@@ -314,6 +314,26 @@ func TestWorkflow_GetWorkflow(t *testing.T) { + }, + }, + // root(pipeline-root) -> child(pipeline-child) ++ { ++ name: "Complexe workflow without joins with a default payload on a non root node should raise an error", ++ fields: fields{ ++ Workflow: map[string]NodeEntry{ ++ "root": NodeEntry{ ++ PipelineName: "pipeline-root", ++ }, ++ "child": NodeEntry{ ++ PipelineName: "pipeline-child", ++ DependsOn: []string{"root"}, ++ Payload: map[string]interface{}{ ++ "test": "content", ++ }, ++ OneAtATime: &True, ++ }, ++ }, ++ }, ++ wantErr: true, ++ }, ++ + { + name: "Complexe workflow unordered without joins should not raise an error", + fields: fields{ +@@ -679,6 +699,11 @@ func TestWorkflow_GetWorkflow(t *testing.T) { + return + } + ++ if tt.wantErr { ++ assert.Error(t, err) ++ return ++ } ++ + got.HookModels = nil + got.OutGoingHookModels = nil + got.Applications = nil +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,20 @@ ++H4sIAAAAAAAAA+1VbW/bNhDOZ/2Kq1rELVZJlh0764uzerGSFHDjzHbgD0thyBIts5FJRaSStM3+ +++46U7WgJ0mJFi2Eony82j8d7Ht4dT+6soGk8JezS2/pRqCN2Wy39i7j7q//7rUa9sdto7e40t+q+ ++3/brW9D6YYoqKIQMc4CtnHP5Jb+v7f9P4d7WXxIhpxFfLkMWu2Lx/Ti+Uv9mq9nc1L/d8rH+O+1G ++ewvq30/Cw/jJ6//4kTejzJuFYmFFMegmmJHYsh5DwESREzjhQiY5Gf3RByogLxijLLGyZJqKKMXs ++kVxAY8+LyaXHijSFG0DvDJwLsDlLKSM23NwA+kcyXR0Avw3LkDJQuZd4etuvEA5JjEQVrlwZnCil ++kOHyAbKTwfGhIiqdBckvkcdx4pAsOaOfCHwkYsO0n5NQElCXhYizOU2AzoFKiDkRrCaBXFMhreV5 ++TDFIBp6qvudGsbDQ7094BM68YtRZE240T9wPgjN4/wrkgjALIAol7H3B8/Xr2v7g+KBmfUZnO571 ++coq67ZdgZ2Xahf283DkVpV2FWtuGPCXKtl6fhEJc8TxWNiRbm4/DJbljOsLoypTyKEwXarEOwXO9 ++0dppNkubEOk7HusAmNlwhpTarhN9L87LdnP3RcWhKsm2/rLUba05rRQhDmWI7UegwBsCzp5bC+aa ++ERJjO4oCHFinBJwI8yMuUlUaJRQcGcGZPQr6wf4YfDgYDt6pjssxPwImR8EwAPzPMA+dmkpg7cyu ++tI6vG/Qf8VS4/WHQHQdwOgqGoA7B5O34CEanJ8FQ2066o9FkMOxBDRNbe3Vm29XW/EbJm7uXqnFZ ++qlYU/0J0rzvu/t4dBYDnYDA5Xl3hnkgswwG9hkvCYo71giLh+QfqJdyLsOYRxEWW0kiVSYlq70CY ++ZotwRiQ8pQy/FVkoKXYEXFG5gEMOex3fbTSfWQJjORRq4k3dbzR3Wu3dX19Mp3Zl9Ytnv6lt5o1X ++KvASjFPMXIzs3ZHiJYS5CVeKu1mWfrztkiVNcpTBmahOMI+wBIePdTg46HcPRx3bWfK4U9LYkHDQ ++Hz5wOJSO4JbTwV0drPRlhvFjoobJzFE9DptuL20ZvplVCdRS97FumHJ39QJ0KbRFVfR2he8LlSFf +++bjQWF6IOGr4uJ4qsVZ2ZzwPC6amDOAITbAeepbNKTb8w1fWPs4ldgovmOz44OCIBXusPvyqUyc8 ++P5+n/OoIX2FK8gkWI8hzdXidFS/MqGcNg7HfefKb9U1Ma5LpIdn8VwQiPvfItcolYZJKSoQmamgi ++vC7Raca3VKRyNYafKCHgkAuow3vY3l6ZGmvTZgyTaMHB7vb7MA5G45F+ukHPVjvXOPXrFkkF2fiV ++Pgfdt/2gB09vL97RfM/hvlK903i2CeirEfdff9oNDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAx+ ++MvwN6hXfiQAoAAA= +diff --git 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-002180/tests/test.sh b/tasks/format-code-task-002180/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c5a079af964f662f00b1b1b31971564349a2a532 --- /dev/null +++ b/tasks/format-code-task-002180/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' +engine/api/workflow_test.go +sdk/exportentities/workflow_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-002180/tests/test_command.sh b/tasks/format-code-task-002180/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002180/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002181/environment/Dockerfile b/tasks/format-code-task-002181/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1d1d9b8c153f69694a80816059e9d508b4878481 --- /dev/null +++ b/tasks/format-code-task-002181/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:384efa1a0f453c615154d5f6b93bee0645dad7ba4388e0ade5b6ff0fa82522e2 diff --git a/tasks/format-code-task-002181/environment/setup/files/blocklist b/tasks/format-code-task-002181/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002181/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002181/environment/setup/setup.sh b/tasks/format-code-task-002181/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002181/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002181/tests/test.patch b/tasks/format-code-task-002181/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4f4550c03c1d936567c9d4efa5b5842c5766a322 --- /dev/null +++ b/tasks/format-code-task-002181/tests/test.patch @@ -0,0 +1,255 @@ +diff --git a/go-controller/pkg/ovn/namespace_test.go b/go-controller/pkg/ovn/namespace_test.go +index b480ae8b5bb..63b7189647a 100644 +--- a/go-controller/pkg/ovn/namespace_test.go ++++ b/go-controller/pkg/ovn/namespace_test.go +@@ -52,7 +52,7 @@ func (n namespace) addCmds(fexec *ovntest.FakeExec, namespaces ...v1.Namespace) + for _, n := range namespaces { + fexec.AddFakeCmd(&ovntest.ExpectedCmd{ + Cmd: "ovn-nbctl --timeout=15 --data=bare --no-heading --columns=_uuid find address_set name=" + hashedAddressSet(n.Name), +- Output: fmt.Sprintf("name=%s\n", n.Name), ++ Output: fakeUUID, + }) + fexec.AddFakeCmdsNoOutputNoError([]string{ + fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedAddressSet(n.Name)), +@@ -66,16 +66,28 @@ func (n namespace) delCmds(fexec *ovntest.FakeExec, namespace v1.Namespace) { + }) + } + +-func (n namespace) addPodCmds(fexec *ovntest.FakeExec, tP pod, namespace v1.Namespace) { +- fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf(`ovn-nbctl --timeout=15 set address_set %s addresses="%s"`, hashedAddressSet(namespace.Name), tP.podIP), +- }) ++func (n namespace) addPodCmds(fexec *ovntest.FakeExec, tP pod, namespace v1.Namespace, set bool) { ++ if set { ++ fexec.AddFakeCmdsNoOutputNoError([]string{ ++ fmt.Sprintf(`ovn-nbctl --timeout=15 set address_set %s addresses="%s"`, hashedAddressSet(namespace.Name), tP.podIP), ++ }) ++ } else { ++ fexec.AddFakeCmdsNoOutputNoError([]string{ ++ fmt.Sprintf(`ovn-nbctl --timeout=15 add address_set %s addresses %s`, hashedAddressSet(namespace.Name), tP.podIP), ++ }) ++ } + } + +-func (n namespace) delPodCmds(fexec *ovntest.FakeExec, tP pod, namespace v1.Namespace) { +- fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedAddressSet(namespace.Name)), +- }) ++func (n namespace) delPodCmds(fexec *ovntest.FakeExec, tP pod, namespace v1.Namespace, clear bool) { ++ if clear { ++ fexec.AddFakeCmdsNoOutputNoError([]string{ ++ fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedAddressSet(namespace.Name)), ++ }) ++ } else { ++ fexec.AddFakeCmdsNoOutputNoError([]string{ ++ fmt.Sprintf("ovn-nbctl --timeout=15 remove address_set %s addresses %s", hashedAddressSet(namespace.Name), tP.podIP), ++ }) ++ } + } + + func (n namespace) addCmdsWithPods(fexec *ovntest.FakeExec, tP pod, namespace v1.Namespace) { +@@ -83,7 +95,7 @@ func (n namespace) addCmdsWithPods(fexec *ovntest.FakeExec, tP pod, namespace v1 + Cmd: "ovn-nbctl --timeout=15 --data=bare --no-heading --columns=_uuid find address_set name=" + hashedAddressSet(namespace.Name), + Output: fmt.Sprintf("name=%s\n", namespace.Name), + }) +- n.addPodCmds(fexec, tP, namespace) ++ n.addPodCmds(fexec, tP, namespace, true) + } + + var _ = Describe("OVN Namespace Operations", func() { +diff --git a/go-controller/pkg/ovn/pods_test.go b/go-controller/pkg/ovn/pods_test.go +index 4cae67ff70a..9ece212b9e2 100644 +--- a/go-controller/pkg/ovn/pods_test.go ++++ b/go-controller/pkg/ovn/pods_test.go +@@ -144,7 +144,7 @@ func (p pod) delCmds(fexec *ovntest.FakeExec) { + } + func (p pod) delFromNamespaceCmds(fexec *ovntest.FakeExec, pod pod, isMulticastEnabled bool) { + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedAddressSet(pod.namespace)), ++ fmt.Sprintf("ovn-nbctl --timeout=15 remove address_set %s addresses %s", hashedAddressSet(pod.namespace), pod.podIP), + }) + fexec.AddFakeCmd(&ovntest.ExpectedCmd{ + Cmd: fmt.Sprintf("ovn-nbctl --timeout=15 --if-exists get logical_switch_port %s _uuid", pod.portName), +diff --git a/go-controller/pkg/ovn/policy_old_test.go b/go-controller/pkg/ovn/policy_old_test.go +index ff3165eab2e..f969d539f68 100644 +--- a/go-controller/pkg/ovn/policy_old_test.go ++++ b/go-controller/pkg/ovn/policy_old_test.go +@@ -150,14 +150,14 @@ func (n networkPolicyOld) addLocalPodSelectorCmds(fexec *ovntest.FakeExec, pod p + n.addNamespaceSelectorCmdsForGress(fexec, networkPolicy, "ingress", i) + hashedOVNName := hashedAddressSet(fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "ingress", i)) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 set address_set %s addresses=\"%s\"", hashedOVNName, pod.podIP), ++ fmt.Sprintf("ovn-nbctl --timeout=15 add address_set %s addresses %s", hashedOVNName, pod.podIP), + }) + } + for i := range networkPolicy.Spec.Egress { + n.addNamespaceSelectorCmdsForGress(fexec, networkPolicy, "egress", i) + hashedOVNName := hashedAddressSet(fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "egress", i)) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 set address_set %s addresses=\"%s\"", hashedOVNName, pod.podIP), ++ fmt.Sprintf("ovn-nbctl --timeout=15 add address_set %s addresses %s", hashedOVNName, pod.podIP), + }) + } + for i := range networkPolicy.Spec.Ingress { +@@ -187,14 +187,14 @@ func (n networkPolicyOld) addPodAndNamespaceSelectorCmds(fexec *ovntest.FakeExec + hashedOVNName := hashedAddressSet(fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "ingress", i)) + n.addNamespaceSelectorCmdsForGress(fexec, networkPolicy, "ingress", i) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 set address_set %s addresses=\"%s\"", hashedOVNName, pod.podIP), ++ fmt.Sprintf("ovn-nbctl --timeout=15 add address_set %s addresses %s", hashedOVNName, pod.podIP), + }) + } + for i := range networkPolicy.Spec.Egress { + hashedOVNName := hashedAddressSet(fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "egress", i)) + n.addNamespaceSelectorCmdsForGress(fexec, networkPolicy, "egress", i) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 set address_set %s addresses=\"%s\"", hashedOVNName, pod.podIP), ++ fmt.Sprintf("ovn-nbctl --timeout=15 add address_set %s addresses %s", hashedOVNName, pod.podIP), + }) + } + } +@@ -235,18 +235,18 @@ func (n networkPolicyOld) delPodCmds(fexec *ovntest.FakeExec, pod pod, networkPo + for i := range networkPolicy.Spec.Ingress { + hashedOVNName := hashedAddressSet(fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "ingress", i)) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedOVNName), ++ fmt.Sprintf("ovn-nbctl --timeout=15 remove address_set %s addresses %s", hashedOVNName, pod.podIP), + }) + } + for i := range networkPolicy.Spec.Egress { + hashedOVNName := hashedAddressSet(fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "egress", i)) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedOVNName), ++ fmt.Sprintf("ovn-nbctl --timeout=15 remove address_set %s addresses %s", hashedOVNName, pod.podIP), + }) + } + hashedNamespace := hashedAddressSet(pod.namespace) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedNamespace), ++ fmt.Sprintf("ovn-nbctl --timeout=15 remove address_set %s addresses %s", hashedNamespace, pod.podIP), + }) + } + +@@ -261,19 +261,19 @@ func (n networkPolicyOld) delLocalPodCmds(fexec *ovntest.FakeExec, pod pod, netw + hashedOVNName := hashedAddressSet(fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "ingress", i)) + n.baseLocalCmdsForGress(fexec, pod, networkPolicy, i, "Ingress", hashedOVNName) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedOVNName), ++ fmt.Sprintf("ovn-nbctl --timeout=15 remove address_set %s addresses %s", hashedOVNName, pod.podIP), + }) + } + for i := range networkPolicy.Spec.Egress { + hashedOVNName := hashedAddressSet(fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "egress", i)) + n.baseLocalCmdsForGress(fexec, pod, networkPolicy, i, "Egress", hashedOVNName) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedOVNName), ++ fmt.Sprintf("ovn-nbctl --timeout=15 remove address_set %s addresses %s", hashedOVNName, pod.podIP), + }) + } + hashedNamespace := hashedAddressSet(pod.namespace) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedNamespace), ++ fmt.Sprintf("ovn-nbctl --timeout=15 remove address_set %s addresses %s", hashedNamespace, pod.podIP), + }) + } + +diff --git a/go-controller/pkg/ovn/policy_test.go b/go-controller/pkg/ovn/policy_test.go +index e0cb7e4c3b6..99eb653ca0c 100644 +--- a/go-controller/pkg/ovn/policy_test.go ++++ b/go-controller/pkg/ovn/policy_test.go +@@ -96,13 +96,13 @@ func (n networkPolicy) addPodSelectorCmds(fexec *ovntest.FakeExec, pod pod, netw + for i := range networkPolicy.Spec.Ingress { + hashedOVNName := hashedAddressSet(fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "ingress", i)) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 set address_set %s addresses=\"%s\"", hashedOVNName, pod.podIP), ++ fmt.Sprintf("ovn-nbctl --timeout=15 add address_set %s addresses %s", hashedOVNName, pod.podIP), + }) + } + for i := range networkPolicy.Spec.Egress { + hashedOVNName := hashedAddressSet(fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "egress", i)) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 set address_set %s addresses=\"%s\"", hashedOVNName, pod.podIP), ++ fmt.Sprintf("ovn-nbctl --timeout=15 add address_set %s addresses %s", hashedOVNName, pod.podIP), + }) + } + if hasLocalPods { +@@ -168,19 +168,19 @@ func (n networkPolicy) delCmds(fexec *ovntest.FakeExec, pod pod, networkPolicy k + }) + } + +-func (n networkPolicy) delPodCmds(fexec *ovntest.FakeExec, networkPolicy knet.NetworkPolicy, withLocal bool) { ++func (n networkPolicy) delPodCmds(fexec *ovntest.FakeExec, networkPolicy knet.NetworkPolicy, withLocal bool, podIP string) { + for i := range networkPolicy.Spec.Ingress { + localPeerPods := fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "ingress", i) + hashedLocalAddressSet := hashedAddressSet(localPeerPods) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedLocalAddressSet), ++ fmt.Sprintf("ovn-nbctl --timeout=15 remove address_set %s addresses %s", hashedLocalAddressSet, podIP), + }) + } + for i := range networkPolicy.Spec.Egress { + localPeerPods := fmt.Sprintf("%s.%s.%s.%d", networkPolicy.Namespace, networkPolicy.Name, "egress", i) + hashedLocalAddressSet := hashedAddressSet(localPeerPods) + fexec.AddFakeCmdsNoOutputNoError([]string{ +- fmt.Sprintf("ovn-nbctl --timeout=15 clear address_set %s addresses", hashedLocalAddressSet), ++ fmt.Sprintf("ovn-nbctl --timeout=15 remove address_set %s addresses %s", hashedLocalAddressSet, podIP), + }) + } + if withLocal { +@@ -847,7 +847,7 @@ var _ = Describe("OVN NetworkPolicy Operations", func() { + + nPodTest.delCmds(fExec) + nPodTest.delFromNamespaceCmds(fExec, nPodTest, true) +- npTest.delPodCmds(fExec, networkPolicy, true) ++ npTest.delPodCmds(fExec, networkPolicy, true, nPodTest.podIP) + + err = fakeOvn.fakeClient.CoreV1().Pods(nPodTest.namespace).Delete(nPodTest.podName, metav1.NewDeleteOptions(0)) + Expect(err).NotTo(HaveOccurred()) +@@ -956,7 +956,7 @@ var _ = Describe("OVN NetworkPolicy Operations", func() { + + nPodTest.delCmds(fExec) + nPodTest.delFromNamespaceCmds(fExec, nPodTest, true) +- npTest.delPodCmds(fExec, networkPolicy, false) ++ npTest.delPodCmds(fExec, networkPolicy, false, nPodTest.podIP) + + err = fakeOvn.fakeClient.CoreV1().Pods(nPodTest.namespace).Delete(nPodTest.podName, metav1.NewDeleteOptions(0)) + Expect(err).NotTo(HaveOccurred()) +@@ -1212,7 +1212,7 @@ var _ = Describe("OVN NetworkPolicy Operations", func() { + nPodTest.populateLogicalSwitchCache(fakeOvn) + nPodTest.addCmdsForNonExistingPod(fExec) + nPodTest.addPodDenyMcast(fExec, false) +- nTest.addPodCmds(fExec, nPodTest, namespace1) ++ nTest.addPodCmds(fExec, nPodTest, namespace1, false) + + // The pod should be added to the multicast allow group. + mcastPolicy.addPodCmds(fExec, namespace1.Name, "fake_uuid") +@@ -1227,7 +1227,7 @@ var _ = Describe("OVN NetworkPolicy Operations", func() { + // The pod should be removed from the multicasts default deny + // group and from the multicast allow group. + nPodTest.delPodDenyMcast(fExec, false) +- nTest.delPodCmds(fExec, nPodTest, namespace1) ++ nTest.delPodCmds(fExec, nPodTest, namespace1, false) + nPodTest.delCmds(fExec) + + err = fakeOvn.fakeClient.CoreV1().Pods(nPodTest.namespace).Delete( +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+3RvW6DMBQFYGaewsrOj2mAiVcgmbJGxBiKAF9kG6pKffg6LIkitVkStVXPt/jK ++x5Itn/A0d0N9lGqJvGeJnTxN19W5XdeZpwlP4jyJM7fPeZpvPZY+7UVXZmMrzZiniex35+7lf1R4 ++6d9KY4+CxrFSdWheH3fHvf6Tl+zSf5y7/rcZTzwWP+4JX/vn/YuarcWfZO27uaVAkLKahkFqvyV2 ++zliwSFtQ07iBuXxWtuAsjKa+jWhREQvaTvUthQ2J2RSb3aFkZTVKM1VCst0kdWU7UubjHOypvt0q ++pX0j3e9p6MT7Vbjxf/p3AAAAAAAAAAAAAAAAAAAAAAB+t08ZOQFwACgAAA== +diff --git 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-002181/tests/test.sh b/tasks/format-code-task-002181/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..cdb1e96abd3a414911b548c3a02fac115e657ff8 --- /dev/null +++ b/tasks/format-code-task-002181/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' +go-controller/pkg/ovn/namespace_test.go +go-controller/pkg/ovn/pods_test.go +go-controller/pkg/ovn/policy_old_test.go +go-controller/pkg/ovn/policy_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-002181/tests/test_command.sh b/tasks/format-code-task-002181/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002181/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002186/environment/Dockerfile b/tasks/format-code-task-002186/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b26a8afb1fb39f869c5fb3ffd1d141d485b4d082 --- /dev/null +++ b/tasks/format-code-task-002186/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bf86da91173b778c4e0220e44810c9099c54f4602b260d390700512dc59b9e15 diff --git a/tasks/format-code-task-002186/environment/setup/files/blocklist b/tasks/format-code-task-002186/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002186/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002186/environment/setup/setup.sh b/tasks/format-code-task-002186/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002186/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002186/tests/test.patch b/tasks/format-code-task-002186/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c6bbe7166ed2ec531f793475c56ae72f642adb4b --- /dev/null +++ b/tasks/format-code-task-002186/tests/test.patch @@ -0,0 +1,555 @@ +diff --git a/usercase-test-coderl/data_layer_stateful_test.go b/usercase-test-coderl/data_layer_stateful_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/data_layer_stateful_test.go +@@ -0,0 +1,485 @@ ++package usercase_test_coderl ++ ++import ( ++ "context" ++ "fmt" ++ "testing" ++ "time" ++ ++ "github.com/Pacific73/gorm-cache/config" ++ "github.com/Pacific73/gorm-cache/data_layer" ++ "github.com/Pacific73/gorm-cache/util" ++ "github.com/go-redis/redis/v8" ++) ++ ++ ++ ++ ++ ++ ++ ++const redisAddr = "127.0.0.1:6380" ++ ++var _ data_layer.DataLayerInterface = (*data_layer.MemoryLayer)(nil) ++var _ data_layer.DataLayerInterface = (*data_layer.RedisLayer)(nil) ++ ++func TestMemoryLayerSetBatchDeletePrefixAndCleanSession(t *testing.T) { ++ ++ ++ ++ ++ ctx := context.Background() ++ layer := &data_layer.MemoryLayer{} ++ ++ if err := layer.Init(&config.CacheConfig{CacheSize: 32, CacheTTL: 0}, "memory-session"); err != nil { ++ t.Fatalf("Init() error = %v, want nil", err) ++ } ++ exists, err := layer.KeyExists(ctx, "user:1") ++ if exists != false || err != nil { ++ t.Fatalf("fresh KeyExists(user:1) = (%v, %v), want (false, nil)", exists, err) ++ } ++ ++ if err := layer.SetKey(ctx, util.Kv{Key: "user:1", Value: "alice"}); err != nil { ++ t.Fatalf("SetKey(user:1) error = %v, want nil", err) ++ } ++ exists, err = layer.KeyExists(ctx, "user:1") ++ if exists != true || err != nil { ++ t.Fatalf("after SetKey KeyExists(user:1) = (%v, %v), want (true, nil)", exists, err) ++ } ++ value, err := layer.GetValue(ctx, "user:1") ++ if value != "alice" || err != nil { ++ t.Fatalf("after SetKey GetValue(user:1) = (%q, %v), want (%q, nil)", value, err, "alice") ++ } ++ ++ if err := layer.BatchSetKeys(ctx, []util.Kv{{Key: "user:2", Value: "bob"}, {Key: "user:3", Value: "cara"}}); err != nil { ++ t.Fatalf("BatchSetKeys(user:2,user:3) error = %v, want nil", err) ++ } ++ batchExists, err := layer.BatchKeyExist(ctx, []string{"user:2", "user:3"}) ++ if batchExists != true || err != nil { ++ t.Fatalf("after BatchSetKeys BatchKeyExist(user:2,user:3) = (%v, %v), want (true, nil)", batchExists, err) ++ } ++ values, err := layer.BatchGetValues(ctx, []string{"user:2", "user:3"}) ++ if fmt.Sprintf("%q", values) != "[\"bob\" \"cara\"]" || err != nil { ++ t.Fatalf("after BatchSetKeys BatchGetValues(user:2,user:3) = (%q, %v), want ([\"bob\" \"cara\"], nil)", values, err) ++ } ++ ++ if err := layer.DeleteKey(ctx, "user:1"); err != nil { ++ t.Fatalf("DeleteKey(user:1) error = %v, want nil", err) ++ } ++ exists, err = layer.KeyExists(ctx, "user:1") ++ if exists != false || err != nil { ++ t.Fatalf("after DeleteKey KeyExists(user:1) = (%v, %v), want (false, nil)", exists, err) ++ } ++ ++ if err := layer.BatchDeleteKeys(ctx, []string{"user:2", "user:3"}); err != nil { ++ t.Fatalf("BatchDeleteKeys(user:2,user:3) error = %v, want nil", err) ++ } ++ batchExists, err = layer.BatchKeyExist(ctx, []string{"user:2", "user:3"}) ++ if batchExists != false || err != nil { ++ t.Fatalf("after BatchDeleteKeys BatchKeyExist(user:2,user:3) = (%v, %v), want (false, nil)", batchExists, err) ++ } ++ ++ if err := layer.SetKey(ctx, util.Kv{Key: "prefix:a", Value: "A"}); err != nil { ++ t.Fatalf("SetKey(prefix:a) error = %v, want nil", err) ++ } ++ if err := layer.SetKey(ctx, util.Kv{Key: "prefix:b", Value: "B"}); err != nil { ++ t.Fatalf("SetKey(prefix:b) error = %v, want nil", err) ++ } ++ if err := layer.SetKey(ctx, util.Kv{Key: "other:c", Value: "C"}); err != nil { ++ t.Fatalf("SetKey(other:c) error = %v, want nil", err) ++ } ++ if err := layer.DeleteKeysWithPrefix(ctx, "prefix"); err != nil { ++ t.Fatalf("DeleteKeysWithPrefix(prefix) error = %v, want nil", err) ++ } ++ assertMemoryExists(t, layer, ctx, "prefix:a", false) ++ assertMemoryExists(t, layer, ctx, "prefix:b", false) ++ assertMemoryExists(t, layer, ctx, "other:c", true) ++ ++ if err := layer.CleanCache(ctx); err != nil { ++ t.Fatalf("CleanCache() error = %v, want nil", err) ++ } ++ assertMemoryExists(t, layer, ctx, "other:c", false) ++} ++ ++func TestMemoryLayerMissesAndExpiryUseConcreteErrors(t *testing.T) { ++ ++ ++ ++ ++ ctx := context.Background() ++ layer := &data_layer.MemoryLayer{} ++ if err := layer.Init(&config.CacheConfig{CacheSize: 8, CacheTTL: 0}, "memory-miss"); err != nil { ++ t.Fatalf("Init() error = %v, want nil", err) ++ } ++ ++ exists, err := layer.KeyExists(ctx, "user:missing") ++ if exists != false || err != nil { ++ t.Fatalf("KeyExists(user:missing) = (%v, %v), want (false, nil)", exists, err) ++ } ++ value, err := layer.GetValue(ctx, "user:missing") ++ ++ if err == nil || err.Error() != "cannot get item" { ++ t.Fatalf("GetValue(user:missing) = (%q, %T, %v), want error message %q", value, err, err, "cannot get item") ++ } ++ batchExists, err := layer.BatchKeyExist(ctx, []string{"user:2", "user:3"}) ++ if batchExists != false || err != nil { ++ t.Fatalf("BatchKeyExist(absent keys) = (%v, %v), want (false, nil)", batchExists, err) ++ } ++ values, err := layer.BatchGetValues(ctx, []string{"user:2", "user:missing"}) ++ ++ if err == nil || err.Error() != "cannot get items" { ++ t.Fatalf("BatchGetValues(absent keys) = (%q, %T, %v), want error message %q", values, err, err, "cannot get items") ++ } ++ ++ ttlLayer := &data_layer.MemoryLayer{} ++ if err := ttlLayer.Init(&config.CacheConfig{CacheSize: 8, CacheTTL: 1}, "memory-ttl"); err != nil { ++ t.Fatalf("Init(ttl) error = %v, want nil", err) ++ } ++ if err := ttlLayer.SetKey(ctx, util.Kv{Key: "ttl:1", Value: "short"}); err != nil { ++ t.Fatalf("SetKey(ttl:1) error = %v, want nil", err) ++ } ++ ++ deadline := time.Now().Add(1500 * time.Millisecond) ++ for { ++ exists, err = ttlLayer.KeyExists(ctx, "ttl:1") ++ if err != nil { ++ t.Fatalf("KeyExists(ttl:1) while waiting for expiry error = %v, want nil", err) ++ } ++ if !exists || time.Now().After(deadline) { ++ break ++ } ++ time.Sleep(10 * time.Millisecond) ++ } ++ exists, err = ttlLayer.KeyExists(ctx, "ttl:1") ++ if exists != false || err != nil { ++ t.Fatalf("expired KeyExists(ttl:1) = (%v, %v), want (false, nil)", exists, err) ++ } ++ value, err = ttlLayer.GetValue(ctx, "ttl:1") ++ ++ if err == nil || err.Error() != "cannot get item" { ++ t.Fatalf("expired GetValue(ttl:1) = (%q, %T, %v), want error message %q", value, err, err, "cannot get item") ++ } ++} ++ ++func TestMemoryLayerConstructedValueInitializesBeforeUse(t *testing.T) { ++ ++ ++ ++ ++ ctx := context.Background() ++ layer := &data_layer.MemoryLayer{} ++ ++ if err := layer.Init(&config.CacheConfig{CacheSize: 4, CacheTTL: 0}, "memory-lifecycle"); err != nil { ++ t.Fatalf("Init() error = %v, want nil", err) ++ } ++ exists, err := layer.KeyExists(ctx, "after-init-miss") ++ if exists != false || err != nil { ++ t.Fatalf("after Init KeyExists(after-init-miss) = (%v, %v), want (false, nil)", exists, err) ++ } ++ batchExists, err := layer.BatchKeyExist(ctx, []string{"after-init-miss"}) ++ if batchExists != false || err != nil { ++ t.Fatalf("after Init BatchKeyExist(after-init-miss) = (%v, %v), want (false, nil)", batchExists, err) ++ } ++} ++ ++func TestMemoryLayerCleanCacheIsIdempotent(t *testing.T) { ++ ++ ++ ++ ++ ctx := context.Background() ++ layer := &data_layer.MemoryLayer{} ++ if err := layer.Init(&config.CacheConfig{CacheSize: 8, CacheTTL: 0}, "memory-clean-twice"); err != nil { ++ t.Fatalf("Init() error = %v, want nil", err) ++ } ++ if err := layer.SetKey(ctx, util.Kv{Key: "clean:1", Value: "one"}); err != nil { ++ t.Fatalf("SetKey(clean:1) error = %v, want nil", err) ++ } ++ if err := layer.CleanCache(ctx); err != nil { ++ t.Fatalf("first CleanCache() error = %v, want nil", err) ++ } ++ if err := layer.CleanCache(ctx); err != nil { ++ t.Fatalf("second CleanCache() error = %v, want nil", err) ++ } ++ assertMemoryExists(t, layer, ctx, "clean:1", false) ++} ++ ++func TestMemoryLayerInstancesDoNotShareState(t *testing.T) { ++ ++ ++ ++ ++ ctx := context.Background() ++ a := &data_layer.MemoryLayer{} ++ b := &data_layer.MemoryLayer{} ++ if err := a.Init(&config.CacheConfig{CacheSize: 8, CacheTTL: 0}, "memory-a"); err != nil { ++ t.Fatalf("a.Init() error = %v, want nil", err) ++ } ++ if err := b.Init(&config.CacheConfig{CacheSize: 8, CacheTTL: 0}, "memory-b"); err != nil { ++ t.Fatalf("b.Init() error = %v, want nil", err) ++ } ++ if err := a.SetKey(ctx, util.Kv{Key: "shared-looking", Value: "from-a"}); err != nil { ++ t.Fatalf("a.SetKey(shared-looking) error = %v, want nil", err) ++ } ++ aExists, err := a.KeyExists(ctx, "shared-looking") ++ if aExists != true || err != nil { ++ t.Fatalf("a.KeyExists(shared-looking) = (%v, %v), want (true, nil)", aExists, err) ++ } ++ bExists, err := b.KeyExists(ctx, "shared-looking") ++ if bExists != false || err != nil { ++ t.Fatalf("b.KeyExists(shared-looking) = (%v, %v), want (false, nil)", bExists, err) ++ } ++} ++ ++func TestRedisLayerSetBatchDeletePrefixAndCleanSession(t *testing.T) { ++ ++ ++ ++ ++ ctx := context.Background() ++ client := newRedisClient(t) ++ defer client.Close() ++ layer := newRedisLayerWithClient(t, ctx, client, "redis-session") ++ ++ exists, err := layer.KeyExists(ctx, "session:1") ++ if exists != false || err != nil { ++ t.Fatalf("fresh KeyExists(session:1) = (%v, %v), want (false, nil)", exists, err) ++ } ++ ++ batchExists, err := layer.BatchKeyExist(ctx, []string{"session:missing"}) ++ if batchExists != false || err != nil { ++ t.Fatalf("fresh BatchKeyExist(session:missing) = (%v, %v), want (false, nil)", batchExists, err) ++ } ++ ++ if err := layer.SetKey(ctx, util.Kv{Key: "session:1", Value: "token"}); err != nil { ++ t.Fatalf("SetKey(session:1) error = %v, want nil", err) ++ } ++ exists, err = layer.KeyExists(ctx, "session:1") ++ if exists != true || err != nil { ++ t.Fatalf("after SetKey KeyExists(session:1) = (%v, %v), want (true, nil)", exists, err) ++ } ++ value, err := layer.GetValue(ctx, "session:1") ++ if value != "token" || err != nil { ++ t.Fatalf("after SetKey GetValue(session:1) = (%q, %v), want (%q, nil)", value, err, "token") ++ } ++ ++ if err := layer.BatchSetKeys(ctx, []util.Kv{{Key: "session:2", Value: "two"}, {Key: "session:3", Value: "three"}}); err != nil { ++ t.Fatalf("BatchSetKeys(session:2,session:3) error = %v, want nil", err) ++ } ++ batchExists, err = layer.BatchKeyExist(ctx, []string{"session:2", "session:3"}) ++ if batchExists != true || err != nil { ++ t.Fatalf("after BatchSetKeys BatchKeyExist(session:2,session:3) = (%v, %v), want (true, nil)", batchExists, err) ++ } ++ values, err := layer.BatchGetValues(ctx, []string{"session:2", "session:3"}) ++ if fmt.Sprintf("%q", values) != "[\"two\" \"three\"]" || err != nil { ++ t.Fatalf("after BatchSetKeys BatchGetValues(session:2,session:3) = (%q, %v), want ([\"two\" \"three\"], nil)", values, err) ++ } ++ ++ if err := layer.DeleteKey(ctx, "session:1"); err != nil { ++ t.Fatalf("DeleteKey(session:1) error = %v, want nil", err) ++ } ++ assertRedisExists(t, layer, ctx, "session:1", false) ++ if err := layer.BatchDeleteKeys(ctx, []string{"session:2", "session:3"}); err != nil { ++ t.Fatalf("BatchDeleteKeys(session:2,session:3) error = %v, want nil", err) ++ } ++ batchExists, err = layer.BatchKeyExist(ctx, []string{"session:2", "session:3"}) ++ if batchExists != false || err != nil { ++ t.Fatalf("after BatchDeleteKeys BatchKeyExist(session:2,session:3) = (%v, %v), want (false, nil)", batchExists, err) ++ } ++ ++ if err := layer.SetKey(ctx, util.Kv{Key: "session:a", Value: "A"}); err != nil { ++ t.Fatalf("SetKey(session:a) error = %v, want nil", err) ++ } ++ if err := layer.SetKey(ctx, util.Kv{Key: "session:b", Value: "B"}); err != nil { ++ t.Fatalf("SetKey(session:b) error = %v, want nil", err) ++ } ++ if err := layer.SetKey(ctx, util.Kv{Key: "other:c", Value: "C"}); err != nil { ++ t.Fatalf("SetKey(other:c) error = %v, want nil", err) ++ } ++ if err := layer.DeleteKeysWithPrefix(ctx, "session"); err != nil { ++ t.Fatalf("DeleteKeysWithPrefix(session) error = %v, want nil", err) ++ } ++ assertRedisExists(t, layer, ctx, "session:a", false) ++ assertRedisExists(t, layer, ctx, "session:b", false) ++ assertRedisExists(t, layer, ctx, "other:c", true) ++ ++ if err := layer.SetKey(ctx, util.Kv{Key: "redis-session:x", Value: "X"}); err != nil { ++ t.Fatalf("SetKey(redis-session:x) error = %v, want nil", err) ++ } ++ if err := layer.SetKey(ctx, util.Kv{Key: "redis-session:y", Value: "Y"}); err != nil { ++ t.Fatalf("SetKey(redis-session:y) error = %v, want nil", err) ++ } ++ if err := layer.SetKey(ctx, util.Kv{Key: "outside:z", Value: "Z"}); err != nil { ++ t.Fatalf("SetKey(outside:z) error = %v, want nil", err) ++ } ++ if err := layer.CleanCache(ctx); err != nil { ++ t.Fatalf("CleanCache() error = %v, want nil", err) ++ } ++ assertRedisExists(t, layer, ctx, "redis-session:x", false) ++ assertRedisExists(t, layer, ctx, "redis-session:y", false) ++ assertRedisExists(t, layer, ctx, "outside:z", true) ++} ++ ++func TestRedisLayerOptionsModeInitializesAndUsesClient(t *testing.T) { ++ ++ ++ ++ ++ ctx := context.Background() ++ cleanup := newRedisClient(t) ++ if err := cleanup.FlushDB(ctx).Err(); err != nil { ++ t.Fatalf("FlushDB() error = %v, want nil", err) ++ } ++ cleanup.Close() ++ ++ layer := &data_layer.RedisLayer{} ++ err := layer.Init(&config.CacheConfig{ ++ CacheSize: 32, ++ CacheTTL: 0, ++ RedisConfig: &config.RedisConfig{ ++ Mode: config.RedisConfigModeOptions, ++ Options: &redis.Options{Addr: redisAddr, DB: 14}, ++ }, ++ DebugLogger: &config.DefaultLoggerImpl{}, ++ }, "redis-options") ++ if err != nil { ++ t.Fatalf("Init(options mode) error = %v, want nil", err) ++ } ++ if err := layer.SetKey(ctx, util.Kv{Key: "options:1", Value: "created-client"}); err != nil { ++ t.Fatalf("SetKey(options:1) error = %v, want nil", err) ++ } ++ value, err := layer.GetValue(ctx, "options:1") ++ if value != "created-client" || err != nil { ++ t.Fatalf("GetValue(options:1) = (%q, %v), want (%q, nil)", value, err, "created-client") ++ } ++} ++ ++func TestRedisLayerScriptLoadFailureIsReturned(t *testing.T) { ++ ++ ++ ++ ++ layer := &data_layer.RedisLayer{} ++ err := layer.Init(&config.CacheConfig{ ++ CacheTTL: 0, ++ RedisConfig: &config.RedisConfig{ ++ Mode: config.RedisConfigModeRaw, ++ Client: redis.NewClient(&redis.Options{Addr: "127.0.0.1:1", DB: 14}), ++ }, ++ DebugLogger: &config.DefaultLoggerImpl{}, ++ }, "redis-bad") ++ ++ if err == nil { ++ t.Fatalf("Init(bad redis) error = nil, want non-nil") ++ } ++} ++ ++func TestRedisLayerCleanCacheIsIdempotent(t *testing.T) { ++ ++ ++ ++ ++ ctx := context.Background() ++ client := newRedisClient(t) ++ defer client.Close() ++ layer := newRedisLayerWithClient(t, ctx, client, "redis-clean-twice") ++ ++ if err := layer.SetKey(ctx, util.Kv{Key: "redis-clean-twice:1", Value: "one"}); err != nil { ++ t.Fatalf("SetKey(redis-clean-twice:1) error = %v, want nil", err) ++ } ++ if err := layer.CleanCache(ctx); err != nil { ++ t.Fatalf("first CleanCache() error = %v, want nil", err) ++ } ++ if err := layer.CleanCache(ctx); err != nil { ++ t.Fatalf("second CleanCache() error = %v, want nil", err) ++ } ++ assertRedisExists(t, layer, ctx, "redis-clean-twice:1", false) ++} ++ ++func TestRedisCleanCacheLeakFloorKeepsBackendKeysBounded(t *testing.T) { ++ ++ ++ ++ ++ ctx := context.Background() ++ client := newRedisClient(t) ++ defer client.Close() ++ prefix := "leak-floor" ++ initialKeys, err := client.Keys(ctx, prefix+":*").Result() ++ if err != nil { ++ t.Fatalf("initial Keys(%s:*) error = %v, want nil", prefix, err) ++ } ++ if len(initialKeys) != 0 { ++ if deleted, err := client.Del(ctx, initialKeys...).Result(); err != nil { ++ t.Fatalf("initial Del(%s:*) = (%d, %v), want (_, nil)", prefix, deleted, err) ++ } ++ } ++ ++ for i := 0; i < 100; i++ { ++ layer := newRedisLayerWithClient(t, ctx, client, prefix) ++ key := fmt.Sprintf("leak-floor:%03d", i) ++ if err := layer.SetKey(ctx, util.Kv{Key: key, Value: "value"}); err != nil { ++ t.Fatalf("cycle %d SetKey(%s) error = %v, want nil", i, key, err) ++ } ++ if err := layer.CleanCache(ctx); err != nil { ++ t.Fatalf("cycle %d CleanCache() error = %v, want nil", i, err) ++ } ++ } ++ ++ keys, err := client.Keys(ctx, prefix+":*").Result() ++ if err != nil { ++ t.Fatalf("Keys(%s:*) error = %v, want nil", prefix, err) ++ } ++ if len(keys) != 0 { ++ t.Fatalf("Redis key count after 100 clean cycles = %d, want 0; keys=%q", len(keys), keys) ++ } ++} ++ ++func assertMemoryExists(t *testing.T, layer *data_layer.MemoryLayer, ctx context.Context, key string, want bool) { ++ t.Helper() ++ exists, err := layer.KeyExists(ctx, key) ++ if exists != want || err != nil { ++ t.Fatalf("KeyExists(%s) = (%v, %v), want (%v, nil)", key, exists, err, want) ++ } ++} ++ ++func assertRedisExists(t *testing.T, layer *data_layer.RedisLayer, ctx context.Context, key string, want bool) { ++ t.Helper() ++ exists, err := layer.KeyExists(ctx, key) ++ if exists != want || err != nil { ++ t.Fatalf("KeyExists(%s) = (%v, %v), want (%v, nil)", key, exists, err, want) ++ } ++} ++ ++func newRedisClient(t *testing.T) *redis.Client { ++ t.Helper() ++ ctx := context.Background() ++ client := redis.NewClient(&redis.Options{Addr: redisAddr, DB: 14}) ++ if err := client.Ping(ctx).Err(); err != nil { ++ client.Close() ++ t.Fatalf("Redis PING at %s error = %v, want nil", redisAddr, err) ++ } ++ if err := client.FlushDB(ctx).Err(); err != nil { ++ client.Close() ++ t.Fatalf("Redis FlushDB error = %v, want nil", err) ++ } ++ return client ++} ++ ++func newRedisLayerWithClient(t *testing.T, ctx context.Context, client *redis.Client, prefix string) *data_layer.RedisLayer { ++ t.Helper() ++ layer := &data_layer.RedisLayer{} ++ err := layer.Init(&config.CacheConfig{ ++ CacheSize: 32, ++ CacheTTL: 0, ++ RedisConfig: &config.RedisConfig{ ++ Mode: config.RedisConfigModeRaw, ++ Client: client, ++ }, ++ DebugLogger: &config.DefaultLoggerImpl{}, ++ }, prefix) ++ if err != nil { ++ t.Fatalf("RedisLayer.Init(%s) error = %v, want nil", prefix, err) ++ } ++ return layer ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,60 @@ ++#!/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 ! command -v redis-server >/dev/null 2>&1 || ! command -v redis-cli >/dev/null 2>&1; then ++ echo "redis-server and redis-cli must be installed in the image before offline test execution" >&2 ++ exit 127 ++fi ++ ++export GOPROXY=off ++export GOSUMDB=off ++export GOMODCACHE="/go/pkg/mod" ++export GOCACHE="/workspace/repo/.gocache" ++export GOFLAGS="-mod=readonly" ++ ++started_redis=0 ++redis_tmp="" ++if ! redis-cli -h 127.0.0.1 -p 6380 ping >/dev/null 2>&1; then ++ redis_tmp="$(mktemp -d)" ++ redis-server \ ++ --bind 127.0.0.1 \ ++ --port 6380 \ ++ --save "" \ ++ --appendonly no \ ++ --daemonize yes \ ++ --pidfile "$redis_tmp/redis.pid" \ ++ --dir "$redis_tmp" >/dev/null ++ started_redis=1 ++fi ++ ++cleanup() { ++ if [ "$started_redis" = "1" ]; then ++ redis-cli -h 127.0.0.1 -p 6380 shutdown nosave >/dev/null 2>&1 || true ++ fi ++ if [ -n "$redis_tmp" ]; then ++ rm -rf "$redis_tmp" ++ fi ++} ++trap cleanup EXIT ++ ++for _ in $(seq 1 100); do ++ if redis-cli -h 127.0.0.1 -p 6380 ping >/dev/null 2>&1; then ++ break ++ fi ++ sleep 0.1 ++done ++redis-cli -h 127.0.0.1 -p 6380 ping >/dev/null ++ ++go test -v -count=1 ./usercase-test-coderl/... diff --git a/tasks/format-code-task-002186/tests/test.sh b/tasks/format-code-task-002186/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7a57abbb288e7937a37f578be08662851417be18 --- /dev/null +++ b/tasks/format-code-task-002186/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/data_layer_stateful_test.go +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002186/tests/test_command.sh b/tasks/format-code-task-002186/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002186/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-002187/environment/Dockerfile b/tasks/format-code-task-002187/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e2c11d6cfb27b1d1f6aeeb7bcd21a83569612924 --- /dev/null +++ b/tasks/format-code-task-002187/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:43ef50b6000808863c9db75e0e6fe42bd158877683f9d7b0cb4840fa8d73e8a4 diff --git a/tasks/format-code-task-002187/environment/setup/files/blocklist b/tasks/format-code-task-002187/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002187/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002187/environment/setup/setup.sh b/tasks/format-code-task-002187/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002187/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002187/tests/test.patch b/tasks/format-code-task-002187/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..9eb996fcefd53910870b83cb976f12b937b2bcb7 --- /dev/null +++ b/tasks/format-code-task-002187/tests/test.patch @@ -0,0 +1,74 @@ +diff --git a/apps/distgo/cmd/dist/dist_test.go b/apps/distgo/cmd/dist/dist_test.go +index 699bf936..f43b1a07 100644 +--- a/apps/distgo/cmd/dist/dist_test.go ++++ b/apps/distgo/cmd/dist/dist_test.go +@@ -1035,6 +1035,43 @@ daemon: true + assert.False(t, info.IsDir(), "Case %d: %s", caseNum, name) + }, + }, ++ { ++ name: "osarch dist produces archive that contains executable for current OS/Arch by default", ++ spec: func(projectDir string) params.ProductBuildSpecWithDeps { ++ specWithDeps, err := params.NewProductBuildSpecWithDeps(params.NewProductBuildSpec( ++ projectDir, ++ "foo", ++ git.ProjectInfo{ ++ Version: "0.1.0", ++ }, ++ params.Product{ ++ Build: params.Build{ ++ MainPkg: "./.", ++ }, ++ Dist: []params.Dist{{ ++ Info: ¶ms.OSArchsBinDistInfo{}, ++ }}, ++ }, ++ params.Project{}, ++ ), nil) ++ require.NoError(t, err) ++ return specWithDeps ++ }, ++ preDistAction: func(projectDir string, buildSpec params.ProductBuildSpec) { ++ gittest.CreateGitTag(t, projectDir, "0.1.0") ++ }, ++ validate: func(caseNum int, name string, projectDir string) { ++ ++ info, err := os.Stat(path.Join(projectDir, "dist", "foo-0.1.0", osarch.Current().String(), "foo")) ++ require.NoError(t, err) ++ assert.False(t, info.IsDir(), "Case %d: %s", caseNum, name) ++ ++ ++ tgzFiles, err := pathsInTGZ(path.Join(projectDir, "dist", fmt.Sprintf("foo-0.1.0-%v.tgz", osarch.Current()))) ++ require.NoError(t, err) ++ assert.Equal(t, map[string]struct{}{"foo": {}}, tgzFiles) ++ }, ++ }, + { + name: "osarch dist produces archive that contains executable", + spec: func(projectDir string) params.ProductBuildSpecWithDeps { +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/TMBTHe85f8SiogoPjuqXtAW0S0iY4MG0a4zwlsZOaJbZnO4VK++P3klVd ++2QTlsAkQ73OJHb+f32eneatreanMig+eizGymM36L/Lw26/FbCLEQsynU7QTYj6eDWD2bBXt0IaY ++eYCBtzb+ym7f+T9Kej//qEK8LGzTZEamYfl0OfbMX0zm0+38J/MFzv/tfLIYwPjpSvg5//n8Cwn9 ++4HMlk+QlfFYRWgcfLIh0MoXXeB1cFnVeK/im4xLiUgdwXrHGyrZWAQorVZ4F9SaRasUCGhVLqO7c ++dwOenr2/+Ahh3dTaXEFp/eNQztuvqoiJ+u6sjxuXA94Jzyt7/1sIcXJ69OXT8YEty6S5ktoDczB8 ++defBgy94hcW2eYrlc5fVmYnaD5PaAAvltt+9HphVqnrYtXFsQusVSOWUkcoUGuvtmjg/O4EuHBSo ++AWRoog1eqLpGOXUJL2DznoCtwLumf2wwOuQoFjdtXcPNzY9GpWt2z9+hTMokgGQusqpXU2ZRAbu+ ++htFo+3eTFti6P/Ftvu4S9guG0WAn5+RwJPqQlWq2jl1ixoxl0hZto0x85FHqTonz1nQ1Ab6aLm/X ++fFL8vpYPxtddlV4/bJ15DD28wN2RDnEIKc+cC1ziprK8aGS/5MmffjIEQRAEQRAEQRAEQRAEQRAE ++QRAEQRAEQRB/FbdBuhkYACgAAA== +diff --git 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-002187/tests/test.sh b/tasks/format-code-task-002187/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..101a17e7cd56be20de09b29290925eb05ded2a98 --- /dev/null +++ b/tasks/format-code-task-002187/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/distgo/cmd/dist/dist_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-002187/tests/test_command.sh b/tasks/format-code-task-002187/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002187/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002312/environment/Dockerfile b/tasks/format-code-task-002312/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e5c46ed816ae4fc3024c4dcadb3ce2b3cc37e246 --- /dev/null +++ b/tasks/format-code-task-002312/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6dd6588f49055ebfd0d36ba1ce503821d517524474cd0665403cab4883f5ee71 diff --git a/tasks/format-code-task-002312/environment/setup/files/blocklist b/tasks/format-code-task-002312/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002312/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002312/environment/setup/setup.sh b/tasks/format-code-task-002312/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002312/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002312/tests/test.patch b/tasks/format-code-task-002312/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2e949f6344a7dd80fd6e00187a7548913b4925a8 --- /dev/null +++ b/tasks/format-code-task-002312/tests/test.patch @@ -0,0 +1,462 @@ +diff --git a/tests/Predis/Configuration/Option/AggregateInitializerContractTest.php b/tests/Predis/Configuration/Option/AggregateInitializerContractTest.php +new file mode 100644 +index 00000000..34739bc5 +--- /dev/null ++++ b/tests/Predis/Configuration/Option/AggregateInitializerContractTest.php +@@ -0,0 +1,431 @@ ++getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); ++ $options ++ ->method('__get') ++ ->willReturnCallback(function ($name) use ($values) { ++ return isset($values[$name]) ? $values[$name] : null; ++ }); ++ ++ return $options; ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testAggregateReturnsCallableInitializer(): void ++ { ++ $option = new Aggregate(); ++ $options = $this->getOptionsMock(); ++ $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); ++ ++ $initializer = $option->filter($options, function () use ($connection) { ++ return $connection; ++ }); ++ ++ $this->assertIsCallable($initializer); ++ $this->assertSame($connection, $initializer(array())); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testInitializerInvokesUserCallableWithParametersOptionsAndOption(): void ++ { ++ $option = new Aggregate(); ++ $options = $this->getOptionsMock(); ++ $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); ++ ++ $received = null; ++ $callable = function ($parameters, $opts, $opt) use ($connection, &$received) { ++ $received = func_get_args(); ++ ++ return $connection; ++ }; ++ ++ $initializer = $option->filter($options, $callable); ++ $result = $initializer(array('tcp://127.0.0.1:6379')); ++ ++ $this->assertSame($connection, $result); ++ $this->assertCount(3, $received); ++ $this->assertSame(array('tcp://127.0.0.1:6379'), $received[0]); ++ $this->assertInstanceOf('Predis\Configuration\OptionsInterface', $received[1]); ++ $this->assertInstanceOf('Predis\Configuration\OptionInterface', $received[2]); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testInitializerPassesParametersByReference(): void ++ { ++ $option = new Aggregate(); ++ $options = $this->getOptionsMock(); ++ $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); ++ ++ ++ ++ $connection ++ ->expects($this->never()) ++ ->method('add'); ++ ++ $callable = function (&$parameters, $opts, $opt) use ($connection) { ++ $parameters = array(); ++ ++ return $connection; ++ }; ++ ++ $initializer = $option->filter($options, $callable); ++ $initializer(array('tcp://127.0.0.1:6379'), true); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testInitializerThrowsOnInvalidReturnedConnection(): void ++ { ++ $this->expectException('InvalidArgumentException'); ++ ++ $option = new Aggregate(); ++ $options = $this->getOptionsMock(); ++ $notAggregate = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); ++ ++ $initializer = $option->filter($options, function () use ($notAggregate) { ++ return $notAggregate; ++ }); ++ ++ $initializer(array()); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testAggregateRejectsNonCallableValue(): void ++ { ++ $this->expectException('InvalidArgumentException'); ++ ++ $option = new Aggregate(); ++ $options = $this->getOptionsMock(); ++ ++ $option->filter($options, true); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testAggregateHasNoDefaultInitializer(): void ++ { ++ $option = new Aggregate(); ++ $options = $this->getOptionsMock(); ++ ++ $this->assertNull($option->getDefault($options)); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testAutoAggregationAddsNodesWhenEnabled(): void ++ { ++ $option = new Aggregate(); ++ ++ $factory = $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock(); ++ $createdNode = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); ++ $existingNode = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); ++ ++ $factory ++ ->expects($this->once()) ++ ->method('create') ++ ->with('tcp://127.0.0.1:6379') ++ ->willReturn($createdNode); ++ ++ $options = $this->getOptionsMock(array('connections' => $factory)); ++ ++ $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); ++ $connection ++ ->expects($this->exactly(2)) ++ ->method('add') ++ ->withConsecutive( ++ array($createdNode), ++ array($existingNode) ++ ); ++ ++ $initializer = $option->filter($options, function () use ($connection) { ++ return $connection; ++ }); ++ ++ $result = $initializer(array('tcp://127.0.0.1:6379', $existingNode), true); ++ ++ $this->assertSame($connection, $result); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testAutoAggregationIsSkippedWhenDisabled(): void ++ { ++ $option = new Aggregate(); ++ $options = $this->getOptionsMock(); ++ ++ $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); ++ $connection ++ ->expects($this->never()) ++ ->method('add'); ++ ++ $initializer = $option->filter($options, function () use ($connection) { ++ return $connection; ++ }); ++ ++ ++ $initializer(array('tcp://127.0.0.1:6379')); ++ $initializer(array('tcp://127.0.0.1:6379'), false); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testAutoAggregationIsSkippedWhenParametersAreEmpty(): void ++ { ++ $option = new Aggregate(); ++ $options = $this->getOptionsMock(); ++ ++ $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); ++ $connection ++ ->expects($this->never()) ++ ->method('add'); ++ ++ $initializer = $option->filter($options, function () use ($connection) { ++ return $connection; ++ }); ++ ++ $initializer(array(), true); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testClusterDefaultInitializerBuildsPredisCluster(): void ++ { ++ $option = new Cluster(); ++ $options = $this->getOptionsMock(); ++ ++ $initializer = $option->getDefault($options); ++ ++ $this->assertIsCallable($initializer); ++ $this->assertInstanceOf('Predis\Connection\Cluster\PredisCluster', $initializer(array())); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testClusterStringPredisBuildsPredisCluster(): void ++ { ++ $option = new Cluster(); ++ $options = $this->getOptionsMock(); ++ ++ $initializer = $option->filter($options, 'predis'); ++ ++ $this->assertIsCallable($initializer); ++ $this->assertInstanceOf('Predis\Connection\Cluster\PredisCluster', $initializer(array())); ++ } ++ ++ /** ++ * @group disconnected ++ * @dataProvider provideRedisClusterStrings ++ */ ++ public function testClusterStringRedisBuildsRedisCluster(string $value): void ++ { ++ $option = new Cluster(); ++ ++ $factory = $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock(); ++ $crc16 = $this->getMockBuilder('Predis\Cluster\Hash\HashGeneratorInterface')->getMock(); ++ $options = $this->getOptionsMock(array('connections' => $factory, 'crc16' => $crc16)); ++ ++ $initializer = $option->filter($options, $value); ++ ++ $this->assertIsCallable($initializer); ++ $this->assertInstanceOf('Predis\Connection\Cluster\RedisCluster', $initializer(array())); ++ } ++ ++ public function provideRedisClusterStrings(): array ++ { ++ return array( ++ array('redis'), ++ array('redis-cluster'), ++ ); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testClusterRejectsUnknownString(): void ++ { ++ $this->expectException('InvalidArgumentException'); ++ ++ $option = new Cluster(); ++ $options = $this->getOptionsMock(); ++ ++ $option->filter($options, 'unknown'); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testClusterRejectsNonStringNonCallableValue(): void ++ { ++ $this->expectException('InvalidArgumentException'); ++ ++ $option = new Cluster(); ++ $options = $this->getOptionsMock(); ++ ++ $option->filter($options, true); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testClusterCallableInitializerSupportsAutoAggregation(): void ++ { ++ $option = new Cluster(); ++ ++ $factory = $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock(); ++ $createdNode = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); ++ $factory ++ ->expects($this->once()) ++ ->method('create') ++ ->with('tcp://127.0.0.1:6379') ++ ->willReturn($createdNode); ++ ++ $options = $this->getOptionsMock(array('connections' => $factory)); ++ ++ $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); ++ $connection ++ ->expects($this->once()) ++ ->method('add') ++ ->with($createdNode); ++ ++ $received = null; ++ $initializer = $option->filter($options, function ($parameters, $opts, $opt) use ($connection, &$received) { ++ $received = func_get_args(); ++ ++ return $connection; ++ }); ++ ++ $initializer(array('tcp://127.0.0.1:6379'), true); ++ ++ $this->assertCount(3, $received); ++ $this->assertInstanceOf('Predis\Configuration\OptionsInterface', $received[1]); ++ $this->assertInstanceOf('Predis\Configuration\OptionInterface', $received[2]); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testReplicationDefaultInitializerBuildsMasterSlave(): void ++ { ++ $option = new Replication(); ++ $options = $this->getOptionsMock(); ++ ++ $initializer = $option->getDefault($options); ++ ++ $this->assertIsCallable($initializer); ++ $this->assertInstanceOf( ++ 'Predis\Connection\Replication\MasterSlaveReplication', ++ $initializer(array()) ++ ); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testReplicationStringPredisBuildsMasterSlave(): void ++ { ++ $option = new Replication(); ++ $options = $this->getOptionsMock(); ++ ++ $initializer = $option->filter($options, 'predis'); ++ ++ $this->assertIsCallable($initializer); ++ $this->assertInstanceOf( ++ 'Predis\Connection\Replication\MasterSlaveReplication', ++ $initializer(array()) ++ ); ++ } ++ ++ /** ++ * @group disconnected ++ * @dataProvider provideSentinelStrings ++ */ ++ public function testReplicationStringSentinelBuildsSentinelReplication(string $value): void ++ { ++ $option = new Replication(); ++ ++ $factory = $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock(); ++ $options = $this->getOptionsMock(array('connections' => $factory, 'service' => 'mymaster')); ++ ++ $initializer = $option->filter($options, $value); ++ ++ $this->assertIsCallable($initializer); ++ $this->assertInstanceOf( ++ 'Predis\Connection\Replication\SentinelReplication', ++ $initializer(array()) ++ ); ++ } ++ ++ public function provideSentinelStrings(): array ++ { ++ return array( ++ array('sentinel'), ++ array('redis-sentinel'), ++ ); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testReplicationRejectsUnknownString(): void ++ { ++ $this->expectException('InvalidArgumentException'); ++ ++ $option = new Replication(); ++ $options = $this->getOptionsMock(); ++ ++ $option->filter($options, 'unknown'); ++ } ++ ++ /** ++ * @group disconnected ++ */ ++ public function testReplicationRejectsNonStringNonCallableValue(): void ++ { ++ $this->expectException('InvalidArgumentException'); ++ ++ $option = new Replication(); ++ $options = $this->getOptionsMock(); ++ ++ $option->filter($options, 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,20 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++vendor/bin/phpunit --no-coverage \ ++ tests/Predis/Configuration/OptionsTest.php \ ++ tests/Predis/Configuration/Option/ConnectionsTest.php \ ++ tests/Predis/Connection/FactoryTest.php ++ ++ ++vendor/bin/phpunit --no-coverage \ ++ tests/Predis/Configuration/Option/AggregateInitializerContractTest.php diff --git a/tasks/format-code-task-002312/tests/test.sh b/tasks/format-code-task-002312/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..92ec13f7415b0ec13ee234590893f75664317073 --- /dev/null +++ b/tasks/format-code-task-002312/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/Predis/Configuration/Option/AggregateInitializerContractTest.php +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002312/tests/test_command.sh b/tasks/format-code-task-002312/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002312/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002315/environment/Dockerfile b/tasks/format-code-task-002315/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d485ba8daea6b2a09764d3151db8e14da3ca0aef --- /dev/null +++ b/tasks/format-code-task-002315/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:60650ed1353767e94cea16642605f45c3a73e4f5973454f7c958d736d6782731 diff --git a/tasks/format-code-task-002315/environment/setup/files/blocklist b/tasks/format-code-task-002315/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002315/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002315/environment/setup/setup.sh b/tasks/format-code-task-002315/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002315/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002315/tests/test.patch b/tasks/format-code-task-002315/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..395f040867bdf2f5f27c998facc8a43bedcba99c --- /dev/null +++ b/tasks/format-code-task-002315/tests/test.patch @@ -0,0 +1,71 @@ +diff --git a/test/js/conditionals.test.js b/test/js/conditionals.test.js +index f0b3ef2..c926491 100644 +--- a/test/js/conditionals.test.js ++++ b/test/js/conditionals.test.js +@@ -219,6 +219,44 @@ describe("conditionals", () => { + }); + }); + ++ describe("ternaries with not operator", () => { ++ test("ternary with not in truthy stays", () => ++ expect("a ? not(b) : c").toMatchFormat()); ++ ++ test("ternary with not in falsy stays", () => ++ expect("a ? b : not(c)").toMatchFormat()); ++ ++ test("ternary with not in both stays", () => ++ expect("a ? not(b) : not(c)").toMatchFormat()); ++ ++ test("if/else with not transforms to ternary with parens", () => { ++ const content = ruby(` ++ if a ++ not(b) ++ else ++ c ++ end ++ `); ++ ++ return expect(content).toChangeFormat("a ? not(b) : c"); ++ }); ++ ++ test("unless/else with not transforms to ternary with parens", () => { ++ const content = ruby(` ++ unless a ++ not(b) ++ else ++ c ++ end ++ `); ++ ++ return expect(content).toChangeFormat("a ? c : not(b)"); ++ }); ++ ++ test("standalone not as if modifier stays without parens", () => ++ expect("b if not a").toMatchFormat()); ++ }); ++ + describe("if/elsif/else chains", () => { + test("basic", () => { + const content = ruby(` +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..123c01f +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["node_modules/.bin/jest test/js/conditionals.test.js -t \"ternaries with not operator\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++node_modules/.bin/jest test/js/conditionals.test.js -t "ternaries with not operator" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002315/tests/test.sh b/tasks/format-code-task-002315/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8b12ce0dcd5afec04d8c3205779161619405d1ce --- /dev/null +++ b/tasks/format-code-task-002315/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/js/conditionals.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-002315/tests/test_command.sh b/tasks/format-code-task-002315/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002315/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002323/environment/Dockerfile b/tasks/format-code-task-002323/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..bdcd59d87603594f7efa886cb0655d31cc03f897 --- /dev/null +++ b/tasks/format-code-task-002323/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e916549ebc988aff2a3b5e9c93772dc485c08c5bb5f76b68dad07c7bccc244a2 diff --git a/tasks/format-code-task-002323/environment/setup/files/blocklist b/tasks/format-code-task-002323/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002323/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002323/environment/setup/setup.sh b/tasks/format-code-task-002323/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002323/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002323/tests/test.patch b/tasks/format-code-task-002323/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c8e82da1ec74b2d566af3e36ed8e27f7a975bbe8 --- /dev/null +++ b/tasks/format-code-task-002323/tests/test.patch @@ -0,0 +1,102 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..d882a143e +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest tests_integration/__tests__/yaml-quote-mixed.js"] ++} +diff --git a/tests_integration/__tests__/yaml-quote-mixed.js b/tests_integration/__tests__/yaml-quote-mixed.js +new file mode 100644 +index 000000000..c416b00f0 +--- /dev/null ++++ b/tests_integration/__tests__/yaml-quote-mixed.js +@@ -0,0 +1,74 @@ ++"use strict"; ++ ++const prettier = require("prettier/local"); ++const yaml = require("js-yaml"); ++ ++function format(src, opts) { ++ return prettier.format(src, Object.assign({ parser: "yaml" }, opts || {})); ++} ++ ++ ++ ++ ++ ++ ++ ++ ++test("yaml quoteDouble with mixed quotes (issue case) produces valid YAML for the original value", () => { ++ ++ const input = '"\'a\\"b"\n'; ++ const output = format(input); ++ expect(yaml.safeLoad(output)).toBe('\'a"b'); ++}); ++ ++test("yaml quoteDouble with mixed quotes (multiple singles) produces valid YAML for the original value", () => { ++ ++ const input = '"\'\\"\'"\n'; ++ const output = format(input); ++ expect(yaml.safeLoad(output)).toBe('\'"\''); ++}); ++ ++test("yaml quoteDouble re-formatting the issue input is idempotent and stays valid YAML", () => { ++ const input = '"\'a\\"b"\n'; ++ const once = format(input); ++ ++ expect(format(once)).toBe(once); ++ ++ expect(yaml.safeLoad(once)).toBe('\'a"b'); ++}); ++ ++test("yaml quoteDouble with only double quotes is wrapped in single quotes (preservation)", () => { ++ ++ const input = '"only\\"quotes"\n'; ++ expect(format(input)).toBe("'only\"quotes'\n"); ++}); ++ ++test("yaml quoteDouble with only a single quote stays double-quoted (preservation)", () => { ++ ++ const input = "\"a'b\"\n"; ++ expect(format(input)).toBe("\"a'b\"\n"); ++}); ++ ++test("yaml quoteDouble plain ASCII content stays double-quoted (preservation)", () => { ++ const input = '"hello"\n'; ++ expect(format(input)).toBe('"hello"\n'); ++}); ++ ++test("yaml quoteSingle with only a single quote converts to double-quoted (preservation)", () => { ++ ++ const input = "'a''b'\n"; ++ expect(format(input)).toBe("\"a'b\"\n"); ++}); ++ ++ ++ ++ ++ ++ ++ ++test("yaml quoteSingle with mixed quotes preserves the original string value", () => { ++ ++ const input = "'a\"''b'\n"; ++ const output = format(input); ++ expect(yaml.safeLoad(output)).toBe('a"\'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 ++npx jest tests_integration/__tests__/yaml-quote-mixed.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002323/tests/test.sh b/tasks/format-code-task-002323/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b55dcbd3cf9060288d7057a379abd67bc1127530 --- /dev/null +++ b/tasks/format-code-task-002323/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/__tests__/yaml-quote-mixed.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-002323/tests/test_command.sh b/tasks/format-code-task-002323/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002323/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002324/environment/Dockerfile b/tasks/format-code-task-002324/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..21f58da84fd30d0c3dbd5b412f355069e9ff7448 --- /dev/null +++ b/tasks/format-code-task-002324/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6d0656563fa9270307bf7d9a3aee6edf71eca0a3ba683caee42050ec7f8b3deb diff --git a/tasks/format-code-task-002324/environment/setup/files/blocklist b/tasks/format-code-task-002324/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002324/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002324/environment/setup/setup.sh b/tasks/format-code-task-002324/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002324/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002324/tests/test.patch b/tasks/format-code-task-002324/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..16fd5bcf4171a82b48efd42e0e8400c962a27301 --- /dev/null +++ b/tasks/format-code-task-002324/tests/test.patch @@ -0,0 +1,90 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..2cb91e224 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["npx jest tests_integration/__tests__/comment-block-preserve-first-line.js"] ++} +diff --git a/tests_integration/__tests__/comment-block-preserve-first-line.js b/tests_integration/__tests__/comment-block-preserve-first-line.js +new file mode 100644 +index 000000000..82d723fd4 +--- /dev/null ++++ b/tests_integration/__tests__/comment-block-preserve-first-line.js +@@ -0,0 +1,62 @@ ++"use strict"; ++ ++const prettier = require("prettier/local"); ++ ++ ++ ++ ++test("preserves /*! at start of block comment (exact issue reproduction)", () => { ++ const input = `/*! ++ * Extracted from vue codebase ++ * https://github.com/vuejs/vue/blob/cfd73c2386623341fdbb3ac636c4baf84ea89c2c/src/compiler/parser/html-parser.js ++ * HTML Parser By John Resig (ejohn.org) ++ * Modified by Juriy "kangax" Zaytsev ++ * Original code by Erik Arvidsson, Mozilla Public License ++ * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js ++ */ ++`; ++ const output = prettier.format(input, { parser: "babylon" }); ++ expect(output).toBe(input); ++ ++ expect(output).not.toMatch(/\/\* !/); ++}); ++ ++test("preserves /*! with simple jsdoc-like body", () => { ++ const input = `/*!\n * Foo\n */\n`; ++ expect(prettier.format(input, { parser: "babylon" })).toBe(input); ++}); ++ ++test("preserves /*? (non-! non-* non-space first char) at start of block comment", () => { ++ ++ const input = `/*?\n * Foo\n */\n`; ++ expect(prettier.format(input, { parser: "babylon" })).toBe(input); ++}); ++ ++test("preserves /*@ at start of block comment", () => { ++ const input = `/*@preserve\n * Foo\n */\n`; ++ expect(prettier.format(input, { parser: "babylon" })).toBe(input); ++}); ++ ++test("preserves /*! when input has indented inner lines", () => { ++ ++ ++ const input = ` /*!\n * Foo\n */\n let x = 1;\n`; ++ const output = prettier.format(input, { parser: "babylon" }); ++ expect(output).toMatch(/^\/\*!/m); ++ expect(output).not.toMatch(/\/\* !/); ++}); ++ ++test("preserves /* (empty first line) indentable jsdoc comment", () => { ++ const input = `/*\n * Foo\n */\n`; ++ expect(prettier.format(input, { parser: "babylon" })).toBe(input); ++}); ++ ++test("preserves /** (double-star) jsdoc comment", () => { ++ const input = `/**\n * Foo\n */\n`; ++ expect(prettier.format(input, { parser: "babylon" })).toBe(input); ++}); ++ ++test("preserves /* X (text starting with non-! non-* non-whitespace) on same line as opener", () => { ++ const input = `/* @ts-ignore\n * Foo\n */\n`; ++ expect(prettier.format(input, { parser: "babylon" })).toBe(input); ++}); +diff --git 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 tests_integration/__tests__/comment-block-preserve-first-line.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002324/tests/test.sh b/tasks/format-code-task-002324/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4c813fe13fe3306bc0bf73b76596e94ad0dc7c7d --- /dev/null +++ b/tasks/format-code-task-002324/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/__tests__/comment-block-preserve-first-line.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-002324/tests/test_command.sh b/tasks/format-code-task-002324/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002324/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002341/environment/Dockerfile b/tasks/format-code-task-002341/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..75f006d7d108597f4539e8971a4152b95e493043 --- /dev/null +++ b/tasks/format-code-task-002341/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4414b975dbfa80d6c1c7a53040a91fa6d885695bf9ce5eef340d2325209235e7 diff --git a/tasks/format-code-task-002341/environment/setup/files/blocklist b/tasks/format-code-task-002341/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002341/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002341/environment/setup/setup.sh b/tasks/format-code-task-002341/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002341/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002341/tests/test.patch b/tasks/format-code-task-002341/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..7b3611cdca2e94805dd0f449aac0da6001a7d72e --- /dev/null +++ b/tasks/format-code-task-002341/tests/test.patch @@ -0,0 +1,49 @@ +diff --git a/tests/test_agent.py b/tests/test_agent.py +index 7ad538eba27..0cd211123e1 100644 +--- a/tests/test_agent.py ++++ b/tests/test_agent.py +@@ -221,6 +221,24 @@ def test_agentset_get_attribute(): + with pytest.raises(AttributeError): + agentset.get("non_existing_attribute") + ++ model = Model() ++ agents = [] ++ for i in range(10): ++ agent = TestAgent(model.next_id(), model) ++ agent.i = i**2 ++ agents.append(agent) ++ agentset = AgentSet(agents, model) ++ ++ values = agentset.get(["unique_id", "i"]) ++ ++ for value, agent in zip(values, agents): ++ ( ++ unique_id, ++ i, ++ ) = value ++ assert agent.unique_id == unique_id ++ assert agent.i == i ++ + + class OtherAgentType(Agent): + def get_unique_identifier(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+3S3wqCMBTHca99ivMCmtNmjyP+I4P8Q67At2/ahRGUN0pE38/Fdjgb7MBvfnY9 ++nYukbG47ZyuBddB62q3XfaqVDoPwECkdKSdQKrYt0ZtN9OTam/Qi4lza1ny6t3T+o/w5f1P2Jsnb ++uk6bwu+r9d5YzD/Wc/5jX+1jpRwJ1hvhvT/PPy9kCj4rC7cbTNU2kXi12NI2ZVz6x8dIj2Vj/G4Q ++7+Z+e2gAAAAAAAAAAAAAAAAAkzvkD4DmACgAAA== +diff --git 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-002341/tests/test.sh b/tasks/format-code-task-002341/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..3823d9a6356a80c7ba1a82632869aa866acdc170 --- /dev/null +++ b/tasks/format-code-task-002341/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_agent.py +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002341/tests/test_command.sh b/tasks/format-code-task-002341/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002341/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002346/environment/Dockerfile b/tasks/format-code-task-002346/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3466380e1bf6323a90e244e226019b3fc36a7429 --- /dev/null +++ b/tasks/format-code-task-002346/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:740c3d38db75ed2b974e8fdb8200c7c7e0027c2bacc1444fddb63bb8e941e313 diff --git a/tasks/format-code-task-002346/environment/setup/files/blocklist b/tasks/format-code-task-002346/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002346/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002346/environment/setup/setup.sh b/tasks/format-code-task-002346/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002346/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002346/tests/test.patch b/tasks/format-code-task-002346/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..04a3a8099f5492671d38a67e8b19e51b3d7bf99e --- /dev/null +++ b/tasks/format-code-task-002346/tests/test.patch @@ -0,0 +1,596 @@ +diff --git a/pkg/abstract_custom_metrics_test.go b/pkg/abstract_custom_metrics_test.go +new file mode 100644 +index 0000000..b4c9751 +--- /dev/null ++++ b/pkg/abstract_custom_metrics_test.go +@@ -0,0 +1,330 @@ ++package exporter ++ ++import ( ++ "context" ++ "fmt" ++ "sort" ++ "strings" ++ "sync" ++ "testing" ++ "time" ++ ++ "github.com/aws/aws-sdk-go/aws" ++ "github.com/aws/aws-sdk-go/aws/request" ++ "github.com/aws/aws-sdk-go/service/apigateway/apigatewayiface" ++ "github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface" ++ "github.com/aws/aws-sdk-go/service/cloudwatch" ++ "github.com/aws/aws-sdk-go/service/cloudwatch/cloudwatchiface" ++ "github.com/aws/aws-sdk-go/service/databasemigrationservice/databasemigrationserviceiface" ++ "github.com/aws/aws-sdk-go/service/ec2/ec2iface" ++ "github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi/resourcegroupstaggingapiiface" ++ "github.com/aws/aws-sdk-go/service/sts" ++ "github.com/aws/aws-sdk-go/service/sts/stsiface" ++ "github.com/prometheus/client_golang/prometheus" ++ dto "github.com/prometheus/client_model/go" ++) ++ ++type customMetricsTestLogger struct{} ++ ++func (customMetricsTestLogger) Info(string, ...interface{}) {} ++func (customMetricsTestLogger) Debug(string, ...interface{}) {} ++func (customMetricsTestLogger) Error(error, string, ...interface{}) {} ++func (customMetricsTestLogger) Warn(string, ...interface{}) {} ++func (l customMetricsTestLogger) With(...interface{}) Logger { return l } ++func (customMetricsTestLogger) IsDebugEnabled() bool { return false } ++ ++type customMetricsFakeCache struct { ++ account string ++ metricsByName map[string][]*cloudwatch.Metric ++ datapointsByName map[string][]*cloudwatch.Datapoint ++ ++ mu sync.Mutex ++ statisticsQueries map[string]struct{} ++ listQueries []string ++} ++ ++func newCustomMetricsFakeCache() *customMetricsFakeCache { ++ return &customMetricsFakeCache{ ++ account: "123456789012", ++ metricsByName: map[string][]*cloudwatch.Metric{ ++ "queue_depth_total": { ++ { ++ MetricName: aws.String("queue_depth_total"), ++ Namespace: aws.String("Team/AppTelemetry"), ++ Dimensions: []*cloudwatch.Dimension{ ++ {Name: aws.String("NodeId"), Value: aws.String("node-17")}, ++ {Name: aws.String("MountPath"), Value: aws.String("/var/lib/app")}, ++ }, ++ }, ++ }, ++ "request_latency_ms": { ++ { ++ MetricName: aws.String("request_latency_ms"), ++ Namespace: aws.String("Team/AppTelemetry"), ++ Dimensions: []*cloudwatch.Dimension{ ++ {Name: aws.String("WorkerPool"), Value: aws.String("blue-workers")}, ++ }, ++ }, ++ }, ++ "empty_signal_count": { ++ { ++ MetricName: aws.String("empty_signal_count"), ++ Namespace: aws.String("Team/AppTelemetry"), ++ Dimensions: []*cloudwatch.Dimension{ ++ {Name: aws.String("NodeId"), Value: aws.String("node-empty")}, ++ }, ++ }, ++ }, ++ }, ++ datapointsByName: map[string][]*cloudwatch.Datapoint{ ++ "queue_depth_total": { ++ {Timestamp: aws.Time(time.Now()), Sum: aws.Float64(41)}, ++ }, ++ "request_latency_ms": { ++ {Timestamp: aws.Time(time.Now()), Sum: aws.Float64(250)}, ++ }, ++ "empty_signal_count": nil, ++ }, ++ statisticsQueries: map[string]struct{}{}, ++ } ++} ++ ++func (c *customMetricsFakeCache) GetSTS(Role) stsiface.STSAPI { ++ return customMetricsFakeSTS{account: c.account} ++} ++ ++func (c *customMetricsFakeCache) GetCloudwatch(region *string, role Role) cloudwatchiface.CloudWatchAPI { ++ return &customMetricsFakeCloudWatch{cache: c, region: *region, role: role} ++} ++ ++func (c *customMetricsFakeCache) GetTagging(*string, Role) resourcegroupstaggingapiiface.ResourceGroupsTaggingAPIAPI { ++ return nil ++} ++ ++func (c *customMetricsFakeCache) GetASG(*string, Role) autoscalingiface.AutoScalingAPI { ++ return nil ++} ++ ++func (c *customMetricsFakeCache) GetEC2(*string, Role) ec2iface.EC2API { ++ return nil ++} ++ ++func (c *customMetricsFakeCache) GetDMS(*string, Role) databasemigrationserviceiface.DatabaseMigrationServiceAPI { ++ return nil ++} ++ ++func (c *customMetricsFakeCache) GetAPIGateway(*string, Role) apigatewayiface.APIGatewayAPI { ++ return nil ++} ++ ++func (c *customMetricsFakeCache) Refresh() {} ++ ++func (c *customMetricsFakeCache) Clear() {} ++ ++func (c *customMetricsFakeCache) observedStatisticsQueryKeys() []string { ++ c.mu.Lock() ++ defer c.mu.Unlock() ++ keys := make([]string, 0, len(c.statisticsQueries)) ++ for key := range c.statisticsQueries { ++ keys = append(keys, key) ++ } ++ sort.Strings(keys) ++ return keys ++} ++ ++type customMetricsFakeSTS struct { ++ stsiface.STSAPI ++ account string ++} ++ ++func (s customMetricsFakeSTS) GetCallerIdentityWithContext(aws.Context, *sts.GetCallerIdentityInput, ...request.Option) (*sts.GetCallerIdentityOutput, error) { ++ return &sts.GetCallerIdentityOutput{Account: aws.String(s.account)}, nil ++} ++ ++type customMetricsFakeCloudWatch struct { ++ cloudwatchiface.CloudWatchAPI ++ cache *customMetricsFakeCache ++ region string ++ role Role ++} ++ ++func (cw *customMetricsFakeCloudWatch) ListMetricsPagesWithContext(_ aws.Context, input *cloudwatch.ListMetricsInput, fn func(*cloudwatch.ListMetricsOutput, bool) bool, _ ...request.Option) error { ++ namespace := aws.StringValue(input.Namespace) ++ metricName := aws.StringValue(input.MetricName) ++ cw.cache.mu.Lock() ++ cw.cache.listQueries = append(cw.cache.listQueries, namespace+"/"+metricName) ++ cw.cache.mu.Unlock() ++ ++ metrics := cw.cache.metricsByName[metricName] ++ filtered := make([]*cloudwatch.Metric, 0, len(metrics)) ++ for _, metric := range metrics { ++ if aws.StringValue(metric.Namespace) == namespace { ++ filtered = append(filtered, metric) ++ } ++ } ++ fn(&cloudwatch.ListMetricsOutput{Metrics: filtered}, true) ++ return nil ++} ++ ++func (cw *customMetricsFakeCloudWatch) GetMetricStatisticsWithContext(_ aws.Context, input *cloudwatch.GetMetricStatisticsInput, _ ...request.Option) (*cloudwatch.GetMetricStatisticsOutput, error) { ++ metricName := aws.StringValue(input.MetricName) ++ key := fmt.Sprintf("%s|%s|%s|%s", cw.role.RoleArn, cw.role.ExternalID, cw.region, metricName) ++ ++ cw.cache.mu.Lock() ++ cw.cache.statisticsQueries[key] = struct{}{} ++ cw.cache.mu.Unlock() ++ ++ return &cloudwatch.GetMetricStatisticsOutput{ ++ Datapoints: cw.cache.datapointsByName[metricName], ++ }, nil ++} ++ ++func customMetricScrapeConfig(metrics ...string) ScrapeConf { ++ customMetrics := make([]*Metric, 0, len(metrics)) ++ for _, name := range metrics { ++ customMetrics = append(customMetrics, &Metric{ ++ Name: name, ++ Statistics: []string{"Sum"}, ++ Period: 60, ++ Length: 301, ++ Delay: 60, ++ NilToZero: aws.Bool(false), ++ AddCloudwatchTimestamp: aws.Bool(false), ++ }) ++ } ++ return ScrapeConf{ ++ CustomMetrics: []*CustomMetrics{ ++ { ++ Name: "custom-team-telemetry", ++ Namespace: "Team/AppTelemetry", ++ Regions: []string{"us-west-2"}, ++ Roles: []Role{{}}, ++ Metrics: customMetrics, ++ }, ++ }, ++ } ++} ++ ++func gatherCustomMetricFamilies(t *testing.T, config ScrapeConf, cache *customMetricsFakeCache) []*dto.MetricFamily { ++ t.Helper() ++ registry := prometheus.NewRegistry() ++ UpdateMetrics( ++ context.Background(), ++ config, ++ registry, ++ 500, ++ false, ++ make(chan struct{}, 10), ++ make(chan struct{}, 10), ++ cache, ++ map[string]LabelSet{}, ++ customMetricsTestLogger{}, ++ ) ++ families, err := registry.Gather() ++ if err != nil { ++ t.Fatalf("gather prometheus metrics: %v", err) ++ } ++ return families ++} ++ ++func findMetricFamilyByNameParts(families []*dto.MetricFamily, parts ...string) *dto.MetricFamily { ++ for _, family := range families { ++ name := strings.ToLower(family.GetName()) ++ matched := true ++ for _, part := range parts { ++ if !strings.Contains(name, strings.ToLower(part)) { ++ matched = false ++ break ++ } ++ } ++ if matched { ++ return family ++ } ++ } ++ return nil ++} ++ ++func requireMetricFamilyValue(t *testing.T, family *dto.MetricFamily, want float64) { ++ t.Helper() ++ if family == nil { ++ t.Fatalf("metric family not found") ++ } ++ for _, metric := range family.GetMetric() { ++ if metric.GetGauge().GetValue() == want { ++ return ++ } ++ } ++ t.Fatalf("metric family %q did not contain value %v", family.GetName(), want) ++} ++ ++func requireMetricLabelValue(t *testing.T, family *dto.MetricFamily, labelNamePart, wantValue string) { ++ t.Helper() ++ if family == nil { ++ t.Fatalf("metric family not found") ++ } ++ for _, metric := range family.GetMetric() { ++ for _, label := range metric.GetLabel() { ++ if strings.Contains(strings.ToLower(label.GetName()), strings.ToLower(labelNamePart)) && label.GetValue() == wantValue { ++ return ++ } ++ } ++ } ++ t.Fatalf("metric family %q did not contain label matching %q=%q", family.GetName(), labelNamePart, wantValue) ++} ++ ++func TestScrapeCustomMetricsExportsConfiguredNamespaceMetrics(t *testing.T) { ++ cache := newCustomMetricsFakeCache() ++ families := gatherCustomMetricFamilies(t, customMetricScrapeConfig("queue_depth_total", "request_latency_ms"), cache) ++ ++ queueDepth := findMetricFamilyByNameParts(families, "team_apptelemetry", "queue_depth_total", "sum") ++ requestLatency := findMetricFamilyByNameParts(families, "team_apptelemetry", "request_latency_ms", "sum") ++ ++ requireMetricFamilyValue(t, queueDepth, 41) ++ requireMetricFamilyValue(t, requestLatency, 250) ++} ++ ++func TestScrapeCustomMetricsPreservesCloudWatchDimensionsAsLabels(t *testing.T) { ++ cache := newCustomMetricsFakeCache() ++ families := gatherCustomMetricFamilies(t, customMetricScrapeConfig("queue_depth_total"), cache) ++ queueDepth := findMetricFamilyByNameParts(families, "team_apptelemetry", "queue_depth_total", "sum") ++ ++ requireMetricLabelValue(t, queueDepth, "node", "node-17") ++ requireMetricLabelValue(t, queueDepth, "mount", "/var/lib/app") ++} ++ ++func TestScrapeCustomMetricsSkipsMetricsWithNoDatapoints(t *testing.T) { ++ cache := newCustomMetricsFakeCache() ++ families := gatherCustomMetricFamilies(t, customMetricScrapeConfig("queue_depth_total", "empty_signal_count"), cache) ++ ++ requireMetricFamilyValue(t, findMetricFamilyByNameParts(families, "team_apptelemetry", "queue_depth_total", "sum"), 41) ++ if got := findMetricFamilyByNameParts(families, "team_apptelemetry", "empty_signal_count"); got != nil { ++ t.Fatalf("metric with no datapoints was exported as %q", got.GetName()) ++ } ++} ++ ++func TestCustomMetricsUseEachConfiguredRoleRegion(t *testing.T) { ++ cache := newCustomMetricsFakeCache() ++ config := customMetricScrapeConfig("queue_depth_total") ++ config.CustomMetrics[0].Regions = []string{"us-west-2", "eu-central-1"} ++ config.CustomMetrics[0].Roles = []Role{ ++ {RoleArn: "arn:aws:iam::111111111111:role/custom-a"}, ++ {RoleArn: "arn:aws:iam::222222222222:role/custom-b", ExternalID: "external-b"}, ++ } ++ ++ gatherCustomMetricFamilies(t, config, cache) ++ ++ got := cache.observedStatisticsQueryKeys() ++ want := []string{ ++ "arn:aws:iam::111111111111:role/custom-a||eu-central-1|queue_depth_total", ++ "arn:aws:iam::111111111111:role/custom-a||us-west-2|queue_depth_total", ++ "arn:aws:iam::222222222222:role/custom-b|external-b|eu-central-1|queue_depth_total", ++ "arn:aws:iam::222222222222:role/custom-b|external-b|us-west-2|queue_depth_total", ++ } ++ if strings.Join(got, "\n") != strings.Join(want, "\n") { ++ t.Fatalf("custom metric CloudWatch queries:\n got: %v\nwant: %v", got, want) ++ } ++} ++ ++var _ SessionCache = (*customMetricsFakeCache)(nil) ++var _ cloudwatchiface.CloudWatchAPI = (*customMetricsFakeCloudWatch)(nil) ++var _ stsiface.STSAPI = customMetricsFakeSTS{} +diff --git a/pkg/config_custom_metrics_test.go b/pkg/config_custom_metrics_test.go +new file mode 100644 +index 0000000..fab864c +--- /dev/null ++++ b/pkg/config_custom_metrics_test.go +@@ -0,0 +1,189 @@ ++package exporter ++ ++import ( ++ "os" ++ "path/filepath" ++ "strings" ++ "testing" ++) ++ ++func writeCustomMetricsConfigForTest(t *testing.T, body string) string { ++ t.Helper() ++ path := filepath.Join(t.TempDir(), "custom-metrics.yml") ++ if err := os.WriteFile(path, []byte(body), 0600); err != nil { ++ t.Fatalf("write temp config: %v", err) ++ } ++ return path ++} ++ ++func requireBoolPtrValue(t *testing.T, got *bool, want bool, field string) { ++ t.Helper() ++ if got == nil { ++ t.Fatalf("%s = nil, want %v", field, want) ++ } ++ if *got != want { ++ t.Fatalf("%s = %v, want %v", field, *got, want) ++ } ++} ++ ++func TestCustomMetricsConfigLoadAndDefaults(t *testing.T) { ++ configPath := writeCustomMetricsConfigForTest(t, ` ++apiVersion: v1alpha1 ++customMetrics: ++ - name: arbitraryCustomJob ++ namespace: Team/AppTelemetry ++ regions: ++ - us-west-2 ++ - eu-central-1 ++ statistics: ++ - Sum ++ - SampleCount ++ nilToZero: false ++ period: 120 ++ length: 600 ++ delay: 60 ++ addCloudwatchTimestamp: false ++ metrics: ++ - name: queue_depth_total ++ - name: request_latency_ms ++ statistics: ++ - p99 ++ period: 240 ++`) ++ ++ config := ScrapeConf{} ++ if err := config.Load(&configPath); err != nil { ++ t.Fatalf("Load(customMetrics config) returned error: %v", err) ++ } ++ ++ if len(config.CustomMetrics) != 1 { ++ t.Fatalf("len(CustomMetrics) = %d, want 1", len(config.CustomMetrics)) ++ } ++ ++ job := config.CustomMetrics[0] ++ if job.Name != "arbitraryCustomJob" { ++ t.Fatalf("job.Name = %q", job.Name) ++ } ++ if job.Namespace != "Team/AppTelemetry" { ++ t.Fatalf("job.Namespace = %q", job.Namespace) ++ } ++ if strings.Join(job.Regions, ",") != "us-west-2,eu-central-1" { ++ t.Fatalf("job.Regions = %#v", job.Regions) ++ } ++ if len(job.Roles) != 1 || job.Roles[0] != (Role{}) { ++ t.Fatalf("omitted customMetrics roles should default to current identity, got %#v", job.Roles) ++ } ++ if len(job.Metrics) != 2 { ++ t.Fatalf("len(job.Metrics) = %d, want 2", len(job.Metrics)) ++ } ++ ++ firstMetric := job.Metrics[0] ++ if firstMetric.Name != "queue_depth_total" { ++ t.Fatalf("first metric name = %q", firstMetric.Name) ++ } ++ if strings.Join(firstMetric.Statistics, ",") != "Sum,SampleCount" { ++ t.Fatalf("first metric statistics = %#v", firstMetric.Statistics) ++ } ++ if firstMetric.Period != 120 || firstMetric.Length != 600 || firstMetric.Delay != 60 { ++ t.Fatalf("first metric defaults period/length/delay = %d/%d/%d", firstMetric.Period, firstMetric.Length, firstMetric.Delay) ++ } ++ requireBoolPtrValue(t, firstMetric.NilToZero, false, "firstMetric.NilToZero") ++ requireBoolPtrValue(t, firstMetric.AddCloudwatchTimestamp, false, "firstMetric.AddCloudwatchTimestamp") ++ ++ secondMetric := job.Metrics[1] ++ if secondMetric.Name != "request_latency_ms" { ++ t.Fatalf("second metric name = %q", secondMetric.Name) ++ } ++ if strings.Join(secondMetric.Statistics, ",") != "p99" { ++ t.Fatalf("explicit metric statistics should be preserved, got %#v", secondMetric.Statistics) ++ } ++ if secondMetric.Period != 240 { ++ t.Fatalf("explicit metric period should be preserved, got %d", secondMetric.Period) ++ } ++ if secondMetric.Length != 600 || secondMetric.Delay != 60 { ++ t.Fatalf("second metric inherited length/delay = %d/%d, want 600/60", secondMetric.Length, secondMetric.Delay) ++ } ++} ++ ++func TestCustomMetricsOnlyConfigIsNonEmpty(t *testing.T) { ++ configPath := writeCustomMetricsConfigForTest(t, ` ++apiVersion: v1alpha1 ++customMetrics: ++ - name: onlyCustomJob ++ namespace: Example/OnlyCustom ++ regions: ++ - ap-southeast-2 ++ metrics: ++ - name: workers_busy ++ statistics: ++ - Sum ++ period: 301 ++ length: 301 ++`) ++ ++ config := ScrapeConf{} ++ if err := config.Load(&configPath); err != nil { ++ t.Fatalf("custom-only config should load and validate: %v", err) ++ } ++ if len(config.CustomMetrics) != 1 { ++ t.Fatalf("len(CustomMetrics) = %d, want 1", len(config.CustomMetrics)) ++ } ++ if len(config.CustomMetrics[0].Roles) != 1 || config.CustomMetrics[0].Roles[0] != (Role{}) { ++ t.Fatalf("custom-only config with omitted roles should use current identity, got %#v", config.CustomMetrics[0].Roles) ++ } ++} ++ ++func TestCustomMetricsConfigRejectsMissingRequiredFields(t *testing.T) { ++ testCases := []struct { ++ name string ++ yaml string ++ }{ ++ { ++ name: "missing name", ++ yaml: ` ++apiVersion: v1alpha1 ++customMetrics: ++ - namespace: Example/MissingName ++ regions: [us-east-2] ++ metrics: ++ - name: packets_seen ++ statistics: [Sum] ++`, ++ }, ++ { ++ name: "missing namespace", ++ yaml: ` ++apiVersion: v1alpha1 ++customMetrics: ++ - name: missingNamespaceJob ++ regions: [us-east-2] ++ metrics: ++ - name: packets_seen ++ statistics: [Sum] ++`, ++ }, ++ { ++ name: "missing regions", ++ yaml: ` ++apiVersion: v1alpha1 ++customMetrics: ++ - name: missingRegionsJob ++ namespace: Example/MissingRegions ++ metrics: ++ - name: packets_seen ++ statistics: [Sum] ++`, ++ }, ++ } ++ ++ for _, tc := range testCases { ++ t.Run(tc.name, func(t *testing.T) { ++ configPath := writeCustomMetricsConfigForTest(t, tc.yaml) ++ config := ScrapeConf{} ++ err := config.Load(&configPath) ++ if err == nil { ++ t.Fatalf("Load() succeeded, want validation error") ++ } ++ }) ++ } ++} +diff --git a/pkg/docs_custom_metrics_test.go b/pkg/docs_custom_metrics_test.go +new file mode 100644 +index 0000000..3ee1977 +--- /dev/null ++++ b/pkg/docs_custom_metrics_test.go +@@ -0,0 +1,34 @@ ++package exporter ++ ++import ( ++ "os" ++ "strings" ++ "testing" ++) ++ ++func TestReadmeDocumentsCustomMetricsConfiguration(t *testing.T) { ++ body, err := os.ReadFile("../README.md") ++ if err != nil { ++ t.Fatalf("read README.md: %v", err) ++ } ++ readme := string(body) ++ lowerReadme := strings.ToLower(readme) ++ ++ if !strings.Contains(readme, "customMetrics") { ++ t.Fatalf("README.md should mention customMetrics for custom metrics configuration") ++ } ++ ++ requiredConcepts := []string{ ++ "custom", ++ "namespace", ++ "regions", ++ "roles", ++ "metrics", ++ "dimensions", ++ } ++ for _, want := range requiredConcepts { ++ if !strings.Contains(lowerReadme, want) { ++ t.Fatalf("README.md should document custom metrics concept %q", want) ++ } ++ } ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,20 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++ ++ ++case "${1:-}" in ++ base) ++ go test ./pkg/ -run "^(TestConfLoad|TestBadConfigs|TestNewSessionCache)$" -v ++ ;; ++ new) ++ go test ./pkg/ -run "^(TestCustomMetricsConfigLoadAndDefaults|TestCustomMetricsOnlyConfigIsNonEmpty|TestCustomMetricsConfigRejectsMissingRequiredFields|TestReadmeDocumentsCustomMetricsConfiguration|TestScrapeCustomMetricsExportsConfiguredNamespaceMetrics|TestScrapeCustomMetricsPreservesCloudWatchDimensionsAsLabels|TestScrapeCustomMetricsSkipsMetricsWithNoDatapoints|TestCustomMetricsUseEachConfiguredRoleRegion)$" -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002346/tests/test.sh b/tasks/format-code-task-002346/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..eca6fac41e3747f69161e46354e5751cd0e9eb01 --- /dev/null +++ b/tasks/format-code-task-002346/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/abstract_custom_metrics_test.go +pkg/config_custom_metrics_test.go +pkg/docs_custom_metrics_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-002346/tests/test_command.sh b/tasks/format-code-task-002346/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002346/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-002347/environment/Dockerfile b/tasks/format-code-task-002347/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..004d61a5a2d6f78135419d53b3cdf48a9838642d --- /dev/null +++ b/tasks/format-code-task-002347/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:81054ed072f3fac831002d6e05dfcf65505ea771f7e86477712f3901398d69e1 diff --git a/tasks/format-code-task-002347/environment/setup/files/blocklist b/tasks/format-code-task-002347/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002347/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002347/environment/setup/setup.sh b/tasks/format-code-task-002347/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002347/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002347/tests/test.patch b/tasks/format-code-task-002347/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c8bdd97d50ce1929fb211a717c5b917cf3dd62d3 --- /dev/null +++ b/tasks/format-code-task-002347/tests/test.patch @@ -0,0 +1,281 @@ +diff --git a/pkg/prometheus/promcfg_jobname_test.go b/pkg/prometheus/promcfg_jobname_test.go +new file mode 100644 +index 000000000..696420741 +--- /dev/null ++++ b/pkg/prometheus/promcfg_jobname_test.go +@@ -0,0 +1,253 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++package prometheus ++ ++import ( ++ "testing" ++ ++ monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" ++ "github.com/prometheus-operator/prometheus-operator/pkg/assets" ++ yaml "gopkg.in/yaml.v2" ++ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ++) ++ ++ ++ ++type parsedConfig struct { ++ ScrapeConfigs []map[string]interface{} `yaml:"scrape_configs"` ++} ++ ++func extractJobNames(t *testing.T, cfg []byte) []string { ++ t.Helper() ++ var pc parsedConfig ++ if err := yaml.Unmarshal(cfg, &pc); err != nil { ++ t.Fatalf("could not unmarshal generated config: %v\nconfig:\n%s", err, string(cfg)) ++ } ++ names := make([]string, 0, len(pc.ScrapeConfigs)) ++ for _, sc := range pc.ScrapeConfigs { ++ v, ok := sc["job_name"] ++ if !ok { ++ continue ++ } ++ s, ok := v.(string) ++ if !ok { ++ t.Fatalf("job_name is not a string: %v", v) ++ } ++ names = append(names, s) ++ } ++ return names ++} ++ ++func assertJobNamesUnique(t *testing.T, names []string) { ++ t.Helper() ++ seen := map[string]int{} ++ for _, n := range names { ++ seen[n]++ ++ } ++ for n, c := range seen { ++ if c > 1 { ++ t.Fatalf("job_name %q appeared %d times — would crash Prometheus with duplicate-job-name error: %v", n, c, names) ++ } ++ } ++} ++ ++func generateJobNameTestConfig( ++ t *testing.T, ++ sMons map[string]*monitoringv1.ServiceMonitor, ++ pMons map[string]*monitoringv1.PodMonitor, ++ probes map[string]*monitoringv1.Probe, ++) []byte { ++ t.Helper() ++ cg := &configGenerator{} ++ cfg, err := cg.generateConfig( ++ &monitoringv1.Prometheus{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: "test", ++ Namespace: "default", ++ }, ++ Spec: monitoringv1.PrometheusSpec{}, ++ }, ++ sMons, ++ pMons, ++ probes, ++ map[string]assets.BasicAuthCredentials{}, ++ map[string]assets.BearerToken{}, ++ nil, nil, nil, nil, ++ ) ++ if err != nil { ++ t.Fatalf("generateConfig failed: %v", err) ++ } ++ return cfg ++} ++ ++func newServiceMonitor(namespace, name string) *monitoringv1.ServiceMonitor { ++ return &monitoringv1.ServiceMonitor{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: name, ++ Namespace: namespace, ++ }, ++ Spec: monitoringv1.ServiceMonitorSpec{ ++ Endpoints: []monitoringv1.Endpoint{ ++ { ++ Port: "web", ++ Interval: "30s", ++ }, ++ }, ++ }, ++ } ++} ++ ++func newPodMonitor(namespace, name string) *monitoringv1.PodMonitor { ++ return &monitoringv1.PodMonitor{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: name, ++ Namespace: namespace, ++ }, ++ Spec: monitoringv1.PodMonitorSpec{ ++ PodMetricsEndpoints: []monitoringv1.PodMetricsEndpoint{ ++ { ++ Port: "web", ++ Interval: "30s", ++ }, ++ }, ++ }, ++ } ++} ++ ++func newProbe(namespace, name string) *monitoringv1.Probe { ++ return &monitoringv1.Probe{ ++ ObjectMeta: metav1.ObjectMeta{ ++ Name: name, ++ Namespace: namespace, ++ }, ++ Spec: monitoringv1.ProbeSpec{ ++ ProberSpec: monitoringv1.ProberSpec{ ++ Scheme: "http", ++ URL: "blackbox.exporter.io", ++ Path: "/probe", ++ }, ++ Module: "http_2xx", ++ Targets: monitoringv1.ProbeTargets{ ++ StaticConfig: &monitoringv1.ProbeTargetStaticConfig{ ++ Targets: []string{"prometheus.io"}, ++ }, ++ }, ++ }, ++ } ++} ++ ++ ++func TestServiceMonitorJobNameHasServiceMonitorPrefix(t *testing.T) { ++ cfg := generateJobNameTestConfig(t, ++ map[string]*monitoringv1.ServiceMonitor{ ++ "sm": newServiceMonitor("default", "duplicate"), ++ }, nil, nil) ++ ++ names := extractJobNames(t, cfg) ++ if len(names) != 1 { ++ t.Fatalf("expected 1 job_name, got %d: %v\ncfg:\n%s", len(names), names, string(cfg)) ++ } ++ if names[0] == "" { ++ t.Fatalf("job_name must be non-empty") ++ } ++} ++ ++ ++func TestPodMonitorJobNameHasPodMonitorPrefix(t *testing.T) { ++ cfg := generateJobNameTestConfig(t, nil, ++ map[string]*monitoringv1.PodMonitor{ ++ "pm": newPodMonitor("default", "duplicate"), ++ }, nil) ++ ++ names := extractJobNames(t, cfg) ++ if len(names) != 1 { ++ t.Fatalf("expected 1 job_name, got %d: %v\ncfg:\n%s", len(names), names, string(cfg)) ++ } ++ if names[0] == "" { ++ t.Fatalf("job_name must be non-empty") ++ } ++} ++ ++ ++func TestProbeJobNameHasProbePrefix(t *testing.T) { ++ cfg := generateJobNameTestConfig(t, nil, nil, ++ map[string]*monitoringv1.Probe{ ++ "probe": newProbe("default", "duplicate"), ++ }) ++ ++ names := extractJobNames(t, cfg) ++ if len(names) != 1 { ++ t.Fatalf("expected 1 job_name, got %d: %v\ncfg:\n%s", len(names), names, string(cfg)) ++ } ++ if names[0] == "" { ++ t.Fatalf("job_name must be non-empty") ++ } ++} ++ ++ ++ ++ ++ ++func TestPodMonitorAndServiceMonitorSameNameProduceDistinctJobNames(t *testing.T) { ++ cfg := generateJobNameTestConfig(t, ++ map[string]*monitoringv1.ServiceMonitor{ ++ "x": newServiceMonitor("default", "testmonitor"), ++ }, ++ map[string]*monitoringv1.PodMonitor{ ++ "x": newPodMonitor("default", "testmonitor"), ++ }, nil) ++ ++ names := extractJobNames(t, cfg) ++ if len(names) != 2 { ++ t.Fatalf("expected 2 job_names, got %d: %v\ncfg:\n%s", len(names), names, string(cfg)) ++ } ++ assertJobNamesUnique(t, names) ++} ++ ++ ++ ++ ++ ++func TestAllThreeMonitorTypesWithSameNameProduceDistinctPrefixedJobNames(t *testing.T) { ++ cfg := generateJobNameTestConfig(t, ++ map[string]*monitoringv1.ServiceMonitor{ ++ "x": newServiceMonitor("ns1", "shared"), ++ }, ++ map[string]*monitoringv1.PodMonitor{ ++ "x": newPodMonitor("ns1", "shared"), ++ }, ++ map[string]*monitoringv1.Probe{ ++ "x": newProbe("ns1", "shared"), ++ }) ++ ++ names := extractJobNames(t, cfg) ++ if len(names) != 3 { ++ t.Fatalf("expected 3 job_names, got %d: %v\ncfg:\n%s", len(names), names, string(cfg)) ++ } ++ assertJobNamesUnique(t, names) ++} ++ ++ ++ ++func TestServiceMonitorMultipleEndpointsKeepIndexedSuffix(t *testing.T) { ++ sm := newServiceMonitor("default", "testservicemonitor1") ++ sm.Spec.Endpoints = []monitoringv1.Endpoint{ ++ {Port: "web", Interval: "30s"}, ++ {Port: "metrics", Interval: "30s"}, ++ } ++ cfg := generateJobNameTestConfig(t, ++ map[string]*monitoringv1.ServiceMonitor{"sm": sm}, ++ nil, nil) ++ ++ names := extractJobNames(t, cfg) ++ if len(names) != 2 { ++ t.Fatalf("expected 2 job_names, got %d: %v", len(names), names) ++ } ++ assertJobNamesUnique(t, names) ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..af0246355 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["go test ./pkg/prometheus/ -run 'TestServiceMonitorJobNameHasServiceMonitorPrefix|TestPodMonitorJobNameHasPodMonitorPrefix|TestProbeJobNameHasProbePrefix|TestPodMonitorAndServiceMonitorSameNameProduceDistinctJobNames|TestAllThreeMonitorTypesWithSameNameProduceDistinctPrefixedJobNames|TestServiceMonitorMultipleEndpointsKeepIndexedSuffix' -count=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,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++go test ./pkg/prometheus/ -run 'TestServiceMonitorJobNameHasServiceMonitorPrefix|TestPodMonitorJobNameHasPodMonitorPrefix|TestProbeJobNameHasProbePrefix|TestPodMonitorAndServiceMonitorSameNameProduceDistinctJobNames|TestAllThreeMonitorTypesWithSameNameProduceDistinctPrefixedJobNames|TestServiceMonitorMultipleEndpointsKeepIndexedSuffix' -count=1 ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002347/tests/test.sh b/tasks/format-code-task-002347/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ea9822b1635196da7e6117b5e5f3d0f86c60856 --- /dev/null +++ b/tasks/format-code-task-002347/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/prometheus/promcfg_jobname_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-002347/tests/test_command.sh b/tasks/format-code-task-002347/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002347/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002378/environment/Dockerfile b/tasks/format-code-task-002378/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e810ec2d69f1a0198693e0f92b79196ca6e916de --- /dev/null +++ b/tasks/format-code-task-002378/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:77848082bda26a43fadcd04ac93d6dc03be559d150d2ea817d21c80d135693b5 diff --git a/tasks/format-code-task-002378/environment/setup/files/blocklist b/tasks/format-code-task-002378/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002378/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002378/environment/setup/setup.sh b/tasks/format-code-task-002378/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002378/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002378/tests/test.patch b/tasks/format-code-task-002378/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..aee8d3b08a654b06d94b9ca58195a3e3a0685562 --- /dev/null +++ b/tasks/format-code-task-002378/tests/test.patch @@ -0,0 +1,103 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..40d8e67 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest tests/test_source_cli.py -k \"abbrev or full_args_still_work\" -v"] ++} +diff --git a/tests/test_source_cli.py b/tests/test_source_cli.py +index 9cc374b..4e5a731 100644 +--- a/tests/test_source_cli.py ++++ b/tests/test_source_cli.py +@@ -2223,3 +2223,76 @@ def test_cli_mutually_exclusive_group_exceptions(): + + with pytest.raises(ValueError, match='mutually exclusive arguments must be optional'): + CliApp.run(SettingsInvalidReqCircleReqField) ++ ++ ++def test_cli_arg_abbrev_disabled_with_ignore_unknown_args(): ++ ++ ++ ++ class MySettings(BaseSettings): ++ model_config = SettingsConfigDict( ++ cli_parse_args=['--f=/some/path'], cli_ignore_unknown_args=True ++ ) ++ ++ freeze: bool = False ++ ++ settings = MySettings() ++ assert settings.freeze is False ++ ++ ++def test_cli_arg_abbrev_disabled_ambiguous_with_ignore_unknown_args(): ++ ++ ++ ++ ++ class MySettings(BaseSettings): ++ model_config = SettingsConfigDict( ++ cli_parse_args=['--f=/some/path'], cli_ignore_unknown_args=True ++ ) ++ ++ freeze: bool = False ++ freeze_also: bool = False ++ ++ settings = MySettings() ++ assert settings.freeze is False ++ assert settings.freeze_also is False ++ ++ ++def test_cli_arg_abbrev_disabled_via_init_kwargs(): ++ ++ ++ ++ class MySettings(BaseSettings): ++ freeze: bool = False ++ ++ settings = MySettings( ++ _cli_parse_args=['--f=/some/path'], _cli_ignore_unknown_args=True ++ ) ++ assert settings.freeze is False ++ ++ ++def test_cli_full_args_still_work_when_abbrev_disabled(): ++ ++ ++ class MySettings(BaseSettings): ++ model_config = SettingsConfigDict(cli_parse_args=['--freeze=true']) ++ ++ freeze: bool = False ++ ++ settings = MySettings() ++ assert settings.freeze is True ++ ++ ++def test_cli_arg_abbrev_disabled_default_no_ignore_unknown_args(): ++ ++ ++ ++ ++ ++ class MySettings(BaseSettings): ++ model_config = SettingsConfigDict(cli_parse_args=['--f=/some/path']) ++ ++ freeze: bool = False ++ ++ with pytest.raises(SystemExit): ++ MySettings() +diff --git 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_source_cli.py -k "abbrev or full_args_still_work" -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002378/tests/test.sh b/tasks/format-code-task-002378/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8585fb0369a2f1c09d2306c8831dd74fa5846b24 --- /dev/null +++ b/tasks/format-code-task-002378/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_source_cli.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-002378/tests/test_command.sh b/tasks/format-code-task-002378/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002378/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002379/environment/Dockerfile b/tasks/format-code-task-002379/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..5def870bfe75cc4c2c3252055bac42f7232f1af0 --- /dev/null +++ b/tasks/format-code-task-002379/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6df32b9f1efca2f38b2324202ff80ce3f5984a4f01d7ed8b167fede51d1fa486 diff --git a/tasks/format-code-task-002379/environment/setup/files/blocklist b/tasks/format-code-task-002379/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002379/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002379/environment/setup/setup.sh b/tasks/format-code-task-002379/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002379/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002379/tests/test.patch b/tasks/format-code-task-002379/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..473295edab4e76be8a3baa287c5e0d5de3153fbe --- /dev/null +++ b/tasks/format-code-task-002379/tests/test.patch @@ -0,0 +1,170 @@ +diff --git a/pydicom/tests/test_dataset.py b/pydicom/tests/test_dataset.py +index 19909325bd..5dce97ca7d 100644 +--- a/pydicom/tests/test_dataset.py ++++ b/pydicom/tests/test_dataset.py +@@ -1,6 +1,7 @@ + # Copyright 2008-2018 pydicom authors. See LICENSE file for details. + """Unit tests for the pydicom.dataset module.""" + ++import warnings + import pytest + + import pydicom +@@ -8,6 +9,7 @@ from pydicom import compat + from pydicom.data import get_testdata_files + from pydicom.dataelem import DataElement, RawDataElement + from pydicom.dataset import Dataset, FileDataset, validate_file_meta ++from pydicom.encaps import encapsulate + from pydicom import dcmread + from pydicom.filebase import DicomBytesIO + from pydicom.overlay_data_handlers import numpy_handler as NP_HANDLER +@@ -17,6 +19,8 @@ from pydicom.tag import Tag + from pydicom.uid import ( + ImplicitVRLittleEndian, + ExplicitVRBigEndian, ++ JPEGBaseline, ++ UID, + PYDICOM_IMPLEMENTATION_UID + ) + +@@ -1122,6 +1126,105 @@ class TestDataset(object): + ds.file_meta.ImplementationClassUID = '1.4' + ds.save_as(fp, write_like_original=False) + ++ def _save_dataset_to_stream(self, ds): ++ fp = DicomBytesIO() ++ ds.save_as(fp) ++ assert fp.tell() > 0 ++ return fp ++ ++ def _save_dataset_without_output_assertion(self, ds): ++ fp = DicomBytesIO() ++ ds.save_as(fp) ++ return fp ++ ++ def test_save_as_warns_for_unencapsulated_pixel_data(self): ++ """Saving compressed transfer syntax with raw Pixel Data warns.""" ++ ds = Dataset() ++ ds.is_little_endian = True ++ ds.is_implicit_VR = False ++ ds.file_meta = Dataset() ++ ds.file_meta.TransferSyntaxUID = JPEGBaseline ++ ds.PixelData = b'\x00\x01\x02\x03\x04\x05\x06' ++ ds['PixelData'].VR = 'OB' ++ ++ with warnings.catch_warnings(record=True) as caught: ++ warnings.simplefilter("always") ++ self._save_dataset_to_stream(ds) ++ ++ assert caught ++ ++ def test_save_as_warning_not_limited_to_one_compressed_uid(self): ++ """The warning applies to standard compressed UIDs generally.""" ++ ds = Dataset() ++ ds.is_little_endian = True ++ ds.is_implicit_VR = False ++ ds.file_meta = Dataset() ++ ds.file_meta.TransferSyntaxUID = UID("1.2.840.10008.1.2.4.91") ++ ds.PixelData = b'\x10\x20\x30\x40\x50\x60' ++ ds['PixelData'].VR = 'OB' ++ ++ with warnings.catch_warnings(record=True) as caught: ++ warnings.simplefilter("always") ++ self._save_dataset_to_stream(ds) ++ ++ assert caught ++ ++ def test_save_as_encapsulated_pixel_data_no_new_warning(self): ++ """Encapsulated Pixel Data should not trigger the new warning.""" ++ ds = Dataset() ++ ds.is_little_endian = True ++ ds.is_implicit_VR = False ++ ds.file_meta = Dataset() ++ ds.file_meta.TransferSyntaxUID = JPEGBaseline ++ ds.PixelData = encapsulate([b'\x00\x01\x02\x03\x04\x05\x06']) ++ ds['PixelData'].VR = 'OB' ++ ++ with warnings.catch_warnings(record=True) as caught: ++ warnings.simplefilter("always") ++ self._save_dataset_to_stream(ds) ++ ++ assert not caught ++ ++ def test_save_as_missing_pixel_or_transfer_syntax_no_new_warning(self): ++ """Missing Pixel Data or transfer syntax metadata should not warn.""" ++ compressed_no_pixel = Dataset() ++ compressed_no_pixel.is_little_endian = True ++ compressed_no_pixel.is_implicit_VR = False ++ compressed_no_pixel.file_meta = Dataset() ++ compressed_no_pixel.file_meta.TransferSyntaxUID = JPEGBaseline ++ ++ no_transfer_syntax = Dataset() ++ no_transfer_syntax.is_little_endian = True ++ no_transfer_syntax.is_implicit_VR = False ++ no_transfer_syntax.file_meta = Dataset() ++ ++ no_file_meta = Dataset() ++ no_file_meta.is_little_endian = True ++ no_file_meta.is_implicit_VR = False ++ ++ for ds in (compressed_no_pixel, no_transfer_syntax, no_file_meta): ++ with warnings.catch_warnings(record=True) as caught: ++ warnings.simplefilter("always") ++ self._save_dataset_without_output_assertion(ds) ++ ++ assert not caught ++ ++ def test_save_as_private_transfer_syntax_no_new_warning(self): ++ """Private transfer syntaxes should not be treated as compressed.""" ++ ds = Dataset() ++ ds.is_little_endian = True ++ ds.is_implicit_VR = False ++ ds.file_meta = Dataset() ++ ds.file_meta.TransferSyntaxUID = UID("1.2.3.4.5.6") ++ ds.PixelData = b'\x00\x01\x02\x03\x04\x05\x06' ++ ds['PixelData'].VR = 'OB' ++ ++ with warnings.catch_warnings(record=True) as caught: ++ warnings.simplefilter("always") ++ self._save_dataset_to_stream(ds) ++ ++ assert not caught ++ + def test_with(self): + """Test Dataset.__enter__ and __exit__.""" + test_file = get_testdata_files('CT_small.dcm')[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,30 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++set +u ++source /root/.venv/bin/activate ++set -u ++ ++pip install -e . --no-input -q 2>/dev/null ++ ++NEW_TESTS=( ++ "pydicom/tests/test_dataset.py::TestDataset::test_save_as_warns_for_unencapsulated_pixel_data" ++ "pydicom/tests/test_dataset.py::TestDataset::test_save_as_warning_not_limited_to_one_compressed_uid" ++ "pydicom/tests/test_dataset.py::TestDataset::test_save_as_encapsulated_pixel_data_no_new_warning" ++ "pydicom/tests/test_dataset.py::TestDataset::test_save_as_missing_pixel_or_transfer_syntax_no_new_warning" ++ "pydicom/tests/test_dataset.py::TestDataset::test_save_as_private_transfer_syntax_no_new_warning" ++) ++ ++case "${1:-}" in ++ base) ++ python -m pytest pydicom/tests/test_dataset.py -v -k "not test_save_as_warns_for_unencapsulated_pixel_data and not test_save_as_warning_not_limited_to_one_compressed_uid and not test_save_as_encapsulated_pixel_data_no_new_warning and not test_save_as_missing_pixel_or_transfer_syntax_no_new_warning and not test_save_as_private_transfer_syntax_no_new_warning" ++ ;; ++ new) ++ python -m pytest -v "${NEW_TESTS[@]}" ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002379/tests/test.sh b/tasks/format-code-task-002379/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9a79bade1dc7646fda839cf1183ae995f027865a --- /dev/null +++ b/tasks/format-code-task-002379/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' +pydicom/tests/test_dataset.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-002379/tests/test_command.sh b/tasks/format-code-task-002379/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002379/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-002510/environment/Dockerfile b/tasks/format-code-task-002510/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..60a5df757e703eab35b4fee980d1417517a61e44 --- /dev/null +++ b/tasks/format-code-task-002510/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:56706eeaa820e7a4092ca8578945c75a222bd3c2cfc60da1b568cd540695d35a diff --git a/tasks/format-code-task-002510/environment/setup/files/blocklist b/tasks/format-code-task-002510/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002510/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002510/environment/setup/setup.sh b/tasks/format-code-task-002510/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002510/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002510/tests/test.patch b/tasks/format-code-task-002510/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..705bb6fd4fd4a806afe2eb28d9516b2000167b86 --- /dev/null +++ b/tasks/format-code-task-002510/tests/test.patch @@ -0,0 +1,83 @@ +diff --git a/test/github.js b/test/github.js +index 2c8b7793..71fbf6b9 100644 +--- a/test/github.js ++++ b/test/github.js +@@ -99,6 +99,33 @@ test('should create a pre-release and draft release notes', async t => { + exec.restore(); + }); + ++test('should create auto generated release notes', async t => { ++ const options = { ++ git, ++ github: { ++ pushRepo, ++ tokenRef, ++ release: true, ++ releaseName: 'Release ${tagName}', ++ autoGenerate: true ++ } ++ }; ++ const github = factory(GitHub, { options }); ++ const exec = sinon.stub(github.shell, 'exec').callThrough(); ++ exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('2.0.1'); ++ ++ interceptAuthentication(); ++ interceptCollaborator(); ++ interceptCreate({ body: { tag_name: '2.0.2', name: 'Release 2.0.2', draft: false, prerelease: false, generate_release_notes: true } }); ++ ++ await runTasks(github); ++ ++ const { isReleased, releaseUrl } = github.getContext(); ++ t.true(isReleased); ++ t.is(releaseUrl, 'https://github.com/user/repo/releases/tag/2.0.2'); ++ exec.restore(); ++}); ++ + test('should update release and upload assets', async t => { + const asset = 'file1'; + const options = { +diff --git a/test/stub/github.js b/test/stub/github.js +index 9f8c6752..72f507e9 100644 +--- a/test/stub/github.js ++++ b/test/stub/github.js +@@ -40,10 +40,10 @@ const interceptCreate = ({ + host = 'github.com', + owner = 'user', + project = 'repo', +- body: { tag_name, name = '', body = null, prerelease = false, draft = false } ++ body: { tag_name, name = '', body = null, prerelease = false, draft = false, generate_release_notes } + } = {}) => + nock(api) +- .post(`/repos/${owner}/${project}/releases`, { tag_name, name, body, prerelease, draft }) ++ .post(`/repos/${owner}/${project}/releases`, { tag_name, name, body, prerelease, draft, generate_release_notes }) + .reply(() => { + const id = 1; + const responseBody = { +@@ -53,6 +53,7 @@ const interceptCreate = ({ + body, + prerelease, + draft, ++ generate_release_notes, + upload_url: `https://uploads.${host}/repos/${owner}/${project}/releases/${id}/assets{?name,label}`, + html_url: `https://${host}/${owner}/${project}/releases/tag/${tag_name}` + }; +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RWwqDMBCFYZ9dRVbgtdHliDeqpWoxUbr8RkuxFFpflFL6fy+TmQQycJxsqM9F ++Uraja+3FM2Ip52q81vnsy8ALIhl6vnnn+5EZCbnbRk8GpdNeCKvvOv3p3dr9j3KW/HWpdJJ3TZO2 ++haOq7f5YzT+KH/kHcTzlf4jC0BLediu89+f554WYg8/Kwm4vV5GOqZh691jrasick7q3Sg/ZMrO/ ++vTYAAAAAAAAAAAAAAAAA4wZLl5h/ACgAAA== +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,6 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed || exit 1 ++base64 -d mimo_build_env.tar.gz.b64 | tar -xzf - -C /testbed || exit 1 ++exec bash -lc 'cd /testbed && bash -eo pipefail /testbed/.build_env/test_command.sh' diff --git a/tasks/format-code-task-002510/tests/test.sh b/tasks/format-code-task-002510/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0e4bce2dfb9a16ab7a6394cc86f404fd6974290f --- /dev/null +++ b/tasks/format-code-task-002510/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/github.js +test/stub/github.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-002510/tests/test_command.sh b/tasks/format-code-task-002510/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002510/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002511/environment/Dockerfile b/tasks/format-code-task-002511/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a32cf66640ff9f20ef84f00a07321b7a7d9e8293 --- /dev/null +++ b/tasks/format-code-task-002511/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f213d7a5de93b4861529b2ce25e9af309a462d5ed4c3a9d73612e250cdc73222 diff --git a/tasks/format-code-task-002511/environment/setup/files/blocklist b/tasks/format-code-task-002511/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002511/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002511/environment/setup/setup.sh b/tasks/format-code-task-002511/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002511/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002511/tests/test.patch b/tasks/format-code-task-002511/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c4a77d666f49511c698102d0feedced7a796fe91 --- /dev/null +++ b/tasks/format-code-task-002511/tests/test.patch @@ -0,0 +1,183 @@ +diff --git a/tests/apps/python/test_django.py b/tests/apps/python/test_django.py +index 4981e98..fd1ad32 100644 +--- a/tests/apps/python/test_django.py ++++ b/tests/apps/python/test_django.py +@@ -18,7 +18,7 @@ def test_migrate(self, run, backup): + no_new_migrations=dict( + side_effect=('', ), + expected_commands=[ +- mock.call.run('docker run --rm --tty image:tag python manage.py showmigrations --plan | egrep "^\[ \]"; true', quiet=True), ++ mock.call.run('docker run --rm --tty --interactive image:tag python manage.py showmigrations --plan | egrep "^\[ \]"; true', quiet=True), + ], + kwargs=dict(), + container_class_vars=dict(name='name'), +@@ -29,8 +29,8 @@ def test_migrate(self, run, backup): + '', + ), + expected_commands=[ +- mock.call.run('docker run --rm --tty image:tag python manage.py showmigrations --plan | egrep "^\[ \]"; true', quiet=True), +- mock.call.run('docker run --rm --tty image:tag python manage.py migrate --noinput', quiet=False), ++ mock.call.run('docker run --rm --tty --interactive image:tag python manage.py showmigrations --plan | egrep "^\[ \]"; true', quiet=True), ++ mock.call.run('docker run --rm --tty --interactive image:tag python manage.py migrate --noinput', quiet=False), + ], + kwargs=dict(), + container_class_vars=dict(name='name'), +@@ -41,8 +41,8 @@ def test_migrate(self, run, backup): + '', + ), + expected_commands=[ +- mock.call.run('docker run --rm --tty registry/image:foo python manage.py showmigrations --plan | egrep "^\[ \]"; true', quiet=True), +- mock.call.run('docker run --rm --tty registry/image:foo python manage.py migrate --noinput', quiet=False), ++ mock.call.run('docker run --rm --tty --interactive registry/image:foo python manage.py showmigrations --plan | egrep "^\[ \]"; true', quiet=True), ++ mock.call.run('docker run --rm --tty --interactive registry/image:foo python manage.py migrate --noinput', quiet=False), + ], + kwargs=dict(tag='foo', registry='registry'), + container_class_vars=dict(name='name'), +@@ -53,8 +53,8 @@ def test_migrate(self, run, backup): + '', + ), + expected_commands=[ +- mock.call.run('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty image:tag python manage.py showmigrations --plan | egrep "^\[ \]"; true', quiet=True), +- mock.call.run('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty image:tag python manage.py migrate --noinput', quiet=False), ++ mock.call.run('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty --interactive image:tag python manage.py showmigrations --plan | egrep "^\[ \]"; true', quiet=True), ++ mock.call.run('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty --interactive image:tag python manage.py migrate --noinput', quiet=False), + ], + kwargs=dict(), + container_class_vars=dict( +@@ -114,9 +114,9 @@ def test_migrate_back(self): + ), + expected_commands=[ + mock.call('docker inspect --type container name'), +- mock.call('docker run --rm --tty current_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), ++ mock.call('docker run --rm --tty --interactive current_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), + mock.call('docker inspect --type container name_backup'), +- mock.call('docker run --rm --tty backup_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), ++ mock.call('docker run --rm --tty --interactive backup_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), + ], + ), + no_migrations=dict( +@@ -128,9 +128,9 @@ def test_migrate_back(self): + ), + expected_commands=[ + mock.call('docker inspect --type container name'), +- mock.call('docker run --rm --tty current_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), ++ mock.call('docker run --rm --tty --interactive current_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), + mock.call('docker inspect --type container name_backup'), +- mock.call('docker run --rm --tty backup_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), ++ mock.call('docker run --rm --tty --interactive backup_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), + ], + ), + regular=dict( +@@ -157,12 +157,12 @@ def test_migrate_back(self): + ), + expected_commands=[ + mock.call('docker inspect --type container name'), +- mock.call('docker run --rm --tty current_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), ++ mock.call('docker run --rm --tty --interactive current_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), + mock.call('docker inspect --type container name_backup'), +- mock.call('docker run --rm --tty backup_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), +- mock.call('docker run --rm --tty current_image_id python manage.py migrate --no-input app3 zero', quiet=False), +- mock.call('docker run --rm --tty current_image_id python manage.py migrate --no-input app2 0001_initial', quiet=False), +- mock.call('docker run --rm --tty current_image_id python manage.py migrate --no-input app0 zero', quiet=False), ++ mock.call('docker run --rm --tty --interactive backup_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), ++ mock.call('docker run --rm --tty --interactive current_image_id python manage.py migrate --no-input app3 zero', quiet=False), ++ mock.call('docker run --rm --tty --interactive current_image_id python manage.py migrate --no-input app2 0001_initial', quiet=False), ++ mock.call('docker run --rm --tty --interactive current_image_id python manage.py migrate --no-input app0 zero', quiet=False), + ], + ), + with_container_custom_options=dict( +@@ -189,12 +189,12 @@ def test_migrate_back(self): + ), + expected_commands=[ + mock.call('docker inspect --type container name'), +- mock.call('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty current_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), ++ mock.call('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty --interactive current_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), + mock.call('docker inspect --type container name_backup'), +- mock.call('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty backup_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), +- mock.call('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty current_image_id python manage.py migrate --no-input app3 zero', quiet=False), +- mock.call('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty current_image_id python manage.py migrate --no-input app2 0001_initial', quiet=False), +- mock.call('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty current_image_id python manage.py migrate --no-input app0 zero', quiet=False), ++ mock.call('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty --interactive backup_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), ++ mock.call('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty --interactive current_image_id python manage.py migrate --no-input app3 zero', quiet=False), ++ mock.call('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty --interactive current_image_id python manage.py migrate --no-input app2 0001_initial', quiet=False), ++ mock.call('docker run --user user --env env --volume volumes --link links --add-host hosts --net network --rm --tty --interactive current_image_id python manage.py migrate --no-input app0 zero', quiet=False), + ], + container_class_vars=dict( + user='user', +@@ -229,7 +229,7 @@ def test_migrate_back(self): + ), + expected_commands=[ + mock.call('docker inspect --type container name'), +- mock.call('docker run --rm --tty current_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), ++ mock.call('docker run --rm --tty --interactive current_image_id python manage.py showmigrations --plan | egrep "^\[X\]" | awk "{print \$2}"', quiet=True), + mock.call('docker inspect --type container name_backup'), + ], + ), +diff --git a/tests/test_docker.py b/tests/test_docker.py +index caff0b5..530540b 100644 +--- a/tests/test_docker.py ++++ b/tests/test_docker.py +@@ -1104,27 +1104,27 @@ def test_run(self): + cases = dict( + default=dict( + kwargs=dict(), +- expected_command='docker run --rm --tty image:latest ', ++ expected_command='docker run --rm --tty --interactive image:latest ', + ), + with_mapping_option=dict( + kwargs=dict(options=dict(ports='80:80')), +- expected_command='docker run --publish 80:80 --rm --tty image:latest ', ++ expected_command='docker run --publish 80:80 --rm --tty --interactive image:latest ', + ), + with_unknown_option=dict( + kwargs=dict(options=dict(foo='bar')), +- expected_command='docker run --rm --tty --foo bar image:latest ', ++ expected_command='docker run --rm --tty --interactive --foo bar image:latest ', + ), + with_mapping_option_deprecated=dict( + kwargs=dict(ports='80:80'), +- expected_command='docker run --publish 80:80 --rm --tty image:latest ', ++ expected_command='docker run --publish 80:80 --rm --tty --interactive image:latest ', + ), + with_unknown_option_deprecated=dict( + kwargs=dict(foo='bar'), +- expected_command='docker run --rm --tty --foo bar image:latest ', ++ expected_command='docker run --rm --tty --interactive --foo bar image:latest ', + ), + with_cmd=dict( + kwargs=dict(cmd='cmd'), +- expected_command='docker run --rm --tty image:latest cmd', ++ expected_command='docker run --rm --tty --interactive image:latest cmd', + ), + service=dict( + kwargs=dict(temporary=False), +@@ -1132,7 +1132,7 @@ def test_run(self): + ), + with_name=dict( + kwargs=dict(name='name'), +- expected_command='docker run --name name --rm --tty image:latest ', ++ expected_command='docker run --name name --rm --tty --interactive image:latest ', + ), + ) + for case, data in cases.items(): +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+3SW26EIBgFYJ5dBRtQlAouxyDSDm0VAmgyuy9qmzZN2nmZSTPp+R6AcFHC+ath ++sa9jb+aVkVups06Ivc++9/u4EbzmspOikaRuGtk8ECpudqMvlphUoJQE59Jv+y6t36nqM/9kYuq1 ++myY1j1U8Xe8fl/LnOeyP/Fve5fxbyVtC6+td4Wf/PH890j34wYxFdEvQhjLnE3tUQ7Daun7dSmOw ++M1M62VUlU/hzOrmZlhPNo3yUbk1kyvvIjrWjlMZnNT+5yp/fNxyTTr+YsE2WKy19/gTfas6rVPz1 ++UwAAAAAAAAAAAAAAAAAAAAAA3J03Mb267AAoAAA= +diff --git 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-002511/tests/test.sh b/tasks/format-code-task-002511/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e045f64b73c2b11c001e3bcbd7ac5689add09030 --- /dev/null +++ b/tasks/format-code-task-002511/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/apps/python/test_django.py +tests/test_docker.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-002511/tests/test_command.sh b/tasks/format-code-task-002511/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002511/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002516/environment/Dockerfile b/tasks/format-code-task-002516/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a9d7deb61932a9dbd4dbb1f3909033ddb57deec0 --- /dev/null +++ b/tasks/format-code-task-002516/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:cb4da1b6e9e468cb1aa32a36c73dc997b7415e83d1491ca689941436fef45afc diff --git a/tasks/format-code-task-002516/environment/setup/files/blocklist b/tasks/format-code-task-002516/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002516/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002516/environment/setup/setup.sh b/tasks/format-code-task-002516/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002516/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002516/tests/test.patch b/tasks/format-code-task-002516/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..b4176df23214585c45916a3628a73781fe865a5b --- /dev/null +++ b/tasks/format-code-task-002516/tests/test.patch @@ -0,0 +1,196 @@ +diff --git a/test/response.test.js b/test/response.test.js +index 1bbf236..ad73bd2 100644 +--- a/test/response.test.js ++++ b/test/response.test.js +@@ -1,5 +1,6 @@ + 'use strict'; + ++var http = require('http'); + var url = require('url'); + var restifyClients = require('restify-clients'); + var errs = require('restify-errors'); +@@ -574,3 +575,162 @@ test('GH-1429: setting code with res.status not respected', function (t) { + t.end(); + }); + }); ++ ++ ++ ++ ++ ++function rawGet(path, cb) { ++ var req = http.request({ ++ host: '127.0.0.1', ++ port: PORT, ++ path: path, ++ method: 'GET' ++ }, function (res) { ++ cb(null, res); ++ }); ++ req.on('error', cb); ++ req.end(); ++} ++ ++ ++test('GH-1508: redirect with object pathname only should be relative', ++ function (t) { ++ SERVER.get('/gh1508a', function (req, res, next) { ++ return res.redirect({ pathname: '/' }, next); ++ }); ++ ++ rawGet('/gh1508a', function (err, res) { ++ t.ifError(err); ++ t.equal(res.statusCode, 302); ++ ++ t.equal(res.headers.location, '/'); ++ t.end(); ++ }); ++}); ++ ++ ++test('GH-1508: redirect reload with no hostname should be relative', ++ function (t) { ++ SERVER.get('/gh1508b', function (req, res, next) { ++ res.redirect({ reload: true }, next); ++ }); ++ ++ rawGet('/gh1508b', function (err, res) { ++ t.ifError(err); ++ t.equal(res.statusCode, 302); ++ t.equal(res.headers.location, '/gh1508b'); ++ t.end(); ++ }); ++}); ++ ++ ++test('GH-1508: redirect with pathname change and no hostname should ' + ++ 'be relative', function (t) { ++ SERVER.get('/gh1508c', function (req, res, next) { ++ res.redirect({ pathname: '/foo' }, next); ++ }); ++ ++ rawGet('/gh1508c', function (err, res) { ++ t.ifError(err); ++ t.equal(res.statusCode, 302); ++ t.equal(res.headers.location, '/foo'); ++ t.end(); ++ }); ++}); ++ ++ ++test('GH-1508: redirect with query and no hostname should be relative', ++ function (t) { ++ SERVER.get('/gh1508d', function (req, res, next) { ++ res.redirect({ query: { a: 1 } }, next); ++ }); ++ ++ rawGet('/gh1508d', function (err, res) { ++ t.ifError(err); ++ t.equal(res.statusCode, 302); ++ var parsed = url.parse(res.headers.location, true); ++ ++ t.equal(parsed.protocol, null); ++ t.equal(parsed.host, null); ++ t.equal(parsed.pathname, '/gh1508d'); ++ t.deepEqual(parsed.query, { a: '1' }); ++ t.end(); ++ }); ++}); ++ ++ ++test('GH-1508: redirect with secure but no hostname should not add ' + ++ 'protocol', function (t) { ++ SERVER.get('/gh1508e', function (req, res, next) { ++ res.redirect({ pathname: '/x', secure: true }, next); ++ }); ++ ++ rawGet('/gh1508e', function (err, res) { ++ t.ifError(err); ++ t.equal(res.statusCode, 302); ++ ++ t.equal(res.headers.location, '/x'); ++ t.end(); ++ }); ++}); ++ ++ ++test('GH-1508: redirect with hostname should still include http protocol', ++ function (t) { ++ SERVER.get('/gh1508f', function (req, res, next) { ++ res.redirect({ ++ hostname: 'www.foo.com', ++ pathname: '/bar' ++ }, next); ++ }); ++ ++ rawGet('/gh1508f', function (err, res) { ++ t.ifError(err); ++ t.equal(res.statusCode, 302); ++ t.equal(res.headers.location, 'http://www.foo.com/bar'); ++ t.end(); ++ }); ++}); ++ ++ ++test('GH-1508: redirect with hostname and secure should include https', ++ function (t) { ++ SERVER.get('/gh1508g', function (req, res, next) { ++ res.redirect({ ++ hostname: 'www.foo.com', ++ pathname: '/baz', ++ secure: true ++ }, next); ++ }); ++ ++ rawGet('/gh1508g', function (err, res) { ++ t.ifError(err); ++ t.equal(res.statusCode, 302); ++ t.equal(res.headers.location, 'https://www.foo.com/baz'); ++ t.end(); ++ }); ++}); ++ ++ ++test('GH-1508: redirect with hostname and query should include both', ++ function (t) { ++ SERVER.get('/gh1508h', function (req, res, next) { ++ res.redirect({ ++ hostname: 'www.foo.com', ++ pathname: '/q', ++ query: { a: 1 } ++ }, next); ++ }); ++ ++ rawGet('/gh1508h', function (err, res) { ++ t.ifError(err); ++ t.equal(res.statusCode, 302); ++ var parsed = url.parse(res.headers.location, true); ++ t.equal(parsed.protocol, 'http:'); ++ t.equal(parsed.hostname, 'www.foo.com'); ++ t.equal(parsed.pathname, '/q'); ++ t.deepEqual(parsed.query, { a: '1' }); ++ t.end(); ++ }); ++}); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..acf99aa +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/nodeunit test/response.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_modules/.bin/nodeunit test/response.test.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002516/tests/test.sh b/tasks/format-code-task-002516/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..458e1acbee18b7bf81c9fab7d0606424794ea7e3 --- /dev/null +++ b/tasks/format-code-task-002516/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/response.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-002516/tests/test_command.sh b/tasks/format-code-task-002516/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002516/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002517/environment/Dockerfile b/tasks/format-code-task-002517/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7d283cdc88cca877a0dd7cfddb89afe82d4aa79a --- /dev/null +++ b/tasks/format-code-task-002517/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:c47c9b8687c987b101ec296e735c6979a6e70b551ac9f21fa07328a9e985df7a diff --git a/tasks/format-code-task-002517/environment/setup/files/blocklist b/tasks/format-code-task-002517/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002517/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002517/environment/setup/setup.sh b/tasks/format-code-task-002517/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002517/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002517/tests/test.patch b/tasks/format-code-task-002517/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..826f15e372191db36c72aa572f0d3afec52d60e5 --- /dev/null +++ b/tasks/format-code-task-002517/tests/test.patch @@ -0,0 +1,683 @@ +diff --git a/usercase-test-coderl/go.mod b/usercase-test-coderl/go.mod +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/go.mod +@@ -0,0 +1,24 @@ ++module usercase-test-coderl ++ ++go 1.22.0 ++ ++require ( ++ github.com/aws/aws-sdk-go-v2 v1.36.3 ++ github.com/aws/aws-sdk-go-v2/service/s3 v1.79.3 ++ github.com/reugn/go-streams v0.12.0 ++ github.com/reugn/go-streams/aws v0.0.0 ++) ++ ++require ( ++ github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 // indirect ++ github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect ++ github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect ++ github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34 // indirect ++ github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect ++ github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.1 // indirect ++ github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect ++ github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15 // indirect ++ github.com/aws/smithy-go v1.22.3 // indirect ++) ++ ++replace github.com/reugn/go-streams/aws => ../aws +diff --git a/usercase-test-coderl/go.sum b/usercase-test-coderl/go.sum +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/go.sum +@@ -0,0 +1,24 @@ ++github.com/aws/aws-sdk-go-v2 v1.36.3 h1:mJoei2CxPutQVxaATCzDUjcZEjVRdpsiiXi2o38yqWM= ++github.com/aws/aws-sdk-go-v2 v1.36.3/go.mod h1:LLXuLpgzEbD766Z5ECcRmi8AzSwfZItDtmABVkRLGzg= ++github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10 h1:zAybnyUQXIZ5mok5Jqwlf58/TFE7uvd3IAsa1aF9cXs= ++github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.10/go.mod h1:qqvMj6gHLR/EXWZw4ZbqlPbQUyenf4h82UQUlKc+l14= ++github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 h1:ZK5jHhnrioRkUNOc+hOgQKlUL5JeC3S6JgLxtQ+Rm0Q= ++github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34/go.mod h1:p4VfIceZokChbA9FzMbRGz5OV+lekcVtHlPKEO0gSZY= ++github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 h1:SZwFm17ZUNNg5Np0ioo/gq8Mn6u9w19Mri8DnJ15Jf0= ++github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34/go.mod h1:dFZsC0BLo346mvKQLWmoJxT+Sjp+qcVR1tRVHQGOH9Q= ++github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34 h1:ZNTqv4nIdE/DiBfUUfXcLZ/Spcuz+RjeziUtNJackkM= ++github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.34/go.mod h1:zf7Vcd1ViW7cPqYWEHLHJkS50X0JS2IKz9Cgaj6ugrs= ++github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 h1:eAh2A4b5IzM/lum78bZ590jy36+d/aFLgKF/4Vd1xPE= ++github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3/go.mod h1:0yKJC/kb8sAnmlYa6Zs3QVYqaC8ug2AbnNChv5Ox3uA= ++github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.1 h1:4nm2G6A4pV9rdlWzGMPv4BNtQp22v1hg3yrtkYpeLl8= ++github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.1/go.mod h1:iu6FSzgt+M2/x3Dk8zhycdIcHjEFb36IS8HVUVFoMg0= ++github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 h1:dM9/92u2F1JbDaGooxTq18wmmFzbJRfXfVfy96/1CXM= ++github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15/go.mod h1:SwFBy2vjtA0vZbjjaFtfN045boopadnoVPhu4Fv66vY= ++github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15 h1:moLQUoVq91LiqT1nbvzDukyqAlCv89ZmwaHw/ZFlFZg= ++github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.15/go.mod h1:ZH34PJUc8ApjBIfgQCFvkWcUDBtl/WTD+uiYHjd8igA= ++github.com/aws/aws-sdk-go-v2/service/s3 v1.79.3 h1:BRXS0U76Z8wfF+bnkilA2QwpIch6URlm++yPUt9QPmQ= ++github.com/aws/aws-sdk-go-v2/service/s3 v1.79.3/go.mod h1:bNXKFFyaiVvWuR6O16h/I1724+aXe/tAkA9/QS01t5k= ++github.com/aws/smithy-go v1.22.3 h1:Z//5NuZCSW6R4PhQ93hShNbyBbn8BWCmCVCt+Q8Io5k= ++github.com/aws/smithy-go v1.22.3/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI= ++github.com/reugn/go-streams v0.12.0 h1:SEfTZw5+iP0mQG0jWTxVOHMbqlbZjUB0W6dF3XbYd5Q= ++github.com/reugn/go-streams v0.12.0/go.mod h1:dnXv6QgVTW62gEpILoLHRjI95Es7ECK2/+j9h17aIN8= +diff --git a/usercase-test-coderl/s3_connector_test.go b/usercase-test-coderl/s3_connector_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/s3_connector_test.go +@@ -0,0 +1,594 @@ ++package usercase_test_coderl ++ ++import ( ++ "bytes" ++ "context" ++ "encoding/xml" ++ "fmt" ++ "io" ++ "log/slog" ++ "net/http" ++ "net/http/httptest" ++ "os" ++ "runtime" ++ "sort" ++ "strings" ++ "sync" ++ "testing" ++ "time" ++ ++ awssdk "github.com/aws/aws-sdk-go-v2/aws" ++ "github.com/aws/aws-sdk-go-v2/service/s3" ++ "github.com/reugn/go-streams" ++ connector "github.com/reugn/go-streams/aws" ++ "github.com/reugn/go-streams/flow" ++) ++ ++ ++ ++ ++ ++ ++type listBucketResult struct { ++ XMLName xml.Name `xml:"ListBucketResult"` ++ Xmlns string `xml:"xmlns,attr,omitempty"` ++ Name string `xml:"Name"` ++ Prefix string `xml:"Prefix"` ++ KeyCount int `xml:"KeyCount"` ++ MaxKeys int `xml:"MaxKeys"` ++ IsTruncated bool `xml:"IsTruncated"` ++ NextContinuationToken string `xml:"NextContinuationToken,omitempty"` ++ Contents []objectContent `xml:"Contents"` ++} ++ ++type objectContent struct { ++ Key string `xml:"Key"` ++ Size int `xml:"Size"` ++} ++ ++type fakeS3Server struct { ++ server *httptest.Server ++ mu sync.Mutex ++ objects map[string][]byte ++ putBodies map[string]string ++ listCalls []string ++ getCalls []string ++ putCalls []string ++ listPageLen int ++ getDelay time.Duration ++ putDelay time.Duration ++ activeGets int ++ maxGets int ++ activePuts int ++ maxPuts int ++} ++ ++func newFakeS3Server(initial map[string]string, listPageLen int) *fakeS3Server { ++ f := &fakeS3Server{ ++ objects: make(map[string][]byte), ++ putBodies: make(map[string]string), ++ listPageLen: listPageLen, ++ } ++ for key, value := range initial { ++ f.objects[key] = []byte(value) ++ } ++ f.server = httptest.NewServer(http.HandlerFunc(f.serveHTTP)) ++ return f ++} ++ ++func (f *fakeS3Server) close() { ++ f.server.Close() ++} ++ ++func (f *fakeS3Server) client() *s3.Client { ++ return s3.New(s3.Options{ ++ Region: "us-east-1", ++ BaseEndpoint: awssdk.String(f.server.URL), ++ UsePathStyle: true, ++ Credentials: awssdk.CredentialsProviderFunc(func(context.Context) (awssdk.Credentials, error) { ++ return awssdk.Credentials{ ++ AccessKeyID: "test-access-key", ++ SecretAccessKey: "test-secret-key", ++ SessionToken: "test-session-token", ++ Source: "usercase-test-coderl", ++ }, nil ++ }), ++ }) ++} ++ ++func (f *fakeS3Server) serveHTTP(w http.ResponseWriter, r *http.Request) { ++ key := strings.TrimPrefix(r.URL.Path, "/fixture-bucket/") ++ switch r.Method { ++ case http.MethodGet: ++ if _, ok := r.URL.Query()["list-type"]; ok { ++ f.handleList(w, r) ++ return ++ } ++ f.handleGet(w, key) ++ case http.MethodPut: ++ f.handlePut(w, r, key) ++ default: ++ http.Error(w, "unsupported method", http.StatusMethodNotAllowed) ++ } ++} ++ ++func (f *fakeS3Server) handleList(w http.ResponseWriter, r *http.Request) { ++ prefix := r.URL.Query().Get("prefix") ++ token := r.URL.Query().Get("continuation-token") ++ ++ f.mu.Lock() ++ f.listCalls = append(f.listCalls, prefix+"|"+token) ++ keys := make([]string, 0, len(f.objects)) ++ for key := range f.objects { ++ if strings.HasPrefix(key, prefix) { ++ keys = append(keys, key) ++ } ++ } ++ sort.Strings(keys) ++ ++ start := 0 ++ if token != "" { ++ for i, key := range keys { ++ if key == token { ++ start = i + 1 ++ break ++ } ++ } ++ } ++ pageLen := f.listPageLen ++ if pageLen < 1 { ++ pageLen = len(keys) ++ } ++ end := start + pageLen ++ if end > len(keys) { ++ end = len(keys) ++ } ++ page := keys[start:end] ++ truncated := end < len(keys) ++ nextToken := "" ++ if truncated { ++ nextToken = page[len(page)-1] ++ } ++ ++ result := listBucketResult{ ++ Xmlns: "http://s3.amazonaws.com/doc/2006-03-01/", ++ Name: "fixture-bucket", ++ Prefix: prefix, ++ KeyCount: len(page), ++ MaxKeys: 1000, ++ IsTruncated: truncated, ++ } ++ if truncated { ++ result.NextContinuationToken = nextToken ++ } ++ for _, key := range page { ++ result.Contents = append(result.Contents, objectContent{Key: key, Size: len(f.objects[key])}) ++ } ++ f.mu.Unlock() ++ ++ w.Header().Set("Content-Type", "application/xml") ++ if err := xml.NewEncoder(w).Encode(result); err != nil { ++ panic(err) ++ } ++} ++ ++func (f *fakeS3Server) handleGet(w http.ResponseWriter, key string) { ++ f.mu.Lock() ++ f.activeGets++ ++ if f.activeGets > f.maxGets { ++ f.maxGets = f.activeGets ++ } ++ f.getCalls = append(f.getCalls, key) ++ body, ok := f.objects[key] ++ delay := f.getDelay ++ f.mu.Unlock() ++ defer func() { ++ f.mu.Lock() ++ f.activeGets-- ++ f.mu.Unlock() ++ }() ++ if delay > 0 { ++ time.Sleep(delay) ++ } ++ if !ok { ++ http.Error(w, "not found", http.StatusNotFound) ++ return ++ } ++ _, _ = w.Write(body) ++} ++ ++func (f *fakeS3Server) handlePut(w http.ResponseWriter, r *http.Request, key string) { ++ f.mu.Lock() ++ f.activePuts++ ++ if f.activePuts > f.maxPuts { ++ f.maxPuts = f.activePuts ++ } ++ delay := f.putDelay ++ f.mu.Unlock() ++ defer func() { ++ f.mu.Lock() ++ f.activePuts-- ++ f.mu.Unlock() ++ }() ++ if delay > 0 { ++ time.Sleep(delay) ++ } ++ ++ body, err := io.ReadAll(r.Body) ++ if err != nil { ++ http.Error(w, "bad body", http.StatusBadRequest) ++ return ++ } ++ ++ f.mu.Lock() ++ f.objects[key] = body ++ f.putBodies[key] = string(body) ++ f.putCalls = append(f.putCalls, key) ++ f.mu.Unlock() ++ ++ w.Header().Set("Content-Type", "application/xml") ++ _, _ = w.Write([]byte(`"fixture-etag"`)) ++} ++ ++func (f *fakeS3Server) listCallSnapshot() []string { ++ f.mu.Lock() ++ defer f.mu.Unlock() ++ out := append([]string(nil), f.listCalls...) ++ return out ++} ++ ++func (f *fakeS3Server) getCallSnapshot() []string { ++ f.mu.Lock() ++ defer f.mu.Unlock() ++ out := append([]string(nil), f.getCalls...) ++ sort.Strings(out) ++ return out ++} ++ ++func (f *fakeS3Server) maxGetActiveSnapshot() int { ++ f.mu.Lock() ++ defer f.mu.Unlock() ++ return f.maxGets ++} ++ ++func (f *fakeS3Server) putBodySnapshot() map[string]string { ++ f.mu.Lock() ++ defer f.mu.Unlock() ++ out := make(map[string]string, len(f.putBodies)) ++ for key, value := range f.putBodies { ++ out[key] = value ++ } ++ return out ++} ++ ++func (f *fakeS3Server) maxPutActiveSnapshot() int { ++ f.mu.Lock() ++ defer f.mu.Unlock() ++ return f.maxPuts ++} ++ ++func collectSourceObjects(t *testing.T, out <-chan any) []sourceObservation { ++ t.Helper() ++ ++ var observations []sourceObservation ++ for value := range out { ++ object, ok := value.(*connector.S3Object) ++ if !ok { ++ t.Fatalf("source emitted %T, want *aws.S3Object", value) ++ } ++ data, err := io.ReadAll(object.Data) ++ if err != nil { ++ t.Fatalf("read emitted object: %v", err) ++ } ++ ++ if len(data) < 7 { ++ t.Fatalf("source object %q length = %d, want at least 7 bytes", object.Key, len(data)) ++ } ++ observations = append(observations, sourceObservation{ ++ Key: object.Key, ++ Len: len(data), ++ Prefix: string(data[:7]), ++ }) ++ } ++ ++ sort.Slice(observations, func(i, j int) bool { ++ return observations[i].Key < observations[j].Key ++ }) ++ return observations ++} ++ ++type sourceObservation struct { ++ Key string ++ Len int ++ Prefix string ++} ++ ++func silentLogger() *slog.Logger { ++ return slog.New(slog.NewTextHandler(io.Discard, nil)) ++} ++ ++func waitUntilClosed(t *testing.T, ch <-chan any) { ++ t.Helper() ++ select { ++ case value, ok := <-ch: ++ if ok { ++ t.Fatalf("channel produced %T instead of being closed", value) ++ } ++ case <-time.After(2 * time.Second): ++ t.Fatal("timed out waiting for closed source output") ++ } ++} ++ ++func fdCount(t *testing.T) int { ++ t.Helper() ++ entries, err := os.ReadDir("/proc/self/fd") ++ if err != nil { ++ t.Fatalf("read fd directory: %v", err) ++ } ++ return len(entries) ++} ++ ++func TestS3SourceListsPaginatedPrefixFetchesObjectsAndDefaultsConfig(t *testing.T) { ++ ++ ++ ctx := context.Background() ++ alphaBody := strings.Repeat("alpha-A", 750000) ++ bravoBody := strings.Repeat("bravo-B", 750000) ++ charlieBody := strings.Repeat("charlie", 750000) ++ server := newFakeS3Server(map[string]string{ ++ "source/a.txt": alphaBody, ++ "source/b.txt": bravoBody, ++ "source/c.txt": charlieBody, ++ "other/skip.md": "ignored", ++ }, 2) ++ server.getDelay = 20 * time.Millisecond ++ defer server.close() ++ ++ config := &connector.S3SourceConfig{ ++ Bucket: "fixture-bucket", ++ Path: "source/", ++ Parallelism: 0, ++ ChunkSize: 0, ++ } ++ source := connector.NewS3Source(ctx, server.client(), config, nil) ++ ++ if source == nil { ++ t.Fatal("NewS3Source returned nil") ++ } ++ ++ observations := collectSourceObjects(t, source.Out()) ++ ++ wantObjects := map[string]struct { ++ minLen int ++ prefix string ++ }{ ++ "source/a.txt": {minLen: 5242880, prefix: "alpha-A"}, ++ "source/b.txt": {minLen: 5242880, prefix: "bravo-B"}, ++ "source/c.txt": {minLen: 5242880, prefix: "charlie"}, ++ } ++ ++ if len(observations) != len(wantObjects) { ++ t.Fatalf("observation count = %d, want %d: %#v", len(observations), len(wantObjects), observations) ++ } ++ for _, observation := range observations { ++ want, ok := wantObjects[observation.Key] ++ if !ok { ++ t.Fatalf("unexpected source object key %q in %#v", observation.Key, observations) ++ } ++ if observation.Len < want.minLen { ++ t.Fatalf("object %q length = %d, want at least %d", observation.Key, observation.Len, want.minLen) ++ } ++ if observation.Prefix != want.prefix { ++ t.Fatalf("object %q prefix = %q, want %q", observation.Key, observation.Prefix, want.prefix) ++ } ++ } ++ if got := server.listCallSnapshot(); fmt.Sprintf("%#v", got) != `[]string{"source/|", "source/|source/b.txt"}` { ++ t.Fatalf("list calls = %#v, want []string{\"source/|\", \"source/|source/b.txt\"}", got) ++ } ++ if got := server.getCallSnapshot(); fmt.Sprintf("%#v", got) != `[]string{"source/a.txt", "source/b.txt", "source/c.txt"}` { ++ t.Fatalf("get calls = %#v, want []string{\"source/a.txt\", \"source/b.txt\", \"source/c.txt\"}", got) ++ } ++ ++ if got := server.maxGetActiveSnapshot(); got > 1 { ++ t.Fatalf("max concurrent GetObject calls = %d, want <= 1", got) ++ } ++} ++ ++func TestS3SourceViaStreamsIntoFlowAndReturnsSameFlow(t *testing.T) { ++ ++ ++ ctx := context.Background() ++ server := newFakeS3Server(map[string]string{ ++ "via/one.txt": "one", ++ "via/two.txt": "two", ++ }, 10) ++ defer server.close() ++ ++ source := connector.NewS3Source(ctx, server.client(), &connector.S3SourceConfig{ ++ Bucket: "fixture-bucket", ++ Path: "via/", ++ Parallelism: 1, ++ ChunkSize: 8, ++ }, silentLogger()) ++ operator := flow.NewMap(func(object *connector.S3Object) string { ++ data, err := io.ReadAll(object.Data) ++ if err != nil { ++ t.Fatalf("read flow object: %v", err) ++ } ++ return object.Key + "=" + strings.TrimRight(string(data), "\x00") ++ }, 1) ++ ++ returned := source.Via(operator) ++ if returned != streams.Flow(operator) { ++ t.Fatal("Via returned a different flow instance") ++ } ++ ++ var got []string ++ for value := range returned.Out() { ++ got = append(got, value.(string)) ++ } ++ sort.Strings(got) ++ if fmt.Sprintf("%#v", got) != `[]string{"via/one.txt=one", "via/two.txt=two"}` { ++ t.Fatalf("flow output = %#v, want []string{\"via/one.txt=one\", \"via/two.txt=two\"}", got) ++ } ++} ++ ++func TestS3SourceCancellationClosesOutWithoutEmittingObjects(t *testing.T) { ++ ++ ++ ctx, cancel := context.WithCancel(context.Background()) ++ cancel() ++ server := newFakeS3Server(map[string]string{ ++ "cancel/never.txt": "not-read", ++ }, 10) ++ defer server.close() ++ ++ source := connector.NewS3Source(ctx, server.client(), &connector.S3SourceConfig{ ++ Bucket: "fixture-bucket", ++ Path: "cancel/", ++ Parallelism: 1, ++ ChunkSize: 4, ++ }, silentLogger()) ++ ++ waitUntilClosed(t, source.Out()) ++ if got := server.getCallSnapshot(); len(got) != 0 { ++ t.Fatalf("get call count = %d, want 0", len(got)) ++ } ++} ++ ++func TestS3SinkUploadsValuePointerSkipsUnsupportedAndDefaultsParallelism(t *testing.T) { ++ ++ ++ ctx := context.Background() ++ server := newFakeS3Server(nil, 1) ++ server.putDelay = 20 * time.Millisecond ++ defer server.close() ++ config := &connector.S3SinkConfig{Bucket: "fixture-bucket", Parallelism: 0} ++ sink := connector.NewS3Sink(ctx, server.client(), config, silentLogger()) ++ ++ if sink == nil { ++ t.Fatal("NewS3Sink returned nil") ++ } ++ ++ sink.In() <- connector.S3Object{Key: "sink/value.txt", Data: strings.NewReader("value-body")} ++ sink.In() <- &connector.S3Object{Key: "sink/pointer.txt", Data: strings.NewReader("pointer-body")} ++ sink.In() <- "not-an-s3-object" ++ close(sink.In()) ++ sink.AwaitCompletion() ++ ++ want := map[string]string{ ++ "sink/pointer.txt": "pointer-body", ++ "sink/value.txt": "value-body", ++ } ++ if got := server.putBodySnapshot(); fmt.Sprintf("%#v", got) != fmt.Sprintf("%#v", want) { ++ t.Fatalf("put bodies = %#v, want %#v", got, want) ++ } ++ ++ if got := server.maxPutActiveSnapshot(); got > 1 { ++ t.Fatalf("max concurrent PutObject calls = %d, want <= 1", got) ++ } ++} ++ ++func TestS3SinkAwaitCompletionIsIdempotentAfterDone(t *testing.T) { ++ ++ ++ ctx := context.Background() ++ server := newFakeS3Server(nil, 1) ++ defer server.close() ++ sink := connector.NewS3Sink(ctx, server.client(), &connector.S3SinkConfig{ ++ Bucket: "fixture-bucket", ++ Parallelism: 1, ++ }, nil) ++ ++ close(sink.In()) ++ sink.AwaitCompletion() ++ sink.AwaitCompletion() ++ if got := server.putBodySnapshot(); fmt.Sprintf("%#v", got) != `map[string]string{}` { ++ t.Fatalf("put bodies = %#v, want map[string]string{}", got) ++ } ++} ++ ++func TestS3SinkPanicsWhenSendingAfterInputClosed(t *testing.T) { ++ ++ ++ ctx := context.Background() ++ server := newFakeS3Server(nil, 1) ++ defer server.close() ++ sink := connector.NewS3Sink(ctx, server.client(), &connector.S3SinkConfig{ ++ Bucket: "fixture-bucket", ++ Parallelism: 1, ++ }, silentLogger()) ++ ++ close(sink.In()) ++ sink.AwaitCompletion() ++ defer func() { ++ recovered := recover() ++ if recovered == nil { ++ t.Fatal("send after close panic = , want send on closed channel") ++ } ++ ++ }() ++ sink.In() <- &connector.S3Object{Key: "too-late.txt", Data: strings.NewReader("late")} ++} ++ ++func TestS3ConnectorsKeepInstanceStateIndependent(t *testing.T) { ++ ++ ++ ctx := context.Background() ++ serverA := newFakeS3Server(nil, 1) ++ defer serverA.close() ++ serverB := newFakeS3Server(nil, 1) ++ defer serverB.close() ++ sinkA := connector.NewS3Sink(ctx, serverA.client(), &connector.S3SinkConfig{Bucket: "fixture-bucket", Parallelism: 1}, silentLogger()) ++ sinkB := connector.NewS3Sink(ctx, serverB.client(), &connector.S3SinkConfig{Bucket: "fixture-bucket", Parallelism: 1}, silentLogger()) ++ ++ sinkA.In() <- &connector.S3Object{Key: "only/a.txt", Data: strings.NewReader("alpha")} ++ close(sinkA.In()) ++ close(sinkB.In()) ++ sinkA.AwaitCompletion() ++ sinkB.AwaitCompletion() ++ ++ if got := serverA.putBodySnapshot(); fmt.Sprintf("%#v", got) != `map[string]string{"only/a.txt":"alpha"}` { ++ t.Fatalf("server A put bodies = %#v, want map[string]string{\"only/a.txt\":\"alpha\"}", got) ++ } ++ if got := serverB.putBodySnapshot(); fmt.Sprintf("%#v", got) != `map[string]string{}` { ++ t.Fatalf("server B put bodies = %#v, want map[string]string{}", got) ++ } ++} ++ ++func TestS3ConnectorConstructUseCleanupCyclesStayBounded(t *testing.T) { ++ ++ ++ ctx := context.Background() ++ server := newFakeS3Server(nil, 1) ++ defer server.close() ++ client := server.client() ++ runtime.GC() ++ beforeGoroutines := runtime.NumGoroutine() ++ beforeFDs := fdCount(t) ++ ++ for i := 0; i < 120; i++ { ++ sink := connector.NewS3Sink(ctx, client, &connector.S3SinkConfig{ ++ Bucket: "fixture-bucket", ++ Parallelism: 2, ++ }, silentLogger()) ++ sink.In() <- &connector.S3Object{ ++ Key: fmt.Sprintf("cycle/%03d.txt", i), ++ Data: bytes.NewReader([]byte("cycle-body")), ++ } ++ close(sink.In()) ++ sink.AwaitCompletion() ++ } ++ ++ time.Sleep(100 * time.Millisecond) ++ runtime.GC() ++ afterGoroutines := runtime.NumGoroutine() ++ afterFDs := fdCount(t) ++ ++ if beforeGoroutines > 0 && afterGoroutines-beforeGoroutines > 10 { ++ t.Fatalf("goroutines before/after = %d/%d, want increase <= 10", beforeGoroutines, afterGoroutines) ++ } ++ if beforeFDs > 0 && afterFDs-beforeFDs > 10 { ++ t.Fatalf("fds before/after = %d/%d, want increase <= 10", beforeFDs, afterFDs) ++ } ++} +diff --git 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 ++ ++ ++ ++ ++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/usercase-test-coderl ++export GOPROXY=off ++export GOSUMDB=off ++export GOTOOLCHAIN=local ++export GOCACHE=/root/go/build-cache ++export AWS_EC2_METADATA_DISABLED=true ++go mod download ++exec go test -v -count=1 ./... diff --git a/tasks/format-code-task-002517/tests/test.sh b/tasks/format-code-task-002517/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..31c3b05be6603f14a239c65fbc4114ab1bcf6866 --- /dev/null +++ b/tasks/format-code-task-002517/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/go.mod +usercase-test-coderl/go.sum +usercase-test-coderl/s3_connector_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-002517/tests/test_command.sh b/tasks/format-code-task-002517/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002517/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-002529/environment/Dockerfile b/tasks/format-code-task-002529/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..311e58c3e8f7c8ddd1ff0111ca489c3acd5afe5f --- /dev/null +++ b/tasks/format-code-task-002529/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:77581e39cd063b429f6fcb16a19f77d14f44d3ff48d3d46e001f07320f10becc diff --git a/tasks/format-code-task-002529/environment/setup/files/blocklist b/tasks/format-code-task-002529/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002529/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002529/environment/setup/setup.sh b/tasks/format-code-task-002529/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002529/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002529/tests/test.patch b/tasks/format-code-task-002529/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1f904f7256d22c25d0b06ba93d9185e3cb54c5f4 --- /dev/null +++ b/tasks/format-code-task-002529/tests/test.patch @@ -0,0 +1,335 @@ +diff --git a/usercase-test-coderl/wstr_multi_string_test.go b/usercase-test-coderl/wstr_multi_string_test.go +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/wstr_multi_string_test.go +@@ -0,0 +1,306 @@ ++package usercase_test_coderl ++ ++import ( ++ "os" ++ "path/filepath" ++ "reflect" ++ "testing" ++ "unsafe" ++ ++ "github.com/rodrigocfd/windigo/wstr" ++) ++ ++ ++ ++ ++ ++ ++ ++ ++func TestEncodeArrToSliceTwoASCIIStrings(t *testing.T) { ++ ++ ++ actual := wstr.EncodeArrToSlice("ab", "cd") ++ expected := []uint16{97, 98, 0, 99, 100, 0, 0} ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("EncodeArrToSlice returned %#v, want %#v", actual, expected) ++ } ++} ++ ++func TestEncodeArrToPtrTwoASCIIStrings(t *testing.T) { ++ ++ ++ ptr := wstr.EncodeArrToPtr("ab", "cd") ++ actual := unsafe.Slice(ptr, 7) ++ expected := []uint16{97, 98, 0, 99, 100, 0, 0} ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("EncodeArrToPtr block is %#v, want %#v", actual, expected) ++ } ++} ++ ++func TestEncodeArrToBufExactFit(t *testing.T) { ++ ++ ++ dest := make([]uint16, 7) ++ written := wstr.EncodeArrToBuf(dest, "ab", "cd") ++ expected := []uint16{97, 98, 0, 99, 100, 0, 0} ++ if written != 7 { ++ t.Fatalf("EncodeArrToBuf wrote %d words, want 7", written) ++ } ++ if !reflect.DeepEqual(dest, expected) { ++ t.Fatalf("EncodeArrToBuf dest is %#v, want %#v", dest, expected) ++ } ++} ++ ++func TestEncodeArrToBufTruncatesAndKeepsFinalDoubleNull(t *testing.T) { ++ ++ ++ dest := []uint16{0xffff, 0xffff, 0xffff, 0xffff} ++ written := wstr.EncodeArrToBuf(dest, "ab", "cd") ++ expected := []uint16{97, 98, 0, 0} ++ if written != 4 { ++ t.Fatalf("EncodeArrToBuf wrote %d words, want 4", written) ++ } ++ if !reflect.DeepEqual(dest, expected) { ++ t.Fatalf("EncodeArrToBuf dest is %#v, want %#v", dest, expected) ++ } ++} ++ ++func TestEncodeArrToBufZeroLengthDestination(t *testing.T) { ++ ++ ++ var dest []uint16 ++ written := wstr.EncodeArrToBuf(dest, "ab", "cd") ++ if written != 0 { ++ t.Fatalf("EncodeArrToBuf wrote %d words, want 0", written) ++ } ++ if !reflect.DeepEqual(dest, []uint16(nil)) { ++ t.Fatalf("zero-length dest was changed to %#v", dest) ++ } ++} ++ ++func TestEncodeArrToBufOneWordDestination(t *testing.T) { ++ ++ ++ dest := []uint16{0xffff} ++ written := wstr.EncodeArrToBuf(dest, "ab", "cd") ++ expected := []uint16{0} ++ if written != 1 { ++ t.Fatalf("EncodeArrToBuf wrote %d words, want 1", written) ++ } ++ if !reflect.DeepEqual(dest, expected) { ++ t.Fatalf("EncodeArrToBuf dest is %#v, want %#v", dest, expected) ++ } ++} ++ ++func TestEncodeArrToSliceNoStrings(t *testing.T) { ++ ++ ++ actual := wstr.EncodeArrToSlice() ++ expected := []uint16{0} ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("EncodeArrToSlice() returned %#v, want %#v", actual, expected) ++ } ++} ++ ++func TestEncodeArrToSliceEmptyStringArgument(t *testing.T) { ++ ++ ++ actual := wstr.EncodeArrToSlice("") ++ expected := []uint16{0, 0} ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("EncodeArrToSlice(\"\") returned %#v, want %#v", actual, expected) ++ } ++} ++ ++func TestEncodeArrToSliceSurrogatePairSizing(t *testing.T) { ++ ++ ++ actual := wstr.EncodeArrToSlice("a😀", "z") ++ expected := []uint16{97, 0xd83d, 0xde00, 0, 122, 0, 0} ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("EncodeArrToSlice with surrogate pair returned %#v, want %#v", actual, expected) ++ } ++} ++ ++func TestEncodeArrToBufSurrogatePairDoesNotSplitWhenTruncated(t *testing.T) { ++ ++ ++ dest := []uint16{0xffff, 0xffff, 0xffff} ++ written := wstr.EncodeArrToBuf(dest, "😀") ++ expected := []uint16{0, 0, 0xffff} ++ if written != 2 { ++ t.Fatalf("EncodeArrToBuf wrote %d words, want 2", written) ++ } ++ if !reflect.DeepEqual(dest, expected) { ++ t.Fatalf("EncodeArrToBuf dest is %#v, want %#v", dest, expected) ++ } ++} ++ ++func TestDecodeArrPtrTwoASCIIStrings(t *testing.T) { ++ ++ ++ block := []uint16{97, 98, 0, 99, 100, 0, 0} ++ actual := wstr.DecodeArrPtr(&block[0]) ++ expected := []string{"ab", "cd"} ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("DecodeArrPtr returned %#v, want %#v", actual, expected) ++ } ++} ++ ++func TestDecodeArrPtrNil(t *testing.T) { ++ ++ ++ actual := wstr.DecodeArrPtr(nil) ++ ++ if len(actual) != 0 { ++ t.Fatalf("DecodeArrPtr(nil) returned %#v, want empty []string", actual) ++ } ++} ++ ++func TestDecodeArrPtrStopsAtEmptyTerminator(t *testing.T) { ++ ++ ++ block := []uint16{65, 0, 0, 937, 0, 0} ++ actual := wstr.DecodeArrPtr(&block[0]) ++ expected := []string{"A"} ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("DecodeArrPtr returned %#v, want %#v", actual, expected) ++ } ++} ++ ++func TestDecodeArrPtrSurrogatePair(t *testing.T) { ++ ++ ++ block := []uint16{97, 0xd83d, 0xde00, 0, 122, 0, 0} ++ actual := wstr.DecodeArrPtr(&block[0]) ++ expected := []string{"a😀", "z"} ++ if !reflect.DeepEqual(actual, expected) { ++ t.Fatalf("DecodeArrPtr returned %#v, want %#v", actual, expected) ++ } ++} ++ ++func TestReferentialTransparency(t *testing.T) { ++ x1 := wstr.EncodeArrToSlice("a😀", "z") ++ x2 := wstr.EncodeArrToSlice("a😀", "z") ++ if !reflect.DeepEqual(x1, x2) { ++ t.Fatalf("same input returned %#v then %#v", x1, x2) ++ } ++ ++ block := []uint16{97, 0xd83d, 0xde00, 0, 122, 0, 0} ++ d1 := wstr.DecodeArrPtr(&block[0]) ++ d2 := wstr.DecodeArrPtr(&block[0]) ++ if !reflect.DeepEqual(d1, d2) { ++ t.Fatalf("same decode input returned %#v then %#v", d1, d2) ++ } ++} ++ ++func TestNoMutationBeyondDestinationBuffer(t *testing.T) { ++ strs := []string{"ab", "cd"} ++ strsBefore := append([]string(nil), strs...) ++ dest := []uint16{0xffff, 0xffff, 0xffff, 0xffff, 0xbeef} ++ written := wstr.EncodeArrToBuf(dest[:4], strs...) ++ ++ if written != 4 { ++ t.Fatalf("EncodeArrToBuf wrote %d words, want 4", written) ++ } ++ if !reflect.DeepEqual(strs, strsBefore) { ++ t.Fatalf("EncodeArrToBuf mutated variadic input slice to %#v, want %#v", strs, strsBefore) ++ } ++ if dest[4] != 0xbeef { ++ t.Fatalf("EncodeArrToBuf wrote past provided destination: guard is %#x, want 0xbeef", dest[4]) ++ } ++ ++ decodeBlock := []uint16{97, 98, 0, 99, 100, 0, 0} ++ decodeBefore := append([]uint16(nil), decodeBlock...) ++ _ = wstr.DecodeArrPtr(&decodeBlock[0]) ++ if !reflect.DeepEqual(decodeBlock, decodeBefore) { ++ t.Fatalf("DecodeArrPtr mutated source block to %#v, want %#v", decodeBlock, decodeBefore) ++ } ++} ++ ++func TestNoGlobalStateViaInProcessNoise(t *testing.T) { ++ baseline := wstr.EncodeArrToSlice("ab", "cd") ++ _ = wstr.EncodeArrToSlice() ++ _ = wstr.EncodeArrToSlice("a😀", "z") ++ afterNoise := wstr.EncodeArrToSlice("ab", "cd") ++ expected := []uint16{97, 98, 0, 99, 100, 0, 0} ++ if !reflect.DeepEqual(baseline, expected) { ++ t.Fatalf("baseline returned %#v, want %#v", baseline, expected) ++ } ++ if !reflect.DeepEqual(afterNoise, expected) { ++ t.Fatalf("after noise returned %#v, want %#v", afterNoise, expected) ++ } ++ ++ block := []uint16{97, 98, 0, 99, 100, 0, 0} ++ decodedBaseline := wstr.DecodeArrPtr(&block[0]) ++ noiseBlock := []uint16{97, 0xd83d, 0xde00, 0, 122, 0, 0} ++ _ = wstr.DecodeArrPtr(nil) ++ _ = wstr.DecodeArrPtr(&noiseBlock[0]) ++ decodedAfterNoise := wstr.DecodeArrPtr(&block[0]) ++ expectedDecoded := []string{"ab", "cd"} ++ if !reflect.DeepEqual(decodedBaseline, expectedDecoded) { ++ t.Fatalf("decode baseline returned %#v, want %#v", decodedBaseline, expectedDecoded) ++ } ++ if !reflect.DeepEqual(decodedAfterNoise, expectedDecoded) { ++ t.Fatalf("decode after noise returned %#v, want %#v", decodedAfterNoise, expectedDecoded) ++ } ++} ++ ++func TestNoUndeclaredFilesystemSideEffects(t *testing.T) { ++ tempDir := t.TempDir() ++ oldWd, err := os.Getwd() ++ if err != nil { ++ t.Fatalf("Getwd failed: %v", err) ++ } ++ if err := os.Chdir(tempDir); err != nil { ++ t.Fatalf("Chdir(%q) failed: %v", tempDir, err) ++ } ++ t.Cleanup(func() { ++ _ = os.Chdir(oldWd) ++ }) ++ ++ before := listRelativeFiles(t, tempDir) ++ ++ _ = wstr.EncodeArrToSlice("ab", "cd") ++ dest := make([]uint16, 7) ++ _ = wstr.EncodeArrToBuf(dest, "ab", "cd") ++ ptr := wstr.EncodeArrToPtr("ab", "cd") ++ _ = unsafe.Slice(ptr, 7) ++ block := []uint16{97, 98, 0, 99, 100, 0, 0} ++ _ = wstr.DecodeArrPtr(&block[0]) ++ _ = wstr.DecodeArrPtr(nil) ++ ++ after := listRelativeFiles(t, tempDir) ++ if !reflect.DeepEqual(after, before) { ++ t.Fatalf("wstr multi-string calls changed cwd files from %#v to %#v", before, after) ++ } ++ ++} ++ ++func listRelativeFiles(t *testing.T, root string) []string { ++ t.Helper() ++ var files []string ++ err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error { ++ if err != nil { ++ return err ++ } ++ if path == root { ++ return nil ++ } ++ rel, err := filepath.Rel(root, path) ++ if err != nil { ++ return err ++ } ++ if d.IsDir() { ++ files = append(files, rel+"/") ++ } else { ++ files = append(files, rel) ++ } ++ return nil ++ }) ++ if err != nil { ++ t.Fatalf("WalkDir(%q) failed: %v", root, err) ++ } ++ return files ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,19 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++export NODE_OPTIONS="${NODE_OPTIONS:-} --max-old-space-size=4096" ++export MAVEN_OPTS="${MAVEN_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export GRADLE_OPTS="${GRADLE_OPTS:-} -Xmx3g -XX:+UseG1GC" ++export TEST_JVM_OPTS="${TEST_JVM_OPTS:-} -Xmx3g" ++set -e ++cd /workspace/repo ++set -euo pipefail ++cd /workspace/repo ++ ++ ++export GOTOOLCHAIN=local ++export GOPROXY=off ++export GOSUMDB=off ++exec go test -v ./usercase-test-coderl/... diff --git a/tasks/format-code-task-002529/tests/test.sh b/tasks/format-code-task-002529/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f1fa8c262ea65ab0aaaffe229c9df24a417d785 --- /dev/null +++ b/tasks/format-code-task-002529/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/wstr_multi_string_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-002529/tests/test_command.sh b/tasks/format-code-task-002529/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002529/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-002543/environment/Dockerfile b/tasks/format-code-task-002543/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..035936f4a76931176b0062389099c20d4da00f77 --- /dev/null +++ b/tasks/format-code-task-002543/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0daf730cb46eca6d9bb88ac33995db03e793a636df511501f31bd59853a4030d diff --git a/tasks/format-code-task-002543/environment/setup/files/blocklist b/tasks/format-code-task-002543/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002543/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002543/environment/setup/setup.sh b/tasks/format-code-task-002543/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002543/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002543/tests/test.patch b/tasks/format-code-task-002543/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..944d4ab70d2fe2d300944a80f1fefd5bc99b9f38 --- /dev/null +++ b/tasks/format-code-task-002543/tests/test.patch @@ -0,0 +1,147 @@ +diff --git a/tests/test_asyncbackend_interface.py b/tests/test_asyncbackend_interface.py +new file mode 100644 +index 00000000..39c71537 +--- /dev/null ++++ b/tests/test_asyncbackend_interface.py +@@ -0,0 +1,35 @@ ++import asyncio ++import socket ++ ++import pytest ++ ++import dns._asyncbackend ++import dns._asyncio_backend ++ ++ ++def _await(coro): ++ return asyncio.get_event_loop().run_until_complete(coro) ++ ++ ++def test_base_backend_sleep_is_awaitable_and_fails_when_used_directly(): ++ backend = dns._asyncbackend.Backend() ++ delay = backend.sleep(0) ++ assert hasattr(delay, "__await__") ++ ++ with pytest.raises(Exception): ++ _await(delay) ++ ++ ++def test_base_datagram_socket_preserves_given_family(): ++ first = dns._asyncbackend.DatagramSocket(socket.AF_INET) ++ assert first.family == socket.AF_INET ++ ++ family_marker = object() ++ second = dns._asyncbackend.DatagramSocket(family_marker) ++ assert second.family is family_marker ++ ++ ++def test_asyncio_datagram_socket_preserves_family(): ++ family = socket.AF_INET6 if hasattr(socket, "AF_INET6") else socket.AF_INET ++ datagram = dns._asyncio_backend.DatagramSocket(family, object(), object()) ++ assert datagram.family == family +diff --git a/tests/test_makefile_type_targets.py b/tests/test_makefile_type_targets.py +new file mode 100644 +index 00000000..7c7bddf2 +--- /dev/null ++++ b/tests/test_makefile_type_targets.py +@@ -0,0 +1,46 @@ ++from pathlib import Path ++ ++ ++def _target_body(target_name): ++ lines = Path("Makefile").read_text().splitlines() ++ header = f"{target_name}:" ++ body = [] ++ in_target = False ++ for line in lines: ++ if not in_target: ++ if line == header: ++ in_target = True ++ continue ++ if line and not line.startswith(("\t", " ")): ++ break ++ if line.strip(): ++ body.append(line.strip()) ++ if not in_target: ++ raise AssertionError(f"missing Makefile target {target_name!r}") ++ return " ".join(body) ++ ++ ++def _tokens(target_name): ++ return _target_body(target_name).split() ++ ++ ++def _has_mypy_invocation(tokens): ++ return any(token == "mypy" or token.endswith("/mypy") for token in tokens) ++ ++ ++def test_potype_scope_is_dns_only(): ++ tokens = _tokens("potype") ++ ++ assert _has_mypy_invocation(tokens) ++ assert "dns/*.py" in tokens ++ assert "examples" not in tokens ++ assert "tests" not in tokens ++ ++ ++def test_potypetests_target_exists_for_examples_and_tests(): ++ tokens = _tokens("potypetests") ++ ++ assert _has_mypy_invocation(tokens) ++ assert "examples" in tokens ++ assert "tests" in tokens ++ assert "dns/*.py" not in tokens +diff --git a/tests/test_public_exports.py b/tests/test_public_exports.py +new file mode 100644 +index 00000000..b0ac721e +--- /dev/null ++++ b/tests/test_public_exports.py +@@ -0,0 +1,18 @@ ++import dns ++ ++ ++def test_dns_star_import_includes_public_type_modules(monkeypatch): ++ ++ ++ monkeypatch.setattr(dns, "__all__", ["dnssectypes", "zonetypes"]) ++ namespace = {} ++ exec("from dns import *", namespace) ++ assert "dnssectypes" in namespace ++ assert "zonetypes" in namespace ++ assert getattr(namespace["dnssectypes"], "__name__", None) == "dns.dnssectypes" ++ assert getattr(namespace["zonetypes"], "__name__", None) == "dns.zonetypes" ++ ++ ++def test_dns_all_contains_public_type_modules(): ++ exported = set(dns.__all__) ++ assert {"dnssectypes", "zonetypes"} <= exported +diff --git 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 ++ ++case "${1:-}" in ++ base) ++ python3 -m pytest \ ++ tests/test_dnssec.py \ ++ tests/test_name.py \ ++ tests/test_processing_order.py \ ++ tests/test_zone.py \ ++ -v ++ ;; ++ new) ++ python3 -m pytest \ ++ tests/test_asyncbackend_interface.py \ ++ tests/test_makefile_type_targets.py \ ++ tests/test_public_exports.py \ ++ -v ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002543/tests/test.sh b/tasks/format-code-task-002543/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..baf554ccfb1e43ca5cf02cc7251bb607aad43a7c --- /dev/null +++ b/tasks/format-code-task-002543/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_asyncbackend_interface.py +tests/test_makefile_type_targets.py +tests/test_public_exports.py +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002543/tests/test_command.sh b/tasks/format-code-task-002543/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002543/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-002544/environment/Dockerfile b/tasks/format-code-task-002544/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7f11308838c6bfdba02380609c0f9947c5801253 --- /dev/null +++ b/tasks/format-code-task-002544/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1397a8615aff04cab0622108fe63ce9cc1ecd434a3269743665436b81c9c1d6b diff --git a/tasks/format-code-task-002544/environment/setup/files/blocklist b/tasks/format-code-task-002544/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002544/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002544/environment/setup/setup.sh b/tasks/format-code-task-002544/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002544/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002544/tests/test.patch b/tasks/format-code-task-002544/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..39d3d2aa3b8156b8f74e569a746ee88482cc939e --- /dev/null +++ b/tasks/format-code-task-002544/tests/test.patch @@ -0,0 +1,87 @@ +diff --git a/test/yarp/encoding_test.rb b/test/yarp/encoding_test.rb +index 828b45be73..c2c9a3f4a1 100644 +--- a/test/yarp/encoding_test.rb ++++ b/test/yarp/encoding_test.rb +@@ -96,5 +96,48 @@ def test_first_lexed_token + encoding = YARP.lex("# encoding: ascii-8bit").value[0][0].value.encoding + assert_equal Encoding.find("ascii-8bit"), encoding + end ++ ++ def test_parse_source_encoding_from_magic_comment ++ source = "# encoding: Shift_JIS\nã‚¢" ++ result = YARP.parse(source) ++ ++ assert_equal Encoding::SHIFT_JIS, result.source.source.encoding ++ end ++ ++ def test_parse_source_and_slice_encoding_from_non_magic_utf8_content ++ source = "\"中文\"" ++ result = YARP.parse(source) ++ ++ assert_equal Encoding::UTF_8, result.source.source.encoding ++ ++ slice = result.value.slice ++ assert_equal source, slice ++ assert_equal Encoding::UTF_8, slice.encoding ++ end ++ ++ def test_slice_encoding ++ slice = YARP.parse("# encoding: Shift_JIS\nã‚¢").value.slice ++ assert_equal (+"ã‚¢").force_encoding(Encoding::SHIFT_JIS), slice ++ assert_equal Encoding::SHIFT_JIS, slice.encoding ++ end ++ ++ def test_load_source_and_slice_encoding_from_serialized_magic_comment ++ source = "# encoding: Shift_JIS\nã‚¢" ++ result = YARP.load(source, YARP.dump(source)) ++ ++ assert_equal Encoding::SHIFT_JIS, result.source.source.encoding ++ assert_equal Encoding::SHIFT_JIS, result.value.slice.encoding ++ end ++ ++ def test_load_source_and_slice_encoding_from_serialized_non_magic_utf8_content ++ source = "\"中文\"" ++ result = YARP.load(source, YARP.dump(source)) ++ ++ assert_equal Encoding::UTF_8, result.source.source.encoding ++ ++ slice = result.value.slice ++ assert_equal source, slice ++ assert_equal Encoding::UTF_8, slice.encoding ++ end + 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,28 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++apt-get -o Acquire::AllowInsecureRepositories=true -o Acquire::AllowDowngradeToInsecureRepositories=true install -y -qq ruby ruby-dev build-essential > /dev/null 2>&1 || true ++ ++ ++gem install bundler --no-document > /dev/null 2>&1 ++bundle install --quiet 2>&1 ++ ++ ++bundle exec rake compile 2>&1 ++ ++ ++case "${1:-}" in ++ base) ++ bundle exec ruby -Ilib -Itest test/yarp/encoding_test.rb --name '/^(?!test_(parse_source_encoding_from_magic_comment|parse_source_and_slice_encoding_from_non_magic_utf8_content|slice_encoding|load_source_and_slice_encoding_from_serialized_magic_comment|load_source_and_slice_encoding_from_serialized_non_magic_utf8_content)$)/' ++ ;; ++ new) ++ bundle exec ruby -Ilib -Itest test/yarp/encoding_test.rb --name '/^test_(parse_source_encoding_from_magic_comment|parse_source_and_slice_encoding_from_non_magic_utf8_content|slice_encoding|load_source_and_slice_encoding_from_serialized_magic_comment|load_source_and_slice_encoding_from_serialized_non_magic_utf8_content)$/' ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002544/tests/test.sh b/tasks/format-code-task-002544/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d611039084d284d7260e0127a080e635aa568d6d --- /dev/null +++ b/tasks/format-code-task-002544/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/yarp/encoding_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-002544/tests/test_command.sh b/tasks/format-code-task-002544/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002544/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-002572/environment/Dockerfile b/tasks/format-code-task-002572/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..63a518248cb6f30a6dcbb2af5193e50aaff3c9dc --- /dev/null +++ b/tasks/format-code-task-002572/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:68220df6bcc1092b495012ff5691a59b0fb07ee90822a1cb4eef714f0575134c diff --git a/tasks/format-code-task-002572/environment/setup/files/blocklist b/tasks/format-code-task-002572/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002572/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002572/environment/setup/setup.sh b/tasks/format-code-task-002572/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002572/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002572/tests/test.patch b/tasks/format-code-task-002572/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..51c9eef139c42b2f88ba537e4adcebd47a147a6e --- /dev/null +++ b/tasks/format-code-task-002572/tests/test.patch @@ -0,0 +1,1295 @@ +diff --git a/tests/pytests/unit/modules/test_yumpkg.py b/tests/pytests/unit/modules/test_yumpkg.py +index d2f3a2869eca..188ed58ec7ed 100644 +--- a/tests/pytests/unit/modules/test_yumpkg.py ++++ b/tests/pytests/unit/modules/test_yumpkg.py +@@ -1,3 +1,4 @@ ++import configparser + import logging + import os + +@@ -8,11 +9,15 @@ + import salt.modules.rpm_lowpkg as rpm + import salt.modules.yumpkg as yumpkg + import salt.utils.platform +-from salt.exceptions import CommandExecutionError, SaltInvocationError ++from salt.exceptions import CommandExecutionError, MinionError, SaltInvocationError + from tests.support.mock import MagicMock, Mock, call, patch + + log = logging.getLogger(__name__) + ++pytestmark = [ ++ pytest.mark.skip_unless_on_linux, ++] ++ + + @pytest.fixture + def configure_loader_modules(): +@@ -28,7 +33,9 @@ def _add_data(data, key, value): + "os_family": "RedHat", + "osmajorrelease": 7, + }, +- "__salt__": {"pkg_resource.add_pkg": _add_data}, ++ "__salt__": { ++ "pkg_resource.add_pkg": _add_data, ++ }, + }, + pkg_resource: {}, + } +@@ -36,7 +43,6 @@ def _add_data(data, key, value): + + @pytest.fixture(scope="module") + def list_repos_var(): +- + return { + "base": { + "file": "/etc/yum.repos.d/CentOS-Base.repo", +@@ -93,6 +99,71 @@ def yum_and_dnf(request): + yield request.param["cmd"] + + ++def test__virtual_normal(): ++ assert yumpkg.__virtual__() == "pkg" ++ ++ ++def test__virtual_yumpkg_api(): ++ with patch.dict(yumpkg.__opts__, {"yum_provider": "yumpkg_api"}): ++ assert yumpkg.__virtual__() == ( ++ False, ++ "Module yumpkg: yumpkg_api provider not available", ++ ) ++ ++ ++def test__virtual_exception(): ++ with patch.dict(yumpkg.__grains__, {"os": 1}): ++ assert yumpkg.__virtual__() == ( ++ False, ++ "Module yumpkg: no yum based system detected", ++ ) ++ ++ ++def test__virtual_no_yum(): ++ with patch.object(yumpkg, "_yum", MagicMock(return_value=None)): ++ assert yumpkg.__virtual__() == (False, "DNF nor YUM found") ++ ++ ++def test__virtual_non_yum_system(): ++ with patch.dict(yumpkg.__grains__, {"os_family": "ubuntu"}): ++ assert yumpkg.__virtual__() == ( ++ False, ++ "Module yumpkg: no yum based system detected", ++ ) ++ ++ ++def test_strip_headers(): ++ output = os.linesep.join(["spongebob", "squarepants", "squidward"]) ++ args = ("spongebob", "squarepants") ++ assert yumpkg._strip_headers(output, *args) == "squidward\n" ++ ++ ++def test_get_copr_repo(): ++ result = yumpkg._get_copr_repo("copr:spongebob/squarepants") ++ assert result == "copr:copr.fedorainfracloud.org:spongebob:squarepants" ++ ++ ++def test_get_hold(): ++ line = "vim-enhanced-2:7.4.827-1.fc22" ++ with patch.object(yumpkg, "_yum", MagicMock(return_value="dnf")): ++ assert yumpkg._get_hold(line) == "vim-enhanced-2:7.4.827-1.fc22" ++ ++ ++def test_get_options(): ++ result = yumpkg._get_options( ++ repo="spongebob", ++ disableexcludes="squarepants", ++ __dunder_keyword="this is skipped", ++ stringvalue="string_value", ++ boolvalue=True, ++ get_extra_options=True, ++ ) ++ assert "--enablerepo=spongebob" in result ++ assert "--disableexcludes=squarepants" in result ++ assert "--stringvalue=string_value" in result ++ assert "--boolvalue" in result ++ ++ + def test_list_pkgs(): + """ + Test packages listing. +@@ -468,6 +539,16 @@ def test_list_patches(): + assert _patch in patches["my-fake-patch-installed-1234"]["summary"] + + ++def test_list_patches_refresh(): ++ expected = ["spongebob"] ++ mock_get_patches = MagicMock(return_value=expected) ++ patch_get_patches = patch.object(yumpkg, "_get_patches", mock_get_patches) ++ patch_refresh_db = patch.object(yumpkg, "refresh_db", MagicMock()) ++ with patch_refresh_db, patch_get_patches: ++ result = yumpkg.list_patches(refresh=True) ++ assert result == expected ++ ++ + def test_latest_version_with_options(): + with patch.object(yumpkg, "list_pkgs", MagicMock(return_value={})): + +@@ -559,6 +640,66 @@ def test_latest_version_with_options(): + ) + + ++def test_list_repo_pkgs_attribute_error(): ++ patch_get_options = patch.object(yumpkg, "_get_options", MagicMock()) ++ mock_run = MagicMock(return_value="3.4.5") ++ patch_run = patch.dict(yumpkg.__salt__, {"cmd.run": mock_run}) ++ mock_yum = MagicMock(return_value={"retcode": 0, "stdout": ""}) ++ patch_yum = patch.object(yumpkg, "_call_yum", mock_yum) ++ with patch_get_options, patch_run, patch_yum: ++ assert yumpkg.list_repo_pkgs(fromrepo=1, disablerepo=2, enablerepo=3) == {} ++ ++ ++def test_list_repo_pkgs_byrepo(list_repos_var): ++ patch_get_options = patch.object(yumpkg, "_get_options", MagicMock()) ++ stdout_installed = """\ ++Installed Packages ++spongebob.x86_64 1.1.el9_1 @bikini-bottom-rpms ++squarepants.x86_64 1.2.el9_1 @bikini-bottom-rpms ++patrick.noarch 1.3.el9_1 @rock-bottom-rpms ++squidward.x86_64 1.4.el9_1 @rock-bottom-rpms""" ++ stdout_available = """\ ++Available Packages ++plankton.noarch 2.1-1.el9_2 bikini-bottom-rpms ++dennis.x86_64 2.2-2.el9 bikini-bottom-rpms ++man-ray.x86_64 2.3-1.el9_2 bikini-bottom-rpms ++doodlebob.x86_64 2.4-1.el9_2 bikini-bottom-rpms""" ++ run_all_side_effect = ( ++ {"retcode": 0, "stdout": stdout_installed}, ++ {"retcode": 0, "stdout": stdout_available}, ++ ) ++ patch_salt = patch.dict( ++ yumpkg.__salt__, ++ { ++ "cmd.run": MagicMock(return_value="3.4.5"), ++ "cmd.run_all": MagicMock(side_effect=run_all_side_effect), ++ "config.get": MagicMock(return_value=False), ++ }, ++ ) ++ patch_list_repos = patch.object( ++ yumpkg, ++ "list_repos", ++ MagicMock(return_value=list_repos_var), ++ ) ++ with patch_get_options, patch_salt, patch_list_repos: ++ expected = { ++ "bikini-bottom-rpms": { ++ "dennis": ["2.2-2.el9"], ++ "doodlebob": ["2.4-1.el9_2"], ++ "man-ray": ["2.3-1.el9_2"], ++ "plankton": ["2.1-1.el9_2"], ++ "spongebob": ["1.1.el9_1"], ++ "squarepants": ["1.2.el9_1"], ++ }, ++ "rock-bottom-rpms": { ++ "patrick": ["1.3.el9_1"], ++ "squidward": ["1.4.el9_1"], ++ }, ++ } ++ result = yumpkg.list_repo_pkgs(byrepo=True) ++ assert result == expected ++ ++ + def test_list_repo_pkgs_with_options(list_repos_var): + """ + Test list_repo_pkgs with and without fromrepo +@@ -762,6 +903,87 @@ def test_list_upgrades_dnf(): + ) + + ++def test_list_upgrades_refresh(): ++ mock_call_yum = MagicMock(return_value={"retcode": 0, "stdout": ""}) ++ with patch.object(yumpkg, "refresh_db", MagicMock()): ++ with patch.object(yumpkg, "_call_yum", mock_call_yum): ++ assert yumpkg.list_upgrades(refresh=True) == {} ++ ++ ++def test_list_upgrades_error(): ++ mock_return = {"retcode": 1, "Error:": "Error"} ++ mock_call_yum = MagicMock(return_value=mock_return) ++ with patch.object(yumpkg, "_call_yum", mock_call_yum): ++ assert yumpkg.list_upgrades(refresh=False) == {} ++ ++ ++def test_list_downloaded(): ++ mock_walk = MagicMock( ++ return_value=[ ++ ( ++ "/var/cache/yum", ++ [], ++ ["pkg1-3.1-16.1.x86_64.rpm", "pkg2-1.2-13.2.x86_64.rpm"], ++ ) ++ ] ++ ) ++ mock_pkginfo = MagicMock( ++ side_effect=[ ++ { ++ "name": "pkg1", ++ "version": "3.1", ++ }, ++ { ++ "name": "pkg2", ++ "version": "1.2", ++ }, ++ ] ++ ) ++ mock_getctime = MagicMock(return_value=1696536082.861206) ++ mock_getsize = MagicMock(return_value=75701688) ++ with patch.dict(yumpkg.__salt__, {"lowpkg.bin_pkg_info": mock_pkginfo}), patch( ++ "salt.utils.path.os_walk", mock_walk ++ ), patch("os.path.getctime", mock_getctime), patch("os.path.getsize", mock_getsize): ++ result = yumpkg.list_downloaded() ++ expected = { ++ "pkg1": { ++ "3.1": { ++ "creation_date_time": "2023-10-05T14:01:22", ++ "creation_date_time_t": 1696536082, ++ "path": "/var/cache/yum/pkg1-3.1-16.1.x86_64.rpm", ++ "size": 75701688, ++ }, ++ }, ++ "pkg2": { ++ "1.2": { ++ "creation_date_time": "2023-10-05T14:01:22", ++ "creation_date_time_t": 1696536082, ++ "path": "/var/cache/yum/pkg2-1.2-13.2.x86_64.rpm", ++ "size": 75701688, ++ }, ++ }, ++ } ++ assert ( ++ result["pkg1"]["3.1"]["creation_date_time_t"] ++ == expected["pkg1"]["3.1"]["creation_date_time_t"] ++ ) ++ assert result["pkg1"]["3.1"]["path"] == expected["pkg1"]["3.1"]["path"] ++ assert result["pkg1"]["3.1"]["size"] == expected["pkg1"]["3.1"]["size"] ++ assert ( ++ result["pkg2"]["1.2"]["creation_date_time_t"] ++ == expected["pkg2"]["1.2"]["creation_date_time_t"] ++ ) ++ assert result["pkg2"]["1.2"]["path"] == expected["pkg2"]["1.2"]["path"] ++ assert result["pkg2"]["1.2"]["size"] == expected["pkg2"]["1.2"]["size"] ++ ++ ++def test_list_installed_patches(): ++ mock_get_patches = MagicMock(return_value="spongebob") ++ with patch.object(yumpkg, "_get_patches", mock_get_patches): ++ result = yumpkg.list_installed_patches() ++ assert result == "spongebob" ++ ++ + def test_list_upgrades_yum(): + """ + The subcommand should be "updates" with yum +@@ -815,6 +1037,213 @@ def test_list_upgrades_yum(): + ) + + ++def test_modified(): ++ mock = MagicMock() ++ with patch.dict(yumpkg.__salt__, {"lowpkg.modified": mock}): ++ yumpkg.modified("spongebob", "squarepants") ++ mock.assert_called_once_with("spongebob", "squarepants") ++ ++ ++def test_clean_metadata_with_options(): ++ ++ with patch("salt.utils.pkg.clear_rtag", Mock()): ++ ++ ++ ++ ++ ++ yum_call = MagicMock() ++ with patch.dict( ++ yumpkg.__salt__, ++ {"cmd.run_all": yum_call, "config.get": MagicMock(return_value=False)}, ++ ): ++ yumpkg.clean_metadata(check_update=True, fromrepo="good", branch="foo") ++ ++ assert yum_call.call_count == 2 ++ yum_call.assert_any_call( ++ [ ++ "yum", ++ "--quiet", ++ "--assumeyes", ++ "clean", ++ "expire-cache", ++ "--disablerepo=*", ++ "--enablerepo=good", ++ "--branch=foo", ++ ], ++ env={}, ++ ignore_retcode=True, ++ output_loglevel="trace", ++ python_shell=False, ++ ) ++ yum_call.assert_any_call( ++ [ ++ "yum", ++ "--quiet", ++ "--assumeyes", ++ "check-update", ++ "--setopt=autocheck_running_kernel=false", ++ "--disablerepo=*", ++ "--enablerepo=good", ++ "--branch=foo", ++ ], ++ output_loglevel="trace", ++ env={}, ++ ignore_retcode=True, ++ python_shell=False, ++ ) ++ ++ ++def test_del_repo_error(): ++ basedir = "/mr/krabs" ++ ret_dict = { ++ "spongebob": {"file": "/square/pants"}, ++ "patrick": {"file": "/squid/ward"}, ++ } ++ mock_list = MagicMock(return_value=ret_dict) ++ patch_list = patch.object(yumpkg, "list_repos", mock_list) ++ with patch_list: ++ result = yumpkg.del_repo("plankton", basedir=basedir) ++ expected = "Error: the plankton repo does not exist in ['/mr/krabs']" ++ assert result == expected ++ ++ result = yumpkg.del_repo("copr:plankton/karen", basedir=basedir) ++ expected = "Error: the copr:copr.fedorainfracloud.org:plankton:karen repo does not exist in ['/mr/krabs']" ++ assert result == expected ++ ++ ++def test_del_repo_single_file(): ++ basedir = "/mr/krabs" ++ ret_dict = { ++ "spongebob": {"file": "/square/pants"}, ++ "patrick": {"file": "/squid/ward"}, ++ } ++ mock_list = MagicMock(return_value=ret_dict) ++ patch_list = patch.object(yumpkg, "list_repos", mock_list) ++ with patch_list, patch("os.remove"): ++ result = yumpkg.del_repo("spongebob", basedir=basedir) ++ expected = "File /square/pants containing repo spongebob has been removed" ++ assert result == expected ++ ++ ++def test_download_error_no_packages(): ++ patch_which = patch("salt.utils.path.which", MagicMock(return_value="path.exe")) ++ with patch_which, pytest.raises(SaltInvocationError): ++ yumpkg.download() ++ ++ ++def test_download(): ++ patch_which = patch("salt.utils.path.which", MagicMock(return_value="path.exe")) ++ patch_exists = patch("os.path.exists", MagicMock(return_value=False)) ++ patch_makedirs = patch("os.makedirs") ++ mock_listdir = MagicMock(side_effect=([], ["spongebob-1.2.rpm"])) ++ patch_listdir = patch("os.listdir", mock_listdir) ++ mock_run = MagicMock() ++ dict_salt = { ++ "cmd.run": mock_run, ++ } ++ patch_salt = patch.dict(yumpkg.__salt__, dict_salt) ++ with patch_which, patch_exists, patch_makedirs, patch_listdir, patch_salt: ++ result = yumpkg.download("spongebob") ++ cmd = ["yumdownloader", "-q", "--destdir=/var/cache/yum/packages", "spongebob"] ++ mock_run.assert_called_once_with( ++ cmd, output_loglevel="trace", python_shell=False ++ ) ++ expected = {"spongebob": "/var/cache/yum/packages/spongebob-1.2.rpm"} ++ assert result == expected ++ ++ ++def test_download_failed(): ++ patch_which = patch("salt.utils.path.which", MagicMock(return_value="path.exe")) ++ patch_exists = patch("os.path.exists", MagicMock(return_value=True)) ++ mock_listdir = MagicMock(return_value=["spongebob-1.2.rpm", "junk.txt"]) ++ patch_listdir = patch("os.listdir", mock_listdir) ++ patch_unlink = patch("os.unlink") ++ mock_run = MagicMock() ++ dict_salt = { ++ "cmd.run": mock_run, ++ } ++ patch_salt = patch.dict(yumpkg.__salt__, dict_salt) ++ with patch_which, patch_exists, patch_listdir, patch_unlink, patch_salt: ++ result = yumpkg.download("spongebob", "patrick") ++ cmd = [ ++ "yumdownloader", ++ "-q", ++ "--destdir=/var/cache/yum/packages", ++ "spongebob", ++ "patrick", ++ ] ++ mock_run.assert_called_once_with( ++ cmd, output_loglevel="trace", python_shell=False ++ ) ++ expected = { ++ "_error": "The following package(s) failed to download: patrick", ++ "spongebob": "/var/cache/yum/packages/spongebob-1.2.rpm", ++ } ++ assert result == expected ++ ++ ++def test_download_missing_yumdownloader(): ++ patch_which = patch("salt.utils.path.which", MagicMock(return_value=None)) ++ with patch_which, pytest.raises(CommandExecutionError): ++ yumpkg.download("spongebob") ++ ++ ++def test_download_to_purge(): ++ patch_which = patch("salt.utils.path.which", MagicMock(return_value="path.exe")) ++ patch_exists = patch("os.path.exists", MagicMock(return_value=True)) ++ mock_listdir = MagicMock(return_value=["spongebob-1.2.rpm", "junk.txt"]) ++ patch_listdir = patch("os.listdir", mock_listdir) ++ patch_unlink = patch("os.unlink") ++ mock_run = MagicMock() ++ dict_salt = { ++ "cmd.run": mock_run, ++ } ++ patch_salt = patch.dict(yumpkg.__salt__, dict_salt) ++ with patch_which, patch_exists, patch_listdir, patch_unlink, patch_salt: ++ result = yumpkg.download("spongebob") ++ cmd = ["yumdownloader", "-q", "--destdir=/var/cache/yum/packages", "spongebob"] ++ mock_run.assert_called_once_with( ++ cmd, output_loglevel="trace", python_shell=False ++ ) ++ expected = {"spongebob": "/var/cache/yum/packages/spongebob-1.2.rpm"} ++ assert result == expected ++ ++ ++def test_download_unlink_error(): ++ patch_which = patch("salt.utils.path.which", MagicMock(return_value="path.exe")) ++ patch_exists = patch("os.path.exists", MagicMock(return_value=True)) ++ se_listdir = ( ++ ["spongebob-1.2.rpm", "junk.txt"], ++ ["spongebob1.2.rpm", "junk.txt"], ++ ) ++ mock_listdir = MagicMock(side_effect=se_listdir) ++ patch_listdir = patch("os.listdir", mock_listdir) ++ patch_unlink = patch("os.unlink", MagicMock(side_effect=OSError)) ++ mock_run = MagicMock() ++ dict_salt = { ++ "cmd.run": mock_run, ++ } ++ patch_salt = patch.dict(yumpkg.__salt__, dict_salt) ++ with patch_which, patch_exists, patch_listdir, patch_unlink, patch_salt: ++ with pytest.raises(CommandExecutionError): ++ yumpkg.download("spongebob") ++ ++ ++def test_file_dict(): ++ mock = MagicMock() ++ with patch.dict(yumpkg.__salt__, {"lowpkg.file_dict": mock}): ++ yumpkg.file_dict("spongebob", "squarepants") ++ mock.assert_called_once_with("spongebob", "squarepants") ++ ++ ++def test_file_list(): ++ mock = MagicMock() ++ with patch.dict(yumpkg.__salt__, {"lowpkg.file_list": mock}): ++ yumpkg.file_list("spongebob", "squarepants") ++ mock.assert_called_once_with("spongebob", "squarepants") ++ ++ + def test_refresh_db_with_options(): + + with patch("salt.utils.pkg.clear_rtag", Mock()): +@@ -1040,6 +1469,36 @@ def test_install_with_options(): + ) + + ++def test_remove_retcode_error(): ++ """ ++ Tests that we throw an error if retcode isn't 0 ++ """ ++ name = "foo" ++ installed = "8:3.8.12-4.n.el7" ++ list_pkgs_mock = MagicMock( ++ side_effect=lambda **kwargs: { ++ name: [installed] if kwargs.get("versions_as_list", False) else installed ++ } ++ ) ++ cmd_mock = MagicMock( ++ return_value={"pid": 12345, "retcode": 1, "stdout": "", "stderr": "error"} ++ ) ++ salt_mock = { ++ "cmd.run_all": cmd_mock, ++ "lowpkg.version_cmp": rpm.version_cmp, ++ "pkg_resource.parse_targets": MagicMock( ++ return_value=({name: installed}, "repository") ++ ), ++ } ++ with patch.object(yumpkg, "list_pkgs", list_pkgs_mock), patch( ++ "salt.utils.systemd.has_scope", MagicMock(return_value=False) ++ ), patch.dict(yumpkg.__salt__, salt_mock), patch.dict( ++ yumpkg.__grains__, {"os": "CentOS", "osrelease": 7} ++ ): ++ with pytest.raises(CommandExecutionError): ++ yumpkg.remove("spongebob") ++ ++ + def test_remove_with_epoch(): + """ + Tests that we properly identify a version containing an epoch for +@@ -1228,6 +1687,54 @@ def test_install_with_epoch(): + assert call == expected, call + + ++def test_install_minion_error(): ++ patch_get_options = patch.object(yumpkg, "_get_options", MagicMock()) ++ patch_salt = patch.dict( ++ yumpkg.__salt__, ++ { ++ "pkg_resource.parse_targets": MagicMock(side_effect=MinionError), ++ }, ++ ) ++ with patch_get_options, patch_salt: ++ with pytest.raises(CommandExecutionError): ++ yumpkg.install("spongebob") ++ ++ ++def test_install_no_pkg_params(): ++ patch_get_options = patch.object(yumpkg, "_get_options", MagicMock()) ++ parse_return = ("", "junk") ++ patch_salt = patch.dict( ++ yumpkg.__salt__, ++ { ++ "pkg_resource.parse_targets": MagicMock(return_value=parse_return), ++ }, ++ ) ++ with patch_get_options, patch_salt: ++ assert yumpkg.install("spongebob") == {} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + @pytest.mark.skipif(not salt.utils.platform.is_linux(), reason="Only run on Linux") + def test_install_error_reporting(): + """ +@@ -1266,6 +1773,13 @@ def test_install_error_reporting(): + assert exc_info.value.info == expected, exc_info.value.info + + ++def test_remove_error(): ++ mock_salt = {"pkg_resource.parse_targets": MagicMock(side_effect=MinionError)} ++ with patch.dict(yumpkg.__salt__, mock_salt): ++ with pytest.raises(CommandExecutionError): ++ yumpkg.remove("spongebob") ++ ++ + def test_remove_not_installed(): + """ + Tests that no exception raised on removing not installed package +@@ -1303,6 +1817,17 @@ def test_remove_not_installed(): + cmd_mock.assert_not_called() + + ++def test_upgrade_error(): ++ patch_yum = patch.object(yumpkg, "_yum", return_value="yum") ++ patch_get_options = patch.object(yumpkg, "_get_options") ++ patch_list_pkgs = patch.object(yumpkg, "list_pkgs") ++ salt_dict = {"pkg_resource.parse_targets": MagicMock(side_effect=MinionError)} ++ patch_salt = patch.dict(yumpkg.__salt__, salt_dict) ++ with patch_yum, patch_get_options, patch_list_pkgs, patch_salt: ++ with pytest.raises(CommandExecutionError): ++ yumpkg.upgrade("spongebob", refresh=False) ++ ++ + def test_upgrade_with_options(): + with patch.object(yumpkg, "list_pkgs", MagicMock(return_value={})), patch( + "salt.utils.systemd.has_scope", MagicMock(return_value=False) +@@ -1317,6 +1842,7 @@ def test_upgrade_with_options(): + exclude="kernel*", + branch="foo", + setopt="obsoletes=0,plugins=0", ++ skip_verify=True, + ) + cmd.assert_called_once_with( + [ +@@ -1331,6 +1857,7 @@ def test_upgrade_with_options(): + "--setopt", + "plugins=0", + "--exclude=kernel*", ++ "--nogpgcheck", + "upgrade", + ], + env={}, +@@ -1338,6 +1865,19 @@ def test_upgrade_with_options(): + python_shell=False, + ) + ++ ++ cmd = MagicMock(return_value={"retcode": 1}) ++ with patch.dict(yumpkg.__salt__, {"cmd.run_all": cmd}): ++ with pytest.raises(CommandExecutionError): ++ yumpkg.upgrade( ++ refresh=False, ++ fromrepo="good", ++ exclude="kernel*", ++ branch="foo", ++ setopt="obsoletes=0,plugins=0", ++ skip_verify=True, ++ ) ++ + # without fromrepo + cmd = MagicMock(return_value={"retcode": 0}) + with patch.dict(yumpkg.__salt__, {"cmd.run_all": cmd}): +@@ -1370,6 +1910,64 @@ def test_upgrade_with_options(): + ) + + ++def test_upgrade_available(): ++ mock_return = MagicMock(return_value="non-empty value") ++ patch_latest_version = patch.object(yumpkg, "latest_version", mock_return) ++ with patch_latest_version: ++ assert yumpkg.upgrade_available("foo") is True ++ ++ ++def test_verify_args(): ++ mock_verify = MagicMock() ++ with patch.dict(yumpkg.__salt__, {"lowpkg.verify": mock_verify}): ++ yumpkg.verify("spongebob") ++ mock_verify.assert_called_once_with("spongebob") ++ ++ ++def test_verify_kwargs(): ++ mock_verify = MagicMock() ++ with patch.dict(yumpkg.__salt__, {"lowpkg.verify": mock_verify}): ++ yumpkg.verify(spongebob="squarepants") ++ mock_verify.assert_called_once_with(spongebob="squarepants") ++ ++ ++def test_purge_not_installed(): ++ """ ++ Tests that no exception raised on purging not installed package ++ """ ++ name = "foo" ++ list_pkgs_mock = MagicMock(return_value={}) ++ cmd_mock = MagicMock( ++ return_value={"pid": 12345, "retcode": 0, "stdout": "", "stderr": ""} ++ ) ++ salt_mock = { ++ "cmd.run_all": cmd_mock, ++ "lowpkg.version_cmp": rpm.version_cmp, ++ "pkg_resource.parse_targets": MagicMock( ++ return_value=({name: None}, "repository") ++ ), ++ } ++ with patch.object(yumpkg, "list_pkgs", list_pkgs_mock), patch( ++ "salt.utils.systemd.has_scope", MagicMock(return_value=False) ++ ), patch.dict(yumpkg.__salt__, salt_mock): ++ ++ ++ with patch.dict(yumpkg.__context__, {"yum_bin": "yum"}), patch.dict( ++ yumpkg.__grains__, {"os": "CentOS", "osrelease": 7} ++ ): ++ yumpkg.purge(name) ++ cmd_mock.assert_not_called() ++ ++ ++ yumpkg.__context__.pop("yum_bin") ++ cmd_mock.reset_mock() ++ with patch.dict(yumpkg.__context__, {"yum_bin": "dnf"}), patch.dict( ++ yumpkg.__grains__, {"os": "Fedora", "osrelease": 27} ++ ): ++ yumpkg.purge(name) ++ cmd_mock.assert_not_called() ++ ++ + def test_info_installed_with_all_versions(): + """ + Test the return information of all versions for the named package(s), installed on the system. +@@ -1525,6 +2123,260 @@ def test_pkg_hold_tdnf(): + yumpkg.hold("foo") + + ++def test_hold_empty(): ++ """ ++ Tests that we raise a SaltInvocationError if nothing is passed ++ """ ++ with patch.object(yumpkg, "_check_versionlock", MagicMock()): ++ with pytest.raises(SaltInvocationError): ++ yumpkg.hold() ++ ++ ++def test_hold_pkgs_and_sources_error(): ++ """ ++ Tests that we raise a SaltInvocationError if both pkgs and sources is passed ++ """ ++ with patch.object(yumpkg, "_check_versionlock", MagicMock()): ++ with pytest.raises(SaltInvocationError): ++ yumpkg.hold(pkgs=["foo", "bar"], sources=["src1", "src2"]) ++ ++ ++def test_hold_pkgs_sources(): ++ patch_versionlock = patch.object(yumpkg, "_check_versionlock", MagicMock()) ++ patch_list_holds = patch.object(yumpkg, "list_holds", MagicMock()) ++ mock_call_yum = MagicMock(return_value={"retcode": 0}) ++ patch_call_yum = patch.object(yumpkg, "_call_yum", mock_call_yum) ++ patch_opts = patch.dict(yumpkg.__opts__, {"test": False}) ++ expected = { ++ "foo": { ++ "name": "foo", ++ "changes": { ++ "new": "hold", ++ "old": "", ++ }, ++ "result": True, ++ "comment": "Package foo is now being held.", ++ }, ++ "bar": { ++ "name": "bar", ++ "changes": { ++ "new": "hold", ++ "old": "", ++ }, ++ "result": True, ++ "comment": "Package bar is now being held.", ++ }, ++ } ++ sources = [{"foo": "salt://foo.rpm"}, {"bar": "salt://bar.rpm"}] ++ pkgs = ["foo", "bar"] ++ with patch_versionlock, patch_list_holds, patch_call_yum, patch_opts: ++ result = yumpkg.hold(sources=sources) ++ assert result == expected ++ with patch_versionlock, patch_list_holds, patch_call_yum, patch_opts: ++ result = yumpkg.hold(pkgs=pkgs) ++ assert result == expected ++ ++ ++def test_hold_test_true(): ++ patch_versionlock = patch.object(yumpkg, "_check_versionlock", MagicMock()) ++ patch_list_holds = patch.object(yumpkg, "list_holds", MagicMock()) ++ mock_call_yum = MagicMock(return_value={"retcode": 0}) ++ patch_call_yum = patch.object(yumpkg, "_call_yum", mock_call_yum) ++ patch_opts = patch.dict(yumpkg.__opts__, {"test": True}) ++ with patch_versionlock, patch_list_holds, patch_call_yum, patch_opts: ++ result = yumpkg.hold(name="foo") ++ expected = { ++ "foo": { ++ "name": "foo", ++ "changes": {}, ++ "result": None, ++ "comment": "Package foo is set to be held.", ++ }, ++ } ++ assert result == expected ++ ++ ++def test_hold_fails(): ++ patch_versionlock = patch.object(yumpkg, "_check_versionlock", MagicMock()) ++ patch_list_holds = patch.object(yumpkg, "list_holds", MagicMock()) ++ mock_call_yum = MagicMock(return_value={"retcode": 1}) ++ patch_call_yum = patch.object(yumpkg, "_call_yum", mock_call_yum) ++ patch_opts = patch.dict(yumpkg.__opts__, {"test": False}) ++ with patch_versionlock, patch_list_holds, patch_call_yum, patch_opts: ++ result = yumpkg.hold(name="foo") ++ expected = { ++ "foo": { ++ "name": "foo", ++ "changes": {}, ++ "result": False, ++ "comment": "Package foo was unable to be held.", ++ }, ++ } ++ assert result == expected ++ ++ ++def test_hold_already_held(): ++ patch_versionlock = patch.object(yumpkg, "_check_versionlock", MagicMock()) ++ mock_list_holds = MagicMock(return_value=["foo"]) ++ patch_list_holds = patch.object(yumpkg, "list_holds", mock_list_holds) ++ with patch_versionlock, patch_list_holds: ++ result = yumpkg.hold(name="foo") ++ expected = { ++ "foo": { ++ "name": "foo", ++ "changes": {}, ++ "result": True, ++ "comment": "Package foo is already set to be held.", ++ }, ++ } ++ assert result == expected ++ ++ ++def test_unhold_empty(): ++ """ ++ Tests that we raise a SaltInvocationError if nothing is passed ++ """ ++ with patch.object(yumpkg, "_check_versionlock", MagicMock()): ++ with pytest.raises(SaltInvocationError): ++ yumpkg.unhold() ++ ++ ++def test_unhold_pkgs_and_sources_error(): ++ """ ++ Tests that we raise a SaltInvocationError if both pkgs and sources is passed ++ """ ++ with patch.object(yumpkg, "_check_versionlock", MagicMock()): ++ with pytest.raises(SaltInvocationError): ++ yumpkg.unhold(pkgs=["foo", "bar"], sources=["src1", "src2"]) ++ ++ ++def test_unhold_pkgs_sources(): ++ patch_versionlock = patch.object(yumpkg, "_check_versionlock", MagicMock()) ++ mock_list_holds = MagicMock(return_value=["foo", "bar"]) ++ patch_list_holds = patch.object(yumpkg, "list_holds", mock_list_holds) ++ mock_call_yum = MagicMock(return_value={"retcode": 0}) ++ patch_call_yum = patch.object(yumpkg, "_call_yum", mock_call_yum) ++ patch_opts = patch.dict(yumpkg.__opts__, {"test": False}) ++ patch_yum = patch.object(yumpkg, "_yum", MagicMock(return_value="dnf")) ++ expected = { ++ "foo": { ++ "name": "foo", ++ "changes": { ++ "new": "", ++ "old": "hold", ++ }, ++ "result": True, ++ "comment": "Package foo is no longer held.", ++ }, ++ "bar": { ++ "name": "bar", ++ "changes": { ++ "new": "", ++ "old": "hold", ++ }, ++ "result": True, ++ "comment": "Package bar is no longer held.", ++ }, ++ } ++ sources = [{"foo": "salt://foo.rpm"}, {"bar": "salt://bar.rpm"}] ++ pkgs = ["foo", "bar"] ++ with patch_versionlock, patch_list_holds, patch_call_yum, patch_opts, patch_yum: ++ result = yumpkg.unhold(sources=sources) ++ assert result == expected ++ ++ with patch_versionlock, patch_list_holds, patch_call_yum, patch_opts, patch_yum: ++ result = yumpkg.unhold(pkgs=pkgs) ++ assert result == expected ++ ++ ++def test_unhold_test_true(): ++ patch_versionlock = patch.object(yumpkg, "_check_versionlock", MagicMock()) ++ mock_list_holds = MagicMock(return_value=["foo"]) ++ patch_list_holds = patch.object(yumpkg, "list_holds", mock_list_holds) ++ patch_opts = patch.dict(yumpkg.__opts__, {"test": True}) ++ patch_yum = patch.object(yumpkg, "_yum", MagicMock(return_value="dnf")) ++ with patch_versionlock, patch_list_holds, patch_opts, patch_yum: ++ result = yumpkg.unhold(name="foo") ++ expected = { ++ "foo": { ++ "name": "foo", ++ "changes": {}, ++ "result": None, ++ "comment": "Package foo is set to be unheld.", ++ }, ++ } ++ assert result == expected ++ ++ ++def test_unhold_fails(): ++ patch_versionlock = patch.object(yumpkg, "_check_versionlock", MagicMock()) ++ mock_list_holds = MagicMock(return_value=["foo"]) ++ patch_list_holds = patch.object(yumpkg, "list_holds", mock_list_holds) ++ mock_call_yum = MagicMock(return_value={"retcode": 1}) ++ patch_call_yum = patch.object(yumpkg, "_call_yum", mock_call_yum) ++ patch_opts = patch.dict(yumpkg.__opts__, {"test": False}) ++ patch_yum = patch.object(yumpkg, "_yum", MagicMock(return_value="dnf")) ++ with patch_versionlock, patch_list_holds, patch_call_yum, patch_opts, patch_yum: ++ result = yumpkg.unhold(name="foo") ++ expected = { ++ "foo": { ++ "name": "foo", ++ "changes": {}, ++ "result": False, ++ "comment": "Package foo was unable to be unheld.", ++ }, ++ } ++ assert result == expected ++ ++ ++def test_unhold_already_unheld(): ++ patch_versionlock = patch.object(yumpkg, "_check_versionlock", MagicMock()) ++ mock_list_holds = MagicMock(return_value=[]) ++ patch_list_holds = patch.object(yumpkg, "list_holds", mock_list_holds) ++ with patch_versionlock, patch_list_holds: ++ result = yumpkg.unhold(name="foo") ++ expected = { ++ "foo": { ++ "name": "foo", ++ "changes": {}, ++ "result": True, ++ "comment": "Package foo is not being held.", ++ }, ++ } ++ assert result == expected ++ ++ ++def test_owner_empty(): ++ assert yumpkg.owner() == "" ++ ++ ++def test_owner_not_owned(): ++ mock_stdout = MagicMock(return_value="not owned") ++ expected = { ++ "/fake/path1": "", ++ "/fake/path2": "", ++ } ++ with patch.dict(yumpkg.__salt__, {"cmd.run_stdout": mock_stdout}): ++ result = yumpkg.owner(*expected.keys()) ++ assert result == expected ++ ++ ++def test_owner_not_owned_single(): ++ mock_stdout = MagicMock(return_value="not owned") ++ with patch.dict(yumpkg.__salt__, {"cmd.run_stdout": mock_stdout}): ++ result = yumpkg.owner("/fake/path") ++ assert result == "" ++ ++ ++def test_parse_repo_file_error(): ++ mock_read = MagicMock( ++ side_effect=configparser.MissingSectionHeaderError("spongebob", 101, "test2") ++ ) ++ with patch.object(configparser.ConfigParser, "read", mock_read): ++ result = yumpkg._parse_repo_file("spongebob") ++ assert result == ("", {}) ++ ++ + def test_pkg_hold_dnf(): + """ + Tests that we properly identify versionlock plugin when using dnf +@@ -1606,14 +2458,84 @@ def test_pkg_hold_dnf(): + ) + + +-@pytest.mark.skipif(not yumpkg.HAS_YUM, reason="Could not import yum") +-def test_yum_base_error(): +- with patch("yum.YumBase") as mock_yum_yumbase: +- mock_yum_yumbase.side_effect = CommandExecutionError ++def test_get_yum_config_no_config(): ++ with patch("os.path.exists", MagicMock(return_value=False)): + with pytest.raises(CommandExecutionError): + yumpkg._get_yum_config() + + ++def test_get_yum_config(grains): ++ os_family = grains["os_family"] ++ if os_family in ("Arch", "Debian", "Suse"): ++ pytest.skip(f"{os_family} does not have yum.conf") ++ setting = "cache_dir" ++ if os_family == "RedHat": ++ ++ ++ ++ setting = "installonly_limit" ++ result = yumpkg._get_yum_config() ++ assert setting in result ++ ++ ++def test_get_yum_config_value_none(grains): ++ os_family = grains["os_family"] ++ if os_family in ("Arch", "Debian", "Suse"): ++ pytest.skip(f"{os_family} does not have yum.conf") ++ result = yumpkg._get_yum_config_value("spongebob") ++ assert result is None ++ ++ ++def test_get_yum_config_unreadable(): ++ with patch.object( ++ configparser.ConfigParser, "read", MagicMock(side_effect=OSError) ++ ): ++ with pytest.raises(CommandExecutionError): ++ yumpkg._get_yum_config() ++ ++ ++def test_get_yum_config_no_main(caplog): ++ mock_false = MagicMock(return_value=False) ++ with patch.object(configparser.ConfigParser, "read"), patch.object( ++ configparser.ConfigParser, "has_section", mock_false ++ ), patch("os.path.exists", MagicMock(return_value=True)): ++ yumpkg._get_yum_config() ++ assert "Could not find [main] section" in caplog.text ++ ++ ++def test_normalize_basedir_str(): ++ basedir = "/etc/yum/yum.conf,/etc/yum.conf" ++ result = yumpkg._normalize_basedir(basedir) ++ assert result == ["/etc/yum/yum.conf", "/etc/yum.conf"] ++ ++ ++def test_normalize_basedir_error(): ++ basedir = 1 ++ with pytest.raises(SaltInvocationError): ++ yumpkg._normalize_basedir(basedir) ++ ++ ++def test_normalize_name_noarch(): ++ assert yumpkg.normalize_name("zsh.noarch") == "zsh" ++ ++ ++def test_latest_version_no_names(): ++ assert yumpkg.latest_version() == "" ++ ++ ++def test_latest_version_nonzero_retcode(): ++ yum_ret = {"retcode": 1, "stderr": "some error"} ++ mock_call_yum = MagicMock(return_value=yum_ret) ++ patch_call_yum = patch.object(yumpkg, "_call_yum", mock_call_yum) ++ list_pkgs_ret = {"foo": "1.1", "bar": "2.2"} ++ mock_list_pkgs = MagicMock(return_value=list_pkgs_ret) ++ patch_list_pkgs = patch.object(yumpkg, "list_pkgs", mock_list_pkgs) ++ patch_get_options = patch.object(yumpkg, "_get_options", MagicMock()) ++ patch_refresh_db = patch.object(yumpkg, "refresh_db", MagicMock()) ++ with patch_list_pkgs, patch_call_yum, patch_get_options, patch_refresh_db: ++ assert yumpkg.latest_version("foo", "bar") == {"foo": "", "bar": ""} ++ ++ + def test_group_info(): + """ + Test yumpkg.group_info parsing +@@ -1855,6 +2777,180 @@ def test_group_info(): + assert info == expected + + ++def test_group_install(): ++ group_info = ( ++ { ++ "default": ["spongebob", "gary", "patrick"], ++ "mandatory": ["spongebob", "gary"], ++ }, ++ { ++ "default": ["mr_krabs", "pearl_krabs", "plankton"], ++ "mandatory": ["mr_krabs", "pearl_krabs"], ++ }, ++ ) ++ mock_info = MagicMock(side_effect=group_info) ++ patch_info = patch.object(yumpkg, "group_info", mock_info) ++ mock_list_pkgs = MagicMock(return_value=[]) ++ patch_list_pkgs = patch.object(yumpkg, "list_pkgs", mock_list_pkgs) ++ patch_install = patch.object(yumpkg, "install", MagicMock()) ++ expected = [ ++ "mr_krabs", ++ "gary", ++ "pearl_krabs", ++ "plankton", ++ "spongebob", ++ "patrick", ++ ] ++ with patch_info, patch_list_pkgs, patch_install: ++ yumpkg.group_install("spongebob,mr_krabs") ++ _, kwargs = yumpkg.install.call_args ++ assert kwargs["pkgs"].sort() == expected.sort() ++ ++ ++def test_group_install_include(): ++ group_info = ( ++ { ++ "default": ["spongebob", "gary", "patrick"], ++ "mandatory": ["spongebob", "gary"], ++ }, ++ { ++ "default": ["mr_krabs", "pearl_krabs", "plankton"], ++ "mandatory": ["mr_krabs", "pearl_krabs"], ++ }, ++ ) ++ mock_info = MagicMock(side_effect=group_info) ++ patch_info = patch.object(yumpkg, "group_info", mock_info) ++ mock_list_pkgs = MagicMock(return_value=[]) ++ patch_list_pkgs = patch.object(yumpkg, "list_pkgs", mock_list_pkgs) ++ patch_install = patch.object(yumpkg, "install", MagicMock()) ++ expected = [ ++ "mr_krabs", ++ "gary", ++ "pearl_krabs", ++ "plankton", ++ "spongebob", ++ "patrick", ++ ] ++ with patch_info, patch_list_pkgs, patch_install: ++ yumpkg.group_install("spongebob,mr_krabs", include="napoleon") ++ _, kwargs = yumpkg.install.call_args ++ expected.append("napoleon") ++ assert kwargs["pkgs"].sort() == expected.sort() ++ ++ ++def test_group_install_skip(): ++ group_info = ( ++ { ++ "default": ["spongebob", "gary", "patrick"], ++ "mandatory": ["spongebob", "gary"], ++ }, ++ { ++ "default": ["mr_krabs", "pearl_krabs", "plankton"], ++ "mandatory": ["mr_krabs", "pearl_krabs"], ++ }, ++ ) ++ mock_info = MagicMock(side_effect=group_info) ++ patch_info = patch.object(yumpkg, "group_info", mock_info) ++ mock_list_pkgs = MagicMock(return_value=[]) ++ patch_list_pkgs = patch.object(yumpkg, "list_pkgs", mock_list_pkgs) ++ patch_install = patch.object(yumpkg, "install", MagicMock()) ++ expected = [ ++ "mr_krabs", ++ "gary", ++ "pearl_krabs", ++ "spongebob", ++ "patrick", ++ ] ++ with patch_info, patch_list_pkgs, patch_install: ++ yumpkg.group_install("spongebob,mr_krabs", skip="plankton") ++ _, kwargs = yumpkg.install.call_args ++ assert kwargs["pkgs"].sort() == expected.sort() ++ ++ ++def test_group_install_already_present(): ++ group_info = ( ++ { ++ "default": ["spongebob", "gary", "patrick"], ++ "mandatory": ["spongebob", "gary"], ++ }, ++ { ++ "default": ["mr_krabs", "pearl_krabs", "plankton"], ++ "mandatory": ["mr_krabs", "pearl_krabs"], ++ }, ++ ) ++ mock_info = MagicMock(side_effect=group_info) ++ patch_info = patch.object(yumpkg, "group_info", mock_info) ++ patch_install = patch.object(yumpkg, "install", MagicMock()) ++ expected = [ ++ "mr_krabs", ++ "gary", ++ "pearl_krabs", ++ "plankton", ++ "spongebob", ++ "patrick", ++ ] ++ mock_list_pkgs = MagicMock(return_value=expected) ++ patch_list_pkgs = patch.object(yumpkg, "list_pkgs", mock_list_pkgs) ++ with patch_info, patch_list_pkgs, patch_install: ++ assert yumpkg.group_install("spongebob,mr_krabs") == {} ++ ++ ++def test_group_install_no_groups(): ++ with pytest.raises(SaltInvocationError): ++ yumpkg.group_install(None) ++ ++ ++def test_group_install_non_list_groups(): ++ with pytest.raises(SaltInvocationError): ++ yumpkg.group_install(1) ++ ++ ++def test_group_install_non_list_skip(): ++ with pytest.raises(SaltInvocationError): ++ yumpkg.group_install(name="string", skip=1) ++ ++ ++def test_group_install_non_list_include(): ++ with pytest.raises(SaltInvocationError): ++ yumpkg.group_install(name="string", include=1) ++ ++ ++def test_group_list(): ++ mock_out = MagicMock( ++ return_value="""\ ++Available Environment Groups: ++ Spongebob ++ Squarepants ++Installed Environment Groups: ++ Patrick ++Installed Groups: ++ Squidward ++ Sandy ++Available Groups: ++ Mr. Krabs ++ Plankton ++Available Language Groups: ++ Gary the Snail [sb]\ ++ """ ++ ) ++ patch_grplist = patch.dict(yumpkg.__salt__, {"cmd.run_stdout": mock_out}) ++ with patch_grplist: ++ result = yumpkg.group_list() ++ expected = { ++ "installed": ["Squidward", "Sandy"], ++ "available": ["Mr. Krabs", "Plankton"], ++ "installed environments": ["Patrick"], ++ "available environments": ["Spongebob", "Squarepants"], ++ "available languages": { ++ "Gary the Snail [sb]": { ++ "language": "sb", ++ "name": "Gary the Snail", ++ }, ++ }, ++ } ++ assert result == expected ++ ++ + def test_get_repo_with_existent_repo(list_repos_var): + """ + Test get_repo with an existent repository +@@ -2063,6 +3159,15 @@ def test_services_need_restart_requires_dnf(): + pytest.raises(CommandExecutionError, yumpkg.services_need_restart) + + ++def test_services_need_restart_no_dnf_output(): ++ patch_yum = patch("salt.modules.yumpkg._yum", Mock(return_value="dnf")) ++ patch_booted = patch("salt.utils.systemd.booted", Mock(return_value=True)) ++ mock_run_stdout = MagicMock(return_value="") ++ patch_run_stdout = patch.dict(yumpkg.__salt__, {"cmd.run_stdout": mock_run_stdout}) ++ with patch_yum, patch_booted, patch_run_stdout: ++ assert yumpkg.services_need_restart() == [] ++ ++ + def test_61003_pkg_should_not_fail_when_target_not_in_old_pkgs(): + patch_list_pkgs = patch( + "salt.modules.yumpkg.list_pkgs", return_value={}, autospec=True +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+3S327CIBiHYY69iu8G2oKVerRrMdY2q5mUpsCy3v1qPXBZsnmiWRbf5wA+/iRA ++fuR1Op6aXdu/F+pR9Gxr7dLPvvdLbexal9qajd0qbUylSyX2YTf6IoW4H0XU6H38bd+t9X8qv+Yf ++2xB3B+/cvm/y0N3vjFv5m3V1zV+f899UxijR97vCz548/0MjS/B126yGKXa+LyVzMpfzpJybUFwG ++oUj9MRbON+nUhstvmZIb3l7zYZLsQ7Is1i+h82Nc/fWrAAAAAAAAAAAAAAAAgOfwCSWWSTMAKAAA +diff --git 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-002572/tests/test.sh b/tasks/format-code-task-002572/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e935e396475664fae253ff54eff9898c186f2642 --- /dev/null +++ b/tasks/format-code-task-002572/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/pytests/unit/modules/test_yumpkg.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-002572/tests/test_command.sh b/tasks/format-code-task-002572/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002572/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002581/environment/Dockerfile b/tasks/format-code-task-002581/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6993eb1534a40619d71e2bac8d969396dd957e0a --- /dev/null +++ b/tasks/format-code-task-002581/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:72435335ac7e4b994228ff11d0dc733ceb23fc11f8b7ea21ce27ee1b2c00d532 diff --git a/tasks/format-code-task-002581/environment/setup/files/blocklist b/tasks/format-code-task-002581/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002581/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002581/environment/setup/setup.sh b/tasks/format-code-task-002581/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002581/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002581/tests/test.patch b/tasks/format-code-task-002581/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..423325f286fe964941fea368f5d9ebe144b2dec3 --- /dev/null +++ b/tasks/format-code-task-002581/tests/test.patch @@ -0,0 +1,59 @@ +diff --git a/src/test/python/test_imsc_reader.py b/src/test/python/test_imsc_reader.py +index 1e944b42..913dc1ec 100644 +--- a/src/test/python/test_imsc_reader.py ++++ b/src/test/python/test_imsc_reader.py +@@ -35,7 +35,6 @@ + import ttconv.model as model + import ttconv.style_properties as styles + import ttconv.imsc.reader as imsc_reader +-import ttconv.imsc.namespaces as xml_ns + + class IMSCReaderTest(unittest.TestCase): + +@@ -222,5 +221,25 @@ def test_frame_rate(self): + + self.assertEqual(p.get_end(), Fraction(4394201, 1000)) + ++ def test_ooo_set_element(self): ++ xml_str = """ ++ ++ ++

hello

++ ++

bye

++ ++
""" ++ ++ tree = et.ElementTree(et.fromstring(xml_str)) ++ ++ with self.assertLogs() as logs: ++ logging.getLogger().info("*****dummy*****") ++ self.assertIsNotNone(imsc_reader.to_model(tree)) ++ if len(logs.output) != 2: ++ self.fail(logs.output) ++ + if __name__ == '__main__': + unittest.main() +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3SW2rEIBQG4DxnFWcDJjHEZjkhUekIEw3eYHY/JgNtKbTzMkMZ+n8vihfOwd9m ++SeasJm1zWz1LV4xCHGPxfTzmXPScj53o93XOxdhXJJ7W0RcpxNkTVd65+Nu5e/svqvnMP+oQJ+nW ++dbaqCafH1biXf9/zj/z5sOc/vHVDRd3jWvjZP89fKjqCX7Sq302kkJbVqXTWlDY1R02MGVvWGfNa ++Jh9M1nVwyUtNrdtiG6N0NrO8f6DF2HaW0eRyr94u8eQssZXKrBSg4OVRqb3t3L6bWYOcvJ6V9s12 ++IZbrv34QAAAAAAAAAAAAAAAAAAAAAIAXcgUYYMP4ACgAAA== +diff --git 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-002581/tests/test.sh b/tasks/format-code-task-002581/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..7e1cfcc2419225e808c097865a6e6e0973375e2f --- /dev/null +++ b/tasks/format-code-task-002581/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/test/python/test_imsc_reader.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-002581/tests/test_command.sh b/tasks/format-code-task-002581/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002581/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002586/environment/Dockerfile b/tasks/format-code-task-002586/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..4dfa99ea2db4ca6b782344194f09e6b5886cc9a8 --- /dev/null +++ b/tasks/format-code-task-002586/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:51a85acf6880818e04797345e3a98990977371126a7e9fb7b9ef1a41c95f7d4d diff --git a/tasks/format-code-task-002586/environment/setup/files/blocklist b/tasks/format-code-task-002586/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002586/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002586/environment/setup/setup.sh b/tasks/format-code-task-002586/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002586/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002586/tests/test.patch b/tasks/format-code-task-002586/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..116236f9fbfcfe10fdd737b6135f2e6ac97776f1 --- /dev/null +++ b/tasks/format-code-task-002586/tests/test.patch @@ -0,0 +1,103 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..e833543 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/mocha -R spec -t 3000 tests/rules/single-line-per-selector.js"] ++} +diff --git a/tests/rules/single-line-per-selector.js b/tests/rules/single-line-per-selector.js +index 68c4925..8d82b55 100644 +--- a/tests/rules/single-line-per-selector.js ++++ b/tests/rules/single-line-per-selector.js +@@ -18,6 +18,35 @@ describe('single line per selector - scss', function () { + }); + }); + ++describe('single line per selector - scss with inline comments (issue)', function () { ++ var file = lint.file('single-line-per-selector-comments.scss'); ++ ++ it('inline and block comments after selector comma should not be reported', function (done) { ++ lint.test(file, { ++ 'single-line-per-selector': 1 ++ }, function (data) { ++ lint.assert.equal(0, data.warningCount); ++ done(); ++ }); ++ }); ++}); ++ ++describe('single line per selector - scss with mixed comments and violations', function () { ++ var file = lint.file('single-line-per-selector-mixed.scss'); ++ ++ it('reports only actual same-line selectors, not comments', function (done) { ++ lint.test(file, { ++ 'single-line-per-selector': 1 ++ }, function (data) { ++ ++ ++ lint.assert.equal(2, data.warningCount); ++ lint.assert.equal('Selectors must be placed on new lines', data.messages[0].message); ++ done(); ++ }); ++ }); ++}); ++ + ////////////////////////////// + // Sass syntax tests + ////////////////////////////// +diff --git a/tests/sass/single-line-per-selector-comments.scss b/tests/sass/single-line-per-selector-comments.scss +new file mode 100644 +index 0000000..91d2035 +--- /dev/null ++++ b/tests/sass/single-line-per-selector-comments.scss +@@ -0,0 +1,16 @@ ++button, ++html input[type='button'], // line comment ++input[type='reset'], ++input[type='submit'] { ++ color: red; ++} ++ ++.foo, // another comment ++.bar { ++ color: red; ++} ++ ++.baz, /* block comment */ ++.qux { ++ color: red; ++} +diff --git a/tests/sass/single-line-per-selector-mixed.scss b/tests/sass/single-line-per-selector-mixed.scss +new file mode 100644 +index 0000000..6e6dc54 +--- /dev/null ++++ b/tests/sass/single-line-per-selector-mixed.scss +@@ -0,0 +1,13 @@ ++.first, .second { ++ color: red; ++} ++ ++.foo, // a comment ++.bar, /* block */ ++.baz { ++ color: red; ++} ++ ++.qux, .quux { ++ color: red; ++} +diff --git 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/mocha -R spec -t 3000 tests/rules/single-line-per-selector.js ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002586/tests/test.sh b/tasks/format-code-task-002586/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6cc42a48c64fab507bfc1e55bcce30a9ce61a913 --- /dev/null +++ b/tasks/format-code-task-002586/tests/test.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +test_commands.json +tests/rules/single-line-per-selector.js +tests/sass/single-line-per-selector-comments.scss +tests/sass/single-line-per-selector-mixed.scss +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002586/tests/test_command.sh b/tasks/format-code-task-002586/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002586/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002588/environment/Dockerfile b/tasks/format-code-task-002588/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..683673e5419ac278a96b767aec081cfe1024e155 --- /dev/null +++ b/tasks/format-code-task-002588/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:916ae3eef0371b34c7c5a934c6879a97d110f2c81d59b44f858d4b2a82c7972c diff --git a/tasks/format-code-task-002588/environment/setup/files/blocklist b/tasks/format-code-task-002588/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002588/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002588/environment/setup/setup.sh b/tasks/format-code-task-002588/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002588/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002588/tests/test.patch b/tasks/format-code-task-002588/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..6d3bba5121689a7a1da00f440d076ad1b06ec445 --- /dev/null +++ b/tasks/format-code-task-002588/tests/test.patch @@ -0,0 +1,86 @@ +diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/KdocMethodsTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/KdocMethodsTest.kt +index 009cad3e52..3c8a123e3d 100644 +--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/KdocMethodsTest.kt ++++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/KdocMethodsTest.kt +@@ -61,17 +61,11 @@ class KdocMethodsTest : LintTestBase(::KdocMethods) { + lintMethod(validCode, fileName = "src/main/kotlin/org/cqfn/diktat/Example.kt") + // no false positive triggers on annotations + lintMethod(complexAnnotationCode, +- LintError(1, 1, ruleId, "${KDOC_WITHOUT_PARAM_TAG.warnText()} doubleInt (a)", true), +- LintError(1, 1, ruleId, "${KDOC_WITHOUT_RETURN_TAG.warnText()} doubleInt", true), +- LintError(1, 1, ruleId, "${KDOC_WITHOUT_THROWS_TAG.warnText()} doubleInt (IllegalStateException)", true), + LintError(1, 1, ruleId, "${MISSING_KDOC_ON_FUNCTION.warnText()} doubleInt", true), + fileName = "src/main/kotlin/org/cqfn/diktat/Example.kt" + ) + // should check all .kt files unless both conditions on location and name are true + lintMethod(funCode, +- LintError(1, 1, ruleId, "${KDOC_WITHOUT_PARAM_TAG.warnText()} doubleInt (a)", true), +- LintError(1, 1, ruleId, "${KDOC_WITHOUT_RETURN_TAG.warnText()} doubleInt", true), +- LintError(1, 1, ruleId, "${KDOC_WITHOUT_THROWS_TAG.warnText()} doubleInt (IllegalStateException)", true), + LintError(1, 1, ruleId, "${MISSING_KDOC_ON_FUNCTION.warnText()} doubleInt", true), + fileName = "src/test/kotlin/org/cqfn/diktat/Example.kt" + ) +@@ -308,9 +302,7 @@ class KdocMethodsTest : LintTestBase(::KdocMethods) { + |} + """.trimMargin(), + LintError(10, 5, ruleId, "${MISSING_KDOC_ON_FUNCTION.warnText()} getY", false), +- LintError(12, 5, ruleId, "${KDOC_WITHOUT_PARAM_TAG.warnText()} setY (y)", true), + LintError(12, 5, ruleId, "${MISSING_KDOC_ON_FUNCTION.warnText()} setY", true), +- LintError(17, 5, ruleId, "${KDOC_WITHOUT_RETURN_TAG.warnText()} getZ", true), + LintError(17, 5, ruleId, "${MISSING_KDOC_ON_FUNCTION.warnText()} getZ", true) + ) + } +@@ -353,4 +345,19 @@ class KdocMethodsTest : LintTestBase(::KdocMethods) { + """.trimMargin() + ) + } ++ ++ @Test ++ @Tag(WarningNames.MISSING_KDOC_ON_FUNCTION) ++ fun `should check if KfDoc is not trivial`() { ++ lintMethod( ++ """ ++ |fun foo(x: Int): TypeX { ++ | val q = goo() ++ | throw UnsupportedOperationException() ++ | return qwe ++ |} ++ """.trimMargin(), ++ LintError(1, 1, ruleId, "${MISSING_KDOC_ON_FUNCTION.warnText()} foo", true) ++ ) ++ } + } +diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/KdocParamPresentWarnTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/KdocParamPresentWarnTest.kt +index 0aead5a7b3..95d6c374ef 100644 +--- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/KdocParamPresentWarnTest.kt ++++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/KdocParamPresentWarnTest.kt +@@ -103,7 +103,6 @@ class KdocParamPresentWarnTest : LintTestBase(::KdocMethods) { + |* @param a - qwe + |*/ + """.trimMargin(), +- LintError(1, 1, ruleId, "${KDOC_WITHOUT_PARAM_TAG.warnText()} foo (b, a)", true), + LintError(1, 1, ruleId, "${MISSING_KDOC_ON_FUNCTION.warnText()} foo", true) + ) + } +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+3SQW/CIBQH8J79FMSzZa0WPXnbZVm2eFiyo8FClUjBAXVff9At0SyZ7qBZzP6/ ++C5RX+h590FWntFhKs7/LrqWIZoz1Y/R97OclGxeTYlJVRZUVZclmVUbY1So60vnAHSGZszaceu9c ++/EbRQ/+D9GFZ27blRlC/uVyOc/2vpof+j9k09r+aliwjxeVK+Nk/738tSN/4lRSDdm+IMvF/aE3y ++e79Vu5cY8XHe8r00dK1Cuh4qqHg/YnQeXCdJvtNEqG3gIU9Ra0ZfT+mzeeN4K9+t25Kct32GtHy8 ++yXVaphxpfT60bk3rt8bQzyjtozLQesN3QboxfRS2fpJhY4VP1Y1+tWHBYxkLFwMmvHJn0s5hzNlw ++pR+aZ9ufc95w7eXp0w7+ul8AAAAAAAAAAAAAAAAAAAAAAMc+AFih210AKAAA +diff --git 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-002588/tests/test.sh b/tasks/format-code-task-002588/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..4f1b69cf9b8324e4a955eb7c855e0bf74c4a728b --- /dev/null +++ b/tasks/format-code-task-002588/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' +diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/KdocMethodsTest.kt +diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/chapter2/KdocParamPresentWarnTest.kt +mimo_build_env.tar.gz.b64 +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002588/tests/test_command.sh b/tasks/format-code-task-002588/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002588/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002722/environment/Dockerfile b/tasks/format-code-task-002722/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6ca80f4fed44ae18e24c1381823daa0567b869b4 --- /dev/null +++ b/tasks/format-code-task-002722/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:825c64cc0298496a806471ba624e3abb0bb25e1d08fefda6bd2964408f4e6221 diff --git a/tasks/format-code-task-002722/environment/setup/files/blocklist b/tasks/format-code-task-002722/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002722/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002722/environment/setup/setup.sh b/tasks/format-code-task-002722/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002722/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002722/tests/test.patch b/tasks/format-code-task-002722/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..1345d4d3154187f279284f1187f5df1098b026bb --- /dev/null +++ b/tasks/format-code-task-002722/tests/test.patch @@ -0,0 +1,99 @@ +diff --git a/test/rules/std_RF02_test.py b/test/rules/std_RF02_test.py +index e9a774693..87deb3531 100644 +--- a/test/rules/std_RF02_test.py ++++ b/test/rules/std_RF02_test.py +@@ -13,3 +13,72 @@ def test__rules__std_RF02_wildcard_single_count(): + result = sqlfluff.lint(sql) + assert "RF02" in [r["code"] for r in result] + assert [r["code"] for r in result].count("RF02") == 1 ++ ++ ++def test__rules__std_RF02_unaliased_subquery_single_table(): ++ """Inner select with single table should not raise RF02 (issue #5811). ++ ++ Reproduces the exact snippet from the GitHub issue. ++ """ ++ sql = "SELECT *\nFROM (SELECT a FROM table_a)\n" ++ result = sqlfluff.lint(sql, dialect="postgres") ++ rf02 = [r for r in result if r["code"] == "RF02"] ++ assert rf02 == [], f"Unexpected RF02 violations: {rf02}" ++ ++ ++def test__rules__std_RF02_aliased_subquery_single_table(): ++ """Inner select with single table inside an ALIASED subquery. ++ ++ Discriminates fixes that skip only unnamed subqueries (ref_str filter). ++ """ ++ sql = "SELECT *\nFROM (SELECT a FROM tab) AS sub\n" ++ result = sqlfluff.lint(sql, dialect="postgres") ++ rf02 = [r for r in result if r["code"] == "RF02"] ++ assert rf02 == [], f"Unexpected RF02 violations: {rf02}" ++ ++ ++def test__rules__std_RF02_subquery_mix_with_outer_join_still_flagged(): ++ """Preservation: subquery whose parent has another real table. ++ ++ Outer scope is (subquery_alias, vee). After excluding the subquery ++ itself, the inner SELECT still sees a sibling table (vee), so the ++ unqualified reference `c` inside the subquery should be flagged. ++ """ ++ sql = ( ++ "SELECT foo.a, vee.b\n" ++ "FROM (\n" ++ " SELECT c\n" ++ " FROM bar\n" ++ ") AS foo\n" ++ "LEFT JOIN vee ON vee.a = foo.a\n" ++ ) ++ result = sqlfluff.lint(sql, dialect="postgres") ++ rf02 = [r for r in result if r["code"] == "RF02"] ++ inner_c = [r for r in rf02 if "'c'" in r.get("description", "")] ++ assert inner_c, f"Expected RF02 violation for inner 'c'; got {rf02}" ++ ++ ++def test__rules__std_RF02_nested_subquery_single_table(): ++ """Doubly-nested subquery, each level with one table — no RF02.""" ++ sql = "SELECT *\nFROM (SELECT * FROM (SELECT a FROM tab))\n" ++ result = sqlfluff.lint(sql, dialect="postgres") ++ rf02 = [r for r in result if r["code"] == "RF02"] ++ assert rf02 == [], f"Unexpected RF02 violations: {rf02}" ++ ++ ++def test__rules__std_RF02_multitable_inner_still_flagged(): ++ """Preservation: inner select with multiple tables still flags unqualified refs.""" ++ sql = ( ++ "SELECT a\n" ++ "FROM (\n" ++ " SELECT a, b\n" ++ " FROM foo\n" ++ " LEFT JOIN vee ON vee.a = foo.a\n" ++ ")\n" ++ ) ++ result = sqlfluff.lint(sql, dialect="postgres") ++ rf02 = [r for r in result if r["code"] == "RF02"] ++ inner_a = [r for r in rf02 if "'a'" in r.get("description", "")] ++ inner_b = [r for r in rf02 if "'b'" in r.get("description", "")] ++ assert inner_a, f"Expected RF02 for inner unqualified 'a'; got {rf02}" ++ assert inner_b, f"Expected RF02 for inner unqualified 'b'; got {rf02}" +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..662c409be +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest test/rules/std_RF02_test.py -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest test/rules/std_RF02_test.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002722/tests/test.sh b/tasks/format-code-task-002722/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..597d80e1ad3a91f9ca86ee181478e242ab0ffa64 --- /dev/null +++ b/tasks/format-code-task-002722/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/rules/std_RF02_test.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002722/tests/test_command.sh b/tasks/format-code-task-002722/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002722/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002723/environment/Dockerfile b/tasks/format-code-task-002723/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..d10e78f006fdc343f3386b9080862815ca4a35f9 --- /dev/null +++ b/tasks/format-code-task-002723/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:ff6185ee56b985806b6848d5b365ac3e9b21ff4e1f1217ffc984a375528a6e57 diff --git a/tasks/format-code-task-002723/environment/setup/files/blocklist b/tasks/format-code-task-002723/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002723/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002723/environment/setup/setup.sh b/tasks/format-code-task-002723/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002723/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002723/tests/test.patch b/tasks/format-code-task-002723/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..82af55d2701199ec3bdb75de19b1b9206be7ab11 --- /dev/null +++ b/tasks/format-code-task-002723/tests/test.patch @@ -0,0 +1,137 @@ +diff --git a/test/rules/std_LT02_jinja_test.py b/test/rules/std_LT02_jinja_test.py +new file mode 100644 +index 000000000..70335dd63 +--- /dev/null ++++ b/test/rules/std_LT02_jinja_test.py +@@ -0,0 +1,109 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import sqlfluff ++ ++ ++ ++JINJA_NESTED_LOOPS_SQL = ( ++ "-- sqlfluff:templater:jinja:context:tables:" ++ "['tbl_a','tbl_b','tbl_c']\n" ++ "-- sqlfluff:templater:jinja:context:each_table_cols:" ++ "[['aa', 'ab', 'ac'],['ba','bb','bc'],['ca','cb','cc']]\n" ++ "-- sqlfluff:indentation:template_blocks_indent:false\n" ++ "\n" ++ "CREATE OR REPLACE TRANSIENT TABLE TEST AS\n" ++ "WITH abc AS (\n" ++ " SELECT\n" ++ " spine.some_id AS some_id\n" ++ " {% for cols in each_table_cols -%}\n" ++ " {%- set src_loop = loop -%}\n" ++ " {%- for c in cols -%}\n" ++ " , t{{ src_loop.index }}.\"{{ c }}\"\n" ++ " {% endfor %}\n" ++ " {%- endfor %}\n" ++ " FROM tbl AS spine\n" ++ " {% for t in tables %}\n" ++ " LEFT JOIN {{ t }} AS t{{ loop.index }}\n" ++ " ON spine.some_id = t{{ loop.index }}.some_id\n" ++ " {% endfor %}\n" ++ ")\n" ++ "\n" ++ "SELECT * FROM abc;\n" ++) ++ ++ ++def _lt02_violations(sql): ++ ++ return sqlfluff.lint(sql, dialect="ansi", rules=["LT02"]) ++ ++ ++def test__rules__std_LT02_jinja_nested_loops_no_crash(): ++ ++ ++ ++ ++ ++ ++ result = _lt02_violations(JINJA_NESTED_LOOPS_SQL) ++ ++ ++ for violation in result: ++ assert "Unexpected exception" not in violation["description"], ( ++ "LT02 raised an unexpected exception: " + violation["description"] ++ ) ++ assert "max() arg is an empty sequence" not in violation["description"], ( ++ "LT02 still hits the empty-overlap bug: " + violation["description"] ++ ) ++ ++ ++def test__rules__std_LT02_jinja_nested_loops_violations_exact(): ++ ++ ++ ++ ++ ++ ++ ++ ++ result = _lt02_violations(JINJA_NESTED_LOOPS_SQL) ++ ++ ++ for violation in result: ++ assert violation["code"] == "LT02" ++ ++ ++ locations = sorted( ++ (v["start_line_no"], v["start_line_pos"]) for v in result ++ ) ++ ++ ++ assert locations == [(18, 1)], ( ++ "Expected exactly one LT02 violation at L:18 P:1, " ++ f"got {locations!r}" ++ ) ++ ++ ++def test__rules__std_LT02_jinja_nested_loops_fix_is_stable(): ++ ++ ++ ++ fixed_once = sqlfluff.fix( ++ JINJA_NESTED_LOOPS_SQL, dialect="ansi", rules=["LT02"] ++ ) ++ assert isinstance(fixed_once, str) ++ ++ ++ assert "CREATE OR REPLACE TRANSIENT TABLE TEST AS" in fixed_once ++ ++ ++ fixed_twice = sqlfluff.fix(fixed_once, dialect="ansi", rules=["LT02"]) ++ assert fixed_once == fixed_twice +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..061fe0848 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=src python -m pytest test/rules/std_LT02_jinja_test.py -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=src python -m pytest test/rules/std_LT02_jinja_test.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002723/tests/test.sh b/tasks/format-code-task-002723/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..64294bcc7f9551192edbf3170f51f1afed122a02 --- /dev/null +++ b/tasks/format-code-task-002723/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/rules/std_LT02_jinja_test.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002723/tests/test_command.sh b/tasks/format-code-task-002723/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002723/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002724/environment/Dockerfile b/tasks/format-code-task-002724/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f98ee38dabb9b29e8e3d8311c3ca6ff2607028b6 --- /dev/null +++ b/tasks/format-code-task-002724/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:dcdbee7bc6de32bd3878bfe421943be75acb55081abc1472bf4b3d6d90db84a7 diff --git a/tasks/format-code-task-002724/environment/setup/files/blocklist b/tasks/format-code-task-002724/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002724/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002724/environment/setup/setup.sh b/tasks/format-code-task-002724/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002724/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002724/tests/test.patch b/tasks/format-code-task-002724/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9830523b5996eb1f4696c526d16874c063219d6 --- /dev/null +++ b/tasks/format-code-task-002724/tests/test.patch @@ -0,0 +1,118 @@ +diff --git a/test/dialects/duckdb_map_test.py b/test/dialects/duckdb_map_test.py +new file mode 100644 +index 000000000..e74e65c0e +--- /dev/null ++++ b/test/dialects/duckdb_map_test.py +@@ -0,0 +1,90 @@ ++ ++ ++ ++ ++ ++ ++import pytest ++ ++from sqlfluff.core import FluffConfig, Linter ++ ++ ++@pytest.fixture(scope="module") ++def linter(): ++ config = FluffConfig(overrides={"dialect": "duckdb"}) ++ return Linter(config=config) ++ ++ ++def _parse_clean(linter, sql): ++ parsed = linter.parse_string(sql) ++ assert not parsed.violations, ( ++ f"Unexpected parse violations for {sql!r}: {parsed.violations}" ++ ) ++ ++ unparsable = list(parsed.tree.recursive_crawl("unparsable")) ++ assert not unparsable, ( ++ f"Found unparsable segments for {sql!r}: " ++ f"{[u.raw for u in unparsable]}" ++ ) ++ return parsed.tree ++ ++ ++def test_create_table_map_varchar_varchar(linter): ++ ++ tree = _parse_clean( ++ linter, "CREATE TABLE map (tags MAP(VARCHAR, VARCHAR));" ++ ) ++ ++ assert list(tree.recursive_crawl("map_type")), ( ++ "Expected a map_type segment in the parse tree" ++ ) ++ ++ ++def test_create_table_map_integer_varchar(linter): ++ ++ _parse_clean( ++ linter, "CREATE TABLE m (col MAP(INTEGER, VARCHAR));" ++ ) ++ ++ ++def test_create_table_map_with_struct_value(linter): ++ ++ _parse_clean( ++ linter, ++ "CREATE TABLE m (col MAP(VARCHAR, STRUCT(a INTEGER, b VARCHAR)));", ++ ) ++ ++ ++def test_create_table_nested_map(linter): ++ ++ _parse_clean( ++ linter, ++ "CREATE TABLE m (col MAP(VARCHAR, MAP(VARCHAR, INTEGER)));", ++ ) ++ ++ ++def test_cast_to_map_using_cast_keyword(linter): ++ ++ _parse_clean( ++ linter, "SELECT CAST(x AS MAP(VARCHAR, INTEGER)) FROM t;" ++ ) ++ ++ ++def test_cast_to_map_using_double_colon(linter): ++ ++ _parse_clean( ++ linter, "SELECT x::MAP(VARCHAR, INTEGER) FROM t;" ++ ) ++ ++ ++def test_map_function_call_still_parses(linter): ++ ++ ++ ++ ++ ++ ++ ++ _parse_clean( ++ linter, "SELECT MAP(['a', 'b'], [1, 2]);" ++ ) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..6e25ec799 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=$PWD/src python -m pytest test/dialects/duckdb_map_test.py -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=$PWD/src python -m pytest test/dialects/duckdb_map_test.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002724/tests/test.sh b/tasks/format-code-task-002724/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..718b1df1e828ca0db55fcc0df7ea565b99af9726 --- /dev/null +++ b/tasks/format-code-task-002724/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/dialects/duckdb_map_test.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002724/tests/test_command.sh b/tasks/format-code-task-002724/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002724/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002725/environment/Dockerfile b/tasks/format-code-task-002725/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ebe850698c314f7d30e80fdeb581698b5df1eb43 --- /dev/null +++ b/tasks/format-code-task-002725/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3b19f437018b0ff3df3664e62ed878c5d8f6726aaf20339ff4855d2d8d77baba diff --git a/tasks/format-code-task-002725/environment/setup/files/blocklist b/tasks/format-code-task-002725/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002725/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002725/environment/setup/setup.sh b/tasks/format-code-task-002725/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002725/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002725/tests/test.patch b/tasks/format-code-task-002725/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..8d72d8cad006a21cffc977afab5075a5f26a41c5 --- /dev/null +++ b/tasks/format-code-task-002725/tests/test.patch @@ -0,0 +1,173 @@ +diff --git a/test/rules/std_RF02_test.py b/test/rules/std_RF02_test.py +index e9a774693..3a1a51843 100644 +--- a/test/rules/std_RF02_test.py ++++ b/test/rules/std_RF02_test.py +@@ -13,3 +13,146 @@ def test__rules__std_RF02_wildcard_single_count(): + result = sqlfluff.lint(sql) + assert "RF02" in [r["code"] for r in result] + assert [r["code"] for r in result].count("RF02") == 1 ++ ++ ++def _rf02_count(sql, dialect="ansi"): ++ return [r["code"] for r in sqlfluff.lint(sql, dialect=dialect)].count("RF02") ++ ++ ++def test__rules__std_RF02_issue_repro_trino(): ++ """Issue 6649: a FROM-subquery with one inner table must not trigger RF02 (Trino).""" ++ sql = ( ++ "SELECT\n" ++ " a.id AS a_id,\n" ++ " b.id AS b_id\n" ++ "FROM\n" ++ " (\n" ++ " SELECT id\n" ++ " FROM foo\n" ++ " ) AS a\n" ++ "JOIN bar AS b ON a.id = b.ib\n" ++ ) ++ assert _rf02_count(sql, dialect="trino") == 0 ++ ++ ++def test__rules__std_RF02_issue_repro_ansi(): ++ """Issue 6649: same as above but in ANSI dialect — must not trigger RF02.""" ++ sql = ( ++ "SELECT\n" ++ " a.id AS a_id,\n" ++ " b.id AS b_id\n" ++ "FROM\n" ++ " (\n" ++ " SELECT id\n" ++ " FROM foo\n" ++ " ) AS a\n" ++ "JOIN bar AS b ON a.id = b.ib\n" ++ ) ++ assert _rf02_count(sql, dialect="ansi") == 0 ++ ++ ++def test__rules__std_RF02_from_subquery_single_table_unqualified(): ++ """A FROM-subquery referencing only one inner table must not trigger RF02 ++ even though the outer query has multiple tables. ++ """ ++ sql = ( ++ "SELECT a.x, b.y\n" ++ "FROM (SELECT id, x FROM only_one) AS a\n" ++ "JOIN other AS b ON a.id = b.id\n" ++ ) ++ assert _rf02_count(sql) == 0 ++ ++ ++def test__rules__std_RF02_from_subquery_multi_table_unqualified_still_fails(): ++ """Preservation: a FROM-subquery whose inner SELECT itself has multiple tables ++ and unqualified columns must still trigger RF02 inside the subquery. ++ """ ++ sql = ( ++ "SELECT a\n" ++ "FROM (\n" ++ " SELECT a, b\n" ++ " FROM foo\n" ++ " LEFT JOIN vee ON vee.a = foo.a\n" ++ ")\n" ++ ) ++ assert _rf02_count(sql) >= 1 ++ ++ ++def test__rules__std_RF02_from_subquery_multi_table_qualified_passes(): ++ """Preservation: a FROM-subquery with multiple inner tables but fully qualified ++ references must not trigger RF02. ++ """ ++ sql = ( ++ "SELECT a\n" ++ "FROM (\n" ++ " SELECT foo.a, vee.b\n" ++ " FROM foo\n" ++ " LEFT JOIN vee ON vee.a = foo.a\n" ++ ")\n" ++ ) ++ assert _rf02_count(sql) == 0 ++ ++ ++def test__rules__std_RF02_where_subquery_unreferenced_still_fails(): ++ """Preservation (issue 6067): a WHERE subquery with an unqualified reference ++ that is ambiguous between the inner and outer table must still trigger RF02. ++ """ ++ sql = ( ++ "SELECT a\n" ++ "FROM foo\n" ++ "WHERE a IN (SELECT a FROM bar)\n" ++ ) ++ assert _rf02_count(sql) >= 1 ++ ++ ++def test__rules__std_RF02_where_subquery_referenced_passes(): ++ """Preservation (issue 6067): a WHERE subquery with a fully qualified reference ++ inside must not trigger RF02. ++ """ ++ sql = ( ++ "SELECT a\n" ++ "FROM foo\n" ++ "WHERE a IN (SELECT bar.a FROM bar)\n" ++ ) ++ assert _rf02_count(sql) == 0 ++ ++ ++def test__rules__std_RF02_basic_multi_table_unqualified_still_fails(): ++ """Preservation: the canonical RF02 trigger – multiple tables with ++ unqualified column references at the top level – must still fail. ++ """ ++ sql = ( ++ "SELECT a, b\n" ++ "FROM foo\n" ++ "LEFT JOIN vee ON vee.a = foo.a\n" ++ ) ++ assert _rf02_count(sql) >= 1 ++ ++ ++def test__rules__std_RF02_basic_multi_table_qualified_passes(): ++ """Preservation: the canonical RF02 happy path – multiple tables with ++ fully qualified references – must not trigger. ++ """ ++ sql = ( ++ "SELECT foo.a, vee.b\n" ++ "FROM foo\n" ++ "LEFT JOIN vee ON vee.a = foo.a\n" ++ ) ++ assert _rf02_count(sql) == 0 ++ ++ ++def test__rules__std_RF02_nested_correlated_where_in_from_subquery_fails(): ++ """Discriminator: a correlated-looking WHERE subquery inside a FROM subquery ++ must still surface its unqualified-reference ambiguity. The inner subquery's ++ parent is a single-table query, so 'id' is ambiguous between the inner ++ 'bar' table and the outer 'foo' table and RF02 must trigger. ++ """ ++ sql = ( ++ "SELECT *\n" ++ "FROM (\n" ++ " SELECT id\n" ++ " FROM foo\n" ++ " WHERE id IN (SELECT id FROM bar)\n" ++ ") AS sub\n" ++ ) ++ assert _rf02_count(sql) >= 1 +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..1feaa3bb6 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["PYTHONPATH=./src python -m pytest test/rules/std_RF02_test.py -v"] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++PYTHONPATH=./src python -m pytest test/rules/std_RF02_test.py -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002725/tests/test.sh b/tasks/format-code-task-002725/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..597d80e1ad3a91f9ca86ee181478e242ab0ffa64 --- /dev/null +++ b/tasks/format-code-task-002725/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/rules/std_RF02_test.py +test_commands.json +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002725/tests/test_command.sh b/tasks/format-code-task-002725/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002725/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002740/environment/Dockerfile b/tasks/format-code-task-002740/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..0b5eee0bd1d3fb1a851468c16fdb55d2c8c9bd90 --- /dev/null +++ b/tasks/format-code-task-002740/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:820a386f68cea59f3693ae6b6b24011ea075fd7ea8f6f9b83409875f759d2079 diff --git a/tasks/format-code-task-002740/environment/setup/files/blocklist b/tasks/format-code-task-002740/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002740/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002740/environment/setup/setup.sh b/tasks/format-code-task-002740/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002740/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002740/tests/test.patch b/tasks/format-code-task-002740/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..925ca9e62f7b074cd4acfbe5ddff60085002eaef --- /dev/null +++ b/tasks/format-code-task-002740/tests/test.patch @@ -0,0 +1,109 @@ +diff --git a/tests/test_sync_committee_cache.nim b/tests/test_sync_committee_cache.nim +new file mode 100644 +index 000000000..644cee4b7 +--- /dev/null ++++ b/tests/test_sync_committee_cache.nim +@@ -0,0 +1,72 @@ ++ ++ ++ ++ ++ ++ ++ ++{.used.} ++ ++import ++ std/[options], ++ chronicles, ++ unittest2, ++ eth/keys, taskpools, ++ ../beacon_chain/spec/datatypes/base, ++ ../beacon_chain/spec/[beaconstate, forks, helpers, state_transition], ++ ../beacon_chain/[beacon_chain_db], ++ ../beacon_chain/consensus_object_pools/[blockchain_dag, block_quarantine], ++ ./testutil, ./testdbutil, ./testblockutil ++ ++suite "Sync committee index cache" & preset(): ++ setup: ++ var ++ cfg = defaultRuntimeConfig ++ cfg.ALTAIR_FORK_EPOCH = Epoch(1) ++ ++ var ++ db = makeTestDB(SLOTS_PER_EPOCH) ++ dag = init(ChainDAGRef, cfg, db, {}) ++ taskpool = Taskpool.new() ++ quarantine = QuarantineRef.init(keys.newRng(), taskpool) ++ state = newClone(dag.headState.data) ++ cache = StateCache() ++ info = ForkedEpochInfo() ++ ++ ++ check: ++ process_slots( ++ cfg, state[], cfg.ALTAIR_FORK_EPOCH.compute_start_slot_at_epoch(), cache, ++ info, {}) ++ ++ state[].kind == BeaconStateFork.Altair ++ ++ test "Resolves committee seats to validator indices" & preset(): ++ let s = state[].altairData.data ++ ++ var c = StateCache() ++ let scc = get_sync_committee_cache(s, c) ++ ++ for i in 0 ..< SYNC_COMMITTEE_SIZE: ++ check: ++ s.validators[scc.current_sync_committee[i]].pubkey == ++ s.current_sync_committee.pubkeys[i] ++ s.validators[scc.next_sync_committee[i]].pubkey == ++ s.next_sync_committee.pubkeys[i] ++ ++ test "Stable across repeated calls" & preset(): ++ let s = state[].altairData.data ++ ++ var c = StateCache() ++ let ++ first = get_sync_committee_cache(s, c) ++ second = get_sync_committee_cache(s, c) ++ ++ var freshCache = StateCache() ++ let third = get_sync_committee_cache(s, freshCache) ++ ++ check: ++ first.current_sync_committee == second.current_sync_committee ++ first.next_sync_committee == second.next_sync_committee ++ first.current_sync_committee == third.current_sync_committee ++ first.next_sync_committee == third.next_sync_committee +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,26 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++set +eu ++source env.sh >/dev/null 2>&1 || true ++set -eu ++ ++NIM_FLAGS="-r --verbosity:0 --hints:off -d:chronicles_log_level=WARN" ++ ++ ++ ++nim c $NIM_FLAGS -o:build/test_block_pool_grade tests/test_block_pool.nim ++ ++ ++nim c $NIM_FLAGS -o:build/test_sync_committee_cache_grade tests/test_sync_committee_cache.nim diff --git a/tasks/format-code-task-002740/tests/test.sh b/tasks/format-code-task-002740/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b0feec9427c5659128108bea0bf40abae727365c --- /dev/null +++ b/tasks/format-code-task-002740/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_sync_committee_cache.nim +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002740/tests/test_command.sh b/tasks/format-code-task-002740/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002740/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002747/environment/Dockerfile b/tasks/format-code-task-002747/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b10dfe20c6572b55667ea3546bae2fc4999d28e1 --- /dev/null +++ b/tasks/format-code-task-002747/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:4a1320509b13ad9cc24faec66238f07df2f07a62d2e851c81dd09f6c8215fe19 diff --git a/tasks/format-code-task-002747/environment/setup/files/blocklist b/tasks/format-code-task-002747/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002747/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002747/environment/setup/setup.sh b/tasks/format-code-task-002747/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002747/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002747/tests/test.patch b/tasks/format-code-task-002747/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..887e0e1baa9cee91c151d4dc0c7420223baf451a --- /dev/null +++ b/tasks/format-code-task-002747/tests/test.patch @@ -0,0 +1,36 @@ +diff --git a/test/disconnect.js b/test/disconnect.js +new file mode 100644 +index 000000000..0bdf04de3 +--- /dev/null ++++ b/test/disconnect.js +@@ -0,0 +1,10 @@ ++import expect from 'expect'; ++ ++import MockRedis from '../src'; ++ ++describe('disconnect', () => { ++ it('should be available, but do nothing', () => { ++ const redis = new MockRedis({}); ++ expect(redis.disconnect()).toBe(undefined); ++ }); ++}); +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+3RQQ7CIBAF0K57irlAW6jSHse0MNEaCwrUeHzbLtSYqBuNMf7HYghMwpCft0O3 ++Myu2xyL5FDGqlZrr6L7Oe6lKWYppLRIhpaqWCamPTXRjCLHxRIl3Lj7re3X/o/Jr/pFDXGnX9401 ++edi8741X+UtRX/KXVT3mv6zGIxLvG+GxP89fG5qDb9mkdn+i3ulNQ1nm+TB0nqltWt5l2nkuPK+7 ++ENnT1F+YLmhnLeuYb0P67W8AAAAAAAAAAAAAAAAAAAAAAPylMwOKiMwAKAAA +diff --git 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-002747/tests/test.sh b/tasks/format-code-task-002747/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c25a6912518483ffcf1c3c7b7f250b4381d80aed --- /dev/null +++ b/tasks/format-code-task-002747/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/disconnect.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-002747/tests/test_command.sh b/tasks/format-code-task-002747/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002747/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002749/environment/Dockerfile b/tasks/format-code-task-002749/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..cb2ee0720592ea3684fa6b4c36b007c3b0f2cbf2 --- /dev/null +++ b/tasks/format-code-task-002749/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:8a69d9f8b165532a8b6178955d747f0d2425674df3e2cf2139efe091a6edea14 diff --git a/tasks/format-code-task-002749/environment/setup/files/blocklist b/tasks/format-code-task-002749/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002749/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002749/environment/setup/setup.sh b/tasks/format-code-task-002749/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002749/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002749/tests/test.patch b/tasks/format-code-task-002749/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..66842f1c77117e058cee9e5695a27fc546a2302a --- /dev/null +++ b/tasks/format-code-task-002749/tests/test.patch @@ -0,0 +1,90 @@ +diff --git a/packages/react/tests/issue-555.js b/packages/react/tests/issue-555.js +new file mode 100644 +index 00000000..3dd7b0c3 +--- /dev/null ++++ b/packages/react/tests/issue-555.js +@@ -0,0 +1,63 @@ ++import * as React from 'react' ++import * as renderer from 'react-test-renderer' ++import createCss from '../src/index.js' ++ ++let RenderOf = (...args) => { ++ let Rendered ++ ++ void renderer.act(() => { ++ Rendered = renderer.create(React.createElement(...args)) ++ }) ++ ++ const json = Rendered.toJSON() ++ const { props } = json ++ ++ for (const prop in props) { ++ const value = props[prop] ++ ++ ++ if (typeof value === 'object' && value !== null && value[Symbol.toPrimitive]) { ++ props[prop] = value[Symbol.toPrimitive]() ++ } ++ } ++ ++ return json ++} ++ ++describe('Issue #555', () => { ++ test('an element accepts styles via className prop', () => { ++ const { css, toString } = createCss() ++ ++ const el = css({ color: "dodgerblue" }) ++ ++ expect( ++ RenderOf('div', { className: el() }) ++ ).toEqual({ ++ type: 'div', ++ props: { ++ className: 'sxr9r9e', ++ }, ++ children: null, ++ }) ++ ++ expect(toString()).toBe(`.sxr9r9e{color:dodgerblue;}`) ++ }) ++ test('an element accepts styles via className prop', () => { ++ const { css, styled, toString } = createCss() ++ ++ const el = css({ color: "dodgerblue" }) ++ const Box = styled('div', {}) ++ ++ expect( ++ RenderOf(Box, { className: el() }) ++ ).toEqual({ ++ type: 'div', ++ props: { ++ className: 'sx03kze sxr9r9e', ++ }, ++ children: null, ++ }) ++ ++ expect(toString()).toBe(`.sxr9r9e{color:dodgerblue;}`) ++ }) ++}) // prettier-ignore +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+3R0W7CIBQG4F73Kc4LwKAd8DjGFqKYFkyhmr39CBe6LHHeaMy2/7uBwAkc+Pmw +++sluXDi9Nc8iCqNUHYvvY51L1YnO9MZ0ZV1KLXRD6mkdfbGmvF2ImiXG/FPdvf1fil/zzy7lzRjn ++eRssT/vH3XEvf9mbS/5a9yX/d93LhsTjWrjtn+c/WqrBD8621p1YOvs87ilE66gTbTjO5EP5omki ++xvwuxMWxNC7+mFNbi/jgQz2BH1IpiWH6IJ/S6phSqn318wAAAAAAAAAAAAAAAAAAAAAA/rRPZuON ++MwAoAAA= +diff --git 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-002749/tests/test.sh b/tasks/format-code-task-002749/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..64329fa7b73250269d8691246b9b1a5856dceb68 --- /dev/null +++ b/tasks/format-code-task-002749/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +packages/react/tests/issue-555.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-002749/tests/test_command.sh b/tasks/format-code-task-002749/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002749/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002771/environment/Dockerfile b/tasks/format-code-task-002771/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..214dae95ec7e9c1f95476f18a68456288062991e --- /dev/null +++ b/tasks/format-code-task-002771/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:e455dc8cbd67a1f40d1d8253a6092f1a550c9ec75f2aa075a2f4d1dbd184d531 diff --git a/tasks/format-code-task-002771/environment/setup/files/blocklist b/tasks/format-code-task-002771/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002771/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002771/environment/setup/setup.sh b/tasks/format-code-task-002771/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002771/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002771/tests/test.patch b/tasks/format-code-task-002771/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..86a482485b47a0385e21af287f33e949b9db4fc3 --- /dev/null +++ b/tasks/format-code-task-002771/tests/test.patch @@ -0,0 +1,63 @@ +diff --git a/sunpy/net/tests/test_fido.py b/sunpy/net/tests/test_fido.py +index 38c65b3db9c..12504939e7b 100644 +--- a/sunpy/net/tests/test_fido.py ++++ b/sunpy/net/tests/test_fido.py +@@ -1,6 +1,7 @@ + import os + import copy + import pathlib ++from stat import S_IREAD, S_IRGRP, S_IROTH + from unittest import mock + + import hypothesis.strategies as st +@@ -24,6 +25,7 @@ + from sunpy.net.vso.vso import DownloadFailed + from sunpy.time import TimeRange, parse_time + from sunpy.util.datatype_factory_base import MultipleMatchError ++from sunpy.tests.helpers import skip_windows + + TIMEFORMAT = config.get("general", "time_format") + +@@ -253,8 +255,19 @@ def test_path(): + results = Fido.search( + a.Time("2012/1/1", "2012/1/5"), a.Instrument("lyra")) + +- with pytest.raises(PermissionError): +- Fido.fetch(results, path="/some/path/{file}") ++ Fido.fetch(results, path="notapath/{file}") ++ ++@skip_windows ++def test_path_read_only(tmp_path): ++ results = Fido.search( ++ a.Time("2012/1/1", "2012/1/5"), a.Instrument("lyra")) ++ ++ ++ os.chmod(tmp_path, S_IREAD|S_IRGRP|S_IROTH) ++ ++ if not os.access(tmp_path, os.W_OK): ++ with pytest.raises(PermissionError): ++ Fido.fetch(results, path=tmp_path / "{file}") + + @settings(deadline=50000) + @given(st.tuples(offline_query(), offline_query()).filter(filter_queries)) +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+3SzWrEIBQF4KzzFJZCd6PR1gizmFcJJloSmGiIJpC3r2PpD4V2upihLT3fRsUr ++iufSdhmOprFuZcW1VImSMo/JxzHPuRRcyOqeC1FUnEslCiKv9qJ3lhD1TEgxex+/qju3/0fRt/yj ++DbHp/DhqZ2joL3fHufyFrF/yF6pWKf+HWqiCVJd7wuf+ef63N6wdHGt16MvOkNwErTVl8Mvc2dc1 ++o+upRU6luovDqqMtpy323pHdSNIslZGwuGljzsZ8Kjw31ONgPJ22/T6vJh3779Y1s9Wm8e64kd1K ++xOGOlz/9WwAAAAAAAAAAAAAAAAAAAAAAv8sTesDd4gAoAAA= +diff --git 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-002771/tests/test.sh b/tasks/format-code-task-002771/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..f83805053bbc7639e7637d458e922845ef5c0fe3 --- /dev/null +++ b/tasks/format-code-task-002771/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' +sunpy/net/tests/test_fido.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-002771/tests/test_command.sh b/tasks/format-code-task-002771/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002771/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002776/environment/Dockerfile b/tasks/format-code-task-002776/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a5024f243731ce35423cad0fa3ea9fb13eec6db7 --- /dev/null +++ b/tasks/format-code-task-002776/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:2d00910d7b86360c039af1a77aeb5f40ed7c33d66a7af4cf174b008175cc3f22 diff --git a/tasks/format-code-task-002776/environment/setup/files/blocklist b/tasks/format-code-task-002776/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002776/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002776/environment/setup/setup.sh b/tasks/format-code-task-002776/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002776/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002776/tests/test.patch b/tasks/format-code-task-002776/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..893323d0a6c9da7915b391fd1ad5fa47afff47b4 --- /dev/null +++ b/tasks/format-code-task-002776/tests/test.patch @@ -0,0 +1,86 @@ +diff --git a/test/throw-on-error.test-d.ts b/test/throw-on-error.test-d.ts +new file mode 100644 +index 0000000..e903f71 +--- /dev/null ++++ b/test/throw-on-error.test-d.ts +@@ -0,0 +1,58 @@ ++import { expectType } from 'tsd' ++import { PostgrestClient } from '../src/index' ++import { Database } from './types' ++ ++const REST_URL = 'http://localhost:3000' ++const postgrest = new PostgrestClient(REST_URL) ++ ++ ++ ++{ ++ const { data, error } = await postgrest ++ .from('users') ++ .select('username') ++ .single() ++ .throwOnError() ++ expectType<{ username: string }>(data) ++ expectType(error) ++} ++ ++ ++ ++{ ++ const { data, error } = await postgrest ++ .from('users') ++ .select('username') ++ .maybeSingle() ++ .throwOnError() ++ expectType<{ username: string } | null>(data) ++ expectType(error) ++} ++ ++ ++{ ++ const { data, error } = await postgrest ++ .from('users') ++ .select('username') ++ .throwOnError() ++ expectType<{ username: string }[]>(data) ++ expectType(error) ++} ++ ++ ++ ++{ ++ const { data } = await postgrest.from('users').select('username').single() ++ expectType<{ username: string } | null>(data) ++} ++ ++ ++ ++{ ++ const res = await postgrest.from('users').select('username').single() ++ ++ ++ type ErrorIsNotJustNull = [Exclude] extends [never] ? false : true ++ const check: ErrorIsNotJustNull = true ++ expectType(check) ++} +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..d11859d +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/tsd --files 'test/throw-on-error.test-d.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/tsd --files 'test/throw-on-error.test-d.ts' ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002776/tests/test.sh b/tasks/format-code-task-002776/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e43ef54e656b4922060885feebc5a23589d3f35e --- /dev/null +++ b/tasks/format-code-task-002776/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/throw-on-error.test-d.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-002776/tests/test_command.sh b/tasks/format-code-task-002776/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002776/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002778/environment/Dockerfile b/tasks/format-code-task-002778/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..aa320a8747ab63d90b885ca9311670953d0fe446 --- /dev/null +++ b/tasks/format-code-task-002778/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b4ce897a6459581c1dddc53942f93e3f6a72042a8f8c2816693d7918b8d64d25 diff --git a/tasks/format-code-task-002778/environment/setup/files/blocklist b/tasks/format-code-task-002778/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002778/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002778/environment/setup/setup.sh b/tasks/format-code-task-002778/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002778/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002778/tests/test.patch b/tasks/format-code-task-002778/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..2118a28f044157c03c9abb87e0566c10022da92e --- /dev/null +++ b/tasks/format-code-task-002778/tests/test.patch @@ -0,0 +1,259 @@ +diff --git a/server/superdesk/io/rss_ingest_test.py b/server/superdesk/io/rss_ingest_test.py +new file mode 100644 +index 000000000..04f91f5fc +--- /dev/null ++++ b/server/superdesk/io/rss_ingest_test.py +@@ -0,0 +1,213 @@ ++# -*- coding: utf-8; -*- ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++import importlib ++import unittest ++from datetime import datetime, timezone ++from unittest import mock ++from unittest.mock import MagicMock ++ ++import superdesk.errors as errors ++from superdesk.errors import IngestApiError, ParserError ++from superdesk.io import providers, allowed_providers ++ ++ ++ ++ ++ ++RSS_FEED = b""" ++ ++ ++ Example News ++ http://news.example.com/ ++ Example feed ++ ++ urn:news:item-1 ++ First headline ++ First summary ++ Wed, 25 Feb 2015 17:11:11 GMT ++ ++ ++ urn:news:item-2 ++ Second headline ++ Second summary ++ Wed, 25 Feb 2015 10:00:00 GMT ++ ++ ++""" ++ ++ ++ITEM_1_TIME = datetime(2015, 2, 25, 17, 11, 11) ++ITEM_2_TIME = datetime(2015, 2, 25, 10, 0, 0) ++ ++FEED_URL = 'http://news.example.com/rss' ++ ++ ++ ++ ++REQUESTS_TARGET = 'requests.sessions.Session.request' ++ ++ ++def load_rss_provider(): ++ ++ ++ from settings import INSTALLED_APPS ++ for app in INSTALLED_APPS: ++ if app == 'superdesk.io' or app.startswith('superdesk.io.'): ++ importlib.import_module(app) ++ return providers.get('rss') ++ ++ ++def fake_response(ok=True, status_code=200, content=b'', reason='OK'): ++ return MagicMock(ok=ok, status_code=status_code, content=content, ++ reason=reason) ++ ++ ++def call_url(call): ++ args, kwargs = call ++ if 'url' in kwargs: ++ return kwargs['url'] ++ ++ return args[1] if len(args) > 1 else args[0] ++ ++ ++def call_auth(call): ++ _, kwargs = call ++ return kwargs.get('auth') ++ ++ ++def to_naive_utc(dt): ++ if dt.tzinfo is not None: ++ dt = dt.astimezone(timezone.utc).replace(tzinfo=None) ++ return dt ++ ++ ++class RssProviderRegistrationTestCase(unittest.TestCase): ++ def test_provider_is_registered_under_rss(self): ++ service = load_rss_provider() ++ self.assertIsNotNone( ++ service, "No ingest provider registered under type 'rss'.") ++ self.assertIn('rss', providers) ++ ++ def test_rss_is_an_allowed_provider(self): ++ load_rss_provider() ++ self.assertIn('rss', allowed_providers) ++ ++ ++class RssUpdateTestCase(unittest.TestCase): ++ def setUp(self): ++ self.service = load_rss_provider() ++ if self.service is None: ++ self.fail("No ingest provider registered under type 'rss'.") ++ ++ ++ errors.notifiers = [] ++ ++ def _update(self, provider): ++ with mock.patch(REQUESTS_TARGET) as req: ++ req.return_value = fake_response(content=RSS_FEED) ++ result = self.service.update(provider) ++ return result, req ++ ++ ++ ++ def test_fetches_configured_url(self): ++ _, req = self._update({'config': {'url': FEED_URL}}) ++ self.assertTrue(req.called) ++ self.assertEqual(call_url(req.call_args), FEED_URL) ++ ++ def test_sends_basic_auth_when_required(self): ++ _, req = self._update({'config': { ++ 'url': FEED_URL, ++ 'auth_required': True, ++ 'username': 'johndoe', ++ 'password': 'secret', ++ }}) ++ self.assertEqual(call_auth(req.call_args), ('johndoe', 'secret')) ++ ++ def test_does_not_send_auth_when_not_required(self): ++ _, req = self._update({'config': {'url': FEED_URL}}) ++ self.assertIsNone(call_auth(req.call_args)) ++ ++ ++ ++ def test_result_is_single_batch_of_items(self): ++ result, _ = self._update({'config': {'url': FEED_URL}}) ++ self.assertEqual(len(result), 1) ++ self.assertIsInstance(result[0], list) ++ ++ def test_returns_all_entries_when_no_last_updated(self): ++ result, _ = self._update({'config': {'url': FEED_URL}}) ++ guids = [item['guid'] for item in result[0]] ++ self.assertEqual(guids, ['urn:news:item-1', 'urn:news:item-2']) ++ ++ def test_only_returns_entries_newer_than_last_updated(self): ++ result, _ = self._update({ ++ 'config': {'url': FEED_URL}, ++ 'last_updated': datetime(2015, 2, 25, 14, 0, 0), ++ }) ++ guids = [item['guid'] for item in result[0]] ++ self.assertEqual(guids, ['urn:news:item-1']) ++ ++ def test_returns_no_items_when_feed_is_up_to_date(self): ++ result, _ = self._update({ ++ 'config': {'url': FEED_URL}, ++ 'last_updated': datetime(2015, 2, 26, 0, 0, 0), ++ }) ++ self.assertEqual(result[0], []) ++ ++ ++ ++ def test_builds_item_fields_from_entry(self): ++ result, _ = self._update({'config': {'url': FEED_URL}}) ++ item = result[0][0] ++ self.assertEqual(item['guid'], 'urn:news:item-1') ++ self.assertEqual(item['type'], 'text') ++ self.assertEqual(item['headline'], 'First headline') ++ self.assertEqual(item['abstract'], 'First summary') ++ self.assertEqual(to_naive_utc(item['firstcreated']), ITEM_1_TIME) ++ self.assertEqual(to_naive_utc(item['versioncreated']), ITEM_1_TIME) ++ ++ ++ ++ def _expect_api_error(self, status_code, expected_code): ++ provider = {'config': {'url': FEED_URL}, 'name': 'TestProvider'} ++ with mock.patch(REQUESTS_TARGET) as req: ++ req.return_value = fake_response( ++ ok=False, status_code=status_code, reason='boom') ++ with self.assertRaises(IngestApiError) as ctx: ++ self.service.update(provider) ++ self.assertEqual(ctx.exception.code, expected_code) ++ ++ def test_raises_auth_error_on_401(self): ++ self._expect_api_error(401, 4007) ++ ++ def test_raises_auth_error_on_403(self): ++ self._expect_api_error(403, 4007) ++ ++ def test_raises_not_found_error_on_404(self): ++ self._expect_api_error(404, 4006) ++ ++ def test_raises_general_error_on_500(self): ++ self._expect_api_error(500, 4000) ++ ++ def test_raises_general_error_on_other_status(self): ++ self._expect_api_error(418, 4000) ++ ++ def test_wraps_other_failures_as_parser_error(self): ++ provider = {'config': {'url': FEED_URL}, 'name': 'TestProvider'} ++ with mock.patch(REQUESTS_TARGET, side_effect=ValueError('boom')): ++ with self.assertRaises(ParserError): ++ self.service.update(provider) ++ ++ ++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,35 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++PY=/testbed/.venv/bin/python ++if [ ! -f /testbed/.venv/pyvenv.cfg ]; then ++ cat > /testbed/.venv/pyvenv.cfg <<'CFG' ++home = /root/.pyenv/versions/3.6.15/bin ++include-system-site-packages = false ++version = 3.6.15 ++CFG ++fi ++ ++cd /testbed/server ++ ++ ++"$PY" -m pytest -q \ ++ superdesk/io/nitf_tests.py \ ++ superdesk/io/afp_tests.py \ ++ superdesk/io/wenn_parser_test.py \ ++ superdesk/io/zczc_parser_test.py \ ++ superdesk/io/anpa_tests.py ++ ++ ++"$PY" -m pytest -q superdesk/io/rss_ingest_test.py diff --git a/tasks/format-code-task-002778/tests/test.sh b/tasks/format-code-task-002778/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d0e3b420a2e21fa39210b561c5879127f5c62009 --- /dev/null +++ b/tasks/format-code-task-002778/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' +server/superdesk/io/rss_ingest_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-002778/tests/test_command.sh b/tasks/format-code-task-002778/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002778/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002782/environment/Dockerfile b/tasks/format-code-task-002782/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ff23aa720466ec1388b587eacdf97b5a446343ce --- /dev/null +++ b/tasks/format-code-task-002782/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:bfc769092ecad8cd62e8cc6433ce165fd9acfd7365f32935c519500983c8b6e8 diff --git a/tasks/format-code-task-002782/environment/setup/files/blocklist b/tasks/format-code-task-002782/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002782/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002782/environment/setup/setup.sh b/tasks/format-code-task-002782/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002782/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002782/tests/test.patch b/tasks/format-code-task-002782/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ce0a2deefe81cd21f45ec0aec2c9f002e5212877 --- /dev/null +++ b/tasks/format-code-task-002782/tests/test.patch @@ -0,0 +1,62 @@ +diff --git a/packages/svelte/tests/migrate/samples/slot-usages/input.svelte b/packages/svelte/tests/migrate/samples/slot-usages/input.svelte +index 5646174c4c64..248ff0ac1312 100644 +--- a/packages/svelte/tests/migrate/samples/slot-usages/input.svelte ++++ b/packages/svelte/tests/migrate/samples/slot-usages/input.svelte +@@ -77,6 +77,14 @@ +
bar
+ + ++ ++ should be children ++ ++ ++ ++ should be children {with_prop} too ++ ++ + +
unchanged
+
+diff --git a/packages/svelte/tests/migrate/samples/slot-usages/output.svelte b/packages/svelte/tests/migrate/samples/slot-usages/output.svelte +index 42e219a567f8..d2aea33c83ec 100644 +--- a/packages/svelte/tests/migrate/samples/slot-usages/output.svelte ++++ b/packages/svelte/tests/migrate/samples/slot-usages/output.svelte +@@ -121,6 +121,16 @@ + {/snippet} + + ++ ++ should be children ++ ++ ++ ++ {#snippet children({ with_prop })} ++ should be children {with_prop} too {/snippet} ++ ++ ++ + +
unchanged
+
+\ No newline at end of file +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,5 @@ ++H4sIAAAAAAAAA+3STUvDMBwG8J77KeL0uiZpmxaEHTwoCh5Edh9pG7Zim4QkLX581yIqgu6yIcPn ++d8kr/4Q8Saqh7ZqN0iONToXtlULM7d73du5zkXJesrzIsohxXrAsIuJkN/pi8EE6QiJnTPht36H1 ++M5V85h+UD5va9L3UTeJ3xzvjUP4pKz7yF8WUf17wMiLseFf42T/P//KCVq2mlfS7uG7I/Akq1cTq ++1RoXyNPN+n61oMYGqk2jlmk+bb++muYX8d3D4/r2eeU7E5aDl1vlidW2J2M7lSFu0MTK+mVaoH5U ++XVBzfU/7duvk+ygJPv7rVwAAAAAAAAAAAAAAAAAAAAAAOE9vEW7yiwAoAAA= +diff --git 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-002782/tests/test.sh b/tasks/format-code-task-002782/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..2de7402bdd52ad9b7dcc995232b156fa24e9ae76 --- /dev/null +++ b/tasks/format-code-task-002782/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' +packages/svelte/tests/migrate/samples/slot-usages/input.svelte +packages/svelte/tests/migrate/samples/slot-usages/output.svelte +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-002782/tests/test_command.sh b/tasks/format-code-task-002782/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002782/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002785/environment/Dockerfile b/tasks/format-code-task-002785/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b5e6cca074f54470d75271c8431a3c6cc4ad211c --- /dev/null +++ b/tasks/format-code-task-002785/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:6f352ff2e1f2dcff1a912ecfc01b86df7f671825b058e17fdfdbabfba982ea35 diff --git a/tasks/format-code-task-002785/environment/setup/files/blocklist b/tasks/format-code-task-002785/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002785/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002785/environment/setup/setup.sh b/tasks/format-code-task-002785/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002785/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002785/tests/test.patch b/tasks/format-code-task-002785/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..179461d8af872e1cfabcc2865a96c17cbb338c88 --- /dev/null +++ b/tasks/format-code-task-002785/tests/test.patch @@ -0,0 +1,289 @@ +diff --git a/projects/swimlane/ngx-ui/src/lib/components/toggle/toggle.component.spec.ts b/projects/swimlane/ngx-ui/src/lib/components/toggle/toggle.component.spec.ts +index 0edc0190..80765e82 100644 +--- a/projects/swimlane/ngx-ui/src/lib/components/toggle/toggle.component.spec.ts ++++ b/projects/swimlane/ngx-ui/src/lib/components/toggle/toggle.component.spec.ts +@@ -1,27 +1,196 @@ ++import { Component, ViewChild } from '@angular/core'; + import { ComponentFixture, TestBed } from '@angular/core/testing'; +-import { NO_ERRORS_SCHEMA } from '@angular/core'; ++import { FormsModule } from '@angular/forms'; ++import { By } from '@angular/platform-browser'; ++ + import { ToggleComponent } from './toggle.component'; ++ ++@Component({ ++ template: `` ++}) ++class ToggleHostComponent { ++ value = false; ++ changes: boolean[] = []; ++ ++ record(value: boolean): void { ++ this.changes.push(value); ++ } ++} ++ ++@Component({ ++ template: `` ++}) ++class StaticFalseInputsHostComponent {} ++ ++@Component({ ++ template: `` ++}) ++class BoundBooleanInputsHostComponent { ++ disabledValue: any = true; ++ requiredValue: any = true; ++} ++ ++@Component({ ++ template: `` ++}) ++class TabIndexHostComponent { ++ tabValue: any = '7'; ++} ++ ++@Component({ ++ template: `` ++}) ++class ExportAsHostComponent { ++ @ViewChild('toggleRef', { static: false }) toggleRef: ToggleComponent; ++} ++ + describe('ToggleComponent', () => { + let component: ToggleComponent; + let fixture: ComponentFixture; ++ + beforeEach(() => { + TestBed.configureTestingModule({ +- schemas: [NO_ERRORS_SCHEMA], +- declarations: [ToggleComponent] ++ declarations: [ ++ ToggleComponent, ++ ToggleHostComponent, ++ StaticFalseInputsHostComponent, ++ BoundBooleanInputsHostComponent, ++ TabIndexHostComponent, ++ ExportAsHostComponent ++ ], ++ imports: [FormsModule] + }); ++ + fixture = TestBed.createComponent(ToggleComponent); + component = fixture.componentInstance; + }); ++ ++ function checkbox(hostFixture: ComponentFixture): HTMLInputElement { ++ return hostFixture.debugElement.query(By.css('input[type="checkbox"]')).nativeElement; ++ } ++ ++ function toggleDebug(hostFixture: ComponentFixture) { ++ return hostFixture.debugElement.query(By.directive(ToggleComponent)); ++ } ++ + it('can load instance', () => { + expect(component).toBeTruthy(); + }); +- it('disabled defaults to: false', () => { +- expect(component.disabled).toEqual(false); ++ ++ it('emits the current boolean value from change when clicked', () => { ++ const hostFixture = TestBed.createComponent(ToggleHostComponent); ++ hostFixture.detectChanges(); ++ const host = hostFixture.componentInstance; ++ const toggle = toggleDebug(hostFixture).componentInstance as ToggleComponent; ++ const input = checkbox(hostFixture); ++ ++ input.checked = true; ++ input.dispatchEvent(new Event('change')); ++ hostFixture.detectChanges(); ++ ++ expect(toggle.value).toBe(true); ++ expect(host.changes.length).toBeGreaterThan(0); ++ expect(host.changes[host.changes.length - 1]).toBe(true); ++ ++ input.checked = false; ++ input.dispatchEvent(new Event('change')); ++ hostFixture.detectChanges(); ++ ++ expect(toggle.value).toBe(false); ++ expect(host.changes[host.changes.length - 1]).toBe(false); + }); +- it('required defaults to: false', () => { +- expect(component.required).toEqual(false); ++ ++ it('emits change when ControlValueAccessor writes a different value', () => { ++ const hostFixture = TestBed.createComponent(ToggleHostComponent); ++ hostFixture.detectChanges(); ++ const host = hostFixture.componentInstance; ++ const toggle = toggleDebug(hostFixture).componentInstance as ToggleComponent; ++ host.changes = []; ++ ++ toggle.writeValue(true); ++ hostFixture.detectChanges(); ++ ++ expect(toggle.value).toBe(true); ++ expect(host.changes.length).toBeGreaterThan(0); ++ expect(host.changes[host.changes.length - 1]).toBe(true); ++ ++ host.changes = []; ++ toggle.writeValue(false); ++ hostFixture.detectChanges(); ++ ++ expect(toggle.value).toBe(false); ++ expect(host.changes.length).toBeGreaterThan(0); ++ expect(host.changes[host.changes.length - 1]).toBe(false); + }); +- it('tabIndex defaults to: 0', () => { +- expect(component.tabIndex).toEqual(0); ++ ++ it('emits change when the public toggle method changes the value', () => { ++ const hostFixture = TestBed.createComponent(ToggleHostComponent); ++ hostFixture.detectChanges(); ++ const host = hostFixture.componentInstance; ++ const toggle = toggleDebug(hostFixture).componentInstance as ToggleComponent; ++ host.changes = []; ++ ++ toggle.toggle(); ++ hostFixture.detectChanges(); ++ ++ expect(toggle.value).toBe(true); ++ expect(host.changes.length).toBeGreaterThan(0); ++ expect(host.changes[host.changes.length - 1]).toBe(true); ++ }); ++ ++ ++ it('coerces disabled and required string inputs before applying them to the checkbox', () => { ++ const hostFixture = TestBed.createComponent(StaticFalseInputsHostComponent); ++ hostFixture.detectChanges(); ++ ++ const toggle = toggleDebug(hostFixture).componentInstance as ToggleComponent; ++ const input = checkbox(hostFixture); ++ ++ expect(toggle.disabled).toBe(false); ++ expect(toggle.required).toBe(false); ++ expect(input.disabled).toBe(false); ++ expect(input.required).toBe(false); ++ }); ++ ++ it('coerces bound boolean-like input values when they change', () => { ++ const hostFixture = TestBed.createComponent(BoundBooleanInputsHostComponent); ++ hostFixture.detectChanges(); ++ const host = hostFixture.componentInstance; ++ const toggle = toggleDebug(hostFixture).componentInstance as ToggleComponent; ++ ++ expect(toggle.disabled).toBe(true); ++ expect(toggle.required).toBe(true); ++ ++ host.disabledValue = 'false'; ++ host.requiredValue = 'false'; ++ hostFixture.detectChanges(); ++ ++ expect(toggle.disabled).toBe(false); ++ expect(toggle.required).toBe(false); ++ expect(checkbox(hostFixture).disabled).toBe(false); ++ expect(checkbox(hostFixture).required).toBe(false); ++ }); ++ ++ it('coerces numeric tabIndex input before applying it to the checkbox', () => { ++ const hostFixture = TestBed.createComponent(TabIndexHostComponent); ++ hostFixture.detectChanges(); ++ const host = hostFixture.componentInstance; ++ const toggle = toggleDebug(hostFixture).componentInstance as ToggleComponent; ++ ++ expect(toggle.tabIndex).toBe(7); ++ expect(checkbox(hostFixture).tabIndex).toBe(7); ++ ++ host.tabValue = '3'; ++ hostFixture.detectChanges(); ++ ++ expect(toggle.tabIndex).toBe(3); ++ expect(checkbox(hostFixture).tabIndex).toBe(3); ++ }); ++ ++ it('can be referenced from templates as ngxToggle', () => { ++ const hostFixture = TestBed.createComponent(ExportAsHostComponent); ++ hostFixture.detectChanges(); ++ ++ expect(hostFixture.componentInstance.toggleRef).toEqual(jasmine.any(ToggleComponent)); + }); + }); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,74 @@ ++#!/bin/bash ++set -uo pipefail ++cd /testbed ++ ++ ++ ++dev-switch node 20 2>/dev/null || true ++ ++ ++if [ ! -d "node_modules/@angular" ]; then ++ npm install --ignore-scripts 2>/dev/null ++fi ++ ++ ++if [ ! -f "node_modules/node-sass/lib/index.js" ] || grep -q "require('sass')" node_modules/node-sass/lib/index.js 2>/dev/null; then ++ true ++else ++ rm -rf node_modules/node-sass ++ mkdir -p node_modules/node-sass/lib ++ cat > node_modules/node-sass/package.json << 'PKGEOF' ++{ ++ "name": "node-sass", ++ "version": "4.12.0", ++ "main": "lib/index.js" ++} ++PKGEOF ++ cat > node_modules/node-sass/lib/index.js << 'IDXEOF' ++const sass = require('sass'); ++module.exports = sass; ++IDXEOF ++fi ++ ++ ++if [ ! -d "node_modules/sass" ]; then ++ npm install sass@1.26.0 --no-save --ignore-scripts --legacy-peer-deps 2>/dev/null ++fi ++ ++ ++export CHROME_BIN=$(find /root/.cache/puppeteer -name "chrome" -type f -path "*/chrome-linux64/*" 2>/dev/null | head -1) ++if [ -z "$CHROME_BIN" ]; then ++ npm install -g puppeteer 2>/dev/null ++ export CHROME_BIN=$(find /root/.cache/puppeteer -name "chrome" -type f -path "*/chrome-linux64/*" 2>/dev/null | head -1) ++fi ++ ++ ++export NODE_OPTIONS=--openssl-legacy-provider ++ ++ ++run_ngx_ui_tests() { ++ npx ng test @swimlane/ngx-ui --watch=false --browsers=ChromeHeadlessCI --no-progress ++} ++ ++case "${1:-}" in ++ base) ++ run_ngx_ui_tests ++ ;; ++ new) ++ cat > projects/swimlane/ngx-ui/src/test.ts <<'TSEOF' ++import 'core-js/es7/reflect'; ++import 'zone.js/dist/zone'; ++import 'zone.js/dist/zone-testing'; ++import { getTestBed } from '@angular/core/testing'; ++import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; ++ ++getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); ++require('./lib/components/toggle/toggle.component.spec.ts'); ++TSEOF ++ run_ngx_ui_tests ++ ;; ++ *) ++ echo "usage: $0 base|new" ++ exit 2 ++ ;; ++esac diff --git a/tasks/format-code-task-002785/tests/test.sh b/tasks/format-code-task-002785/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..c3056c05edb2a5f4f25a71be71d40646bcb0c489 --- /dev/null +++ b/tasks/format-code-task-002785/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' +projects/swimlane/ngx-ui/src/lib/components/toggle/toggle.component.spec.ts +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002785/tests/test_command.sh b/tasks/format-code-task-002785/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..e8d2f32b64045b5a5a56e0ad5667da87d8e0bc2a --- /dev/null +++ b/tasks/format-code-task-002785/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-002912/environment/Dockerfile b/tasks/format-code-task-002912/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b99aeccc8bdb6bff3e09bca058062b0290fca900 --- /dev/null +++ b/tasks/format-code-task-002912/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:af75be3be4cec5d597a83254b742c853deac5061c1be01b3f23b379a28402a9c diff --git a/tasks/format-code-task-002912/environment/setup/files/blocklist b/tasks/format-code-task-002912/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002912/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002912/environment/setup/setup.sh b/tasks/format-code-task-002912/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002912/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002912/tests/test.patch b/tasks/format-code-task-002912/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..960905ae483d765a717c6005d968f89a5f7145ca --- /dev/null +++ b/tasks/format-code-task-002912/tests/test.patch @@ -0,0 +1,151 @@ +diff --git a/test/api/function-as-assertion.spec.js b/test/api/function-as-assertion.spec.js +new file mode 100644 +index 00000000..6d454c7f +--- /dev/null ++++ b/test/api/function-as-assertion.spec.js +@@ -0,0 +1,116 @@ ++ ++describe('expect with a function as the assertion', () => { ++ describe('at the top level', () => { ++ it('succeeds when the function does not throw', () => { ++ expect(5, n => { ++ expect(n, 'to be a number'); ++ }); ++ }); ++ ++ it('treats a function that returns without throwing as a success regardless of return value', () => { ++ expect('anything', () => 'some truthy return value'); ++ }); ++ ++ it('fails with the error thrown by the function', () => { ++ expect( ++ () => { ++ expect(5, n => { ++ expect(n, 'to be a string'); ++ }); ++ }, ++ 'to throw', ++ 'expected 5 to be a string' ++ ); ++ }); ++ ++ it('no longer raises the "second parameter" error for a function', () => { ++ ++ ++ expect(5, () => {}); ++ }); ++ ++ it('does not call the function more than once', () => { ++ let calls = 0; ++ expect('foo', () => { ++ calls += 1; ++ }); ++ expect(calls, 'to equal', 1); ++ }); ++ }); ++ ++ describe('with an asynchronous function', () => { ++ it('succeeds when the returned promise is fulfilled', () => { ++ return expect('foo', value => ++ expect.promise(run => { ++ setTimeout(run(() => expect(value, 'to equal', 'foo'))); ++ }) ++ ); ++ }); ++ ++ it('fails when the returned promise is rejected', () => { ++ return expect( ++ () => ++ expect('foo', value => ++ expect.promise(run => { ++ setTimeout(run(() => expect(value, 'to equal', 'bar'))); ++ }) ++ ), ++ 'to be rejected with', ++ "expected 'foo' to equal 'bar'\n" + '\n' + '-foo\n' + '+bar' ++ ); ++ }); ++ }); ++ ++ describe('from inside a custom assertion', () => { ++ const clonedExpect = expect ++ .clone() ++ .addAssertion(' to pass the check ', (expect, subject, fn) => ++ expect(subject, fn) ++ ); ++ ++ it('succeeds when the function does not throw', () => { ++ clonedExpect(5, 'to pass the check', n => { ++ expect(n, 'to be a number'); ++ }); ++ }); ++ ++ it("reports the function's failure nested within the surrounding assertion", () => { ++ clonedExpect( ++ () => { ++ clonedExpect(5, 'to pass the check', n => { ++ expect(n, 'to be a string'); ++ }); ++ }, ++ 'to throw', ++ err => { ++ expect(err.message, 'to contain', 'to pass the check'); ++ expect(err.message, 'to contain', 'expected 5 to be a string'); ++ } ++ ); ++ }); ++ }); ++ ++ describe('compatibility with existing argument kinds', () => { ++ it('still supports string assertions', () => { ++ expect(2, 'to be a number'); ++ expect( ++ () => { ++ expect(2, 'to be a string'); ++ }, ++ 'to throw', ++ 'expected 2 to be a string' ++ ); ++ }); ++ ++ it('still supports expect.it expressions', () => { ++ expect('foo', expect.it('to be a string')); ++ expect( ++ () => { ++ expect(5, expect.it('to be a string')); ++ }, ++ 'to throw', ++ 'expected 5 to be a string' ++ ); ++ }); ++ }); ++}); +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,24 @@ ++#!/usr/bin/env bash ++ ++ ++ ++ ++set -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++ ++ ++ ++./node_modules/.bin/mocha --opts ./test/mocha.opts \ ++ test/api/it.spec.js \ ++ test/assertions/to-satisfy.spec.js \ ++ test/unexpected.spec.js ++ ++ ++./node_modules/.bin/mocha --opts ./test/mocha.opts \ ++ test/api/function-as-assertion.spec.js diff --git a/tasks/format-code-task-002912/tests/test.sh b/tasks/format-code-task-002912/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..25b5d3d9d831fdc0b73140da91bb6590017649be --- /dev/null +++ b/tasks/format-code-task-002912/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/api/function-as-assertion.spec.js +mimo_test_command.sh +EOF_RESET_TEST_FILES + +); then echo "could not reset the test files (testbed problem, not scored)" >&2; exit 1; fi +if ! git apply --verbose /tests/test.patch > "$V/apply.log" 2>&1; then + cat "$V/apply.log" >&2 + echo "the hidden tests could not be applied (testbed problem, not scored)" >&2 + exit 1 +fi +timeout 1800 sh -c "$(cat /tests/test_command.sh)" > "$V/test_output.log" 2>&1 +RC=$? +tail -c 12000 "$V/test_output.log" +if [ $RC -eq 0 ]; then echo 1 > "$V/reward.txt"; else echo 0 > "$V/reward.txt"; fi +echo "test command exited $RC" diff --git a/tasks/format-code-task-002912/tests/test_command.sh b/tasks/format-code-task-002912/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002912/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002915/environment/Dockerfile b/tasks/format-code-task-002915/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..be21612e4d029e890a2cafc08807eca28811344e --- /dev/null +++ b/tasks/format-code-task-002915/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d163355848009d4c57850c595cd4bef1a0437e0c88a56ca765edd495dc597efe diff --git a/tasks/format-code-task-002915/environment/setup/files/blocklist b/tasks/format-code-task-002915/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002915/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002915/environment/setup/setup.sh b/tasks/format-code-task-002915/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002915/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002915/tests/test.patch b/tasks/format-code-task-002915/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..dc83b0d96e21812c74db1682c4f23eeca15aeefc --- /dev/null +++ b/tasks/format-code-task-002915/tests/test.patch @@ -0,0 +1,138 @@ +diff --git a/mitiq/tests/test_utils.py b/mitiq/tests/test_utils.py +index e3e600f8..114f82e6 100644 +--- a/mitiq/tests/test_utils.py ++++ b/mitiq/tests/test_utils.py +@@ -87,3 +87,111 @@ def test_circuit_equality_gridqubit_namedqubit_unequal_indices(): + circB = cirq.Circuit(cirq.ops.H.on_each(*qregB)) + assert _equal(circA, circB, require_qubit_equality=False) + assert not _equal(circA, circB, require_qubit_equality=True) ++ ++ ++def test_circuit_equality_default_ignores_measurement_keys_issue_repro(): ++ """Default behavior (no require_measurement_equality kwarg) should ++ treat circuits with different measurement keys as equal. ++ This is the exact example from the issue. ++ """ ++ qbit = cirq.LineQubit(0) ++ circA = cirq.Circuit(cirq.ops.measure(qbit, key="a")) ++ circB = cirq.Circuit(cirq.ops.measure(qbit, key="b")) ++ assert _equal(circA, circB) ++ ++ ++def test_circuit_equality_different_measurement_keys_explicit_false(): ++ qbit = cirq.LineQubit(0) ++ circA = cirq.Circuit(cirq.ops.measure(qbit, key="a")) ++ circB = cirq.Circuit(cirq.ops.measure(qbit, key="b")) ++ assert _equal(circA, circB, require_measurement_equality=False) ++ ++ ++def test_circuit_equality_different_measurement_keys_required(): ++ qbit = cirq.LineQubit(0) ++ circA = cirq.Circuit(cirq.ops.measure(qbit, key="a")) ++ circB = cirq.Circuit(cirq.ops.measure(qbit, key="b")) ++ assert not _equal(circA, circB, require_measurement_equality=True) ++ ++ ++def test_circuit_equality_same_measurement_keys_required_true(): ++ qbit = cirq.LineQubit(0) ++ circA = cirq.Circuit(cirq.ops.measure(qbit, key="a")) ++ circB = cirq.Circuit(cirq.ops.measure(qbit, key="a")) ++ assert _equal(circA, circB, require_measurement_equality=True) ++ ++ ++def test_circuit_equality_same_measurement_keys_default(): ++ qbit = cirq.LineQubit(0) ++ circA = cirq.Circuit(cirq.ops.measure(qbit, key="a")) ++ circB = cirq.Circuit(cirq.ops.measure(qbit, key="a")) ++ assert _equal(circA, circB) ++ ++ ++def test_circuit_equality_multi_qubit_measurement_different_keys_default(): ++ q0, q1 = cirq.LineQubit.range(2) ++ circA = cirq.Circuit(cirq.ops.measure(q0, q1, key="a")) ++ circB = cirq.Circuit(cirq.ops.measure(q0, q1, key="b")) ++ assert _equal(circA, circB) ++ ++ ++def test_circuit_equality_multi_qubit_measurement_different_keys_required(): ++ q0, q1 = cirq.LineQubit.range(2) ++ circA = cirq.Circuit(cirq.ops.measure(q0, q1, key="a")) ++ circB = cirq.Circuit(cirq.ops.measure(q0, q1, key="b")) ++ assert not _equal(circA, circB, require_measurement_equality=True) ++ ++ ++def test_circuit_equality_mixed_gates_different_measurement_keys_default(): ++ qbit = cirq.LineQubit(0) ++ circA = cirq.Circuit([cirq.ops.H.on(qbit), cirq.ops.measure(qbit, key="a")]) ++ circB = cirq.Circuit([cirq.ops.H.on(qbit), cirq.ops.measure(qbit, key="b")]) ++ assert _equal(circA, circB) ++ ++ ++def test_circuit_equality_mixed_gates_different_measurement_keys_required(): ++ qbit = cirq.LineQubit(0) ++ circA = cirq.Circuit([cirq.ops.H.on(qbit), cirq.ops.measure(qbit, key="a")]) ++ circB = cirq.Circuit([cirq.ops.H.on(qbit), cirq.ops.measure(qbit, key="b")]) ++ assert not _equal(circA, circB, require_measurement_equality=True) ++ ++ ++def test_circuit_equality_different_gates_same_keys_default(): ++ """Preservation: circuits with different non-measurement gates should ++ NOT be equal, even with identical measurement keys and default flag. ++ """ ++ qbit = cirq.LineQubit(0) ++ circA = cirq.Circuit([cirq.ops.H.on(qbit), cirq.ops.measure(qbit, key="a")]) ++ circB = cirq.Circuit([cirq.ops.X.on(qbit), cirq.ops.measure(qbit, key="a")]) ++ assert not _equal(circA, circB) ++ ++ ++def test_circuit_equality_no_measurements_default_preserved(): ++ """Preservation: circuits with no measurements should still compare ++ equal when they have the same gates, with default flag. ++ """ ++ qreg = cirq.LineQubit.range(3) ++ circA = cirq.Circuit(cirq.ops.H.on_each(*qreg)) ++ circB = cirq.Circuit(cirq.ops.H.on_each(*qreg)) ++ assert _equal(circA, circB) ++ ++ ++def test_circuit_equality_measurement_keys_with_require_qubit_equality(): ++ """Interaction: different measurement keys with require_qubit_equality ++ should still be considered equal (since measurement keys are ignored). ++ """ ++ qbit = cirq.LineQubit(0) ++ circA = cirq.Circuit(cirq.ops.measure(qbit, key="a")) ++ circB = cirq.Circuit(cirq.ops.measure(qbit, key="b")) ++ assert _equal( ++ circA, ++ circB, ++ require_qubit_equality=True, ++ require_measurement_equality=False, ++ ) ++ assert not _equal( ++ circA, ++ circB, ++ require_qubit_equality=True, ++ require_measurement_equality=True, ++ ) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..f541719e +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m pytest mitiq/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 mitiq/tests/test_utils.py::test_circuit_equality_default_ignores_measurement_keys_issue_repro mitiq/tests/test_utils.py::test_circuit_equality_different_measurement_keys_explicit_false mitiq/tests/test_utils.py::test_circuit_equality_different_measurement_keys_required mitiq/tests/test_utils.py::test_circuit_equality_same_measurement_keys_required_true mitiq/tests/test_utils.py::test_circuit_equality_same_measurement_keys_default mitiq/tests/test_utils.py::test_circuit_equality_multi_qubit_measurement_different_keys_default mitiq/tests/test_utils.py::test_circuit_equality_multi_qubit_measurement_different_keys_required mitiq/tests/test_utils.py::test_circuit_equality_mixed_gates_different_measurement_keys_default mitiq/tests/test_utils.py::test_circuit_equality_mixed_gates_different_measurement_keys_required mitiq/tests/test_utils.py::test_circuit_equality_different_gates_same_keys_default mitiq/tests/test_utils.py::test_circuit_equality_no_measurements_default_preserved mitiq/tests/test_utils.py::test_circuit_equality_measurement_keys_with_require_qubit_equality ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002915/tests/test.sh b/tasks/format-code-task-002915/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1b0ae5a8abaac4215dbfaaf51ea777c109f8699 --- /dev/null +++ b/tasks/format-code-task-002915/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' +mitiq/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-002915/tests/test_command.sh b/tasks/format-code-task-002915/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002915/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002923/environment/Dockerfile b/tasks/format-code-task-002923/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e7bc765ac69f99c67e974cc52abbc65532617533 --- /dev/null +++ b/tasks/format-code-task-002923/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:85dec1033326dc2512fe6b0d5999b0c2bdfaffc96ed8b0674f40a93614d4c578 diff --git a/tasks/format-code-task-002923/environment/setup/files/blocklist b/tasks/format-code-task-002923/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002923/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002923/environment/setup/setup.sh b/tasks/format-code-task-002923/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002923/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002923/tests/test.patch b/tasks/format-code-task-002923/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..847af3adea721da96755821922fe90a9a6c4fee0 --- /dev/null +++ b/tasks/format-code-task-002923/tests/test.patch @@ -0,0 +1,418 @@ +diff --git a/usercase-test-coderl/test_pagination_state.py b/usercase-test-coderl/test_pagination_state.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_pagination_state.py +@@ -0,0 +1,387 @@ ++ ++ ++ ++ ++ ++ ++from __future__ import annotations ++ ++import copy ++from urllib.parse import parse_qs, urlparse ++ ++import httpx ++import pytest ++ ++from pyzotero import Zotero ++ ++ ++PAGE_ONE = [{"key": "P0", "data": {"title": "first page"}}] ++PAGE_TWO = [{"key": "P1", "data": {"title": "second page"}}] ++PAGE_THREE = [{"key": "P2", "data": {"title": "third page"}}] ++BIBTEX_PAGES = { ++ "0": "@article{alpha,\n title = {Entry Zero},\n author = {Author, A}\n}\n", ++ "1": "@article{beta,\n title = {Entry One},\n author = {Author, B}\n}\n", ++ "2": "@article{gamma,\n title = {Entry Two},\n author = {Author, C}\n}\n", ++} ++ ++ ++class TopPages: ++ def __init__( ++ self, ++ *, ++ library_id: str = "42", ++ local: bool = False, ++ limit_two: bool = False, ++ single_page: bool = False, ++ ) -> None: ++ self.library_id = library_id ++ self.local = local ++ self.limit_two = limit_two ++ self.single_page = single_page ++ self.calls: list[str] = [] ++ ++ @property ++ def endpoint(self) -> str: ++ if self.local: ++ return "http://localhost:23119/api" ++ return "https://api.zotero.org" ++ ++ @property ++ def base(self) -> str: ++ return f"{self.endpoint}/users/{self.library_id}/items/top" ++ ++ def client(self) -> httpx.Client: ++ return httpx.Client( ++ transport=httpx.MockTransport(self._handle), ++ follow_redirects=True, ++ ) ++ ++ def _handle(self, request: httpx.Request) -> httpx.Response: ++ self.calls.append(str(request.url)) ++ parsed = urlparse(str(request.url)) ++ params = parse_qs(parsed.query) ++ start = params.get("start", ["0"])[0] ++ limit = params.get("limit", ["1"])[0] ++ headers = {"Content-Type": "application/json"} ++ ++ if self.single_page: ++ body = [{"key": "B0"}, {"key": "B1"}] ++ elif self.limit_two: ++ if start == "0": ++ body = [{"key": "A0"}, {"key": "A1"}] ++ headers["Link"] = ( ++ f'<{self.base}?limit=2&locale=en-US>; rel="self", ' ++ f'<{self.base}?limit=2&start=2&locale=en-US>; rel="next", ' ++ f'<{self.base}?limit=2&start=2&locale=en-US>; rel="last"' ++ ) ++ else: ++ body = [{"key": "A2"}] ++ headers["Link"] = ( ++ f'<{self.base}?limit=2&start=2&locale=en-US>; rel="self", ' ++ f'<{self.base}?limit=2&start=2&locale=en-US>; rel="last"' ++ ) ++ else: ++ pages = {"0": PAGE_ONE, "1": PAGE_TWO, "2": PAGE_THREE} ++ body = pages[start] ++ if start == "0": ++ headers["Link"] = ( ++ f'<{self.base}?limit={limit}&locale=en-US>; rel="self", ' ++ f'<{self.base}?limit={limit}&start=1&locale=en-US>; rel="next", ' ++ f'<{self.base}?limit={limit}&start=2&locale=en-US>; rel="last"' ++ ) ++ elif start == "1": ++ headers["Link"] = ( ++ f'<{self.base}?limit={limit}&start=1&locale=en-US>; rel="self", ' ++ f'<{self.base}?limit={limit}&start=2&locale=en-US>; rel="next", ' ++ f'<{self.base}?limit={limit}&start=2&locale=en-US>; rel="last"' ++ ) ++ else: ++ headers["Link"] = ( ++ f'<{self.base}?limit={limit}&start=2&locale=en-US>; rel="self", ' ++ f'<{self.base}?limit={limit}&start=2&locale=en-US>; rel="last"' ++ ) ++ ++ return httpx.Response( ++ 200, ++ headers=headers, ++ json=copy.deepcopy(body), ++ request=request, ++ ) ++ ++ ++class BibtexTopPages: ++ def __init__(self) -> None: ++ self.calls: list[str] = [] ++ ++ def client(self) -> httpx.Client: ++ return httpx.Client( ++ transport=httpx.MockTransport(self._handle), ++ follow_redirects=True, ++ ) ++ ++ def _handle(self, request: httpx.Request) -> httpx.Response: ++ self.calls.append(str(request.url)) ++ parsed = urlparse(str(request.url)) ++ start = parse_qs(parsed.query).get("start", ["0"])[0] ++ base = "https://api.zotero.org/users/42/items/top" ++ headers = {"Content-Type": "application/x-bibtex"} ++ if start == "0": ++ headers["Link"] = ( ++ f'<{base}?format=bibtex&limit=1&locale=en-US>; rel="self", ' ++ f'<{base}?format=bibtex&limit=1&start=1&locale=en-US>; rel="next", ' ++ f'<{base}?format=bibtex&limit=1&start=2&locale=en-US>; rel="last"' ++ ) ++ elif start == "1": ++ headers["Link"] = ( ++ f'<{base}?format=bibtex&limit=1&start=1&locale=en-US>; rel="self", ' ++ f'<{base}?format=bibtex&limit=1&start=2&locale=en-US>; rel="next", ' ++ f'<{base}?format=bibtex&limit=1&start=2&locale=en-US>; rel="last"' ++ ) ++ else: ++ headers["Link"] = ( ++ f'<{base}?format=bibtex&limit=1&start=2&locale=en-US>; rel="self", ' ++ f'<{base}?format=bibtex&limit=1&start=2&locale=en-US>; rel="last"' ++ ) ++ return httpx.Response( ++ 200, ++ headers=headers, ++ text=BIBTEX_PAGES[start], ++ request=request, ++ ) ++ ++ ++def _assert_requested_page( ++ url: str, ++ *, ++ path: str = "/users/42/items/top", ++ limit: str = "1", ++ start: str | None = None, ++ locale: str = "en-US", ++) -> None: ++ parsed = urlparse(url) ++ params = parse_qs(parsed.query) ++ ++ assert parsed.path == path ++ assert params.get("limit") == [limit] ++ assert params.get("locale") == [locale] ++ if start is None: ++ assert "start" not in params or params["start"] == ["0"] ++ else: ++ assert params.get("start") == [start] ++ ++ ++def test_follow_advances_link_state_and_returns_next_pages() -> None: ++ ++ ++ ++ backend = TopPages() ++ client = backend.client() ++ zot = Zotero("42", "user", "key", client=client) ++ ++ ++ assert callable(zot.follow) ++ assert zot.top(limit=1) == [{"key": "P0", "data": {"title": "first page"}}] ++ ++ ++ _assert_requested_page(backend.calls[0]) ++ ++ assert zot.follow() == [{"key": "P1", "data": {"title": "second page"}}] ++ ++ _assert_requested_page(backend.calls[-1], start="1") ++ ++ assert zot.follow() == [{"key": "P2", "data": {"title": "third page"}}] ++ ++ _assert_requested_page(backend.calls[-1], start="2") ++ assert list(zot.iterfollow()) == [] ++ client.close() ++ ++ ++def test_local_follow_uses_next_link_without_duplicate_api_path() -> None: ++ ++ ++ ++ backend = TopPages(local=True) ++ client = backend.client() ++ zot = Zotero("42", "user", "key", local=True, client=client) ++ ++ assert zot.top(limit=1) == [{"key": "P0", "data": {"title": "first page"}}] ++ assert zot.follow() == [{"key": "P1", "data": {"title": "second page"}}] ++ ++ ++ _assert_requested_page( ++ backend.calls[-1], ++ path="/api/users/42/items/top", ++ start="1", ++ ) ++ assert "/api/api/" not in urlparse(backend.calls[-1]).path ++ client.close() ++ ++ ++def test_iterfollow_yields_successive_follow_results_then_stops() -> None: ++ ++ ++ ++ backend = TopPages() ++ client = backend.client() ++ zot = Zotero("42", "user", "key", client=client) ++ ++ assert zot.top(limit=1) == [{"key": "P0", "data": {"title": "first page"}}] ++ assert list(zot.iterfollow()) == [ ++ [{"key": "P1", "data": {"title": "second page"}}], ++ [{"key": "P2", "data": {"title": "third page"}}], ++ ] ++ ++ assert list(zot.iterfollow()) == [] ++ client.close() ++ ++ ++def test_makeiter_requires_previous_paginated_self_link() -> None: ++ ++ ++ ++ backend = TopPages() ++ client = backend.client() ++ zot = Zotero("42", "user", "key", client=client) ++ ++ with pytest.raises(RuntimeError) as excinfo: ++ zot.makeiter([]) ++ ++ message = str(excinfo.value).lower() ++ assert "link" in message or "pagination" in message ++ client.close() ++ ++ ++def test_makeiter_resets_to_self_link_and_refetches_first_page() -> None: ++ ++ ++ ++ backend = TopPages() ++ client = backend.client() ++ zot = Zotero("42", "user", "key", client=client) ++ ++ first_page = zot.top(limit=1) ++ assert first_page == [{"key": "P0", "data": {"title": "first page"}}] ++ generator = zot.makeiter(first_page) ++ assert list(generator) == [ ++ [{"key": "P0", "data": {"title": "first page"}}], ++ [{"key": "P1", "data": {"title": "second page"}}], ++ [{"key": "P2", "data": {"title": "third page"}}], ++ ] ++ ++ ++ _assert_requested_page(backend.calls[1], limit="1", start=None, locale="en-US") ++ client.close() ++ ++ ++def test_everything_extends_list_pages() -> None: ++ ++ ++ ++ backend = TopPages() ++ client = backend.client() ++ zot = Zotero("42", "user", "key", client=client) ++ ++ assert zot.everything(zot.top(limit=1)) == [ ++ {"key": "P0", "data": {"title": "first page"}}, ++ {"key": "P1", "data": {"title": "second page"}}, ++ {"key": "P2", "data": {"title": "third page"}}, ++ ] ++ ++ assert list(zot.iterfollow()) == [] ++ client.close() ++ ++ ++def test_everything_copies_and_extends_entries_collection() -> None: ++ ++ ++ ++ backend = BibtexTopPages() ++ client = backend.client() ++ zot = Zotero("42", "user", "key", client=client) ++ ++ first_page = zot.top(format="bibtex", limit=1) ++ result = zot.everything(first_page) ++ ++ ++ ++ assert [entry.get("title") for entry in result.entries] == [ ++ "Entry Zero", ++ "Entry One", ++ "Entry Two", ++ ] ++ assert [entry.get("title") for entry in first_page.entries] == ["Entry Zero"] ++ ++ ++ _assert_requested_page(backend.calls[-1], start="2") ++ client.close() ++ ++ ++def test_all_top_fetches_top_then_everything_with_limit_two() -> None: ++ ++ ++ ++ backend = TopPages(limit_two=True) ++ client = backend.client() ++ zot = Zotero("42", "user", "key", client=client) ++ ++ assert zot.all_top(limit=2) == [{"key": "A0"}, {"key": "A1"}, {"key": "A2"}] ++ ++ _assert_requested_page(backend.calls[-1], limit="2", start="2") ++ client.close() ++ ++ ++def test_two_zotero_instances_keep_independent_link_state() -> None: ++ ++ ++ ++ backend_a = TopPages(library_id="42") ++ backend_b = TopPages(library_id="99", single_page=True) ++ client_a = backend_a.client() ++ client_b = backend_b.client() ++ a = Zotero("42", "user", "key", client=client_a) ++ b = Zotero("99", "user", "key", client=client_b) ++ ++ ++ assert callable(a.follow) ++ assert callable(b.follow) ++ assert a.top(limit=1) == [{"key": "P0", "data": {"title": "first page"}}] ++ assert a.follow() == [{"key": "P1", "data": {"title": "second page"}}] ++ assert b.top(limit=2) == [{"key": "B0"}, {"key": "B1"}] ++ ++ ++ assert list(b.iterfollow()) == [] ++ assert a.follow() == [{"key": "P2", "data": {"title": "third page"}}] ++ client_a.close() ++ client_b.close() ++ ++ ++def test_iterfollow_stops_immediately_when_no_next_link_exists() -> None: ++ ++ ++ ++ backend = TopPages(single_page=True) ++ client = backend.client() ++ zot = Zotero("42", "user", "key", client=client) ++ ++ assert zot.top(limit=2) == [{"key": "B0"}, {"key": "B1"}] ++ ++ assert list(zot.iterfollow()) == [] ++ client.close() ++ ++ ++def test_everything_works_from_fresh_instances_across_repeated_cycles() -> None: ++ ++ ++ ++ for _ in range(3): ++ backend = TopPages() ++ client = backend.client() ++ zot = Zotero("42", "user", "key", client=client) ++ ++ ++ assert zot.everything(zot.top(limit=1)) == [ ++ {"key": "P0", "data": {"title": "first page"}}, ++ {"key": "P1", "data": {"title": "second page"}}, ++ {"key": "P2", "data": {"title": "third page"}}, ++ ] ++ client.close() +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,21 @@ ++#!/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_DISABLE_PIP_VERSION_CHECK=1 ++export PIP_ROOT_USER_ACTION=ignore ++export PIP_NO_INDEX=1 ++export PYTHONNOUSERSITE=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++ ++exec /opt/coderl-venv/bin/python -W ignore -m pytest -o addopts='' /workspace/repo/usercase-test-coderl/test_pagination_state.py -v diff --git a/tasks/format-code-task-002923/tests/test.sh b/tasks/format-code-task-002923/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..a58cea7d4afb5b722b742dda44007cd1dfe0a1a9 --- /dev/null +++ b/tasks/format-code-task-002923/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_pagination_state.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-002923/tests/test_command.sh b/tasks/format-code-task-002923/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002923/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-002924/environment/Dockerfile b/tasks/format-code-task-002924/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9d82b6b0fb620ae7b882c3901069dd13fdd8b8b0 --- /dev/null +++ b/tasks/format-code-task-002924/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:b1250a4561198712ebefc5e56c0f779b8923542ad3b19e444ce5d7f2e61a3e35 diff --git a/tasks/format-code-task-002924/environment/setup/files/blocklist b/tasks/format-code-task-002924/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002924/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002924/environment/setup/setup.sh b/tasks/format-code-task-002924/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-002924/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-002924/tests/test.patch b/tasks/format-code-task-002924/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..df0f39326f8ad6d1c0b727b2b86546b6d400ad62 --- /dev/null +++ b/tasks/format-code-task-002924/tests/test.patch @@ -0,0 +1,308 @@ +diff --git a/usercase-test-coderl/test_collection_creation_session.py b/usercase-test-coderl/test_collection_creation_session.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/test_collection_creation_session.py +@@ -0,0 +1,280 @@ ++ ++ ++from __future__ import annotations ++ ++import json ++import time ++ ++import httpx ++import pytest ++ ++from pyzotero import ConflictError, ParamNotPassedError, Zotero ++ ++ ++COLLECTIONS_URL = "https://api.zotero.org/users/myuserID/collections" ++ ++ ++class RecordingEndpoint: ++ def __init__( ++ self, ++ responses: list[tuple[int, bytes, dict[str, str]]] | None = None, ++ events: list[tuple[str, object]] | None = None, ++ ) -> None: ++ self.requests: list[httpx.Request] = [] ++ self.events = events if events is not None else [] ++ self.responses = responses or [ ++ (200, b'{"success":{"0":"ABC123"}}', {"content-type": "application/json"}) ++ ] ++ ++ def handler(self, request: httpx.Request) -> httpx.Response: ++ self.requests.append(request) ++ self.events.append(("post", str(request.url))) ++ status, body, headers = self.responses[min(len(self.requests) - 1, len(self.responses) - 1)] ++ return httpx.Response(status, headers=headers, content=body, request=request) ++ ++ def client(self) -> httpx.Client: ++ return httpx.Client( ++ transport=httpx.MockTransport(self.handler), ++ follow_redirects=True, ++ ) ++ ++ ++def request_json(request: httpx.Request) -> object: ++ return json.loads(request.content.decode("utf-8")) ++ ++ ++def test_create_collections_posts_default_parent_and_stores_response() -> None: ++ ++ ++ ++ endpoint = RecordingEndpoint() ++ zot = Zotero("myuserID", "user", "myuserkey", client=endpoint.client()) ++ payload = [{"name": "foo", "key": "ABC123"}] ++ ++ ++ assert callable(zot.create_collections) ++ ++ response = zot.create_collections(payload) ++ ++ assert response == {"success": {"0": "ABC123"}} ++ assert len(endpoint.requests) == 1 ++ request = endpoint.requests[0] ++ ++ assert request_json(request) == [ ++ {"name": "foo", "key": "ABC123", "parentCollection": ""} ++ ] ++ assert request.method == "POST" ++ assert str(request.url) == COLLECTIONS_URL ++ assert ("if-unmodified-since-version" in request.headers) is False ++ assert ("zotero-write-token" in request.headers) is True ++ ++ assert request.headers["zotero-write-token"] != "" ++ ++ assert request.headers["content-type"].lower().split(";", 1)[0] == "application/json" ++ assert zot.request.status_code == 200 ++ assert str(zot.request.url) == COLLECTIONS_URL ++ assert zot.request.json() == {"success": {"0": "ABC123"}} ++ ++ ++def test_create_collections_uses_last_modified_and_updates_session_request() -> None: ++ ++ ++ ++ endpoint = RecordingEndpoint( ++ responses=[ ++ (200, b'{"success":{"0":"ABC123"}}', {"content-type": "application/json"}), ++ (200, b'{"success":{"0":"DEF456"}}', {"content-type": "application/json"}), ++ ] ++ ) ++ zot = Zotero("myuserID", "user", "myuserkey", client=endpoint.client()) ++ ++ first = zot.create_collections([{"name": "foo", "key": "ABC123"}]) ++ second = zot.create_collections( ++ [{"name": "bar", "key": "DEF456", "parentCollection": "ABC123"}], ++ last_modified=5, ++ ) ++ ++ assert first == {"success": {"0": "ABC123"}} ++ assert second == {"success": {"0": "DEF456"}} ++ assert len(endpoint.requests) == 2 ++ assert endpoint.requests[0].headers.get("if-unmodified-since-version") is None ++ assert endpoint.requests[1].headers["if-unmodified-since-version"] == "5" ++ assert request_json(endpoint.requests[1]) == [ ++ {"name": "bar", "key": "DEF456", "parentCollection": "ABC123"} ++ ] ++ assert zot.request.status_code == 200 ++ assert zot.request.json() == {"success": {"0": "DEF456"}} ++ ++ ++def test_create_collection_alias_preserves_payload_and_last_modified() -> None: ++ ++ ++ ++ endpoint = RecordingEndpoint( ++ responses=[ ++ (200, b'{"success":{"0":"XYZ789"}}', {"content-type": "application/json"}) ++ ] ++ ) ++ zot = Zotero("myuserID", "user", "myuserkey", client=endpoint.client()) ++ payload = [{"name": "bar", "key": "XYZ789", "parentCollection": "PARENT1"}] ++ ++ response = zot.create_collection(payload, last_modified=5) ++ ++ assert response == {"success": {"0": "XYZ789"}} ++ assert len(endpoint.requests) == 1 ++ ++ assert request_json(endpoint.requests[0]) == [ ++ {"name": "bar", "key": "XYZ789", "parentCollection": "PARENT1"} ++ ] ++ assert str(endpoint.requests[0].url) == COLLECTIONS_URL ++ assert endpoint.requests[0].headers["if-unmodified-since-version"] == "5" ++ ++ ++def test_missing_name_raises_specific_error_before_post() -> None: ++ ++ ++ ++ endpoint = RecordingEndpoint() ++ zot = Zotero("myuserID", "user", "myuserkey", client=endpoint.client()) ++ ++ with pytest.raises(ParamNotPassedError) as excinfo: ++ zot.create_collections([{"key": "NO_NAME"}]) ++ ++ assert str(excinfo.value) == "The dict you pass must include a 'name' key" ++ assert len(endpoint.requests) == 0 ++ assert zot.request is None ++ ++ ++def test_failed_response_uses_zotero_http_error_handling_and_stores_request() -> None: ++ ++ ++ ++ endpoint = RecordingEndpoint( ++ responses=[(409, b"library locked", {"content-type": "text/plain"})] ++ ) ++ zot = Zotero("myuserID", "user", "myuserkey", client=endpoint.client()) ++ ++ with pytest.raises(ConflictError) as excinfo: ++ zot.create_collections([{"name": "foo", "key": "ABC123"}]) ++ ++ ++ assert isinstance(excinfo.value, ConflictError) ++ assert len(endpoint.requests) == 1 ++ assert zot.request.status_code == 409 ++ assert zot.request.text == "library locked" ++ ++ ++def test_create_collections_waits_for_active_write_backoff_before_post( ++ monkeypatch: pytest.MonkeyPatch, ++) -> None: ++ ++ ++ ++ events: list[tuple[str, object]] = [] ++ endpoint = RecordingEndpoint(events=events) ++ zot = Zotero("myuserID", "user", "myuserkey", client=endpoint.client()) ++ ++ def fake_sleep(duration: float) -> None: ++ events.append(("sleep", duration)) ++ ++ monkeypatch.setattr(time, "time", lambda: 100.0) ++ monkeypatch.setattr(time, "sleep", fake_sleep) ++ zot.backoff_until = 105.0 ++ ++ response = zot.create_collections([{"name": "foo", "key": "ABC123"}]) ++ ++ assert response == {"success": {"0": "ABC123"}} ++ assert events == [ ++ ("sleep", 5.0), ++ ("post", "https://api.zotero.org/users/myuserID/collections"), ++ ] ++ assert len(endpoint.requests) == 1 ++ ++ ++def test_two_zotero_instances_keep_collection_write_state_independent() -> None: ++ ++ ++ ++ endpoint_a = RecordingEndpoint( ++ responses=[ ++ (200, b'{"success":{"0":"AAA111"}}', {"content-type": "application/json"}) ++ ] ++ ) ++ endpoint_b = RecordingEndpoint( ++ responses=[ ++ (200, b'{"success":{"0":"BBB222"}}', {"content-type": "application/json"}) ++ ] ++ ) ++ zot_a = Zotero("alpha", "user", "keyA", client=endpoint_a.client()) ++ zot_b = Zotero("beta", "group", "keyB", client=endpoint_b.client()) ++ ++ response_a = zot_a.create_collections([{"name": "alpha", "key": "AAA111"}]) ++ ++ assert response_a == {"success": {"0": "AAA111"}} ++ assert str(endpoint_a.requests[0].url) == "https://api.zotero.org/users/alpha/collections" ++ assert zot_a.request.status_code == 200 ++ assert zot_a.request.json() == {"success": {"0": "AAA111"}} ++ assert zot_b.request is None ++ assert len(endpoint_b.requests) == 0 ++ ++ response_b = zot_b.create_collections( ++ [{"name": "beta", "key": "BBB222"}], ++ last_modified=7, ++ ) ++ ++ assert response_b == {"success": {"0": "BBB222"}} ++ assert str(endpoint_b.requests[0].url) == "https://api.zotero.org/groups/beta/collections" ++ assert endpoint_b.requests[0].headers["if-unmodified-since-version"] == "7" ++ assert zot_b.request.status_code == 200 ++ assert zot_b.request.json() == {"success": {"0": "BBB222"}} ++ ++ ++def test_configured_client_is_used_for_collection_creation() -> None: ++ ++ ++ ++ endpoint = RecordingEndpoint() ++ client = endpoint.client() ++ zot = Zotero("myuserID", "user", "myuserkey", client=client) ++ ++ response = zot.create_collections([{"name": "configured", "key": "CFG001"}]) ++ ++ ++ assert response == {"success": {"0": "ABC123"}} ++ assert len(endpoint.requests) == 1 ++ assert str(endpoint.requests[0].url) == COLLECTIONS_URL ++ ++ ++def test_repeated_construct_use_cycles_use_each_configured_client() -> None: ++ ++ ++ ++ clients: list[httpx.Client] = [] ++ posted_urls: list[str] = [] ++ ++ for index in range(100): ++ endpoint = RecordingEndpoint( ++ responses=[ ++ ( ++ 200, ++ b'{"success":{"0":"LEAK00"}}', ++ {"content-type": "application/json"}, ++ ) ++ ] ++ ) ++ client = endpoint.client() ++ zot = Zotero(str(index), "user", "myuserkey", client=client) ++ ++ assert zot.create_collections([{"name": "leak", "key": "LEAK00"}]) == { ++ "success": {"0": "LEAK00"} ++ } ++ assert len(endpoint.requests) == 1 ++ posted_urls.append(str(endpoint.requests[0].url)) ++ clients.append(client) ++ del zot ++ ++ ++ assert posted_urls == [ ++ f"https://api.zotero.org/users/{index}/collections" for index in range(100) ++ ] ++ assert len(clients) == 100 +diff --git 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 PYTHONNOUSERSITE=1 ++export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ++export PYTHONPATH="/workspace/repo/src${PYTHONPATH:+:${PYTHONPATH}}" ++exec /workspace/repo/.venv/bin/python -m pytest -o addopts='' /workspace/repo/usercase-test-coderl/test_collection_creation_session.py -v diff --git a/tasks/format-code-task-002924/tests/test.sh b/tasks/format-code-task-002924/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..8d714a747d8de48f83aca145fdf3d147f950a279 --- /dev/null +++ b/tasks/format-code-task-002924/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_collection_creation_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-002924/tests/test_command.sh b/tasks/format-code-task-002924/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-002924/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-002948/environment/Dockerfile b/tasks/format-code-task-002948/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ccc783d560dc0085a0955e5918bfba5774833d4b --- /dev/null +++ b/tasks/format-code-task-002948/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:f3f925fca5f71382459f72957883048c3a4fb05b46d963e7ea7e3b3d73ae5de1 diff --git a/tasks/format-code-task-002948/environment/setup/files/blocklist b/tasks/format-code-task-002948/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002948/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002948/environment/setup/setup.sh b/tasks/format-code-task-002948/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002948/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002948/tests/test.patch b/tasks/format-code-task-002948/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..4843a923861cd2e766c6efcb7edbb18705a838e9 --- /dev/null +++ b/tasks/format-code-task-002948/tests/test.patch @@ -0,0 +1,98 @@ +diff --git a/grok_test.go b/grok_test.go +index d527c3f..4f8ee17 100644 +--- a/grok_test.go ++++ b/grok_test.go +@@ -1,6 +1,11 @@ + package grok + +-import "testing" ++import ( ++ "bufio" ++ "fmt" ++ "strings" ++ "testing" ++) + + func TestNew(t *testing.T) { + g, _ := New() +@@ -84,8 +89,10 @@ func TestAddPatternsFromPathErr(t *testing.T) { + } + + func TestConfigPatternsDir(t *testing.T) { +- g, _ := NewWithConfig(&Config{PatternsDir: []string{"./patterns"}}) +- // g,_ := New() ++ g, err := NewWithConfig(&Config{PatternsDir: []string{"./patterns"}}) ++ if err != nil { ++ t.Error(err) ++ } + + if captures, err := g.Parse("%{SYSLOGLINE}", `Sep 12 23:19:02 docker syslog-ng[25389]: syslog-ng starting up; version='3.5.3'`); err != nil { + t.Fatalf("error : %s", err.Error()) +@@ -657,3 +664,45 @@ func TestGrok_AddPatternsFromMap_complex(t *testing.T) { + t.Errorf("bad match: expected 333666, got %s", mss["match"]) + } + } ++ ++func TestParseStream(t *testing.T) { ++ g, _ := New() ++ pTest := func(m map[string]string) error { ++ ts, ok := m["timestamp"] ++ if !ok { ++ t.Error("timestamp not found") ++ } ++ if len(ts) == 0 { ++ t.Error("empty timestamp") ++ } ++ return nil ++ } ++ const testLog = `127.0.0.1 - - [23/Apr/2014:22:58:32 +0200] "GET /index.php HTTP/1.1" 404 207 ++127.0.0.1 - - [23/Apr/2014:22:59:32 +0200] "GET /index.php HTTP/1.1" 404 207 ++127.0.0.1 - - [23/Apr/2014:23:00:32 +0200] "GET /index.php HTTP/1.1" 404 207 ++` ++ ++ r := bufio.NewReader(strings.NewReader(testLog)) ++ if err := g.ParseStream(r, "%{COMMONAPACHELOG}", pTest); err != nil { ++ t.Fatal(err) ++ } ++} ++ ++func TestParseStreamError(t *testing.T) { ++ g, _ := New() ++ pTest := func(m map[string]string) error { ++ if _, ok := m["timestamp"]; !ok { ++ return fmt.Errorf("timestamp not found") ++ } ++ return nil ++ } ++ const testLog = `127.0.0.1 - - [23/Apr/2014:22:58:32 +0200] "GET /index.php HTTP/1.1" 404 207 ++127.0.0.1 - - [xxxxxxxxxxxxxxxxxxxx +0200] "GET /index.php HTTP/1.1" 404 207 ++127.0.0.1 - - [23/Apr/2014:23:00:32 +0200] "GET /index.php HTTP/1.1" 404 207 ++` ++ ++ r := bufio.NewReader(strings.NewReader(testLog)) ++ if err := g.ParseStream(r, "%{COMMONAPACHELOG}", pTest); err == nil { ++ t.Fatal("Error expected") ++ } ++} +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,6 @@ ++H4sIAAAAAAAAA+3Sy0rDQBQG4KzzFAdc5zJp0666EJS6UCpe1iVNJum0yUyZS8C3d1KwiqBFaBHx ++/zYzyZzhHPInXjnRVksu+yQ4l9Sb5vl+9T6v+z3LM5aN0nSS+feM5dM0oPxsE33gjC00UaCVst/V ++HTv/o+L3/C03dlmqritkFZv16Xocy3+csUP++Wji8x9P0mlA6elG+No/z7+saB/8ildheEGP3JLb ++0Xxxf/l0Q+ala4XcUq002bUwtNM86lTlWj7s1YaXNuy2ldAU7SgZPlHSqMToMmmEXbtV7H+npN/w ++Qlpuw1ZSZGp5aHj0RtJotR3GenCSiral4aIhIWk4WA5PcaOoF8XbxH44Hs4XjLG7xdXz7fVM1TX5 ++kqGUop6iUjlpZ4y+7PbbgQAAAAAAAAAAAAAAAAAAAAAA/MArFytcXgAoAAA= +diff --git 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-002948/tests/test.sh b/tasks/format-code-task-002948/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0941513bcd4ecdbff663b14df7662c9d2460cd47 --- /dev/null +++ b/tasks/format-code-task-002948/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' +grok_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-002948/tests/test_command.sh b/tasks/format-code-task-002948/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002948/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002949/environment/Dockerfile b/tasks/format-code-task-002949/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..689e5dc53bbb3949128e56d1bf0b9f7285e1afd8 --- /dev/null +++ b/tasks/format-code-task-002949/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:a1fe0c1492d6ca2a1f286e5f311ca55ec1886138e1ea1b4391d8e96b91aa40cc diff --git a/tasks/format-code-task-002949/environment/setup/files/blocklist b/tasks/format-code-task-002949/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002949/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002949/environment/setup/setup.sh b/tasks/format-code-task-002949/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002949/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002949/tests/test.patch b/tasks/format-code-task-002949/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..fd095ccf15e4d5acb47572feed508ea67fd4129a --- /dev/null +++ b/tasks/format-code-task-002949/tests/test.patch @@ -0,0 +1,411 @@ +diff --git a/internal/objectstore/codespec_apply_yaml_preflight_test.go b/internal/objectstore/codespec_apply_yaml_preflight_test.go +new file mode 100644 +index 00000000..b4be1f20 +--- /dev/null ++++ b/internal/objectstore/codespec_apply_yaml_preflight_test.go +@@ -0,0 +1,394 @@ ++ ++ ++ ++ ++ ++package objectstore ++ ++import ( ++ "context" ++ "errors" ++ "testing" ++ ++ "github.com/golang/mock/gomock" ++ "github.com/stretchr/testify/assert" ++ "github.com/stretchr/testify/require" ++ kerrors "k8s.io/apimachinery/pkg/api/errors" ++ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ++ "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ++ "k8s.io/apimachinery/pkg/runtime/schema" ++ "k8s.io/apimachinery/pkg/types" ++ ++ clusterFake "github.com/vmware-tanzu/octant/internal/cluster/fake" ++ "github.com/vmware-tanzu/octant/pkg/store" ++) ++ ++type codespecApplyRecorder struct { ++ gets []store.Key ++ creates []*unstructured.Unstructured ++} ++ ++func (r *codespecApplyRecorder) get(_ context.Context, key store.Key) (*unstructured.Unstructured, error) { ++ r.gets = append(r.gets, key) ++ return nil, kerrors.NewNotFound(schema.GroupResource{Group: key.GroupVersionKind().Group}, key.Name) ++} ++ ++func (r *codespecApplyRecorder) create(_ context.Context, object *unstructured.Unstructured) error { ++ r.creates = append(r.creates, object.DeepCopy()) ++ return nil ++} ++ ++func codespecApplyClient(t *testing.T) (*gomock.Controller, *clusterFake.MockClientInterface) { ++ t.Helper() ++ controller := gomock.NewController(t) ++ client := clusterFake.NewMockClientInterface(controller) ++ client.EXPECT().Resource(gomock.Any()).DoAndReturn( ++ func(gk schema.GroupKind) (schema.GroupVersionResource, bool, error) { ++ switch gk.Kind { ++ case "ConfigMap": ++ return schema.GroupVersionResource{Group: gk.Group, Version: "v1", Resource: "configmaps"}, true, nil ++ case "Secret": ++ return schema.GroupVersionResource{Group: gk.Group, Version: "v1", Resource: "secrets"}, true, nil ++ case "Namespace": ++ return schema.GroupVersionResource{Group: gk.Group, Version: "v1", Resource: "namespaces"}, false, nil ++ default: ++ return schema.GroupVersionResource{Group: gk.Group, Version: "v1", Resource: "unknown"}, false, nil ++ } ++ }).AnyTimes() ++ return controller, client ++} ++ ++func TestCodespecApplyYAMLPreflightMalformedTailIsSideEffectFree(t *testing.T) { ++ controller, client := codespecApplyClient(t) ++ defer controller.Finish() ++ recorder := &codespecApplyRecorder{} ++ ++ input := ` ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: first ++--- ++apiVersion: v1 ++kind: Secret ++metadata: ++ name: broken ++data: [ ++` ++ results, err := CreateOrUpdateFromHandler(context.Background(), "default", input, recorder.get, recorder.create, client) ++ ++ require.Error(t, err) ++ assert.Empty(t, results) ++ assert.Empty(t, recorder.gets, "preflight errors must occur before object lookup") ++ assert.Empty(t, recorder.creates, "preflight errors must occur before object creation") ++} ++ ++func TestCodespecApplyYAMLPreflightRejectsInvalidResourcesAndDuplicates(t *testing.T) { ++ tests := []struct { ++ name string ++ input string ++ }{ ++ { ++ name: "missing apiVersion", ++ input: `kind: ConfigMap ++metadata: ++ name: missing-version ++`, ++ }, ++ { ++ name: "missing kind", ++ input: `apiVersion: v1 ++metadata: ++ name: missing-kind ++`, ++ }, ++ { ++ name: "missing name", ++ input: `apiVersion: v1 ++kind: ConfigMap ++metadata: {} ++`, ++ }, ++ { ++ name: "list item is not an object", ++ input: `apiVersion: v1 ++kind: List ++items: ++ - not-an-object ++`, ++ }, ++ { ++ name: "list has no items array", ++ input: `apiVersion: v1 ++kind: List ++metadata: ++ name: invalid-list ++`, ++ }, ++ { ++ name: "namespace escapes selected namespace", ++ input: `apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: cross-namespace ++ namespace: other ++`, ++ }, ++ { ++ name: "duplicate after list expansion and namespace defaulting", ++ input: `apiVersion: v1 ++kind: List ++items: ++ - apiVersion: v1 ++ kind: ConfigMap ++ metadata: ++ name: repeated ++--- ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: repeated ++ namespace: default ++`, ++ }, ++ } ++ ++ for _, tt := range tests { ++ t.Run(tt.name, func(t *testing.T) { ++ controller, client := codespecApplyClient(t) ++ defer controller.Finish() ++ recorder := &codespecApplyRecorder{} ++ ++ results, err := CreateOrUpdateFromHandler(context.Background(), "default", tt.input, recorder.get, recorder.create, client) ++ ++ require.Error(t, err) ++ assert.Empty(t, results) ++ assert.Empty(t, recorder.gets) ++ assert.Empty(t, recorder.creates) ++ }) ++ } ++} ++ ++func TestCodespecApplyYAMLExpandsListsInStreamOrder(t *testing.T) { ++ controller, client := codespecApplyClient(t) ++ defer controller.Finish() ++ recorder := &codespecApplyRecorder{} ++ ++ input := ` ++apiVersion: v1 ++kind: List ++items: ++ - apiVersion: v1 ++ kind: ConfigMap ++ metadata: ++ name: first ++ - apiVersion: v1 ++ kind: List ++ items: ++ - apiVersion: v1 ++ kind: Namespace ++ metadata: ++ name: team-a ++ - apiVersion: v1 ++ kind: Secret ++ metadata: ++ name: credentials ++ namespace: default ++--- ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: last ++` ++ results, err := CreateOrUpdateFromHandler(context.Background(), "default", input, recorder.get, recorder.create, client) ++ ++ require.NoError(t, err) ++ assert.Equal(t, []string{ ++ "Created ConfigMap (v1) first in default", ++ "Created Namespace (v1) team-a", ++ "Created Secret (v1) credentials in default", ++ "Created ConfigMap (v1) last in default", ++ }, results) ++ require.Len(t, recorder.creates, 4) ++ assert.Equal(t, []string{"first", "team-a", "credentials", "last"}, []string{ ++ recorder.creates[0].GetName(), ++ recorder.creates[1].GetName(), ++ recorder.creates[2].GetName(), ++ recorder.creates[3].GetName(), ++ }) ++ assert.Equal(t, "default", recorder.creates[0].GetNamespace()) ++ assert.Empty(t, recorder.creates[1].GetNamespace(), "cluster-scoped resources must not receive the selected namespace") ++ assert.Equal(t, "default", recorder.creates[2].GetNamespace()) ++ assert.Equal(t, "default", recorder.creates[3].GetNamespace()) ++} ++ ++func TestCodespecApplyYAMLEmptyDocumentsAndListsAreNoOps(t *testing.T) { ++ controller, client := codespecApplyClient(t) ++ defer controller.Finish() ++ recorder := &codespecApplyRecorder{} ++ ++ input := ` ++--- ++apiVersion: v1 ++kind: List ++items: [] ++--- ++` ++ results, err := CreateOrUpdateFromHandler(context.Background(), "default", input, recorder.get, recorder.create, client) ++ ++ require.NoError(t, err) ++ assert.Empty(t, results) ++ assert.Empty(t, recorder.gets) ++ assert.Empty(t, recorder.creates) ++} ++ ++func TestCodespecApplyYAMLLookupFailureKeepsEarlierResults(t *testing.T) { ++ controller, client := codespecApplyClient(t) ++ defer controller.Finish() ++ var creates []*unstructured.Unstructured ++ getCount := 0 ++ get := func(_ context.Context, key store.Key) (*unstructured.Unstructured, error) { ++ getCount++ ++ if getCount == 2 { ++ return nil, errors.New("lookup unavailable") ++ } ++ return nil, kerrors.NewNotFound(schema.GroupResource{}, key.Name) ++ } ++ create := func(_ context.Context, object *unstructured.Unstructured) error { ++ creates = append(creates, object.DeepCopy()) ++ return nil ++ } ++ ++ input := ` ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: completed ++--- ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: fails-at-runtime ++` ++ results, err := CreateOrUpdateFromHandler(context.Background(), "default", input, get, create, client) ++ ++ require.Error(t, err) ++ assert.Contains(t, err.Error(), "lookup unavailable") ++ assert.Equal(t, []string{"Created ConfigMap (v1) completed in default"}, results) ++ require.Len(t, creates, 1) ++ assert.Equal(t, "completed", creates[0].GetName()) ++} ++ ++func TestCodespecApplyYAMLDiscoveryFailureKeepsEarlierResults(t *testing.T) { ++ controller := gomock.NewController(t) ++ defer controller.Finish() ++ client := clusterFake.NewMockClientInterface(controller) ++ client.EXPECT().Resource(schema.GroupKind{Kind: "ConfigMap"}).Return( ++ schema.GroupVersionResource{Version: "v1", Resource: "configmaps"}, true, nil) ++ client.EXPECT().Resource(schema.GroupKind{Kind: "Secret"}).Return( ++ schema.GroupVersionResource{}, false, errors.New("discovery unavailable")) ++ recorder := &codespecApplyRecorder{} ++ ++ input := ` ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: completed ++--- ++apiVersion: v1 ++kind: Secret ++metadata: ++ name: fails-at-discovery ++` ++ results, err := CreateOrUpdateFromHandler(context.Background(), "default", input, recorder.get, recorder.create, client) ++ ++ require.Error(t, err) ++ assert.Contains(t, err.Error(), "discovery unavailable") ++ assert.Equal(t, []string{"Created ConfigMap (v1) completed in default"}, results) ++ require.Len(t, recorder.creates, 1) ++ assert.Equal(t, "completed", recorder.creates[0].GetName()) ++} ++ ++func TestCodespecApplyYAMLCreateFailureKeepsEarlierResults(t *testing.T) { ++ controller, client := codespecApplyClient(t) ++ defer controller.Finish() ++ var creates []*unstructured.Unstructured ++ create := func(_ context.Context, object *unstructured.Unstructured) error { ++ if object.GetName() == "fails-at-create" { ++ return errors.New("create unavailable") ++ } ++ creates = append(creates, object.DeepCopy()) ++ return nil ++ } ++ recorder := &codespecApplyRecorder{} ++ ++ input := ` ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: completed ++--- ++apiVersion: v1 ++kind: Secret ++metadata: ++ name: fails-at-create ++` ++ results, err := CreateOrUpdateFromHandler(context.Background(), "default", input, recorder.get, create, client) ++ ++ require.Error(t, err) ++ assert.Contains(t, err.Error(), "create unavailable") ++ assert.Equal(t, []string{"Created ConfigMap (v1) completed in default"}, results) ++ require.Len(t, creates, 1) ++ assert.Equal(t, "completed", creates[0].GetName()) ++} ++ ++func TestCodespecApplyYAMLPatchFailureKeepsEarlierResults(t *testing.T) { ++ controller := gomock.NewController(t) ++ defer controller.Finish() ++ client := clusterFake.NewMockClientInterface(controller) ++ dynamicClient := clusterFake.NewMockDynamicInterface(controller) ++ resourceClient := clusterFake.NewMockNamespaceableResourceInterface(controller) ++ gvr := schema.GroupVersionResource{Version: "v1", Resource: "configmaps"} ++ client.EXPECT().Resource(schema.GroupKind{Kind: "ConfigMap"}).Return(gvr, true, nil).Times(2) ++ client.EXPECT().DynamicClient().Return(dynamicClient, nil) ++ dynamicClient.EXPECT().Resource(gvr).Return(resourceClient) ++ resourceClient.EXPECT().Namespace("default").Return(resourceClient) ++ resourceClient.EXPECT().Patch( ++ gomock.Any(), "fails-at-patch", types.ApplyPatchType, gomock.Any(), ++ metav1.PatchOptions{FieldManager: "octant", Force: func() *bool { v := true; return &v }()}, ++ gomock.Any(), ++ ).Return(nil, errors.New("patch unavailable")) ++ ++ getCount := 0 ++ get := func(_ context.Context, key store.Key) (*unstructured.Unstructured, error) { ++ getCount++ ++ if getCount == 1 { ++ return nil, kerrors.NewNotFound(schema.GroupResource{}, key.Name) ++ } ++ return &unstructured.Unstructured{}, nil ++ } ++ var creates []*unstructured.Unstructured ++ create := func(_ context.Context, object *unstructured.Unstructured) error { ++ creates = append(creates, object.DeepCopy()) ++ return nil ++ } ++ ++ input := ` ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: completed ++--- ++apiVersion: v1 ++kind: ConfigMap ++metadata: ++ name: fails-at-patch ++` ++ results, err := CreateOrUpdateFromHandler(context.Background(), "default", input, get, create, client) ++ ++ require.Error(t, err) ++ assert.Contains(t, err.Error(), "patch unavailable") ++ assert.Equal(t, []string{"Created ConfigMap (v1) completed in default"}, results) ++ require.Len(t, creates, 1) ++ assert.Equal(t, "completed", creates[0].GetName()) ++} +diff --git 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 ++ ++ ++go test ./internal/objectstore ./internal/octant \ ++ -run '^(TestCodespecApplyYAML|TestNewApplyYaml_)' -count=1 diff --git a/tasks/format-code-task-002949/tests/test.sh b/tasks/format-code-task-002949/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..0e6a23800a6228a3b0dd2d921e3c04a6188c83a9 --- /dev/null +++ b/tasks/format-code-task-002949/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/objectstore/codespec_apply_yaml_preflight_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-002949/tests/test_command.sh b/tasks/format-code-task-002949/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002949/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002971/environment/Dockerfile b/tasks/format-code-task-002971/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ddc7c2c79a793cdd54eac557e3324de573584339 --- /dev/null +++ b/tasks/format-code-task-002971/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:1127680d3c615600284552a251b1d5a33f8234065e136a61aeaec0e4e637dbda diff --git a/tasks/format-code-task-002971/environment/setup/files/blocklist b/tasks/format-code-task-002971/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002971/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002971/environment/setup/setup.sh b/tasks/format-code-task-002971/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002971/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002971/tests/test.patch b/tasks/format-code-task-002971/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..0ffc71befd4576dc2c900f258ad3c423e00621ff --- /dev/null +++ b/tasks/format-code-task-002971/tests/test.patch @@ -0,0 +1,141 @@ +diff --git a/packages/vuetify/src/components/VDataTable/__tests__/disableSortGroupBy.spec.ts b/packages/vuetify/src/components/VDataTable/__tests__/disableSortGroupBy.spec.ts +new file mode 100644 +index 000000000..e9a6390f7 +--- /dev/null ++++ b/packages/vuetify/src/components/VDataTable/__tests__/disableSortGroupBy.spec.ts +@@ -0,0 +1,113 @@ ++ ++import { VDataTable } from '../VDataTable' ++ ++ ++import { describe, expect, it } from '@jest/globals' ++import { mount } from '@vue/test-utils' ++import { createVuetify } from '@/framework' ++ ++const HEADERS = [ ++ { key: 'cat', title: 'Cat' }, ++ { key: 'name', title: 'Name' }, ++] ++ ++const ITEMS = [ ++ { id: 1, cat: 'b', name: 'z' }, ++ { id: 2, cat: 'a', name: 'y' }, ++ { id: 3, cat: 'b', name: 'w' }, ++ { id: 4, cat: 'a', name: 'x' }, ++] ++ ++function mountAndCaptureItems (props: Record) { ++ const vuetify = createVuetify() ++ let captured: any = null ++ mount(VDataTable, { ++ props, ++ slots: { ++ body: (slotProps: any) => { ++ captured = slotProps.items ++ return '' ++ }, ++ }, ++ global: { plugins: [vuetify] }, ++ }) ++ return captured as any[] ++} ++ ++describe('VDataTable - disable-sort + group-by', () => { ++ ++ ++ it('groups items by groupBy key (asc) when disable-sort is true', () => { ++ const items = mountAndCaptureItems({ ++ items: ITEMS, ++ headers: HEADERS, ++ groupBy: [{ key: 'cat', order: 'asc' }], ++ disableSort: true, ++ }) ++ ++ expect(items).not.toBeNull() ++ expect(items).toHaveLength(4) ++ ++ expect(items.map((i: any) => i.cat)).toStrictEqual(['a', 'a', 'b', 'b']) ++ }) ++ ++ ++ ++ it('does NOT apply sortBy when disable-sort is true and there is no groupBy', () => { ++ const items = mountAndCaptureItems({ ++ items: ITEMS, ++ headers: HEADERS, ++ sortBy: [{ key: 'name', order: 'asc' }], ++ disableSort: true, ++ }) ++ ++ ++ expect(items.map((i: any) => i.id)).toStrictEqual([1, 2, 3, 4]) ++ }) ++ ++ ++ ++ it('groups by groupBy but does NOT apply sortBy within groups when disable-sort', () => { ++ const items = mountAndCaptureItems({ ++ items: ITEMS, ++ headers: HEADERS, ++ groupBy: [{ key: 'cat', order: 'asc' }], ++ sortBy: [{ key: 'name', order: 'asc' }], ++ disableSort: true, ++ }) ++ ++ expect(items).toHaveLength(4) ++ ++ expect(items.map((i: any) => i.cat)).toStrictEqual(['a', 'a', 'b', 'b']) ++ ++ ++ ++ ++ expect(items.map((i: any) => i.name)).toStrictEqual(['y', 'x', 'z', 'w']) ++ }) ++ ++ ++ it('sorts by sortBy normally when disable-sort is false', () => { ++ const items = mountAndCaptureItems({ ++ items: ITEMS, ++ headers: HEADERS, ++ sortBy: [{ key: 'name', order: 'asc' }], ++ }) ++ ++ expect(items.map((i: any) => i.name)).toStrictEqual(['w', 'x', 'y', 'z']) ++ }) ++ ++ ++ it('groups by groupBy AND sorts by sortBy within groups when disable-sort is false', () => { ++ const items = mountAndCaptureItems({ ++ items: ITEMS, ++ headers: HEADERS, ++ groupBy: [{ key: 'cat', order: 'asc' }], ++ sortBy: [{ key: 'name', order: 'asc' }], ++ }) ++ ++ ++ expect(items.map((i: any) => i.cat)).toStrictEqual(['a', 'a', 'b', 'b']) ++ expect(items.map((i: any) => i.name)).toStrictEqual(['x', 'y', 'w', 'z']) ++ }) ++}) +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 000000000..67169a190 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd packages/vuetify && npx jest src/components/VDataTable/__tests__/disableSortGroupBy.spec.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 ++cd packages/vuetify && npx jest src/components/VDataTable/__tests__/disableSortGroupBy.spec.ts ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002971/tests/test.sh b/tasks/format-code-task-002971/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..6b8b4c920b98139837987b6cbbaf510194fd0d03 --- /dev/null +++ b/tasks/format-code-task-002971/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/vuetify/src/components/VDataTable/__tests__/disableSortGroupBy.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-002971/tests/test_command.sh b/tasks/format-code-task-002971/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002971/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002976/environment/Dockerfile b/tasks/format-code-task-002976/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..3670277d135bc8c964eb724293580db0f50b7e25 --- /dev/null +++ b/tasks/format-code-task-002976/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:35f64757818f017cfec9a4f5979ebbbe5331edb9904c3add2d0384b4f8e5bd19 diff --git a/tasks/format-code-task-002976/environment/setup/files/blocklist b/tasks/format-code-task-002976/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002976/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002976/environment/setup/setup.sh b/tasks/format-code-task-002976/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002976/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002976/tests/test.patch b/tasks/format-code-task-002976/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..c2b9e3fc0aa17af183c93f2761af0cb7ed4e0cb7 --- /dev/null +++ b/tasks/format-code-task-002976/tests/test.patch @@ -0,0 +1,283 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000000..dda897990d +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python runtests.py wagtail.admin.tests.test_button_searcharea_comparison"] ++} +diff --git a/wagtail/admin/tests/test_button_searcharea_comparison.py b/wagtail/admin/tests/test_button_searcharea_comparison.py +new file mode 100644 +index 0000000000..8c7a5db680 +--- /dev/null ++++ b/wagtail/admin/tests/test_button_searcharea_comparison.py +@@ -0,0 +1,255 @@ ++ ++ ++ ++ ++ ++from django.test import SimpleTestCase ++ ++from wagtail.admin.search import SearchArea ++from wagtail.admin.widgets.button import Button ++ ++ ++class TestSearchAreaComparison(SimpleTestCase): ++ def _make(self, label="Search", url="/search/", order=1000): ++ return SearchArea(label=label, url=url, order=order) ++ ++ ++ def test_eq_same_order_and_label(self): ++ a = self._make(label="A", url="/a/", order=100) ++ b = self._make(label="A", url="/b/", order=100) ++ ++ self.assertTrue(a == b) ++ ++ def test_eq_different_order(self): ++ a = self._make(label="A", order=100) ++ b = self._make(label="A", order=200) ++ self.assertFalse(a == b) ++ ++ def test_eq_different_label(self): ++ a = self._make(label="A", order=100) ++ b = self._make(label="B", order=100) ++ self.assertFalse(a == b) ++ ++ ++ def test_ne_inverse_of_eq(self): ++ a = self._make(label="A", order=100) ++ b = self._make(label="A", order=100) ++ c = self._make(label="A", order=200) ++ self.assertFalse(a != b) ++ self.assertTrue(a != c) ++ ++ ++ def test_lt_by_order(self): ++ a = self._make(label="A", order=100) ++ b = self._make(label="A", order=200) ++ self.assertTrue(a < b) ++ self.assertFalse(b < a) ++ ++ def test_lt_by_label_when_order_equal(self): ++ a = self._make(label="A", order=100) ++ b = self._make(label="B", order=100) ++ self.assertTrue(a < b) ++ self.assertFalse(b < a) ++ ++ def test_lt_equal_returns_false(self): ++ a = self._make(label="A", order=100) ++ b = self._make(label="A", order=100) ++ self.assertFalse(a < b) ++ ++ ++ def test_le_when_less(self): ++ a = self._make(label="A", order=100) ++ b = self._make(label="A", order=200) ++ self.assertTrue(a <= b) ++ ++ def test_le_when_equal(self): ++ a = self._make(label="A", order=100) ++ b = self._make(label="A", order=100) ++ self.assertTrue(a <= b) ++ ++ def test_le_when_greater(self): ++ a = self._make(label="A", order=200) ++ b = self._make(label="A", order=100) ++ self.assertFalse(a <= b) ++ ++ ++ def test_gt_by_order(self): ++ a = self._make(label="A", order=200) ++ b = self._make(label="A", order=100) ++ self.assertTrue(a > b) ++ self.assertFalse(b > a) ++ ++ def test_gt_equal_returns_false(self): ++ a = self._make(label="A", order=100) ++ b = self._make(label="A", order=100) ++ self.assertFalse(a > b) ++ ++ ++ def test_ge_when_greater(self): ++ a = self._make(label="A", order=200) ++ b = self._make(label="A", order=100) ++ self.assertTrue(a >= b) ++ ++ def test_ge_when_equal(self): ++ a = self._make(label="A", order=100) ++ b = self._make(label="A", order=100) ++ self.assertTrue(a >= b) ++ ++ def test_ge_when_less(self): ++ a = self._make(label="A", order=100) ++ b = self._make(label="A", order=200) ++ self.assertFalse(a >= b) ++ ++ ++ def test_sorted_areas(self): ++ c = self._make(label="C", order=100) ++ a = self._make(label="A", order=200) ++ b = self._make(label="B", order=100) ++ result = sorted([a, c, b]) ++ ++ self.assertEqual( ++ [(item.order, item.label) for item in result], ++ [(100, "B"), (100, "C"), (200, "A")], ++ ) ++ ++ ++ def test_eq_with_non_searcharea_is_false(self): ++ a = self._make(label="A", order=100) ++ ++ ++ self.assertFalse(a == "not-a-searcharea") ++ self.assertFalse(a == 42) ++ self.assertFalse(a == None) # noqa: E711 ++ self.assertTrue(a != "not-a-searcharea") ++ ++ def test_lt_with_non_searcharea_raises_typeerror(self): ++ a = self._make(label="A", order=100) ++ ++ with self.assertRaises(TypeError): ++ a < "not-a-searcharea" ++ with self.assertRaises(TypeError): ++ a <= 42 ++ with self.assertRaises(TypeError): ++ a > object() ++ with self.assertRaises(TypeError): ++ a >= 3.14 ++ ++ ++class TestButtonComparison(SimpleTestCase): ++ def _make( ++ self, ++ label="Btn", ++ url="/x/", ++ classes=None, ++ icon_name=None, ++ attrs=None, ++ priority=1000, ++ ): ++ return Button( ++ label=label, ++ url=url, ++ classes=set() if classes is None else set(classes), ++ icon_name=icon_name, ++ attrs={} if attrs is None else dict(attrs), ++ priority=priority, ++ ) ++ ++ ++ def test_eq_when_all_fields_match(self): ++ a = self._make(label="A", url="/x/", classes=["c1"], attrs={"k": "v"}, priority=100) ++ b = self._make(label="A", url="/x/", classes=["c1"], attrs={"k": "v"}, priority=100) ++ self.assertTrue(a == b) ++ self.assertFalse(a != b) ++ ++ def test_eq_differs_on_url_even_with_same_priority_label(self): ++ ++ ++ a = self._make(label="Same", url="/path-a/", priority=500) ++ b = self._make(label="Same", url="/path-b/", priority=500) ++ self.assertFalse(a == b) ++ self.assertTrue(a != b) ++ ++ def test_eq_differs_on_classes(self): ++ a = self._make(label="Same", url="/x/", classes=["one"], priority=500) ++ b = self._make(label="Same", url="/x/", classes=["two"], priority=500) ++ self.assertFalse(a == b) ++ ++ def test_eq_differs_on_attrs(self): ++ a = self._make(label="Same", url="/x/", attrs={"k": "v1"}, priority=500) ++ b = self._make(label="Same", url="/x/", attrs={"k": "v2"}, priority=500) ++ self.assertFalse(a == b) ++ ++ def test_eq_differs_on_priority(self): ++ a = self._make(label="Same", url="/x/", priority=100) ++ b = self._make(label="Same", url="/x/", priority=200) ++ self.assertFalse(a == b) ++ ++ def test_eq_differs_on_label(self): ++ a = self._make(label="A", url="/x/", priority=100) ++ b = self._make(label="B", url="/x/", priority=100) ++ self.assertFalse(a == b) ++ ++ ++ def test_lt_by_priority(self): ++ a = self._make(label="A", priority=100) ++ b = self._make(label="A", priority=200) ++ self.assertTrue(a < b) ++ self.assertFalse(b < a) ++ ++ def test_lt_by_label_when_priority_equal(self): ++ a = self._make(label="A", priority=100) ++ b = self._make(label="B", priority=100) ++ self.assertTrue(a < b) ++ self.assertFalse(b < a) ++ ++ def test_le_when_less_and_equal(self): ++ a = self._make(label="A", priority=100) ++ b = self._make(label="A", priority=200) ++ c = self._make(label="A", priority=100) ++ self.assertTrue(a <= b) ++ ++ self.assertTrue(a <= c) ++ self.assertFalse(b <= a) ++ ++ def test_gt_by_priority(self): ++ a = self._make(label="A", priority=200) ++ b = self._make(label="A", priority=100) ++ self.assertTrue(a > b) ++ self.assertFalse(b > a) ++ ++ def test_ge_when_greater_and_equal(self): ++ a = self._make(label="A", priority=200) ++ b = self._make(label="A", priority=100) ++ c = self._make(label="A", priority=200) ++ self.assertTrue(a >= b) ++ self.assertTrue(a >= c) ++ self.assertFalse(b >= a) ++ ++ def test_sorted_buttons(self): ++ a = self._make(label="A", priority=200) ++ b = self._make(label="B", priority=100) ++ c = self._make(label="C", priority=100) ++ result = sorted([a, c, b]) ++ self.assertEqual( ++ [(item.priority, item.label) for item in result], ++ [(100, "B"), (100, "C"), (200, "A")], ++ ) ++ ++ ++ def test_eq_with_non_button_is_false(self): ++ a = self._make(label="A", priority=100) ++ self.assertFalse(a == "not-a-button") ++ self.assertFalse(a == 42) ++ self.assertFalse(a == None) # noqa: E711 ++ self.assertTrue(a != "not-a-button") ++ ++ def test_lt_with_non_button_raises_typeerror(self): ++ a = self._make(label="A", priority=100) ++ with self.assertRaises(TypeError): ++ a < "not-a-button" ++ with self.assertRaises(TypeError): ++ a <= 42 ++ with self.assertRaises(TypeError): ++ a > object() ++ with self.assertRaises(TypeError): ++ a >= 3.14 +diff --git 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 runtests.py wagtail.admin.tests.test_button_searcharea_comparison ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-002976/tests/test.sh b/tasks/format-code-task-002976/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..b7b8470b4498025d72e6023a9d46f0eb09c3e6c4 --- /dev/null +++ b/tasks/format-code-task-002976/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 +wagtail/admin/tests/test_button_searcharea_comparison.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-002976/tests/test_command.sh b/tasks/format-code-task-002976/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002976/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002982/environment/Dockerfile b/tasks/format-code-task-002982/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ec7bd3ebf76e04877e5a9df3bffa5f5f6f7f51dd --- /dev/null +++ b/tasks/format-code-task-002982/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:85b7805b61d32965219515463782bb6d0e7dc53860e5407f18a6b3ff01d48e01 diff --git a/tasks/format-code-task-002982/environment/setup/files/blocklist b/tasks/format-code-task-002982/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002982/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002982/environment/setup/setup.sh b/tasks/format-code-task-002982/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002982/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002982/tests/test.patch b/tasks/format-code-task-002982/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..af82644198b46ea5976c7b1266349bb93bc5866c --- /dev/null +++ b/tasks/format-code-task-002982/tests/test.patch @@ -0,0 +1,122 @@ +diff --git a/test/address-links.js b/test/address-links.js +new file mode 100644 +index 00000000..1d472f6d +--- /dev/null ++++ b/test/address-links.js +@@ -0,0 +1,94 @@ ++const { expect } = require("chai") ++const DB = require("../sdk/offchain") ++const Arweave = require("arweave") ++const EthWallet = require("ethereumjs-wallet").default ++ ++const lower = arr => arr.map(s => s.toLowerCase()) ++const sorted = arr => lower(arr).slice().sort() ++ ++describe("Address Links (reverse lookup)", function () { ++ let wallet, wallet2, db, arweave, arweave_wallet, walletAddress ++ ++ this.timeout(0) ++ ++ before(async () => { ++ wallet = EthWallet.generate() ++ wallet2 = EthWallet.generate() ++ arweave = Arweave.init() ++ arweave_wallet = await arweave.wallets.generate() ++ walletAddress = await arweave.wallets.jwkToAddress(arweave_wallet) ++ }) ++ ++ beforeEach(async () => { ++ db = new DB({ ++ state: { secure: false, owner: walletAddress }, ++ type: 3, ++ caller: walletAddress, ++ }) ++ db.setDefaultWallet(wallet) ++ }) ++ ++ it("should return an empty array for an account with no links", async () => { ++ const res = await db.getAddressLinks(wallet.getAddressString()) ++ expect(res).to.eql([]) ++ }) ++ ++ it("should list every disposable address linked to an account", async () => { ++ const account = wallet.getAddressString() ++ const { identity: a } = await db.createTempAddress(wallet) ++ const { identity: b } = await db.createTempAddress(wallet) ++ const links = await db.getAddressLinks(account) ++ expect(sorted(links)).to.eql(sorted([a.address, b.address])) ++ }) ++ ++ it("should not contain duplicate entries", async () => { ++ const account = wallet.getAddressString() ++ await db.createTempAddress(wallet) ++ await db.createTempAddress(wallet) ++ const links = await db.getAddressLinks(account) ++ expect(lower(links).length).to.eql([...new Set(lower(links))].length) ++ }) ++ ++ it("should drop a disposable address once its link is removed", async () => { ++ const account = wallet.getAddressString() ++ const { identity: a } = await db.createTempAddress(wallet) ++ const { identity: b } = await db.createTempAddress(wallet) ++ await db.removeAddressLink({ address: a.address }, { wallet }) ++ const links = await db.getAddressLinks(account) ++ expect(sorted(links)).to.eql(sorted([b.address])) ++ expect(lower(links)).to.not.include(a.address.toLowerCase()) ++ }) ++ ++ it("should become empty again after all links are removed", async () => { ++ const account = wallet.getAddressString() ++ const { identity: a } = await db.createTempAddress(wallet) ++ await db.removeAddressLink({ address: a.address }, { wallet }) ++ const links = await db.getAddressLinks(account) ++ expect(links).to.eql([]) ++ }) ++ ++ it("should keep links for different accounts separate", async () => { ++ const account1 = wallet.getAddressString() ++ const account2 = wallet2.getAddressString() ++ const { identity: a } = await db.createTempAddress(wallet) ++ const { identity: b } = await db.createTempAddress(wallet) ++ const { identity: c } = await db.createTempAddress(wallet2) ++ expect(sorted(await db.getAddressLinks(account1))).to.eql( ++ sorted([a.address, b.address]) ++ ) ++ expect(sorted(await db.getAddressLinks(account2))).to.eql( ++ sorted([c.address]) ++ ) ++ }) ++ ++ it("should stay consistent with the forward getAddressLink lookup", async () => { ++ const account = wallet.getAddressString() ++ const { identity: a } = await db.createTempAddress(wallet) ++ const links = await db.getAddressLinks(account) ++ for (const addr of links) { ++ const fwd = await db.getAddressLink(addr) ++ expect(fwd.address.toLowerCase()).to.eql(account.toLowerCase()) ++ } ++ expect(lower(links)).to.include(a.address.toLowerCase()) ++ }) ++}) +diff --git 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 -euo pipefail ++HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ++cd /testbed ++ ++ ++ ++ ++ ++node_modules/.bin/mocha test/offchain-bpt.js --grep "verify zkp" --invert ++ ++ ++node_modules/.bin/mocha test/address-links.js diff --git a/tasks/format-code-task-002982/tests/test.sh b/tasks/format-code-task-002982/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9ed5b794aa69a64e707afee83d669cbe2f09cc0b --- /dev/null +++ b/tasks/format-code-task-002982/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/address-links.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-002982/tests/test_command.sh b/tasks/format-code-task-002982/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002982/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002983/environment/Dockerfile b/tasks/format-code-task-002983/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6f59a3674dd422b52021706250edf9db33712ac9 --- /dev/null +++ b/tasks/format-code-task-002983/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:38c6344b62fe53f11ab292f1972d2812432fe913264114c0b8cbefcb3a6f559c diff --git a/tasks/format-code-task-002983/environment/setup/files/blocklist b/tasks/format-code-task-002983/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002983/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002983/environment/setup/setup.sh b/tasks/format-code-task-002983/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002983/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002983/tests/test.patch b/tasks/format-code-task-002983/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..33aaad53d58aa1ddda8031c81d3b0634909bbf54 --- /dev/null +++ b/tasks/format-code-task-002983/tests/test.patch @@ -0,0 +1,166 @@ +diff --git a/probe/process/reporter_test.go b/probe/process/reporter_test.go +index 2780d7ff03..1e4bf4858a 100644 +--- a/probe/process/reporter_test.go ++++ b/probe/process/reporter_test.go +@@ -27,6 +27,7 @@ func TestReporter(t *testing.T) { + {PID: 2, PPID: 1, Comm: "bash"}, + {PID: 3, PPID: 1, Comm: "apache", Threads: 2}, + {PID: 4, PPID: 2, Comm: "ping", Cmdline: "ping foo.bar.local"}, ++ {PID: 5, PPID: 1, Cmdline: "tail -f /var/log/syslog"}, + }, + } + +@@ -39,21 +40,18 @@ func TestReporter(t *testing.T) { + report.MakeProcessNodeID("", "1"): report.MakeNodeMetadataWith(map[string]string{ + process.PID: "1", + process.Comm: "init", +- process.Cmdline: "", + process.Threads: "0", + }), + report.MakeProcessNodeID("", "2"): report.MakeNodeMetadataWith(map[string]string{ + process.PID: "2", + process.Comm: "bash", + process.PPID: "1", +- process.Cmdline: "", + process.Threads: "0", + }), + report.MakeProcessNodeID("", "3"): report.MakeNodeMetadataWith(map[string]string{ + process.PID: "3", + process.Comm: "apache", + process.PPID: "1", +- process.Cmdline: "", + process.Threads: "2", + }), + report.MakeProcessNodeID("", "4"): report.MakeNodeMetadataWith(map[string]string{ +@@ -63,6 +61,12 @@ func TestReporter(t *testing.T) { + process.Cmdline: "ping foo.bar.local", + process.Threads: "0", + }), ++ report.MakeProcessNodeID("", "5"): report.MakeNodeMetadataWith(map[string]string{ ++ process.PID: "5", ++ process.PPID: "1", ++ process.Cmdline: "tail -f /var/log/syslog", ++ process.Threads: "0", ++ }), + }, + } + +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,103 @@ ++H4sIAAAAAAAAA+yaV5OjypLHz+vOp+jHvaGYxruN2AeEEUJCBmEELzfwIExhhcSnX6Secw/qaTf3 ++7FkTu3TEqGOU9cs/VVlJVtLPbpdk/t+D4gz99ldd8HhRBHH/HK/Xn/ffEQJFUBjGEJL6DUYQgiJ/ ++eyL+MkWTq2tap356+q0GoP3I7rPv/5dez3+sfwSec+D/BT5uC0zi+Hvrj2H4H+sPE+i4/ihJEb89 ++wX+Blp+u/+PrP654lwVPUdLGnfvsgRzqA+cc9KBOG6jxQBl8+xaBJ+QZJZ6Jb9/qoOqSOnj612// ++MhnijyO8KB4j6HtTBv3TGXkefx5MwgZ0g3Oz8IGXBrWXJUHR3i2xZ/TBNAIgyoLxo3RGy/YHjXll ++UydZ5kB5d7l9T7/y9vvXfeA24HcI8Yw9GJV5MDi1f9eUhGGWuDcr+Bl+tKpBHrRx0DXQi+a/RyBz ++iuhmi76WXideDKDF9iBtde3pDN9o31EYRWDkHto0Rn1nHDTACdTHPYR+GDyZ+NGp15TXPwgIAVMw ++iaD4uFe+ey5DwY6DMLCHffvbe4vCDl19m8XvTtEkbVDnEz3EqAcdNx4BY99DxyFCyoURCvGeIOgp ++KfwR5rUPMCXxatCAsL0B+6RIwI1GPqPvjnADUBcUVAbj/bzMK/KurRc0pTOKvVxip4mhM/p0Rp+x ++Z/j9AaBonaQIxtXLQHSTgnxg/RJxN+VdkbTNzZz4wDzNnK4pQdOObvKyDpq7foR+xt8fUkNtcGlv ++ZPQDcg7c631Fai9OzsGXzO//OGVyj2D8gwn/w/r3vQU/4x9M+t20dNoxNIrcab04qF/W9JMhzXVM ++DGPEjS4SJ3sZ8sk93IZ0zQsf/6px0Xy2rnfz3yOb+GhqumKMlWGceqdrQRFEk43F3PYmTGM4Qn53 ++KN+jXRLxaPR92JgSi3/EX/OSPaKgaX8kj6+OS3InCm7p0vuR4N4d+HMGGpN2kH22AafDQJ6D4j7g ++o+WdjLgloPBlAT4a0SR1VzZBcduFdXffJ8xP2wQ8X508e04K6Pb5Y3f/HMn3rPoM6gi63GLgHis/ ++B8v92fA8MR6VtsDtwptvjHymH+z/9u2/+/n6P/16rP+aLv8LfHxc/6HY+GR8Xf9R6P/Xf/8l17Rg ++8J01iBLvntPCbhi+x4Hjj7lqUjjgMD2WIWOuhInvAe0gvk/RNOOTTzHyb9L4H2HkqopP5eJlyzCx ++uulmZOsMFV2IIpMte8DIYg3m6b9/+0/y++PQcnNPAwZXdwkCUUdNPve7Uj0MBz3w7brNktqfYzVj ++o7CboCH96P6fqZNGf52/MgcrumjgJKzMk0EbM/Nw4Y8yvhFZjW3sU0wnS7fZL6M/7W9ymxeQaxGJ ++rWy0Fit7PxzmuDGgB/3oIPNS0oyBWRM7Ld9xuPDg9v0KboSKqLGPWocKvMvC2tIpZtsDph7o0Fge ++jct2Y+i7bCOo4BpaX4NOBF99egtEZT3ILmAiu6JPROWUDe3KjHOIW4Gll2WLgAV31h/YbxWQI87I ++3NWq2ITGCBiCCji4t11VW9K1asyMVvZlS9sIOYubrfIZbiJygdq1Yeqo6Zoa0/cVDsW1u3LHrIgI ++6kHew4kby2SdpWX/QH23ch2Z+ppGiIvOHKpGHA8XQxdFw+kYg4hy1yQ4MnN3YxdrVBfPzZeYE7nG ++4gjze2xPpmZCsYANbL6NMeiEzcV2a6vEcS0uIq8+cdtX6Dfr5hGocXJLJUBBvbGSDVV6sXMXIQMZ ++KnukeXSO704DV4ZHAoeXnwOnQlU1hBmHyiV+qQaDsdJUrt5WFH0mKGpxrDD34GBCXA8GeOTWwXj4 ++g8r2+lIdMRMmWNlCF4gpwa2k8zLeqISipwmMHTlBn+1Jgz8mhd0tZAwTPmSi+I3myrWIjyqvcuFq ++cjWoa2nwFo69QjaBQqQax5wWETgXKtJ8QptIhOmG27gEal4B2yfonr8OOqdF3tkQY30I+q6g+lYL ++z17/KPHtg/SNeD4xJ6hD3Ko4c0Iob3s9brMtq1YNNqtTybIQ7GSZms5Q3heIE6kyZdGWZ6KbJG6i ++3ABQfsYyts+gJt1u8GQtnQ7NcuYREvaYNt85VI1EkqkvR2+eotThfHCci9auY4jOMk/i6bMlaZR5 ++8FUbOp1r/AvEidQw2sWa7m9nPCSnNKny66xsy+S4HyJJFqno6vO86yxXOP/4gPm493DP5bMTu+1U ++RrOxHXtBS19iZ+y6RWw7PtD7y4zFfYbEl9Wx7X+BPJF+kDvUhc+hJ9KN25gNYxgLGEuEUwOiM6Bk ++lj83CdobFvu4v/7RC/nu5eVtRqiXOe5TGqNRQWvOuGzpdr9sCtIqrcRM5o21PsiJ1lznV9foNvSn ++vInM8phUeXFgGXQrCYLDSMc1auIClYWMPHD5wtD96HTENlCiv419bNncAzdoaLUQ7d0iEQvtAHe7 ++/aE99XVHdlsynhVZzZzIcE2l4jtKH5ETsYlMG3RBrg6zAdURli71vqNdkzhcBSU9ynPaApABZtpK ++A6/Ir3tH9wzYzdc40x77qBYtM67qTVTrG8Fi0I5GDru4oxrNH/ZCYlqf0CYS2VXILHFWqMYnsnJt ++PcWDV+kGdBxJGti8tfGKJ8LcPCTK/k3o6/7Vjdk4fGuTO/cCwd3Mjaw9VjFkaUfcEMar42JXtVRq ++U6iz2URfYk7kWiqdETRcXNtgf2aXWoTGNnM0YtwliJmgQ47PnkIkVKT4MW190DEZqeouLlYqu8fF ++mB50VLQg0hb5XjO0SyRDgnL1q4M2CIyDel+kTiSrcAyFh3lD8wIubDKvHp+02K45HkjkDMRLvGxQ ++PlBj7iw/Jpu0Hk+OQdvee2zYSwiEmcrjm01vsXqZlrHhIZLXxiq+EpaiTBIFrfRE5asFthY+ZE3k ++xUBoYsuQnIvSYN4VYFbhgY6wGy8JOx5kdb9b2U6xwC7pa+S0oTSSiM0FthzYriz0GhkYSe6Htqul ++JYLJFUOwpWc48jwuDzPW+oA0kRasg5pCUS1Ik0WnpImvXDioVGA8M4WgdiRdz+c9naFR/Xi37zSx ++RuIQEXteV9A8geWlwoT+3jY5SqdnqB0ml1CzgLSmalP3dvQXiBOp+SZIzhqCA/qiz4gKsYpNne6N ++cjXzi00ArchQqgotwqud/jP4pwbaLX0mTsvs2bjg9yeW6lMkjSGtkgZ0iXQ6SylUyxzYDJI3x+hz ++4EToTN2Tfdat+9ZyNB8xi936mi75XZCm3ZWH1K255zKBxsqheYf72Lsbkbyyj5LGAEqaKw0Vlpi6 ++PfjJvABsR8/OAFtEkZjBpAL11leQE7EDgXLMFt1td9umuNjsFYLMduXtMXQ3O2nQZhEcO4gqwtNi ++/zP57cbhSK2yuHXCvCbTSFnKp5Ws8LliVpS5TldLgGJxU5cqdoFp/I21epM63U78Dly3JW9R27pW +++LVjAQuLQwKNNpwKWVvduqQxW8rLi/cz/O3G5U1yfaGOou5DBH9pKw9ISIxjdCwSWr49DxyUNeXp ++Sg3RmXtD8pvUieTueqYFXas9h9gVfOMri2NsByTHBbQO6Ylm+rNsPaNcaAXehk8bpyPvFHvKKmmp ++A0vD427JRdlz58i5ynsI6nUSsf0uQYP9sVPeCLFXvIlMdzFrLcuSI0dp1VUk5F0XcHAsC6xt9u3S ++tbX5jCY6IJ0+wP7Rsh2JrbE+puL2YnQMS+LQNSaYJpOMM+PEW0ZfBmPlYnfNdr2A3thjPxEnUpeS ++bkUdlDqA3NCWnZUMF+I4fj0czlzOZ/mge1bIS9sMfSPNTNvFt1q1SjFRZkW+IROowkyo3DPU4Ygw ++aLUK7Whx4vZVyMlpNLyxByasiTwf808nkatPxXwWZvRG7i4zQR46OG8aT9/NQjpp6XiXiutXMfrP ++NKlHfxzWM7tquYQRaFshHlLobE7Tylby9hyTEfkyOyhsaSu1xP5pf9NUV1Aana9oqdtrntgLwVDk ++EL+8KNtEZa5Lf8ltwnYtIPz5ceY+a5+PaKfc6mZDICaxy+LuurgOjMgFwXy51XkWIguT3ibQdRvH ++hP4r6On5TB4yJT3Bmjrs7VBOjfPg7mBprmLL1SDUxRmdbxa4iSus8pGHn3v4t34HHOqZGC7teCeO ++t4BRx+06gqHQu5CDJ3FyDwCHXmQWxuFfYk/kV2XFxhifeyFG9of2ejX1WcoFfFQvCvYcoAXH0TMq ++pvfwo/x333jeoDg/73kB3iyuezCX3PXe2vUHfQc4xVSJuTAsUyhEMttl91+ETkv1lURRKRBj66Kt ++kNJTi3SVVqEGosaNqMjeGBbeqLxlQ49V2mcvX+8H2IAhgevFhMobV0zklcIHenNi4wUh+AnOxLAq ++m2oCARj8EnsiX3MRh1yb0hyDDrvlwAGHPy7xJa1Lq0DUhD1icfUMXlyrPPrExcObm1svY95Efblo ++qMQYEuVcL2KBwDxoUa/1xvalotr01W596e1r+gvkafcNy1GRXPhleCX1FlrMG73STLvi9LNiDIdQ ++WZ+8juzZvhTedfD49uj2GCYEOCYgiy4SySP4zFln5pqttf2SapW6CfcnyZj5jA0WzdegE8GR5+hN ++FGKrUD30koX7S+W43hnwCjIjBNj07ODaKSRJkM++x3718uom2EYIV9t0yfiNSnawbJNzVpLy/oCU ++9BzfkYpaXdpBuarvLuAjdCK4DVi3tNU5kixZ2VIFB1k3wNSP19Q4ssgq03Izoy+QPls+Tsav/q3A ++zRcWU6tIlAKUPmBGhbFUglGuqbM8nWn1VYA4kjvutchwAf2nfE1uTzlojeVtscNCRE5QEPSVvVXZ ++wS2xue4mTYLCDC7wO2z26pRdg6gMyvLea0iKW1V3q47GPPYj3WjKVdtKmAjxc4QcVMOzrnWgSOSi ++sO263xsssE7q3L6a4v7L3IlsfV8kF1SiNlEPpThHJKc1MSOJwfdPhXdyRDCP/WYFOSl4XPF33mje ++BDe2QGUIMojc2i7sWRtIuJ6DipjHwjJcDqHK24g+VBnaf4E4bWu1pseY/jaUYYdBi0ZATyIxnhF7 ++iZ6f0cEPthyOqifXQF9JbcdDpxffzndNm4QvfcgfDyGqQZPFfCgJoVcpyFnaNe0AYubXDtYn++tq ++rFC6c2SsOkr/EnMit7f7/2jf2npUVbLwe/8KJ+dlJo4NxZ2XSQBRQcVLg7S+TKAo5H5HhZwfP2j3 ++PpvuffbekzOTOZmEr5NWFNdX1GXdapVrkiVcnffLMUGeNwy9OyF3mS13+8RtmXLKc0CLKZH5KPoP ++lbc8hlKifA1rpKm0sXXRW7YpSWF7wmDyrNK3cW63c8bwd4e1sfvPCXsPClXdrUV4Cx074NaWHVLb ++rWO5uPB64fWjrMbh7LaE5u14vBut9Lm2UfHYku7sCLLCx4b021wnlmQrHONE1/IDS/pxw6tAJ01p ++fI4ltL0RnjwP/Rg58yr9gaRe06R0MaVi68KrqlaYmLmKXHYxP20D58rJNRT2uwUKW/DK2PJD4Hc2 ++4O/hZRtf5YIopvNFxEbl7CwsbrHWYkCLduxtpRSRRni0A9Bc+YGkD6lvYCzGmlxkmpNH0mtM6pVc ++WAleqKf5TTjeeM/G5FVUPmL1/qY/LJqsSvteaKebOqcTsICbQIKjSIQDp1NTfWc70M5QLgAm4bQg ++hWfgr1xfNWg5Y8DOCOcml2dOWSr4+PpTtk4Zgu4/TdIT7u7z8m43Teh+tzf+eWbwl3zRHn2ZM+LL ++EkErlNXAScyADAKK56NkBkNXUj6xRf5bBP6ud+8b3QSB0xwNJizJMSxwSI4Ddo+LvFVgFjgzzjNc ++5rLbKpJnKqI3aw/cOQjKrYy5nbfa7Bzt+InrLuARNIEJ/vx4MNCp+E7RE/QE8jhyEWJxGqEe2S7f ++6sKlyUvZhmjeiq12Ps9ekyKfAcky4OUcOnt6U7HL0/kTWYKqDyNG4RRBEiSgJ8imbWjTwCWs/qqq +++MW8crnFRrvRSCeKKmFzBum5Ih1z45AsS7Ly1JTcZdHPqJhHRxI4OyFtnGIAQpCj+wnilpb2B13X ++Y0FlWFZvV6u5McbtYLvBV2G9WfkURs8r1ewC+N+not7Xb2RVOHE4LomAslbtukXQ97SLHqnazshJ ++wMTEuuCLZM0c5e8L6jXs4m2Ae1EoZ14qgceSpekahyAgNVYSeDNcdnJjorysGfVzH5RNAj/2N9HN ++JIoD+AQAonvfRa6Q7tvv/W19Rlf6oN7aGtFYoOoyXaMgCw7RBmF+W4gsrqYuS1jrb7jKD1QEoAFF ++8BQ/cXAbANuxLMhZ/U0OfctNL9MGYo5C25xOe6VXhcHLWKYIPWlKTTK2TgD9ufd5yn6morpnAWQ3 ++ZSc8y5IES5I4zzv9RBDQAhMi/nW/mu/k0mSv2VKTgjk/rbRIig71bCWfnKlmy5+H9gNVtyoYwHQe ++DEkTE5p3bM5hGdL9EOim29DLwFotPDYxUCaJMKTHsdC6G14tbCHTtLOlO/Opon87WF+rmO5BUOSc ++IlKl6hYttzhbELPxeJOxMi8SvLo3mrFFsLJvV6K++76gXsOo+QrItGJ4Y69abgx5Y3Xhl1cIKG9K ++9zD3s+mxFcQ8keLPuu9L4uLL/H6h9iuDKEUSbDBNisbtTOOFouYFTMoJK19m+kllxPH0qlM/kNRr ++WlR40UJzdupiMwb54egv3NnyUB/8VFU8JEDSFV/Ws6OslOE3At9y1R/lafmak42NAagkCFXSzdfm ++OIPMykmuno8pQXZdVGzT1NfN566r0jQqP2heQD6KjghmQrikbRGU7TCI7Ud7ImE5R8lrHNXLrGw5 ++1S1K3GPea3R6WaU5YWawwvDqdnrkl/pkN1QUaVF+Y1So7q9boJ0ypBjLcTi+v0AVjG4ZnisTfmlx ++OlIhv14WqWG4uShatRns8pVKbLZufLznC35e/3avEVm8wEbayHV9Pcmwi/teNpetLehUu/fwG9T2 ++RxSqVzdv1vDfEdn3VevbvhJuYlNlEdW2ueExGGqMuhsVR/NrOXxNqps/xer9w7pn4fnuLEAPwfD5 ++Anod0/lenafAgbtRInCHoLuYpjMe9Acnh/Htgyq0iWApYZ5xXq1fI3UnnbqfB6mLQVujDiZ9bPHf ++5QK/jTnoxhyQFEURE4B33h5HMCxk4FvRko9RwtR1zFwNwWl9M7QsTyrtapmwPhdiIPiLKM/3/iH8 ++YyT9rfZFuFXsws0clniZY/LBYeJadqe7ACqalu5xiQuIgsxP1K7H9fC4LuToQn4pgXFvhxibt0Ir ++m/lqUV9gpfBg+cJ7nhbH5iY1a/xVP6ovnTX5rpxes5ZU3YRsy4qSvM1rRh5LDHV0LwDu2LBlC+V0 ++8Y1YG8tn+WEh7pHB82NZYW/S3lOpbJjuXGXpNGOFM3RUNfBs5K/my/SanS+AJ5fWON+XsXjkdt8T ++02vUqnJWc5jkeiouONIUG0Hwsat/fZlJQuHMFOOA3W4alcGge8Y/u4ju/xi9+s/7iPzznpexEue5 ++9P57HD87/0VT4Ov5r/vngKKH8z//G/zyF8zulINtld5T2TmrE/T0BJ3RYzLYyHl6+mUkJ2VdoNH8 ++7RTQyC9HFqzu+7R/LZu4C2zCUZ05VoX+PspQUfpldb+hSMtyVHooisq/PTnoMimvfgW90ftZohHx ++D6z7FEvqKBr9+uuoKmp055LSLkp/1wLdNBy91SSP3LQYOShDiYMS2IwKVKZRXflp8gSz39qKfXOW ++7etXb9c/uPvO0r+7u763Z18no8pDo26OnLveud9wPw51fx1NLqNJ0X2vdxd7lKVF5wyNnu/W00aP ++jAMqS2zQTQMGDBgwYMCAAQMGDBgwYMCAAQMGDBgw4M/AvwCiUtrjAFAAAA== +diff --git 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-002983/tests/test.sh b/tasks/format-code-task-002983/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9029474a747c68eaec7dd5f4144cb14c2597ba7e --- /dev/null +++ b/tasks/format-code-task-002983/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' +probe/process/reporter_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-002983/tests/test_command.sh b/tasks/format-code-task-002983/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002983/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-002984/environment/Dockerfile b/tasks/format-code-task-002984/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7acad70c9036dc36a107f19059fa61bd14a7aaef --- /dev/null +++ b/tasks/format-code-task-002984/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:301eee140546cc1cc890c9a663a1cf41957e7ff81f600c6a3cfd811d573648a3 diff --git a/tasks/format-code-task-002984/environment/setup/files/blocklist b/tasks/format-code-task-002984/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-002984/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-002984/environment/setup/setup.sh b/tasks/format-code-task-002984/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-002984/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-002984/tests/test.patch b/tasks/format-code-task-002984/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..68addeff18f69c762b789284735106999cf3045b --- /dev/null +++ b/tasks/format-code-task-002984/tests/test.patch @@ -0,0 +1,337 @@ +diff --git a/modules/qna-transformers/additional/answer/answer_test.go b/modules/qna-transformers/additional/answer/answer_test.go +index 58f9f24410..abc2bd8e4d 100644 +--- a/modules/qna-transformers/additional/answer/answer_test.go ++++ b/modules/qna-transformers/additional/answer/answer_test.go +@@ -238,21 +238,189 @@ func TestAdditionalAnswerProvider(t *testing.T) { + assert.Equal(t, 0, answerAdditional.EndPosition) + assert.Equal(t, false, answerAdditional.HasAnswer) + }) ++ ++ t.Run("should answer with certainty set above ask certainty and the results should be reranked", func(t *testing.T) { ++ ++ qnaClient := &fakeQnAClient{} ++ fakeHelper := &fakeParamsHelper{} ++ answerProvider := New(qnaClient, fakeHelper) ++ in := []search.Result{ ++ { ++ ID: "uuid1", ++ Schema: map[string]interface{}{ ++ "content": "rerank 0.5", ++ }, ++ }, ++ { ++ ID: "uuid2", ++ Schema: map[string]interface{}{ ++ "content": "rerank 0.2", ++ }, ++ }, ++ { ++ ID: "uuid3", ++ Schema: map[string]interface{}{ ++ "content": "rerank 0.9", ++ }, ++ }, ++ } ++ fakeParams := &Params{} ++ limit := 1 ++ argumentModuleParams := map[string]interface{}{ ++ "ask": map[string]interface{}{ ++ "question": "question", ++ "properties": []string{"content"}, ++ "rerank": true, ++ }, ++ } ++ ++ ++ out, err := answerProvider.AdditionalPropertyFn(context.Background(), in, fakeParams, &limit, argumentModuleParams) ++ ++ ++ require.Nil(t, err) ++ require.NotEmpty(t, out) ++ assert.Equal(t, 3, len(in)) ++ answer, answerOK := in[0].AdditionalProperties["answer"] ++ assert.True(t, answerOK) ++ assert.NotNil(t, answer) ++ answerAdditional, answerAdditionalOK := answer.(*qnamodels.Answer) ++ assert.True(t, answerAdditionalOK) ++ assert.Equal(t, "rerank 0.9", *answerAdditional.Result) ++ assert.Equal(t, "content", *answerAdditional.Property) ++ assert.Equal(t, 0.9, *answerAdditional.Certainty) ++ assert.Equal(t, 0, answerAdditional.StartPosition) ++ assert.Equal(t, 10, answerAdditional.EndPosition) ++ assert.Equal(t, true, answerAdditional.HasAnswer) ++ ++ answer, answerOK = in[1].AdditionalProperties["answer"] ++ assert.True(t, answerOK) ++ assert.NotNil(t, answer) ++ answerAdditional, answerAdditionalOK = answer.(*qnamodels.Answer) ++ assert.True(t, answerAdditionalOK) ++ assert.Equal(t, "rerank 0.5", *answerAdditional.Result) ++ assert.Equal(t, "content", *answerAdditional.Property) ++ assert.Equal(t, 0.5, *answerAdditional.Certainty) ++ assert.Equal(t, 0, answerAdditional.StartPosition) ++ assert.Equal(t, 10, answerAdditional.EndPosition) ++ assert.Equal(t, true, answerAdditional.HasAnswer) ++ ++ answer, answerOK = in[2].AdditionalProperties["answer"] ++ assert.True(t, answerOK) ++ assert.NotNil(t, answer) ++ answerAdditional, answerAdditionalOK = answer.(*qnamodels.Answer) ++ assert.True(t, answerAdditionalOK) ++ assert.Equal(t, "rerank 0.2", *answerAdditional.Result) ++ assert.Equal(t, "content", *answerAdditional.Property) ++ assert.Equal(t, 0.2, *answerAdditional.Certainty) ++ assert.Equal(t, 0, answerAdditional.StartPosition) ++ assert.Equal(t, 10, answerAdditional.EndPosition) ++ assert.Equal(t, true, answerAdditional.HasAnswer) ++ }) ++ ++ t.Run("should answer with certainty set above ask certainty and the results should not be reranked", func(t *testing.T) { ++ ++ qnaClient := &fakeQnAClient{} ++ fakeHelper := &fakeParamsHelper{} ++ answerProvider := New(qnaClient, fakeHelper) ++ in := []search.Result{ ++ { ++ ID: "uuid1", ++ Schema: map[string]interface{}{ ++ "content": "rerank 0.5", ++ }, ++ }, ++ { ++ ID: "uuid2", ++ Schema: map[string]interface{}{ ++ "content": "rerank 0.2", ++ }, ++ }, ++ { ++ ID: "uuid3", ++ Schema: map[string]interface{}{ ++ "content": "rerank 0.9", ++ }, ++ }, ++ } ++ fakeParams := &Params{} ++ limit := 1 ++ argumentModuleParams := map[string]interface{}{ ++ "ask": map[string]interface{}{ ++ "question": "question", ++ "properties": []string{"content"}, ++ "rerank": false, ++ }, ++ } ++ ++ ++ out, err := answerProvider.AdditionalPropertyFn(context.Background(), in, fakeParams, &limit, argumentModuleParams) ++ ++ ++ require.Nil(t, err) ++ require.NotEmpty(t, out) ++ assert.Equal(t, 3, len(in)) ++ answer, answerOK := in[0].AdditionalProperties["answer"] ++ assert.True(t, answerOK) ++ assert.NotNil(t, answer) ++ answerAdditional, answerAdditionalOK := answer.(*qnamodels.Answer) ++ assert.True(t, answerAdditionalOK) ++ assert.Equal(t, "rerank 0.5", *answerAdditional.Result) ++ assert.Equal(t, "content", *answerAdditional.Property) ++ assert.Equal(t, 0.5, *answerAdditional.Certainty) ++ assert.Equal(t, 0, answerAdditional.StartPosition) ++ assert.Equal(t, 10, answerAdditional.EndPosition) ++ assert.Equal(t, true, answerAdditional.HasAnswer) ++ ++ answer, answerOK = in[1].AdditionalProperties["answer"] ++ assert.True(t, answerOK) ++ assert.NotNil(t, answer) ++ answerAdditional, answerAdditionalOK = answer.(*qnamodels.Answer) ++ assert.True(t, answerAdditionalOK) ++ assert.Equal(t, "rerank 0.2", *answerAdditional.Result) ++ assert.Equal(t, "content", *answerAdditional.Property) ++ assert.Equal(t, 0.2, *answerAdditional.Certainty) ++ assert.Equal(t, 0, answerAdditional.StartPosition) ++ assert.Equal(t, 10, answerAdditional.EndPosition) ++ assert.Equal(t, true, answerAdditional.HasAnswer) ++ ++ answer, answerOK = in[2].AdditionalProperties["answer"] ++ assert.True(t, answerOK) ++ assert.NotNil(t, answer) ++ answerAdditional, answerAdditionalOK = answer.(*qnamodels.Answer) ++ assert.True(t, answerAdditionalOK) ++ assert.Equal(t, "rerank 0.9", *answerAdditional.Result) ++ assert.Equal(t, "content", *answerAdditional.Property) ++ assert.Equal(t, 0.9, *answerAdditional.Certainty) ++ assert.Equal(t, 0, answerAdditional.StartPosition) ++ assert.Equal(t, 10, answerAdditional.EndPosition) ++ assert.Equal(t, true, answerAdditional.HasAnswer) ++ }) + } + + type fakeQnAClient struct{} + + func (c *fakeQnAClient) Answer(ctx context.Context, + text, question string) (*ent.AnswerResult, error) { +- answerString := "answer" +- var certainty float64 = 0.8 +- answer := &ent.AnswerResult{ ++ if text == "rerank 0.9" { ++ return c.getAnswer(question, "rerank 0.9", 0.9), nil ++ } ++ if text == "rerank 0.5" { ++ return c.getAnswer(question, "rerank 0.5", 0.5), nil ++ } ++ if text == "rerank 0.2" { ++ return c.getAnswer(question, "rerank 0.2", 0.2), nil ++ } ++ return c.getAnswer(question, "answer", 0.8), nil ++} ++ ++func (c *fakeQnAClient) getAnswer(question, answer string, certainty float64) *ent.AnswerResult { ++ return &ent.AnswerResult{ + Text: question, + Question: question, +- Answer: &answerString, ++ Answer: &answer, + Certainty: &certainty, + } +- return answer, nil + } + + type fakeParamsHelper struct{} +@@ -283,3 +451,12 @@ func (h *fakeParamsHelper) GetCertainty(params interface{}) float64 { + } + return 0 + } ++ ++func (h *fakeParamsHelper) GetRerank(params interface{}) bool { ++ if fakeParamsMap, ok := params.(map[string]interface{}); ok { ++ if rerank, ok := fakeParamsMap["rerank"].(bool); ok { ++ return rerank ++ } ++ } ++ return false ++} +diff --git a/modules/qna-transformers/ask/graphql_argument_test.go b/modules/qna-transformers/ask/graphql_argument_test.go +index 12cb23123a..7f0b4a7183 100644 +--- a/modules/qna-transformers/ask/graphql_argument_test.go ++++ b/modules/qna-transformers/ask/graphql_argument_test.go +@@ -32,13 +32,14 @@ func TestAskGraphQLArgument(t *testing.T) { + // question: "question?", + // certainty: 0.9 + // properties: ["prop1", "prop2"] ++ + // } + assert.NotNil(t, ask) + assert.Equal(t, "QnATransformersPrefixClassAskInpObj", ask.Type.Name()) + askFields, ok := ask.Type.(*graphql.InputObject) + assert.True(t, ok) + assert.NotNil(t, askFields) +- assert.Equal(t, 3, len(askFields.Fields())) ++ assert.Equal(t, 4, len(askFields.Fields())) + fields := askFields.Fields() + question := fields["question"] + questionNonNull, questionNonNullOK := question.Type.(*graphql.NonNull) +@@ -50,6 +51,7 @@ func TestAskGraphQLArgument(t *testing.T) { + propertiesList, propertiesListOK := properties.Type.(*graphql.List) + assert.True(t, propertiesListOK) + assert.Equal(t, "String", propertiesList.OfType.Name()) ++ assert.NotNil(t, fields["rerank"]) + }) + } + +@@ -68,13 +70,14 @@ func TestAskGraphQLArgumentWithAutocorrect(t *testing.T) { + // certainty: 0.9 + // properties: ["prop1", "prop2"] + // autocorrect: true ++ + // } + assert.NotNil(t, ask) + assert.Equal(t, "QnATransformersPrefixClassAskInpObj", ask.Type.Name()) + askFields, ok := ask.Type.(*graphql.InputObject) + assert.True(t, ok) + assert.NotNil(t, askFields) +- assert.Equal(t, 4, len(askFields.Fields())) ++ assert.Equal(t, 5, len(askFields.Fields())) + fields := askFields.Fields() + question := fields["question"] + questionNonNull, questionNonNullOK := question.Type.(*graphql.NonNull) +@@ -87,5 +90,6 @@ func TestAskGraphQLArgumentWithAutocorrect(t *testing.T) { + assert.True(t, propertiesListOK) + assert.Equal(t, "String", propertiesList.OfType.Name()) + assert.NotNil(t, fields["autocorrect"]) ++ assert.NotNil(t, fields["rerank"]) + }) + } +diff --git a/modules/qna-transformers/ask/grapqhl_extract_test.go b/modules/qna-transformers/ask/grapqhl_extract_test.go +index f0a69c1989..1359f0f553 100644 +--- a/modules/qna-transformers/ask/grapqhl_extract_test.go ++++ b/modules/qna-transformers/ask/grapqhl_extract_test.go +@@ -86,6 +86,23 @@ func Test_extractAskFn(t *testing.T) { + Properties: []string{"prop1", "prop2"}, + }, + }, ++ { ++ name: "should parse properly with question and certainty and properties and rerank", ++ args: args{ ++ source: map[string]interface{}{ ++ "question": "some question", ++ "certainty": 0.8, ++ "properties": []interface{}{"prop1", "prop2"}, ++ "rerank": true, ++ }, ++ }, ++ want: &AskParams{ ++ Question: "some question", ++ Certainty: 0.8, ++ Properties: []string{"prop1", "prop2"}, ++ Rerank: true, ++ }, ++ }, + } + + testsWithAutocorrect := []struct { +@@ -149,6 +166,25 @@ func Test_extractAskFn(t *testing.T) { + Autocorrect: true, + }, + }, ++ { ++ name: "should parse properly with question and certainty and properties and autocorrect and rerank", ++ args: args{ ++ source: map[string]interface{}{ ++ "question": "transform this", ++ "certainty": 0.8, ++ "properties": []interface{}{"prop1", "prop2"}, ++ "autocorrect": true, ++ "rerank": true, ++ }, ++ }, ++ want: &AskParams{ ++ Question: "transformed text", ++ Certainty: 0.8, ++ Properties: []string{"prop1", "prop2"}, ++ Autocorrect: true, ++ Rerank: true, ++ }, ++ }, + } + + testsWithAutocorrect = append(testsWithAutocorrect, tests...) +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,4 @@ ++H4sIAAAAAAAAA+3RQQ7CIBAFUNaeYi7QAlrqyrMYLKiNLUSgen3bbmpM1I3GqP+xmAlMAuTnm65u ++zNq6E2fvInpLpcbau61jL9VczJeLol9MSFmKgpF624uudDHpQMSC9+nR3LPzL5VP+Scb07rybaud ++yeP+dXc8y1+qcsp/2JdFKReMxOuecN+f518ZGoPfWDPbeRpayk6UVb5zaSUp5603XWMjPzqdpaBd ++3PrQ2hC5NqZOtXe64f3u2Qb+cDoe+OzTvwUAAAAAAAAAAAAAAAAAAAAA+C0XTmQOUwAoAAA= +diff --git 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-002984/tests/test.sh b/tasks/format-code-task-002984/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..54d48d3e65efbe56dfb0c8057918fea332221ebd --- /dev/null +++ b/tasks/format-code-task-002984/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' +modules/qna-transformers/additional/answer/answer_test.go +modules/qna-transformers/ask/graphql_argument_test.go +modules/qna-transformers/ask/grapqhl_extract_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-002984/tests/test_command.sh b/tasks/format-code-task-002984/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-002984/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003001/environment/Dockerfile b/tasks/format-code-task-003001/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..54601bb90a8002ff2f6695a98a24e05e606176bd --- /dev/null +++ b/tasks/format-code-task-003001/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:d6cd178008b09417511e3c278e76894ae1633ce4c79c889773e7298610d40705 diff --git a/tasks/format-code-task-003001/environment/setup/files/blocklist b/tasks/format-code-task-003001/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003001/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003001/environment/setup/setup.sh b/tasks/format-code-task-003001/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003001/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003001/tests/test.patch b/tasks/format-code-task-003001/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..48390a9fdaa95829c7108bae8d7c34cacca974d5 --- /dev/null +++ b/tasks/format-code-task-003001/tests/test.patch @@ -0,0 +1,99 @@ +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..09d6ba3 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["python -m unittest tests.test_utilities.test_csvlook -v"] ++} +diff --git a/tests/test_utilities/test_csvlook.py b/tests/test_utilities/test_csvlook.py +index ac92d8c..a1bebb1 100644 +--- a/tests/test_utilities/test_csvlook.py ++++ b/tests/test_utilities/test_csvlook.py +@@ -86,3 +86,72 @@ class TestCSVLook(CSVKitTestCase, EmptyFileTests): + '| 1;2;3 |', + '|---------|', + ]) ++ ++ def test_default_does_not_truncate_rows(self): ++ ++ lines = self.get_output_as_list(['examples/iris.csv']) ++ ++ ++ self.assertEqual(len(lines), 155) ++ ++ joined = '\n'.join(lines) ++ self.assertNotIn('| ... | ... | ... |', ++ joined) ++ ++ self.assertIn('Iris-virginica', joined) ++ ++ def test_default_does_not_truncate_columns(self): ++ ++ ++ output = self.get_output(['examples/realdata/ks_1033_data.csv']) ++ ++ ++ ++ lines = output.split('\n') ++ header = lines[1] ++ ++ ++ self.assertIn('ship_date', header) ++ self.assertIn('acquisition_cost', header) ++ ++ self.assertNotIn('| ... |', header) ++ ++ def test_default_does_not_truncate_column_width(self): ++ ++ ++ ++ output = self.get_output(['examples/realdata/ks_1033_data.csv']) ++ ++ self.assertIn('RIFLE,5.56 MILLIMETER', output) ++ ++ self.assertNotIn('RIFLE,5.56 MILLIM...', output) ++ ++ def test_max_rows_option(self): ++ self.assertLines(['--max-rows', '1', 'examples/dummy3.csv'], [ ++ '|-------+---+----|', ++ '| a | b | c |', ++ '|-------+---+----|', ++ '| True | 2 | 3 |', ++ '| ... | ... | ... |', ++ '|-------+---+----|', ++ ]) ++ ++ def test_max_columns_option(self): ++ self.assertLines(['--max-columns', '2', 'examples/dummy3.csv'], [ ++ '|-------+---+------|', ++ '| a | b | ... |', ++ '|-------+---+------|', ++ '| True | 2 | ... |', ++ '| True | 4 | ... |', ++ '|-------+---+------|', ++ ]) ++ ++ def test_max_column_width_option(self): ++ self.assertLines(['--max-column-width', '3', 'examples/dummy3.csv'], [ ++ '|------+---+----|', ++ '| a | b | c |', ++ '|------+---+----|', ++ '| ... | 2 | 3 |', ++ '| ... | 4 | 5 |', ++ '|------+---+----|', ++ ]) +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++python -m unittest tests.test_utilities.test_csvlook -v ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-003001/tests/test.sh b/tasks/format-code-task-003001/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..fc0d958baad9c6fba97bcd953251fe870bdc5b52 --- /dev/null +++ b/tasks/format-code-task-003001/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_utilities/test_csvlook.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-003001/tests/test_command.sh b/tasks/format-code-task-003001/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003001/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003030/environment/Dockerfile b/tasks/format-code-task-003030/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b85bc136c8b7fa672798694c606e66c7890030c6 --- /dev/null +++ b/tasks/format-code-task-003030/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:437c40ee360d9dd205f34798da3f8bdd45dfdb661e7cd051d363010ed89d13ff diff --git a/tasks/format-code-task-003030/environment/setup/files/blocklist b/tasks/format-code-task-003030/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003030/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003030/environment/setup/setup.sh b/tasks/format-code-task-003030/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003030/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003030/tests/test.patch b/tasks/format-code-task-003030/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..88326e8bfe3bd5e1a825cd677644e2b31fb9b689 --- /dev/null +++ b/tasks/format-code-task-003030/tests/test.patch @@ -0,0 +1,95 @@ +diff --git a/test/yargs-parser.js b/test/yargs-parser.js +index ee76e41..4836a66 100644 +--- a/test/yargs-parser.js ++++ b/test/yargs-parser.js +@@ -1788,6 +1788,68 @@ describe('yargs-parser', function () { + + result.foo.should.eql('a') + }) ++ ++ ++ describe('nargs interaction with duplicate-arguments-array=false', function () { ++ it('should collect narg values into an array when duplicate-arguments-array is false (issue reproduction)', function () { ++ var result = parser('foo -p x y', { ++ narg: { p: 2 }, ++ configuration: { 'duplicate-arguments-array': false } ++ }) ++ result.should.have.property('p').and.deep.equal(['x', 'y']) ++ result.should.have.property('_').and.deep.equal(['foo']) ++ }) ++ ++ it('should collect narg values into an array when duplicate-arguments-array is left at its default (issue reference behavior)', function () { ++ var result = parser('foo -p x y', { ++ narg: { p: 2 } ++ }) ++ result.should.have.property('p').and.deep.equal(['x', 'y']) ++ result.should.have.property('_').and.deep.equal(['foo']) ++ }) ++ ++ it('should keep only the last group of narg values when the option is specified multiple times and duplicate-arguments-array is false', function () { ++ var result = parser('-p a b -p c d', { ++ narg: { p: 2 }, ++ configuration: { 'duplicate-arguments-array': false } ++ }) ++ result.should.have.property('p').and.deep.equal(['c', 'd']) ++ }) ++ ++ it('should keep only the last group of narg values when using = form and duplicate-arguments-array is false', function () { ++ var result = parser('-f=a b -f=c d', { ++ narg: { f: 2 }, ++ configuration: { 'duplicate-arguments-array': false } ++ }) ++ result.should.have.property('f').and.deep.equal(['c', 'd']) ++ }) ++ ++ it('should still preserve a narg=1 last-value-wins behavior when duplicate-arguments-array is false', function () { ++ var result = parser('-p a -p b', { ++ narg: { p: 1 }, ++ configuration: { 'duplicate-arguments-array': false } ++ }) ++ result.should.have.property('p').and.equal('b') ++ }) ++ ++ it('should collect narg values into an array via an alias when duplicate-arguments-array is false', function () { ++ var result = parser('--bar x y', { ++ narg: { foo: 2 }, ++ alias: { foo: 'bar' }, ++ configuration: { 'duplicate-arguments-array': false } ++ }) ++ result.should.have.property('foo').and.deep.equal(['x', 'y']) ++ result.should.have.property('bar').and.deep.equal(['x', 'y']) ++ }) ++ ++ it('should collect all narg values when nargs is greater than 2 and duplicate-arguments-array is false', function () { ++ var result = parser('-p a b c', { ++ narg: { p: 3 }, ++ configuration: { 'duplicate-arguments-array': false } ++ }) ++ result.should.have.property('p').and.deep.equal(['a', 'b', 'c']) ++ }) ++ }) + }) + + describe('env vars', function () { +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 0000000..a2039c8 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["./node_modules/.bin/mocha test/yargs-parser.js -g \"duplicate-arguments-array=false\""] ++} +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,8 @@ ++#!/usr/bin/env bash ++ ++set -uo pipefail ++cd /testbed ++rc=0 ++./node_modules/.bin/mocha test/yargs-parser.js -g "duplicate-arguments-array=false" ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-003030/tests/test.sh b/tasks/format-code-task-003030/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e34384fecb5195480ed162c0b10a369d9f048e96 --- /dev/null +++ b/tasks/format-code-task-003030/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/yargs-parser.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-003030/tests/test_command.sh b/tasks/format-code-task-003030/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003030/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003037/environment/Dockerfile b/tasks/format-code-task-003037/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1c4c01c2799d03645938be023b420b123459e32a --- /dev/null +++ b/tasks/format-code-task-003037/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:0fbad53191ebd61ca47b1b13031af9fca4cba1383c44d1c240bb3a75afddfb2a diff --git a/tasks/format-code-task-003037/environment/setup/files/blocklist b/tasks/format-code-task-003037/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003037/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003037/environment/setup/setup.sh b/tasks/format-code-task-003037/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003037/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-003037/tests/test.patch b/tasks/format-code-task-003037/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..59233938ef0f4777540e8155716fceb17ca41c5c --- /dev/null +++ b/tasks/format-code-task-003037/tests/test.patch @@ -0,0 +1,288 @@ +diff --git a/usercase-test-coderl/fixtures/fake_es.py b/usercase-test-coderl/fixtures/fake_es.py +new file mode 100644 +--- /dev/null ++++ b/usercase-test-coderl/fixtures/fake_es.py +@@ -0,0 +1,45 @@ ++#!/usr/bin/env python3 ++import json ++import os ++from http.server import BaseHTTPRequestHandler, HTTPServer ++ ++ ++PORT = int(os.environ["FAKE_ES_PORT"]) ++MODE = os.environ.get("FAKE_ES_MODE", "ok") ++LOG = os.environ["FAKE_ES_LOG"] ++ ++ ++class Handler(BaseHTTPRequestHandler): ++ def log_message(self, fmt, *args): ++ return ++ ++ def send_json(self, code, body): ++ data = json.dumps(body, sort_keys=True).encode("utf-8") ++ self.send_response(code) ++ self.send_header("Content-Type", "application/json") ++ self.send_header("Content-Length", str(len(data))) ++ self.end_headers() ++ self.wfile.write(data) ++ ++ def do_GET(self): ++ self.send_json(200, {"version": {"number": "7.0.0"}, "tagline": "You Know, for Search"}) ++ ++ def log_write(self): ++ length = int(self.headers.get("Content-Length", "0") or "0") ++ body = self.rfile.read(length).decode("utf-8") ++ with open(LOG, "a", encoding="utf-8") as handle: ++ ++ handle.write(json.dumps({"method": self.command, "path": self.path, "body": body}, sort_keys=True) + "\n") ++ if MODE == "fail": ++ self.send_json(500, {"error": {"type": "fixture_failure", "reason": "write rejected"}, "status": 500}) ++ else: ++ self.send_json(201, {"_index": "elastalert_status_silence", "_type": "_doc", "_id": "abc123", "result": "created"}) ++ ++ def do_POST(self): ++ self.log_write() ++ ++ def do_PUT(self): ++ self.log_write() ++ ++ ++HTTPServer(("127.0.0.1", PORT), Handler).serve_forever() +diff --git a/usercase-test-coderl/usecase.sh b/usercase-test-coderl/usecase.sh +new file mode 100755 +--- /dev/null ++++ b/usercase-test-coderl/usecase.sh +@@ -0,0 +1,216 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC ++VENVDIR=/opt/coderl-elastalert-venv ++if [ ! -x "$VENVDIR/bin/elastalert" ] || [ ! -x "$VENVDIR/bin/python" ]; then ++ echo "FAIL: missing offline ElastAlert test venv at $VENVDIR" >&2 ++ exit 1 ++fi ++ ++export PATH="$VENVDIR/bin:$PATH" ++export PYTHONPATH="/workspace/repo${PYTHONPATH:+:$PYTHONPATH}" ++export AWS_EC2_METADATA_DISABLED=true ++unset AWS_DEFAULT_REGION AWS_REGION AWS_PROFILE AWS_DEFAULT_PROFILE ++BIN="$VENVDIR/bin/elastalert" ++ ++TMP=$(mktemp -d); trap 'cleanup' EXIT ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++server_pid="" ++cleanup() { ++ if [ -n "${server_pid}" ]; then ++ kill "${server_pid}" 2>/dev/null || true ++ wait "${server_pid}" 2>/dev/null || true ++ fi ++ rm -rf "$TMP" ++} ++ ++write_case_files() { ++ local dir="$1" ++ local port="$2" ++ mkdir -p "$dir/rules" ++ cat >"$dir/config.yaml" <"$dir/rules/noisy_rule.yaml" <<'EOF' ++name: Fixture Noisy Rule ++index: logstash-* ++type: any ++alert: ++ - debug ++filter: [] ++EOF ++} ++ ++start_fake_es() { ++ local port="$1" ++ local mode="$2" ++ local log="$3" ++ rm -f "$log" ++ FAKE_ES_PORT="$port" FAKE_ES_MODE="$mode" FAKE_ES_LOG="$log" \ ++ python3 /workspace/repo/usercase-test-coderl/fixtures/fake_es.py \ ++ >"$TMP/fake_es_${port}.out" 2>"$TMP/fake_es_${port}.err" & ++ server_pid=$! ++ sleep 0.4 ++} ++ ++stop_fake_es() { ++ if [ -n "${server_pid}" ]; then ++ kill "${server_pid}" 2>/dev/null || true ++ wait "${server_pid}" 2>/dev/null || true ++ server_pid="" ++ fi ++} ++ ++assert_no_scheduler_start() { ++ local fixture="$1" ++ local dir="$2" ++ ! grep -q 'Starting up' "$dir/err" || fail "$fixture started normal scheduler loop" ++ ! grep -q 'Disabled rules are:' "$dir/err" || fail "$fixture entered scheduler polling loop" ++} ++ ++ ++ ++ ++case_dir="$TMP/F1"; write_case_files "$case_dir" 19301; start_fake_es 19301 ok "$case_dir/es.log" ++start_epoch=$(date +%s) ++( cd "$case_dir" && timeout 8s "$BIN" --config config.yaml --rule noisy_rule.yaml --silence hours=4 >out 2>err ); ec=$? ++end_epoch=$(date +%s) ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++ ++grep -Eq 'Success\. Fixture Noisy Rule\._silence will be silenced until .+' "$case_dir/err" \ ++ || fail "F1 missing success message: $(cat "$case_dir/err")" ++assert_no_scheduler_start F1 "$case_dir" ++python3 - "$case_dir/es.log" "$start_epoch" "$end_epoch" <<'PY' ++import datetime ++import json ++import sys ++ ++lines = open(sys.argv[1], encoding="utf-8").read().splitlines() ++if len(lines) != 1: ++ raise SystemExit("FAIL: F1 expected one ES write, got %d" % len(lines)) ++event = json.loads(lines[0]) ++ ++if event.get("method") not in {"POST", "PUT"}: ++ raise SystemExit("FAIL: F1 ES method %r" % event.get("method")) ++body = json.loads(event["body"]) ++if body.get("rule_name") != "Fixture Noisy Rule._silence": ++ raise SystemExit("FAIL: F1 rule_name %r" % body.get("rule_name")) ++until_value = body.get("until") ++if not until_value: ++ raise SystemExit("FAIL: F1 missing until timestamp") ++ ++def parse_dt(value): ++ value = value.replace("Z", "+00:00") ++ parsed = datetime.datetime.fromisoformat(value) ++ if parsed.tzinfo is None: ++ parsed = parsed.replace(tzinfo=datetime.timezone.utc) ++ return parsed.astimezone(datetime.timezone.utc) ++ ++until = parse_dt(until_value) ++ ++earliest = datetime.datetime.fromtimestamp(int(sys.argv[2]), datetime.timezone.utc) + datetime.timedelta(hours=3, minutes=59) ++latest = datetime.datetime.fromtimestamp(int(sys.argv[3]), datetime.timezone.utc) + datetime.timedelta(hours=4, minutes=1) ++if not earliest <= until <= latest: ++ raise SystemExit("FAIL: F1 until %s outside expected four-hour window" % until) ++PY ++stop_fake_es ++ ++ ++ ++ ++case_dir="$TMP/F2"; write_case_files "$case_dir" 19302; start_fake_es 19302 ok "$case_dir/es.log" ++( cd "$case_dir" && timeout 8s "$BIN" --config config.yaml --silence hours=4 >out 2>err ); ec=$? ++[ "$ec" -eq 1 ] || fail "F2 exit $ec; want 1" ++ ++ ++grep -Fq -- '--silence must be used with --rule' "$case_dir/err" || fail "F2 stderr: $(cat "$case_dir/err")" ++[ ! -s "$case_dir/es.log" ] || fail "F2 should not write silence to ES" ++assert_no_scheduler_start F2 "$case_dir" ++stop_fake_es ++ ++ ++ ++ ++case_dir="$TMP/F3"; write_case_files "$case_dir" 19303; start_fake_es 19303 ok "$case_dir/es.log" ++( cd "$case_dir" && timeout 8s "$BIN" --config config.yaml --rule noisy_rule.yaml --debug --silence hours=4 >out 2>err ); ec=$? ++[ "$ec" -eq 1 ] || fail "F3 exit $ec; want 1" ++ ++ ++grep -Fq -- '--silence not compatible with --debug' "$case_dir/err" || fail "F3 stderr: $(cat "$case_dir/err")" ++[ ! -s "$case_dir/es.log" ] || fail "F3 should not write silence to ES" ++assert_no_scheduler_start F3 "$case_dir" ++stop_fake_es ++ ++ ++ ++ ++case_dir="$TMP/F4"; write_case_files "$case_dir" 19304; start_fake_es 19304 ok "$case_dir/es.log" ++( cd "$case_dir" && timeout 8s "$BIN" --config config.yaml --rule noisy_rule.yaml --silence bananas >out 2>err ); ec=$? ++[ "$ec" -eq 1 ] || fail "F4 exit $ec; want 1" ++ ++ ++grep -Fq 'bananas is not a valid time period' "$case_dir/err" || fail "F4 stderr: $(cat "$case_dir/err")" ++[ ! -s "$case_dir/es.log" ] || fail "F4 should not write silence to ES" ++assert_no_scheduler_start F4 "$case_dir" ++stop_fake_es ++ ++ ++ ++ ++case_dir="$TMP/F5"; write_case_files "$case_dir" 19305; start_fake_es 19305 fail "$case_dir/es.log" ++( cd "$case_dir" && timeout 8s "$BIN" --config config.yaml --rule noisy_rule.yaml --silence hours=4 >out 2>err ); ec=$? ++[ "$ec" -eq 1 ] || fail "F5 exit $ec; want 1" ++ ++ ++grep -Fq 'Failed to save silence command to Elasticsearch' "$case_dir/err" || fail "F5 stderr: $(cat "$case_dir/err")" ++ ++! grep -Fq 'Success. Fixture Noisy Rule._silence will be silenced until' "$case_dir/err" \ ++ || fail "F5 reported success after write failure: $(cat "$case_dir/err")" ++python3 - "$case_dir/es.log" <<'PY' ++import json ++import sys ++ ++lines = open(sys.argv[1], encoding="utf-8").read().splitlines() ++if len(lines) != 1: ++ raise SystemExit("FAIL: F5 expected one ES write, got %d" % len(lines)) ++event = json.loads(lines[0]) ++body = json.loads(event["body"]) ++ ++if event.get("method") not in {"POST", "PUT"}: ++ raise SystemExit("FAIL: F5 ES method %r" % event.get("method")) ++if body.get("rule_name") != "Fixture Noisy Rule._silence": ++ raise SystemExit("FAIL: F5 rule_name %r" % body.get("rule_name")) ++PY ++assert_no_scheduler_start F5 "$case_dir" ++stop_fake_es ++ ++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-003037/tests/test.sh b/tasks/format-code-task-003037/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..eed53d14bf4b5cfd556aa8db6cac0af64ac879c2 --- /dev/null +++ b/tasks/format-code-task-003037/tests/test.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/workspace/repo +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 2>/dev/null || true + else + git rm -f --cached "$tf" >/dev/null 2>&1 || true + rm -f "$tf" + fi +done <<'EOF_RESET_TEST_FILES' +usercase-test-coderl/fixtures/fake_es.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-003037/tests/test_command.sh b/tasks/format-code-task-003037/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003037/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-003039/environment/Dockerfile b/tasks/format-code-task-003039/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..9e9b416c24682fff92e61043a62b7733d34993aa --- /dev/null +++ b/tasks/format-code-task-003039/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:3fb4691b2035b2993571420e7f8a16059b0a9f82951fe2544cdadf1ca1c26827 diff --git a/tasks/format-code-task-003039/environment/setup/files/blocklist b/tasks/format-code-task-003039/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003039/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003039/environment/setup/setup.sh b/tasks/format-code-task-003039/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003039/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003039/tests/test.patch b/tasks/format-code-task-003039/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..11ca3d81824d88c84e022a34b4458cd6a0506f62 --- /dev/null +++ b/tasks/format-code-task-003039/tests/test.patch @@ -0,0 +1,647 @@ +diff --git a/server/rpc/server_test.go b/server/rpc/server_test.go +index 0990b97d9..36de756d4 100644 +--- a/server/rpc/server_test.go ++++ b/server/rpc/server_test.go +@@ -25,12 +25,14 @@ import ( + "testing" + "time" + ++ "github.com/gogo/protobuf/types" + "github.com/stretchr/testify/assert" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/status" + ++ "github.com/yorkie-team/yorkie/admin" + api "github.com/yorkie-team/yorkie/api/yorkie/v1" + "github.com/yorkie-team/yorkie/client" + "github.com/yorkie-team/yorkie/server/backend" +@@ -43,13 +45,18 @@ import ( + ) + + var ( ++ defaultProjectName = "default" ++ invalidSlugName = "@#$%^&*()_+" ++ + nilClientID, _ = hex.DecodeString("000000000000000000000000") + emptyClientID, _ = hex.DecodeString("") + invalidClientID, _ = hex.DecodeString("invalid") + +- testRPCServer *rpc.Server +- testRPCAddr = fmt.Sprintf("localhost:%d", helper.RPCPort) +- testClient api.YorkieServiceClient ++ testRPCServer *rpc.Server ++ testRPCAddr = fmt.Sprintf("localhost:%d", helper.RPCPort) ++ testClient api.YorkieServiceClient ++ testAdminAuthInterceptor *admin.AuthInterceptor ++ testAdminClient api.AdminServiceClient + + invalidChangePack = &api.ChangePack{ + DocumentKey: "invalid", +@@ -69,6 +76,7 @@ func TestMain(m *testing.M) { + ClientDeactivateThreshold: helper.ClientDeactivateThreshold, + SnapshotThreshold: helper.SnapshotThreshold, + AuthWebhookCacheSize: helper.AuthWebhookSize, ++ AdminTokenDuration: helper.AdminTokenDuration, + }, &mongo.Config{ + ConnectionURI: helper.MongoConnectionURI, + YorkieDatabase: helper.TestDBName(), +@@ -116,6 +124,19 @@ func TestMain(m *testing.M) { + } + testClient = api.NewYorkieServiceClient(conn) + ++ credentials := grpc.WithTransportCredentials(insecure.NewCredentials()) ++ dialOptions = []grpc.DialOption{credentials} ++ ++ testAdminAuthInterceptor = admin.NewAuthInterceptor("") ++ dialOptions = append(dialOptions, grpc.WithUnaryInterceptor(testAdminAuthInterceptor.Unary())) ++ dialOptions = append(dialOptions, grpc.WithStreamInterceptor(testAdminAuthInterceptor.Stream())) ++ ++ adminConn, err := grpc.Dial(testRPCAddr, dialOptions...) ++ if err != nil { ++ log.Fatal(err) ++ } ++ testAdminClient = api.NewAdminServiceClient(adminConn) ++ + code := m.Run() + + if err := be.Shutdown(); err != nil { +@@ -125,7 +146,7 @@ func TestMain(m *testing.M) { + os.Exit(code) + } + +-func TestRPCServerBackend(t *testing.T) { ++func TestSDKRPCServerBackend(t *testing.T) { + t.Run("activate/deactivate client test", func(t *testing.T) { + activateResp, err := testClient.ActivateClient( + context.Background(), +@@ -671,6 +692,336 @@ func TestRPCServerBackend(t *testing.T) { + }) + } + ++func TestAdminRPCServerBackend(t *testing.T) { ++ t.Run("admin signup test", func(t *testing.T) { ++ adminUser := helper.TestSlugName(t) ++ adminPassword := helper.AdminPassword + "123!" ++ ++ _, err := testAdminClient.SignUp( ++ context.Background(), ++ &api.SignUpRequest{ ++ Username: adminUser, ++ Password: adminPassword, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ ++ _, err = testAdminClient.SignUp( ++ context.Background(), ++ &api.SignUpRequest{ ++ Username: adminUser, ++ Password: adminPassword, ++ }, ++ ) ++ assert.Equal(t, codes.Unknown, status.Convert(err).Code()) ++ }) ++ ++ t.Run("admin login test", func(t *testing.T) { ++ _, err := testAdminClient.LogIn( ++ context.Background(), ++ &api.LogInRequest{ ++ Username: helper.AdminUser, ++ Password: helper.AdminPassword, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ ++ _, err = testAdminClient.LogIn( ++ context.Background(), ++ &api.LogInRequest{ ++ Username: helper.AdminUser, ++ Password: invalidSlugName, ++ }, ++ ) ++ assert.Equal(t, codes.Unauthenticated, status.Convert(err).Code()) ++ }) ++ ++ t.Run("admin create project test", func(t *testing.T) { ++ projectName := helper.TestSlugName(t) ++ ++ resp, err := testAdminClient.LogIn( ++ context.Background(), ++ &api.LogInRequest{ ++ Username: helper.AdminUser, ++ Password: helper.AdminPassword, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ testAdminAuthInterceptor.SetToken(resp.Token) ++ ++ _, err = testAdminClient.CreateProject( ++ context.Background(), ++ &api.CreateProjectRequest{ ++ Name: projectName, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ ++ _, err = testAdminClient.CreateProject( ++ context.Background(), ++ &api.CreateProjectRequest{ ++ Name: projectName, ++ }, ++ ) ++ assert.Equal(t, codes.AlreadyExists, status.Convert(err).Code()) ++ }) ++ ++ t.Run("admin list projects test", func(t *testing.T) { ++ resp, err := testAdminClient.LogIn( ++ context.Background(), ++ &api.LogInRequest{ ++ Username: helper.AdminUser, ++ Password: helper.AdminPassword, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ testAdminAuthInterceptor.SetToken(resp.Token) ++ ++ _, err = testAdminClient.CreateProject( ++ context.Background(), ++ &api.CreateProjectRequest{ ++ Name: helper.TestSlugName(t), ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ _, err = testAdminClient.ListProjects( ++ context.Background(), ++ &api.ListProjectsRequest{}, ++ ) ++ assert.NoError(t, err) ++ }) ++ ++ t.Run("admin get project test", func(t *testing.T) { ++ projectName := helper.TestSlugName(t) ++ ++ resp, err := testAdminClient.LogIn( ++ context.Background(), ++ &api.LogInRequest{ ++ Username: helper.AdminUser, ++ Password: helper.AdminPassword, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ testAdminAuthInterceptor.SetToken(resp.Token) ++ ++ _, err = testAdminClient.CreateProject( ++ context.Background(), ++ &api.CreateProjectRequest{ ++ Name: projectName, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ _, err = testAdminClient.GetProject( ++ context.Background(), ++ &api.GetProjectRequest{ ++ Name: projectName, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ ++ _, err = testAdminClient.GetProject( ++ context.Background(), ++ &api.GetProjectRequest{ ++ Name: invalidSlugName, ++ }, ++ ) ++ assert.Equal(t, codes.NotFound, status.Convert(err).Code()) ++ }) ++ ++ t.Run("admin update project test", func(t *testing.T) { ++ projectName := helper.TestSlugName(t) ++ ++ resp, err := testAdminClient.LogIn( ++ context.Background(), ++ &api.LogInRequest{ ++ Username: helper.AdminUser, ++ Password: helper.AdminPassword, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ testAdminAuthInterceptor.SetToken(resp.Token) ++ ++ createResp, err := testAdminClient.CreateProject( ++ context.Background(), ++ &api.CreateProjectRequest{ ++ Name: projectName, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ _, err = testAdminClient.UpdateProject( ++ context.Background(), ++ &api.UpdateProjectRequest{ ++ Id: createResp.Project.Id, ++ Fields: &api.UpdatableProjectFields{ ++ Name: &types.StringValue{Value: "updated"}, ++ }, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ ++ _, err = testAdminClient.UpdateProject( ++ context.Background(), ++ &api.UpdateProjectRequest{ ++ Id: projectName, ++ Fields: &api.UpdatableProjectFields{ ++ Name: &types.StringValue{Value: invalidSlugName}, ++ }, ++ }, ++ ) ++ assert.Equal(t, codes.InvalidArgument, status.Convert(err).Code()) ++ }) ++ ++ t.Run("admin list documents test", func(t *testing.T) { ++ resp, err := testAdminClient.LogIn( ++ context.Background(), ++ &api.LogInRequest{ ++ Username: helper.AdminUser, ++ Password: helper.AdminPassword, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ testAdminAuthInterceptor.SetToken(resp.Token) ++ ++ _, err = testAdminClient.ListDocuments( ++ context.Background(), ++ &api.ListDocumentsRequest{ ++ ProjectName: defaultProjectName, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ ++ _, err = testAdminClient.ListDocuments( ++ context.Background(), ++ &api.ListDocumentsRequest{ ++ ProjectName: invalidSlugName, ++ }, ++ ) ++ assert.Equal(t, codes.NotFound, status.Convert(err).Code()) ++ }) ++ ++ t.Run("admin get document test", func(t *testing.T) { ++ testDocumentKey := helper.TestDocKey(t).String() ++ ++ resp, err := testAdminClient.LogIn( ++ context.Background(), ++ &api.LogInRequest{ ++ Username: helper.AdminUser, ++ Password: helper.AdminPassword, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ testAdminAuthInterceptor.SetToken(resp.Token) ++ ++ activateResp, err := testClient.ActivateClient( ++ context.Background(), ++ &api.ActivateClientRequest{ClientKey: t.Name()}, ++ ) ++ assert.NoError(t, err) ++ ++ packWithNoChanges := &api.ChangePack{ ++ DocumentKey: testDocumentKey, ++ Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, ++ } ++ ++ _, err = testClient.AttachDocument( ++ context.Background(), ++ &api.AttachDocumentRequest{ ++ ClientId: activateResp.ClientId, ++ ChangePack: packWithNoChanges, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ _, err = testAdminClient.GetDocument( ++ context.Background(), ++ &api.GetDocumentRequest{ ++ ProjectName: defaultProjectName, ++ DocumentKey: testDocumentKey, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ ++ _, err = testAdminClient.GetDocument( ++ context.Background(), ++ &api.GetDocumentRequest{ ++ ProjectName: defaultProjectName, ++ DocumentKey: invalidChangePack.DocumentKey, ++ }, ++ ) ++ assert.Equal(t, codes.NotFound, status.Convert(err).Code()) ++ }) ++ ++ t.Run("admin list changes test", func(t *testing.T) { ++ testDocumentKey := helper.TestDocKey(t).String() ++ ++ resp, err := testAdminClient.LogIn( ++ context.Background(), ++ &api.LogInRequest{ ++ Username: helper.AdminUser, ++ Password: helper.AdminPassword, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ testAdminAuthInterceptor.SetToken(resp.Token) ++ ++ activateResp, err := testClient.ActivateClient( ++ context.Background(), ++ &api.ActivateClientRequest{ClientKey: t.Name()}, ++ ) ++ assert.NoError(t, err) ++ ++ packWithNoChanges := &api.ChangePack{ ++ DocumentKey: testDocumentKey, ++ Checkpoint: &api.Checkpoint{ServerSeq: 0, ClientSeq: 0}, ++ } ++ ++ _, err = testClient.AttachDocument( ++ context.Background(), ++ &api.AttachDocumentRequest{ ++ ClientId: activateResp.ClientId, ++ ChangePack: packWithNoChanges, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ _, err = testAdminClient.ListChanges( ++ context.Background(), ++ &api.ListChangesRequest{ ++ ProjectName: defaultProjectName, ++ DocumentKey: testDocumentKey, ++ }, ++ ) ++ assert.NoError(t, err) ++ ++ ++ _, err = testAdminClient.ListChanges( ++ context.Background(), ++ &api.ListChangesRequest{ ++ ProjectName: defaultProjectName, ++ DocumentKey: invalidChangePack.DocumentKey, ++ }, ++ ) ++ assert.Equal(t, codes.NotFound, status.Convert(err).Code()) ++ }) ++} ++ + func TestConfig_Validate(t *testing.T) { + scenarios := []*struct { + config *rpc.Config +diff --git a/test/bench/grpc_bench_test.go b/test/bench/grpc_bench_test.go +index c64e7eee0..9279bfd60 100644 +--- a/test/bench/grpc_bench_test.go ++++ b/test/bench/grpc_bench_test.go +@@ -301,7 +301,7 @@ func BenchmarkRPC(b *testing.B) { + }) + + b.Run("adminCli to server", func(b *testing.B) { +- adminCli := helper.CreateAdminCli(b, defaultServer.AdminAddr()) ++ adminCli := helper.CreateAdminCli(b, defaultServer.RPCAddr()) + defer func() { assert.NoError(b, adminCli.Close()) }() + + ctx := context.Background() +diff --git a/test/helper/helper.go b/test/helper/helper.go +index e8af6d5d2..656357448 100644 +--- a/test/helper/helper.go ++++ b/test/helper/helper.go +@@ -28,12 +28,12 @@ import ( + "github.com/stretchr/testify/assert" + + adminClient "github.com/yorkie-team/yorkie/admin" ++ "github.com/yorkie-team/yorkie/internal/validation" + "github.com/yorkie-team/yorkie/pkg/document/change" + "github.com/yorkie-team/yorkie/pkg/document/crdt" + "github.com/yorkie-team/yorkie/pkg/document/key" + "github.com/yorkie-team/yorkie/pkg/document/time" + "github.com/yorkie-team/yorkie/server" +- "github.com/yorkie-team/yorkie/server/admin" + "github.com/yorkie-team/yorkie/server/backend" + "github.com/yorkie-team/yorkie/server/backend/database/mongo" + "github.com/yorkie-team/yorkie/server/backend/housekeeping" +@@ -52,13 +52,12 @@ var ( + + ProfilingPort = 21102 + +- AdminPort = 21103 +- + AdminUser = server.DefaultAdminUser + AdminPassword = server.DefaultAdminPassword + HousekeepingInterval = 10 * gotime.Second + HousekeepingCandidatesLimitPerProject = 10 + ++ AdminTokenDuration = "10s" + ClientDeactivateThreshold = "10s" + SnapshotThreshold = int64(10) + SnapshotWithPurgingChanges = false +@@ -84,8 +83,8 @@ func TestDBName() string { + } + + // CreateAdminCli returns a new instance of admin cli for testing. +-func CreateAdminCli(t assert.TestingT, adminAddr string) *adminClient.Client { +- adminCli, err := adminClient.Dial(adminAddr) ++func CreateAdminCli(t assert.TestingT, rpcAddr string) *adminClient.Client { ++ adminCli, err := adminClient.Dial(rpcAddr) + assert.NoError(t, err) + + _, err = adminCli.LogIn(context.Background(), server.DefaultAdminUser, server.DefaultAdminPassword) +@@ -123,9 +122,6 @@ func TestConfig() *server.Config { + Profiling: &profiling.Config{ + Port: ProfilingPort + portOffset, + }, +- Admin: &admin.Config{ +- Port: AdminPort + portOffset, +- }, + Housekeeping: &housekeeping.Config{ + Interval: HousekeepingInterval.String(), + CandidatesLimitPerProject: HousekeepingCandidatesLimitPerProject, +@@ -189,6 +185,38 @@ func TestDocKey(t testing.TB) key.Key { + return key.Key(sb.String()) + } + ++ ++func TestSlugName(t testing.TB) string { ++ name := t.Name() ++ if err := validation.Validate(name, []any{ ++ "required", ++ "min=4", ++ "max=30", ++ "slug", ++ }); err == nil { ++ return name ++ } ++ ++ if len(name) > 35 { ++ name = name[len(name)-30:] ++ } ++ ++ sb := strings.Builder{} ++ for _, c := range name { ++ if c >= 'A' && c <= 'Z' { ++ sb.WriteRune(c + ('a' - 'A')) ++ } else if c >= 'a' && c <= 'z' { ++ sb.WriteRune(c) ++ } else if c >= '0' && c <= '9' { ++ sb.WriteRune(c) ++ } else { ++ sb.WriteRune('-') ++ } ++ } ++ ++ return sb.String() ++} ++ + // NewRangeSlice returns a slice of integers from start to end. + func NewRangeSlice(start, end int) []int { + var slice []int +diff --git a/test/integration/auth_webhook_test.go b/test/integration/auth_webhook_test.go +index 4e4c51c28..0c5651788 100644 +--- a/test/integration/auth_webhook_test.go ++++ b/test/integration/auth_webhook_test.go +@@ -83,7 +83,7 @@ func TestProjectAuthWebhook(t *testing.T) { + assert.NoError(t, svr.Start()) + defer func() { assert.NoError(t, svr.Shutdown(true)) }() + +- adminCli := helper.CreateAdminCli(t, svr.AdminAddr()) ++ adminCli := helper.CreateAdminCli(t, svr.RPCAddr()) + defer func() { assert.NoError(t, adminCli.Close()) }() + + project, err := adminCli.CreateProject(context.Background(), "auth-webhook-test") +@@ -196,7 +196,7 @@ func TestAuthWebhook(t *testing.T) { + assert.NoError(t, svr.Start()) + defer func() { assert.NoError(t, svr.Shutdown(true)) }() + +- adminCli := helper.CreateAdminCli(t, svr.AdminAddr()) ++ adminCli := helper.CreateAdminCli(t, svr.RPCAddr()) + defer func() { assert.NoError(t, adminCli.Close()) }() + project, err := adminCli.CreateProject(context.Background(), "success-webhook-after-retries") + assert.NoError(t, err) +@@ -238,7 +238,7 @@ func TestAuthWebhook(t *testing.T) { + assert.NoError(t, svr.Start()) + defer func() { assert.NoError(t, svr.Shutdown(true)) }() + +- adminCli := helper.CreateAdminCli(t, svr.AdminAddr()) ++ adminCli := helper.CreateAdminCli(t, svr.RPCAddr()) + defer func() { assert.NoError(t, adminCli.Close()) }() + project, err := adminCli.CreateProject(context.Background(), "fail-webhook-after-retries") + assert.NoError(t, err) +@@ -291,7 +291,7 @@ func TestAuthWebhook(t *testing.T) { + assert.NoError(t, svr.Start()) + defer func() { assert.NoError(t, svr.Shutdown(true)) }() + +- adminCli := helper.CreateAdminCli(t, svr.AdminAddr()) ++ adminCli := helper.CreateAdminCli(t, svr.RPCAddr()) + defer func() { assert.NoError(t, adminCli.Close()) }() + project, err := adminCli.CreateProject(context.Background(), "auth-request-cache") + assert.NoError(t, err) +@@ -367,7 +367,7 @@ func TestAuthWebhook(t *testing.T) { + assert.NoError(t, svr.Start()) + defer func() { assert.NoError(t, svr.Shutdown(true)) }() + +- adminCli := helper.CreateAdminCli(t, svr.AdminAddr()) ++ adminCli := helper.CreateAdminCli(t, svr.RPCAddr()) + defer func() { assert.NoError(t, adminCli.Close()) }() + project, err := adminCli.CreateProject(context.Background(), "unauth-request-cache") + assert.NoError(t, err) +diff --git a/test/integration/document_test.go b/test/integration/document_test.go +index e9f7d4fe1..42e944b66 100644 +--- a/test/integration/document_test.go ++++ b/test/integration/document_test.go +@@ -386,7 +386,7 @@ func TestDocument(t *testing.T) { + + func TestDocumentWithProjects(t *testing.T) { + ctx := context.Background() +- adminCli := helper.CreateAdminCli(t, defaultServer.AdminAddr()) ++ adminCli := helper.CreateAdminCli(t, defaultServer.RPCAddr()) + defer func() { assert.NoError(t, adminCli.Close()) }() + + project1, err := adminCli.CreateProject(ctx, "project1") +diff --git a/test/integration/history_test.go b/test/integration/history_test.go +index a2fb27ccb..0142c06fe 100644 +--- a/test/integration/history_test.go ++++ b/test/integration/history_test.go +@@ -34,7 +34,7 @@ func TestHistory(t *testing.T) { + cli := clients[0] + defer deactivateAndCloseClients(t, clients) + +- adminCli := helper.CreateAdminCli(t, defaultServer.AdminAddr()) ++ adminCli := helper.CreateAdminCli(t, defaultServer.RPCAddr()) + defer func() { assert.NoError(t, adminCli.Close()) }() + + t.Run("history test", func(t *testing.T) { +diff --git a/test/integration/retention_test.go b/test/integration/retention_test.go +index 64efa0048..566d6d38b 100644 +--- a/test/integration/retention_test.go ++++ b/test/integration/retention_test.go +@@ -77,7 +77,7 @@ func TestRetention(t *testing.T) { + assert.NoError(t, cli.Close()) + }() + +- adminCli := helper.CreateAdminCli(t, testServer.AdminAddr()) ++ adminCli := helper.CreateAdminCli(t, testServer.RPCAddr()) + assert.NoError(t, err) + defer func() { assert.NoError(t, adminCli.Close()) }() + +diff --git a/test/integration/user_test.go b/test/integration/user_test.go +index 223d98337..f1b5d85db 100644 +--- a/test/integration/user_test.go ++++ b/test/integration/user_test.go +@@ -30,7 +30,7 @@ import ( + ) + + func TestUser(t *testing.T) { +- adminCli := helper.CreateAdminCli(t, defaultServer.AdminAddr()) ++ adminCli := helper.CreateAdminCli(t, defaultServer.RPCAddr()) + defer func() { assert.NoError(t, adminCli.Close()) }() + + t.Run("user test", func(t *testing.T) { +diff --git a/mimo_build_env.tar.gz.b64 b/mimo_build_env.tar.gz.b64 +new file mode 100644 +--- /dev/null ++++ b/mimo_build_env.tar.gz.b64 +@@ -0,0 +1,9 @@ ++H4sIAAAAAAAAA+3TzY7TMBAA4JzzFINAWpCwE6ckPaByQHDkwgMQJbGbWE3syD9heXuctKVZKliQ ++dgWI+XpwNJ56xp2U1l72vBRqSqLHkgbbPF/W4Pt1eWZ5lm7SzTYrNlHKWJFmEeSP1tGKt64yAJHR ++2v0s7779fxS9zN8J68pGD0OlOLXdw9W4Z/4sK7Jv82dbFub/qmB5BOnDtfBj//n8Gw7L4GvB4/gp ++vFfWGwEftGr1u7cgLRivlFRtLPfwBMbWiBHILQxzAoc3kHAxJcr3/WtwnVAxBMOBSwNkhGSqTNLL ++Ojmm16eAbs+BY/rxLEL22hzCEvbHynVXyaeVhlDI4vUqaVWCkFoqXsoRWLalafiwpYrtRWg9i/dy ++vudHr8AKMwmTmLGB+Rew8Fyqpvdc2NNWOYdpq1/ErV5SgExAGu2V2zEgTg5CewebNLVAk8txCaX0 ++XEQqJ1pTOanVVZXKu678LOpO68O51kvguvGDUO4S6aR12ny5BIxwISEceQl5+8v9FnO/xFWtvdMd ++Xd6DZBVa36MWqumubtCG25bL1u/XPp5IwvsFN5+e3QBZAjt6epi/sWO357aW2NLQn/7HIIQQQggh ++hBBCCCGEEEIIIYQQQgj9Xb4CwbzOkgAoAAA= +diff --git 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-003039/tests/test.sh b/tasks/format-code-task-003039/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..bce1b8e8b7f90bb72fea0d8606a70a1a51ee62e0 --- /dev/null +++ b/tasks/format-code-task-003039/tests/test.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Code grading, mimoagent opensource_code.py: reset the files the hidden test patch touches, apply it, run the +# task's test command; reward 1 when it exits 0. A testbed failure (reset or apply) writes no reward: not scored. +M=/var/lib/mimo +CWD=/testbed +V=/logs/verifier +mkdir -p "$V" +BASE=$(cat "$M/base" 2>/dev/null) || { echo "setup never ran (no $M/base)" >&2; exit 1; } +cd "$CWD" || exit 1 +if [ -d "$M/git-hidden" ]; then rm -rf "$CWD/.git"; mv "$M/git-hidden" "$CWD/.git"; fi +# the agent's change against the base, so its own commits count too +git add -A >/dev/null 2>&1 && git -c core.fileMode=false diff --cached "$BASE" > "$V/agent.diff" +git reset -q +if ! ( +while IFS= read -r tf; do + [ -z "$tf" ] && continue + if git cat-file -e $BASE:"$tf" 2>/dev/null; then + git checkout $BASE -- "$tf" 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/rpc/server_test.go +test/bench/grpc_bench_test.go +test/helper/helper.go +test/integration/auth_webhook_test.go +test/integration/document_test.go +test/integration/history_test.go +test/integration/retention_test.go +test/integration/user_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-003039/tests/test_command.sh b/tasks/format-code-task-003039/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003039/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003052/environment/Dockerfile b/tasks/format-code-task-003052/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f3a876c4a3ebaaceca615b310efb381183cf2e65 --- /dev/null +++ b/tasks/format-code-task-003052/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:7cf3cc265023a154c53d9f8d0327b2bb4889e602d0a2b3b2fec7164af0f00896 diff --git a/tasks/format-code-task-003052/environment/setup/files/blocklist b/tasks/format-code-task-003052/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003052/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003052/environment/setup/setup.sh b/tasks/format-code-task-003052/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003052/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003052/tests/test.patch b/tasks/format-code-task-003052/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..325a03f16c86fa7e379b27b1a69748db00768a70 --- /dev/null +++ b/tasks/format-code-task-003052/tests/test.patch @@ -0,0 +1,111 @@ +diff --git a/packages/zenn-cli/src/server/__tests__/commands/new-article.test.ts b/packages/zenn-cli/src/server/__tests__/commands/new-article.test.ts +index 8002c530..e8993928 100644 +--- a/packages/zenn-cli/src/server/__tests__/commands/new-article.test.ts ++++ b/packages/zenn-cli/src/server/__tests__/commands/new-article.test.ts +@@ -92,4 +92,84 @@ describe('cli exec new:article', () => { + ) + ); + }); ++ ++ ++ ++ test('should accept --publication-name option without ARG_UNKNOWN_OPTION error', () => { ++ exec(['--publication-name', 'myPublication']); ++ ++ expect(Log.error).not.toHaveBeenCalled(); ++ }); ++ ++ test('should include publication name line in frontmatter when --publication-name is specified', () => { ++ exec(['--publication-name', 'myPublication']); ++ const calls = (helper.generateFileIfNotExist as jest.Mock).mock.calls; ++ expect(calls.length).toBeGreaterThan(0); ++ const fileBody: string = calls[0][1]; ++ ++ ++ ++ expect(fileBody).toMatch(/^publication[-_]name:\s*"?myPublication"?\s*$/m); ++ }); ++ ++ test('should include publication name line BEFORE the closing --- delimiter', () => { ++ exec(['--publication-name', 'myPublication']); ++ const calls = (helper.generateFileIfNotExist as jest.Mock).mock.calls; ++ expect(calls.length).toBeGreaterThan(0); ++ const fileBody: string = calls[0][1]; ++ const lines = fileBody.split('\n'); ++ const pubIdx = lines.findIndex((l) => /^publication[-_]name:/.test(l)); ++ const closingDelimIdx = lines.findIndex( ++ (l, i) => i > 0 && l === '---' ++ ); ++ expect(pubIdx).toBeGreaterThan(-1); ++ expect(closingDelimIdx).toBeGreaterThan(pubIdx); ++ }); ++ ++ test('should NOT include any publication-name/publication_name line when --publication-name is not specified', () => { ++ exec(['--emoji', '💭']); ++ const calls = (helper.generateFileIfNotExist as jest.Mock).mock.calls; ++ expect(calls.length).toBeGreaterThan(0); ++ const fileBody: string = calls[0][1]; ++ expect(fileBody).not.toMatch(/publication[-_]name/); ++ }); ++ ++ test('should NOT include publication-name line when --publication-name is empty string', () => { ++ exec(['--publication-name', '']); ++ const calls = (helper.generateFileIfNotExist as jest.Mock).mock.calls; ++ expect(calls.length).toBeGreaterThan(0); ++ const fileBody: string = calls[0][1]; ++ expect(fileBody).not.toMatch(/publication[-_]name/); ++ }); ++ ++ test('should preserve other frontmatter fields when --publication-name is specified', () => { ++ exec([ ++ '--publication-name', ++ 'myPublication', ++ '--title', ++ 'Hello', ++ '--published', ++ 'true', ++ '--emoji', ++ '🔥', ++ ]); ++ const calls = (helper.generateFileIfNotExist as jest.Mock).mock.calls; ++ expect(calls.length).toBeGreaterThan(0); ++ const fileBody: string = calls[0][1]; ++ expect(fileBody).toMatch(/^title: "Hello"$/m); ++ expect(fileBody).toMatch(/^emoji: "🔥"$/m); ++ expect(fileBody).toMatch(/^type: "tech"/m); ++ expect(fileBody).toMatch(/^published: true$/m); ++ expect(fileBody).toMatch(/^publication[-_]name:\s*"?myPublication"?\s*$/m); ++ }); ++ ++ test('should call Log.created (not error) when --publication-name is specified with valid args', () => { ++ const createdSpy = jest.spyOn(Log, 'created').mockImplementation(); ++ exec(['--publication-name', 'myPublication', '--slug', 'example-article']); ++ expect(createdSpy).toHaveBeenCalledWith( ++ expect.stringContaining('articles/example-article.md') ++ ); ++ expect(Log.error).not.toHaveBeenCalled(); ++ createdSpy.mockRestore(); ++ }); + }); +diff --git a/test_commands.json b/test_commands.json +new file mode 100644 +index 00000000..1477d783 +--- /dev/null ++++ b/test_commands.json +@@ -0,0 +1,3 @@ ++{ ++ "test_commands": ["cd packages/zenn-cli && npx jest --config=jest.config.server.js src/server/__tests__/commands/new-article.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 ++cd packages/zenn-cli && npx jest --config=jest.config.server.js src/server/__tests__/commands/new-article.test.ts ++rc=$(( rc | $? )) ++exit $rc diff --git a/tasks/format-code-task-003052/tests/test.sh b/tasks/format-code-task-003052/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..233d793966d1360dd411ceac11352bf88f2f1b4a --- /dev/null +++ b/tasks/format-code-task-003052/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/zenn-cli/src/server/__tests__/commands/new-article.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-003052/tests/test_command.sh b/tasks/format-code-task-003052/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003052/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003053/environment/Dockerfile b/tasks/format-code-task-003053/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b03ef91f9dc65b3cf9374e6b8ab0b0ca77987dbd --- /dev/null +++ b/tasks/format-code-task-003053/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:625d29016910c553d90eb6e14ad578674fd2a2f3656c6ae0a1bac5cbb4c05d65 diff --git a/tasks/format-code-task-003053/environment/setup/files/blocklist b/tasks/format-code-task-003053/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003053/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003053/environment/setup/setup.sh b/tasks/format-code-task-003053/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003053/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003053/tests/test.patch b/tasks/format-code-task-003053/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..e508bec4ed61a074a6e32650ef6020434417f422 --- /dev/null +++ b/tasks/format-code-task-003053/tests/test.patch @@ -0,0 +1,91 @@ +diff --git a/tests/mdm/test_setup_dep_enrollment.py b/tests/mdm/test_setup_dep_enrollment.py +index df22643ddc..30eef3a3b4 100644 +--- a/tests/mdm/test_setup_dep_enrollment.py ++++ b/tests/mdm/test_setup_dep_enrollment.py +@@ -1,4 +1,5 @@ + import base64 ++from datetime import datetime, timedelta + from functools import reduce + import operator + from unittest.mock import Mock, patch +@@ -217,6 +218,54 @@ def test_create_dep_enrollment_username_pattern_without_use_realm_user(self): + "username_pattern", + "This field can only be used if the 'use realm user' option is ticked") + ++ def test_create_dep_enrollment_no_token(self): ++ self._login("mdm.add_depenrollment", "mdm.view_depenrollment") ++ name = get_random_string(64) ++ display_name = get_random_string(12) ++ push_certificate = force_push_certificate() ++ scep_config = force_scep_config() ++ dep_virtual_server = force_dep_virtual_server() ++ dep_virtual_server.token = None ++ dep_virtual_server.save() ++ realm = force_realm() ++ response = self.client.post(reverse("mdm:create_dep_enrollment"), ++ {"de-name": name, ++ "de-display_name": display_name, ++ "de-realm": realm.pk, ++ "de-scep_config": scep_config.pk, ++ "de-push_certificate": push_certificate.pk, ++ "de-virtual_server": dep_virtual_server.pk, ++ "es-meta_business_unit": self.mbu.pk, ++ "de-is_supervised": "on"}, ++ follow=True) ++ self.assertEqual(response.status_code, 200) ++ self.assertTemplateUsed(response, "mdm/depenrollment_form.html") ++ self.assertFormError(response.context["form"], None, "DEP virtual server has no token") ++ ++ def test_create_dep_enrollment_token_expired(self): ++ self._login("mdm.add_depenrollment", "mdm.view_depenrollment") ++ name = get_random_string(64) ++ display_name = get_random_string(12) ++ push_certificate = force_push_certificate() ++ scep_config = force_scep_config() ++ dep_virtual_server = force_dep_virtual_server() ++ dep_virtual_server.token.access_token_expiry = datetime.utcnow() - timedelta(seconds=10) ++ dep_virtual_server.token.save() ++ realm = force_realm() ++ response = self.client.post(reverse("mdm:create_dep_enrollment"), ++ {"de-name": name, ++ "de-display_name": display_name, ++ "de-realm": realm.pk, ++ "de-scep_config": scep_config.pk, ++ "de-push_certificate": push_certificate.pk, ++ "de-virtual_server": dep_virtual_server.pk, ++ "es-meta_business_unit": self.mbu.pk, ++ "de-is_supervised": "on"}, ++ follow=True) ++ self.assertEqual(response.status_code, 200) ++ self.assertTemplateUsed(response, "mdm/depenrollment_form.html") ++ self.assertFormError(response.context["form"], None, "DEP virtual server token has expired") ++ + @patch("zentral.contrib.mdm.dep.DEPClient.from_dep_virtual_server") + def test_create_dep_enrollment_post(self, from_dep_virtual_server): + profile_uuid = uuid.uuid4() +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+2UTY/aMBCGOedXTLWXthL5QMCeqER36YeEgBKkqlWlKCQDuDh2ajtoqfjxnUSU ++RZW2XHZVrTrPIbbs1+MZv7H9ZSVknqDaBa2nIiSue72mJf5sm37U60TRdRj1u91WGEX9sNOC3pNl ++dEZlXWoAWkZr9zfdpflnin/vv0PrkkwXRapy324eb48L/ked6N7/br/Tqr9hvwXh46XwMP+5/1cv ++gqVQwTK1G8+igzZ6XpZD8zMsMfe8KxgpWxmEmbZubTD+NAZhwVRKCbX2ynUibSbpFNFYOAApSmj/ ++AK2kUAiHA5Aic/IogagPRSoU1KfuoPMmyHEXqErKWupMhZ6VSCGis50X4xgyJLndFxR1awHvhHXw ++0uAKDaoMc1juoU4ZMq1WYg1UD/rfrVavvGKbCwPtEoKfqJxJZVBrgiaBINfZFk3gpA08qaBtV6fS ++H5C9vhiHEh9mTuxSh+A2CCWdDKVLi2AnjKtSCXTdhNGqoDHP6spkCIEu3e/Iya6+j7Uv6TFQHXRe ++qSYebbgmp5pyV0Ki93U0WcyH42Q2n74dxUn8ZXIzCOHbafxmOnmX3H6cD06l1a1t8ifZbBov3s9p ++4QfqDKTOUrkhr89nZsM4/jyd3w6OCdJcuXcbTT6i2VHh9Gaka/TLowtNfL/IC795VOjHqsokx5Le ++GaOlrOuGdpsWLrUVbj/oeP/6HjAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzxXfgHlfjKgACgAAA== +diff --git 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-003053/tests/test.sh b/tasks/format-code-task-003053/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..9b0ae3e938f6bf43f9e81ff024bf88723729300f --- /dev/null +++ b/tasks/format-code-task-003053/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/mdm/test_setup_dep_enrollment.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-003053/tests/test_command.sh b/tasks/format-code-task-003053/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003053/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file diff --git a/tasks/format-code-task-003054/environment/Dockerfile b/tasks/format-code-task-003054/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a7f2f57997e3a207a1c0ef2010f0aa4eaf73779b --- /dev/null +++ b/tasks/format-code-task-003054/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:928b0a518702f2ab7e548fd671f6400dc4dddbdd7f34b80f1ac2c4639dad0d2d diff --git a/tasks/format-code-task-003054/environment/setup/files/blocklist b/tasks/format-code-task-003054/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003054/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003054/environment/setup/setup.sh b/tasks/format-code-task-003054/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e9eb7daf39f9542bd095367feee457f3da77e492 --- /dev/null +++ b/tasks/format-code-task-003054/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/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-003054/tests/test.patch b/tasks/format-code-task-003054/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..ace1b4108f728f4b534fa327564ecc7f80b6fabe --- /dev/null +++ b/tasks/format-code-task-003054/tests/test.patch @@ -0,0 +1,304 @@ +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,282 @@ ++#!/usr/bin/env bash ++ ++set -u ++export LANG=C.UTF-8 LC_ALL=C.UTF-8 TZ=UTC USER="${USER:-root}" ++export PYTHONDONTWRITEBYTECODE=1 ++ ++( cd /workspace/repo && python3 - <<'PY' ++for path in ('zim.py', 'zim/main/__init__.py', 'zim/main/command.py'): ++ with open(path, 'rb') as fh: ++ compile(fh.read(), path, 'exec') ++PY ++) \ ++ || { echo "FAIL: build" >&2; exit 1; } ++BIN="python3 /workspace/repo/zim.py" ++ ++TMP=$(mktemp -d) ++trap 'rm -rf "$TMP"' EXIT ++cd "$TMP" ++fail() { echo "FAIL: $*" >&2; exit 1; } ++ ++export XDG_CONFIG_HOME="$TMP/xdg-config" ++export XDG_CACHE_HOME="$TMP/xdg-cache" ++export XDG_DATA_HOME="$TMP/xdg-data" ++export XDG_DATA_DIRS="/workspace/repo/data:/usr/share:/usr/local/share" ++export ZIM_TEST_RUNNING= ++mkdir -p "$XDG_CONFIG_HOME/zim" "$XDG_CACHE_HOME" "$XDG_DATA_HOME" ++ ++write_notebook_config() { ++ local nb="$1" ++ local name="$2" ++ mkdir -p "$nb" ++ cat > "$nb/notebook.zim" < "$file" < "$XDG_CONFIG_HOME/zim/notebooks.list" < "$out_file" 2> "$err_file" ++} ++ ++ ++ ++ ++$BIN --help >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F1 exit $ec; want 0" ++ ++grep -Eq 'or:[[:space:]]+zim --index[[:space:]]+\[OPTIONS\][[:space:]]+NOTEBOOK' out || fail "F1 missing index usage" ++ ++grep -Eq '^[[:space:]]*--index[[:space:]]+builds? an index for a notebook' out || fail "F1 missing general --index help" ++grep -Fq 'Index Options:' out || fail "F1 missing Index Options section" ++ ++grep -Eq '^[[:space:]]*-f, --flush[[:space:]].*flush.*index.*rebuild|^[[:space:]]*-f, --flush[[:space:]].*flush.*index.*re-building' out || fail "F1 missing flush help" ++[ ! -s err ] || fail "F1 unexpected stderr: $(cat err)" ++ ++ ++ ++ ++NB_PATH="$TMP/path-notebook" ++write_notebook_config "$NB_PATH" "Path Notebook" ++write_page "$NB_PATH/Home.txt" $'Home page\n[[Alpha:Child]]\n@home' ++write_page "$NB_PATH/Alpha/Child.txt" $'Child page\n[[Home]]\n@child' ++$BIN --index "$NB_PATH" >out 2>err; ec=$? ++EXPECTED_SUMMARY=$'pages=4\npage_names=,Alpha,Alpha:Child,Home\nlinks=2\ntags=2\ntag_names=child,home\ntag_sources=2\nstale_files=0' ++[ "$ec" -eq 0 ] || fail "F2 exit $ec; want 0" ++ ++! grep -qi 'traceback' out err || fail "F2 traceback in output: $(cat out err)" ++[ "$(summary_db "$NB_PATH/.zim/index.db")" = "$EXPECTED_SUMMARY" ] || fail "F2 index summary: $(summary_db "$NB_PATH/.zim/index.db")" ++ ++ ++ ++ ++NB_URI="$TMP/uri-notebook" ++write_notebook_config "$NB_URI" "URI Notebook" ++write_page "$NB_URI/Home.txt" $'Home page\n[[Later]]\n@home' ++$BIN --index "$NB_URI" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F3 setup exit $ec; want 0" ++sleep 1 ++write_page "$NB_URI/Later.txt" $'Later page\n[[Home]]\n@later' ++URI_ARG="$(file_uri "$NB_URI")" ++$BIN --index "$URI_ARG" >out 2>err; ec=$? ++EXPECTED_SUMMARY=$'pages=3\npage_names=,Home,Later\nlinks=2\ntags=2\ntag_names=home,later\ntag_sources=2\nstale_files=0' ++[ "$ec" -eq 0 ] || fail "F3 exit $ec; want 0" ++ ++! grep -qi 'traceback' out err || fail "F3 traceback in output: $(cat out err)" ++[ "$(summary_db "$NB_URI/.zim/index.db")" = "$EXPECTED_SUMMARY" ] || fail "F3 index summary: $(summary_db "$NB_URI/.zim/index.db")" ++ ++ ++ ++ ++NB_NAME="$TMP/name-notebook" ++write_notebook_config "$NB_NAME" "named-cli-notebook-coderl" ++write_page "$NB_NAME/Only.txt" $'Only named page\n@named' ++add_notebook_list_entry "named-cli-notebook-coderl" "$(file_uri "$NB_NAME")" ++$BIN --index named-cli-notebook-coderl >out 2>err; ec=$? ++EXPECTED_SUMMARY=$'pages=2\npage_names=,Only\nlinks=0\ntags=1\ntag_names=named\ntag_sources=1\nstale_files=0' ++[ "$ec" -eq 0 ] || fail "F4 exit $ec; want 0" ++ ++! grep -qi 'traceback' out err || fail "F4 traceback in output: $(cat out err)" ++[ "$(summary_db "$NB_NAME/.zim/index.db")" = "$EXPECTED_SUMMARY" ] || fail "F4 index summary: $(summary_db "$NB_NAME/.zim/index.db")" ++ ++ ++ ++ ++NB_FLUSH_LONG="$TMP/flush-long-notebook" ++write_notebook_config "$NB_FLUSH_LONG" "Long Flush Notebook" ++write_page "$NB_FLUSH_LONG/Home.txt" $'Home page\n@home' ++$BIN --index "$NB_FLUSH_LONG" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F5 setup exit $ec; want 0" ++python3 - "$NB_FLUSH_LONG/.zim/index.db" <<'PY' ++import sqlite3 ++import sys ++con = sqlite3.connect(sys.argv[1]) ++con.execute("INSERT INTO zim_index(key, value) VALUES ('coderl_pollution', 'still_here')") ++con.commit() ++PY ++$BIN --index --flush "$NB_FLUSH_LONG" >out 2>err; ec=$? ++EXPECTED_SUMMARY=$'pages=2\npage_names=,Home\nlinks=0\ntags=1\ntag_names=home\ntag_sources=1\nstale_files=0' ++POLLUTION_COUNT="$(python3 - "$NB_FLUSH_LONG/.zim/index.db" <<'PY' ++import sqlite3 ++import sys ++con = sqlite3.connect(sys.argv[1]) ++print(con.execute("SELECT count(*) FROM zim_index WHERE key='coderl_pollution'").fetchone()[0]) ++PY ++)" ++[ "$ec" -eq 0 ] || fail "F5 exit $ec; want 0" ++[ "$POLLUTION_COUNT" = "0" ] || fail "F5 pollution row survived flush" ++[ "$(summary_db "$NB_FLUSH_LONG/.zim/index.db")" = "$EXPECTED_SUMMARY" ] || fail "F5 index summary: $(summary_db "$NB_FLUSH_LONG/.zim/index.db")" ++ ++! grep -qi 'traceback' out err || fail "F5 traceback in output: $(cat out err)" ++ ++ ++ ++ ++NB_FLUSH_SHORT="$TMP/flush-short-notebook" ++write_notebook_config "$NB_FLUSH_SHORT" "Short Flush Notebook" ++write_page "$NB_FLUSH_SHORT/Home.txt" $'Home page\n@short' ++$BIN --index "$NB_FLUSH_SHORT" >out 2>err; ec=$? ++[ "$ec" -eq 0 ] || fail "F6 setup exit $ec; want 0" ++python3 - "$NB_FLUSH_SHORT/.zim/index.db" <<'PY' ++import sqlite3 ++import sys ++con = sqlite3.connect(sys.argv[1]) ++con.execute("INSERT INTO zim_index(key, value) VALUES ('coderl_pollution', 'still_here')") ++con.commit() ++PY ++$BIN --index -f "$NB_FLUSH_SHORT" >out 2>err; ec=$? ++EXPECTED_SUMMARY=$'pages=2\npage_names=,Home\nlinks=0\ntags=1\ntag_names=short\ntag_sources=1\nstale_files=0' ++POLLUTION_COUNT="$(python3 - "$NB_FLUSH_SHORT/.zim/index.db" <<'PY' ++import sqlite3 ++import sys ++con = sqlite3.connect(sys.argv[1]) ++print(con.execute("SELECT count(*) FROM zim_index WHERE key='coderl_pollution'").fetchone()[0]) ++PY ++)" ++[ "$ec" -eq 0 ] || fail "F6 exit $ec; want 0" ++[ "$POLLUTION_COUNT" = "0" ] || fail "F6 pollution row survived flush" ++[ "$(summary_db "$NB_FLUSH_SHORT/.zim/index.db")" = "$EXPECTED_SUMMARY" ] || fail "F6 index summary: $(summary_db "$NB_FLUSH_SHORT/.zim/index.db")" ++ ++! grep -qi 'traceback' out err || fail "F6 traceback in output: $(cat out err)" ++ ++ ++ ++ ++NB_VERBOSE="$TMP/verbose-notebook" ++write_notebook_config "$NB_VERBOSE" "Verbose Notebook" ++write_page "$NB_VERBOSE/Home.txt" $'Verbose page\n@verbose' ++run_tty "$BIN --index -V '$NB_VERBOSE'" out err; ec=$? ++[ "$ec" -eq 0 ] || fail "F7 exit $ec; want 0" ++[ ! -s err ] || fail "F7 unexpected script stderr: $(cat err)" ++ ++grep -Eq "INFO: .*${NB_VERBOSE}/\\.zim/index\\.db" out || fail "F7 missing elevated indexer database message" ++ ++grep -Eiq 'INFO: .*check.*notebook.*index' out || fail "F7 missing checking message" ++ ++grep -Eiq 'INFO: .*index.*up.to.date|INFO: .*up.to.date.*index' out || fail "F7 missing up-to-date message" ++ ++grep -Eq "INFO: .*${NB_VERBOSE}/Home\\.txt" out || fail "F7 missing elevated indexer file message" ++ ++ ++ ++ ++run_tty "$BIN --index" out err; ec=$? ++[ "$ec" -ne 0 ] || fail "F8 expected non-zero exit" ++[ ! -s err ] || fail "F8 unexpected script stderr: $(cat err)" ++ ++if ! { [ -s out ] && grep -Eiq 'notebook|argument|usage' out; }; then ++ fail "F8 missing command-line error: $(cat out)" ++fi ++ ++ ++ ++ ++run_tty "$BIN --index '$NB_PATH' extra" out err; ec=$? ++[ "$ec" -ne 0 ] || fail "F9 expected non-zero exit" ++[ ! -s err ] || fail "F9 unexpected script stderr: $(cat err)" ++ ++if ! { [ -s out ] && grep -Eiq 'argument|usage|only|takes' out; }; then ++ fail "F9 missing too-many-arguments error: $(cat out)" ++fi ++ ++ ++ ++ ++run_tty "$BIN --index definitely_missing_notebook_name_coderl" out err; ec=$? ++[ "$ec" -ne 0 ] || fail "F10 expected non-zero exit" ++[ ! -s err ] || fail "F10 unexpected script stderr: $(cat err)" ++ ++grep -Fq 'definitely_missing_notebook_name_coderl' out || fail "F10 missing unresolved notebook name: $(cat out)" ++ ++grep -Eiq 'notebook|file|folder|resolve|find' out || fail "F10 missing lookup error description: $(cat out)" ++ ++echo "PASS" ++exit 0 +diff --git a/mimo_test_command.sh b/mimo_test_command.sh +new file mode 100755 +--- /dev/null ++++ b/mimo_test_command.sh +@@ -0,0 +1,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-003054/tests/test.sh b/tasks/format-code-task-003054/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4d80bb634b14076ae561be99f395189577b7ac6 --- /dev/null +++ b/tasks/format-code-task-003054/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-003054/tests/test_command.sh b/tasks/format-code-task-003054/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..88cb7810b836396c4869db31aeac7d4d4b189685 --- /dev/null +++ b/tasks/format-code-task-003054/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-003055/environment/Dockerfile b/tasks/format-code-task-003055/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..391dde9ea3ac90e74ff8c59797ed4631d3ecf8b5 --- /dev/null +++ b/tasks/format-code-task-003055/environment/Dockerfile @@ -0,0 +1,3 @@ +# The task's image, pinned by digest (the same as [environment].docker_image). +# Setup runs at start from [environment.healthcheck]; environment/setup/ is its readable copy. +FROM docker.io/xiaomimimo/mimo-v2.6-rl-oss@sha256:5503cd6f792f2faf9dac498d262cae76a5a10afba1e22790067e8b4abd8ebd9c diff --git a/tasks/format-code-task-003055/environment/setup/files/blocklist b/tasks/format-code-task-003055/environment/setup/files/blocklist new file mode 100644 index 0000000000000000000000000000000000000000..a8e4bdc4c7d9b739c047a3cb58ea72a1bb05bcbc --- /dev/null +++ b/tasks/format-code-task-003055/environment/setup/files/blocklist @@ -0,0 +1,33 @@ +# mimo answer-leak blocklist (mimoagent) +0.0.0.0 github.com +0.0.0.0 www.github.com +0.0.0.0 api.github.com +0.0.0.0 raw.githubusercontent.com +0.0.0.0 codeload.github.com +0.0.0.0 objects.githubusercontent.com +0.0.0.0 gist.github.com +0.0.0.0 gist.githubusercontent.com +0.0.0.0 gitlab.com +0.0.0.0 bitbucket.org +0.0.0.0 sourceforge.net +0.0.0.0 git.kernel.org +0.0.0.0 chromium.googlesource.com +0.0.0.0 android.googlesource.com +0.0.0.0 sourcegraph.com +0.0.0.0 bugs.chromium.org +0.0.0.0 issues.oss-fuzz.com +0.0.0.0 oss-fuzz.com +0.0.0.0 osv.dev +0.0.0.0 api.osv.dev +0.0.0.0 bugzilla.mozilla.org +0.0.0.0 proxy.golang.org +0.0.0.0 sum.golang.org +0.0.0.0 pkg.go.dev +0.0.0.0 google.com +0.0.0.0 www.google.com +0.0.0.0 bing.com +0.0.0.0 www.bing.com +0.0.0.0 duckduckgo.com +0.0.0.0 html.duckduckgo.com +0.0.0.0 search.brave.com +0.0.0.0 stackoverflow.com diff --git a/tasks/format-code-task-003055/environment/setup/setup.sh b/tasks/format-code-task-003055/environment/setup/setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..d883db90cfcfb48f7a139861bbe9f6b5d95cad6f --- /dev/null +++ b/tasks/format-code-task-003055/environment/setup/setup.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Runs once, as root, before the agent starts: Harbor's [environment.healthcheck] unpacks this folder into +# /var/lib/mimo and runs it. Generated by mimo_harbor; see its README for how each step maps to Xiaomi's harness. +M=/var/lib/mimo +[ -f "$M/ready" ] && exit 0 +chmod 700 "$M" +fail() { echo "setup: $*" >&2; exit 1; } +# the answer-leak blocklist (mimoagent), applied to /etc/hosts by the agent right after it installs +write_blocklist() { cp "$M/files/blocklist" "$M/blocklist"; } + +# Code: mimoagent environments/datasets/opensource_code.py + base.py, as the explorer runs it (app/runner/domains.py Code). +CWD=/testbed +git config --global --add safe.directory "$CWD" +cd "$CWD" || fail "no working directory $CWD" +if ! git rev-parse --git-dir >/dev/null 2>&1; then # a bare source tree: give it a baseline commit + git init -q && git add -A && git -c user.name=mimo -c user.email=mimo@localhost commit -q -m baseline --allow-empty +fi +BASE=$(git rev-parse HEAD 2>/dev/null) +[ ${#BASE} -eq 40 ] || fail "could not resolve the base commit in $CWD" +echo "$BASE" > "$M/base" +# Images are built with history truncated at the base. If one is not, the fix could be read out of git log, +# so .git is hidden while the agent works and put back for grading. +LATER=$(git rev-list --all --not "$BASE" 2>/dev/null | head -n 5 | grep -c . || true) +rm -f /tmp/fail.log /tmp/pass.log /tmp/patch.diff /tmp/test_patch.diff /tmp/*.log 2>/dev/null; rm -rf /tmp/claude-0 /tmp/claude-* /tmp/testem-* /tmp/puppeteer_dev_chrome_profile-* 2>/dev/null; rm -f /tmp/test_files.json 2>/dev/null; rm -rf /tmp/jest_* /tmp/jest-* /tmp/build /tmp/build_env 2>/dev/null; rm -rf /tmp/pytest-of-root /tmp/pytest-* /tmp/.pytest_cache /tmp/__pycache__ 2>/dev/null; rm -rf /tmp/go-build* /tmp/standards /tmp/wordpress /tmp/zig-* /tmp/testbase /tmp/testbed 2>/dev/null; rm -f /tmp/tmp*.tmp /tmp/*.bak /tmp/expect* /tmp/butwas* 2>/dev/null; rm -rf /root/.cache/go-build 2>/dev/null; rm -rf /tests 2>/dev/null; find /logs -mindepth 1 -delete 2>/dev/null; mkdir -p /logs/agent /logs/verifier /logs/artifacts; chmod 777 /logs/agent /logs/verifier /logs/artifacts; find /var/log -type f -delete 2>/dev/null || true; rm -rf /var/lib/postgresql/*/*/log /var/lib/postgresql/*/*/pg_log 2>/dev/null || true; find /var/lib/mysql /var/lib/mongodb -type f -name '*.log' -delete 2>/dev/null || true; rm -rf /root/.npm/_logs /root/.babel.json /root/.pytest_cache 2>/dev/null || true; find / -maxdepth 4 -xdev -name task_description.md -path '*/.build_env/*' -delete 2>/dev/null || true; true +git clean -fdx --exclude=node_modules --exclude=bower_components --exclude=.husky --exclude=vendor --exclude=third_party --exclude=_deps --exclude=vcpkg_installed --exclude=.venv --exclude=venv --exclude=.gradle --exclude=target --exclude=.build --exclude=lib --exclude=.bundle --exclude=Manifest.toml --exclude=_build --exclude=.stack-work --exclude=dist-newstyle >/dev/null 2>&1 +find /root/.m2 -type f \( -name '*-SNAPSHOT.jar' -o -name '*-SNAPSHOT-sources.jar' -o -name '*-SNAPSHOT-tests.jar' -o -name '*-SNAPSHOT-test-sources.jar' \) -delete 2>/dev/null; rm -rf /root/.julia/compiled 2>/dev/null; rm -rf /root/.gradle/caches/build-cache-* /root/.gradle/daemon 2>/dev/null; rm -rf /root/.gradle/caches/*/scripts /root/.gradle/caches/jars-* 2>/dev/null; rm -rf /root/.cache/bazel 2>/dev/null; true +if [ "$LATER" -gt 0 ]; then + mv "$CWD/.git" "$M/git-hidden" + echo "history not truncated at ${BASE:0:12}: .git hidden while the agent works" +fi +write_blocklist + +touch "$M/ready" +echo "setup done" diff --git a/tasks/format-code-task-003055/tests/test.patch b/tasks/format-code-task-003055/tests/test.patch new file mode 100644 index 0000000000000000000000000000000000000000..20b70477dc95161e8f0742ab4fbc908a7dde6e9f --- /dev/null +++ b/tasks/format-code-task-003055/tests/test.patch @@ -0,0 +1,75 @@ +diff --git a/core-tests/shared/src/test/scala/zio/prelude/CommutativeSpec.scala b/core-tests/shared/src/test/scala/zio/prelude/CommutativeSpec.scala +index cc719959b..8d68fedfb 100644 +--- a/core-tests/shared/src/test/scala/zio/prelude/CommutativeSpec.scala ++++ b/core-tests/shared/src/test/scala/zio/prelude/CommutativeSpec.scala +@@ -43,7 +43,8 @@ object CommutativeSpec extends ZIOBaseSpec { + test("tuple2")(checkAllLaws(CommutativeLaws)(anySumInt.zip(anySumInt))), + test("tuple3")( + checkAllLaws(CommutativeLaws)(anySumInt.zip(anySumInt).zip(anySumInt)) +- ) ++ ), ++ test("unit")(checkAllLaws(CommutativeLaws)(Gen.unit)) + ) + ) + } +diff --git a/core-tests/shared/src/test/scala/zio/prelude/IdempotentSpec.scala b/core-tests/shared/src/test/scala/zio/prelude/IdempotentSpec.scala +index 5729a40d0..b33352289 100644 +--- a/core-tests/shared/src/test/scala/zio/prelude/IdempotentSpec.scala ++++ b/core-tests/shared/src/test/scala/zio/prelude/IdempotentSpec.scala +@@ -48,7 +48,8 @@ object IdempotentSpec extends ZIOBaseSpec { + test("tuple2")(checkAllLaws(IdempotentLaws)(anyMaxInt.zip(anyMaxInt))), + test("tuple3")( + checkAllLaws(IdempotentLaws)(anyMaxInt.zip(anyMaxInt).zip(anyMaxInt)) +- ) ++ ), ++ test("unit")(checkAllLaws(IdempotentLaws)(Gen.unit)) + ), + test("Idempotent.reduceIdempotent") { + +diff --git a/core-tests/shared/src/test/scala/zio/prelude/IdentitySpec.scala b/core-tests/shared/src/test/scala/zio/prelude/IdentitySpec.scala +index 178b8aa6c..d7297e64f 100644 +--- a/core-tests/shared/src/test/scala/zio/prelude/IdentitySpec.scala ++++ b/core-tests/shared/src/test/scala/zio/prelude/IdentitySpec.scala +@@ -29,6 +29,7 @@ object IdentitySpec extends ZIOBaseSpec { + test("option")(checkAllLaws(IdentityLaws)(Gen.option(Gen.int.map(Sum(_))))), + test("short multiplication")(checkAllLaws(IdentityLaws)(Gen.short.map(Prod(_)))), + test("string")(checkAllLaws(IdentityLaws)(Gen.string)), ++ test("unit")(checkAllLaws(IdentityLaws)(Gen.unit)), + test("vector")(checkAllLaws(IdentityLaws)(Gen.vectorOf(Gen.int))) + ) + ) +diff --git a/core-tests/shared/src/test/scala/zio/prelude/InverseSpec.scala b/core-tests/shared/src/test/scala/zio/prelude/InverseSpec.scala +index c69be96b8..18f480d10 100644 +--- a/core-tests/shared/src/test/scala/zio/prelude/InverseSpec.scala ++++ b/core-tests/shared/src/test/scala/zio/prelude/InverseSpec.scala +@@ -24,7 +24,8 @@ object InverseSpec extends ZIOBaseSpec { + test("tuple2")(checkAllLaws(InverseLaws)(Gen.int.map(Sum(_)).zip(Gen.int.map(Sum(_))))), + test("tuple3")( + checkAllLaws(InverseLaws)(Gen.int.map(Sum(_)).zip(Gen.int.map(Sum(_))).zip(Gen.int.map(Sum(_)))) +- ) ++ ), ++ test("unit")(checkAllLaws(InverseLaws)(Gen.unit)) + ) + ) + } +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+3S32rDIBgF8Fz3KaQP4FTm8gC7WmHsomO3JYkfLJBo0C+B9ukn3nT/e9Myys7v ++RskRIx5lO/eD25FfbqpLUVltbRmzz2OZa2u00arWpq6U1rauK2EvdqJ35sRNFKKKIfBv607lV0oe +++2dKvOvCODbeyfR6vn+c6t+YY/9K53X69k7pSqjzHeFn/7z/zolSfEtulVoW6y5Ees4f0ublsSRP ++ftiLQx/kFGmYHcn7/ERmbrhfaDtR9yF7cDROgcnzd5HnnvdfA79QTGWv9eqv7wMAAAAAAAAAAAAA ++AAAAAAAA4Jq8AXjCItMAKAAA +diff --git 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-003055/tests/test.sh b/tasks/format-code-task-003055/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..e37f2ed995addd4945c142f0b24c9e0f00e2b0e5 --- /dev/null +++ b/tasks/format-code-task-003055/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' +core-tests/shared/src/test/scala/zio/prelude/CommutativeSpec.scala +core-tests/shared/src/test/scala/zio/prelude/IdempotentSpec.scala +core-tests/shared/src/test/scala/zio/prelude/IdentitySpec.scala +core-tests/shared/src/test/scala/zio/prelude/InverseSpec.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-003055/tests/test_command.sh b/tasks/format-code-task-003055/tests/test_command.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb23076694ad17d72e8296d62b2b240083e36db --- /dev/null +++ b/tasks/format-code-task-003055/tests/test_command.sh @@ -0,0 +1 @@ +bash /testbed/mimo_test_command.sh \ No newline at end of file